akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int jk(int n){
int count =0;
    while(n){
        count = count + n%10;
        n/=10;
    }
return count;
}
int main(){
    int a;
    cin >> a;
    int count = jk(a);
    if(a%count==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#import <stdio.h>
typedef long long INT;
void loop(int n, char c){
    for(int i=0;i<n;i++) printf("%c", c);
}
int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int x = c-a;
    int y = d-b;
    loop(y,'U');
    loop(x,'R');
    loop(y,'D');
    loop(x+1,'L');
    loop(y+1,'U');
    loop(x+1,'R');
    loop(1,'D');
    loop(1,'R');
    loop(y+1,'D');
    loop(x+1,'L');
    loop(1,'U');
}


Measured memory_bytes: 7124
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int x, a;
    cin >> x >> a;

    if(x < a)
        cout << 0 << endl;
    else
        cout << 10 << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, stdout, Write};

fn main() {
    let mut first_line = String::new();
    stdin().read_line(&mut first_line).unwrap();
    let v: Vec<&str> = first_line.split_whitespace().collect();
    let s = v[0];
    let t = v[1];

    let mut second_line = String::new();
    stdin().read_line(&mut second_line).unwrap();
    let v2: Vec<&str> = second_line.split_whitespace().collect();
    let mut s_num: i64 = match v2[0].trim().parse() {
        Ok(n) => n,
        Err(_) => 0,
    };
    let mut t_num: i64 = match v2[1].trim().parse() {
        Ok(n) => n,
        Err(_) => 0,
    };
    let mut third_line = String::new();
    stdin().read_line(&mut third_line).unwrap();
    let target = third_line.trim();

    if target == t {
        t_num -= 1;
    } else {
        s_num -= 1;
    }

    let out = stdout();
    let mut out = out.lock();
    write!(out, "{} {}", s_num, t_num);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef float fl;
typedef long long ll;
int A;
ll B,N;

ll f(ll x){
    ll ans = (A*x)/B - A*(x/B);
    return ans;
}


int main(){
    cin >> A >> B >> N;
    if(B > N){
        cout << f(N) << endl;
    }else{
        cout << f(B-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    ll k;
    cin>>k;
    ll cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0 ;
    string t = s+s;
    string u = t+s;
    string v = t+t;
    int n = s.size();
    rep(i,n-1){
        if(s[i]==s[i+1])s[i+1]='#',++cnt1;
    }
    rep(i,2*n-1){
        if(t[i]==t[i+1])t[i+1]='#',++cnt2;
    }
    rep(i,3*n-1){
        if(u[i]==u[i+1])u[i+1]='#',++cnt3;
    }
    rep(i,4*n-1){
        if(v[i]==v[i+1])v[i+1]='#',++cnt4;
    }

    if(k%2)cout<<cnt1+(cnt3-cnt1)*(k-1)/2<<endl;
    else cout<<cnt2+(cnt4-cnt2)*(k-2)/2<<endl;

    return 0;
}

Measured memory_bytes: 256
(* O(n) *)
let n = read_int ()
let s = read_line ()
let accs = Array.make_matrix 2 (n + 1) 0
let ans = ref max_int
let _ =
  let cs = [|ref 0; ref 0|] in
  for i = 0 to n - 1 do
    incr @@ if s.[i] = 'W' then cs.(0) else cs.(1);
    for j = 0 to 1 do accs.(j).(i + 1) <- !(cs.(j)) done
  done;
  for i = 0 to n - 1 do
    ans := min !ans @@ accs.(0).(i) + accs.(1).(n) - accs.(1).(i + 1)
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int q;cin>>q;
    int flag = 0;
    string beg = "",ed = "";
    while (q--) {
        int t,f;
        char c;
        cin>>t;
        if(t == 1){
            flag = (flag == 0?1:0);
        }
        else{
            cin>>f>>c;
            if(f == 1){
                if(flag == 1)ed += c;
                else if(flag == 0) beg = c+beg;
            }
            else{
                if(flag == 1) beg = c+beg;
                else if(flag == 0) ed += c;
            }
        }
    }
    //dump(s);
    s = beg + s + ed;
    if(flag == 1){
        reverse(s.begin() , s.end());
        cout<<s;
    }
    else{
        cout<<s;
    }
    return 0;
}


Measured memory_bytes: 1316
#include <bits/stdc++.h>

using namespace std;

const int N = 100005 ;

int noPeople , noMuc ;


vector < pair< int , int > > allMuc [ N ];
int viz [ N ] ;
int dist [ N ] ;
int spy ;

void dfs ( int crNode ){

    viz[ crNode ] = 1 ;

    for ( pair < int , int > crPair : allMuc[ crNode ] ){
        int vec = crPair.first ;
        int cost = crPair.second ;
        if ( viz [ vec ] == 1 ){
            if (dist[ vec ] - dist [ crNode ] != cost ){
                spy = 1 ;
            }

        }else{
            dist [ vec ] = dist [ crNode ] + cost ;
            dfs( vec );
        }

    }

}

int main()
{


    scanf("%d%d",&noPeople,&noMuc);

    for ( int i = 0 ; i < noMuc ; i++ ){
        int x , y , cost ;
        scanf("%d%d%d",&x,&y,&cost);
        allMuc [ x ].push_back ( make_pair( y , cost ) );
        allMuc [ y ].push_back ( make_pair( x , -cost ) );
    }


    for ( int i = 1 ; i <= noPeople ; i++ ){
        if ( viz [ i ] ==0  ){
            dfs ( i );
        }
    }

    if ( spy == 0 ){
        printf("Yes");
        return 0 ;
    }
    printf("No");


    return 0;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<double,double>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////

void solve(){
  ini(N);
  vi P(N); in(P);
  multiset<int> s;
  s.insert(-1); s.insert(N);
  s.insert(-1); s.insert(N);
  vi idx(N + 1); rep(i,N) idx[P[i]] = i;
  ll ans = 0;
  repr1(i , N){
    trc(i , idx[i]);
    auto its = s.lower_bound(idx[i]); its--;
    auto ite = s.lower_bound(idx[i]);
    ll x = *its , w = *(--its);
    ll y = *ite , z = *(++ite);
    trc(w,x,y,z);
    ans += ( (x-w) * (y-idx[i]) + (idx[i]-x)*(z-y) ) * i;
    trc(ans);
    s.insert(idx[i]);
  }
  out(ans);
  
}

Measured memory_bytes: 5760
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num[] = new int[n];
        int right = 0;
        int count = 0;
        for(int i = 0; i < n; i++){
        	num[i] = sc.nextInt();
            if(i >= 1 && num[i] <= num[i - 1]){
                right++;
            }else{
                right = 0;
            }
            if(count < right){
                count = right;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 59780
func readInt() -> Int {
    return Int(readLine()!)!
}

func readArrayInt() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let N = readInt()
let threshold = Int(1e18)
var valid = true
var ans = 1
let A = readArrayInt().sorted()

if A[0] == 0 {
    print(0)
} else {
    for a in A {
        if (a > (threshold / ans)) {
            valid = false
            break
        }
        ans *= a
    }
    print(valid ? ans : -1)
}


Measured memory_bytes: 15216
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N,K;string S;cin>>N>>K>>S;vector<int>A;A.push_back(0);int last='1';for(char ch:S){if(ch!=last)last=ch,A.push_back(0);A.back()++;}if(last!='1')A.push_back(0);assert(A.size()%2==1);vector<int>sum(A.size()+1);partial_sum(A.begin(),A.end(),sum.begin()+1);if((int)A.size()/2<=K){cout<<sum.back()<<endl;}else{int ma=0;for(int i=0;2*K+i<(int)A.size();i+=2){updmax(ma,sum[2*K+i+1]-sum[i]);}cout<<ma<<endl;}}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;

int main()
{
  long long h, s = 0;
  cin >> h;
  for(long long i = 1; i <= 40; i++)
  {
     if(h / pow(2,i) >= 1) s += pow(2,i-1);
     else
     {
        s += pow(2,i-1);
        break;
     }
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 256
n,d=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(A[i][k]-A[j][k])**2 for k in range(d)])
    if dis**(1/2)==int(dis**(1/2)):
      ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <set>

std::string s, res;
std::set<char> freq;

int main() {
    std::cin >> s;
    for (int i=0; i<s.size(); ++i) {
        if (freq.find(s[i]) == freq.end()) freq.insert(s[i]);
    }
    if (freq.size() >= 26) {
        res = "None";
    } else {
        char x = 'a';
        while ( freq.find(x) != freq.end() ) ++x;
        res = x;
    }
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main (void){
  int N,K,P,i;
  scanf("%d",&N);
  int a[N];

  for(i=0; i<N; i++){
     scanf("%d %d",&K,&P);
         a[i] = K%P;
         if(K%P==0)
            a[i] = P;
  }

  for(i=0; i<N; i++)
     printf("%d\n",a[i]);

  return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int alice = 0;
		int bob = 0;
		int k = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (k % 2 == 0)
				alice += a[i];
			else
				bob += a[i];
			k++;
		}
		System.out.println(Math.abs(alice - bob));
	}

}


Measured memory_bytes: 21712
#include <iostream>
#include <random>
using namespace std;

class Dice{
private:
  int tmp;
public:
  int q[6];
  void roll(char d){
    if(d=='N'){
      tmp = q[4];
      q[4] = q[0];
      q[0] = q[1];
      q[1] = q[5];
      q[5] = tmp;
    } else if(d=='E'){
      tmp = q[2];
      q[2] = q[0];
      q[0] = q[3];
      q[3] = q[5];
      q[5] = tmp;
    } else if(d=='W'){
      tmp = q[3];
      q[3] = q[0];
      q[0] = q[2];
      q[2] = q[5];
      q[5] = tmp;
    } else if(d=='S'){
      tmp = q[1];
      q[1] = q[0];
      q[0] = q[4];
      q[4] = q[5];
      q[5] = tmp;
    }
  }
};


int main(){
  Dice d;
  for(int i=0; i<6; i++){
    cin >> d.q[i];
  }
  int n;
  int a, b;
  int r;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a >> b;
    while(d.q[0]!=a||d.q[1]!=b){
      r = rand()%4;
      if(r==0)d.roll('N');
      else if(r==1)d.roll('E');
      else if(r==2)d.roll('W');
      else if(r==3)d.roll('S');
    }
    cout << d.q[2] << endl;
  }
}




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    string s,t;
    cin >> s;
    s[m - 1] -= ('A' - 'a');
    cout << s << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
//  配列の最大の大きさ
#define MAX_LENGTH  200010

typedef struct{
    int array[MAX_LENGTH];
    int first;
    int last;
}QUEUE;

void init(QUEUE*);
int enqueue(QUEUE*,int);
int dequeue(QUEUE*,int*);
struct touple { int a; int b; };
int cmp_touple(const void*n1, const void*n2);
int bisect_left(int x,struct touple a[],int left,int right);
int bisect_right(int x,struct touple a[],int left,int right);

int main(void){
    int N,M;
    scanf("%d%d", &N,&M);
    struct touple *ts = (struct touple *)malloc((M*2)*sizeof(struct touple));
    for (int i = 0; i < M; i++) {
        int x,y;
        scanf("%d%d", &x,&y);
        ts[i].a = x;ts[i].b = y;
        //逆辺も入れとく
        ts[i+M].a = y;ts[i+M].b = x;
    }
    qsort(ts,2*M,sizeof (ts), cmp_touple);
    // その部屋が指し示してる方向
    int *direction = (int *)malloc((N+1) * sizeof(int));
    memset(direction,0xFF,sizeof(int)*(N+1));
    //以下bfs やる
    //queueには処理する部屋の順(頂点)が詰まってる
    QUEUE q;
    init(&q);
    enqueue(&q,1);
    direction[1] = 0;
    while (q.first != q.last){
        //queueの頭から一個取り出す
        int v;
        dequeue(&q,&v);
        //printf("%d\n",v);
        int index1 = bisect_left(v,ts,0,(2*M)-1); //<- 引数上手く書く
        int index2 = bisect_right(v,ts,0,(2*M)-1); //<-引数上手く書く
        //printf("%d %d index\n",index1,index2);
        // 計算量は一番深いのがこの一個したのネストでO(Mlog(M)+N)
        for (int index = index1; index < index2; index++) {
            int nv = ts[index].b;
            // nvは新しい頂点(行ける頂点)
            if (direction[nv] != -1) continue;//到達しているのでいらん
            direction[nv] = v;//普通 direction[nv] = direction[v] + 1で距離見る
            enqueue(&q,nv);
        }
    }
    // direction をうまいこと出力
    printf("Yes\n");
    for (int i = 2; i <= N; i++) {
        printf("%d\n",direction[i]);
    }
}

int bisect_left(int x,struct touple a[],int left,int right){
    int mid; right++;
    while (left < right) {
        mid = (left + right) / 2;
        if (a[mid].a < x) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return left;
}

int bisect_right(int x,struct touple a[],int left,int right){
    int mid;
    right++;
    while (left < right) {
        mid = (left + right) / 2;
        if (a[mid].a <= x) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return left;
}

int cmp_touple(const void*n1, const void*n2){
    return ((struct touple*)n1)->a - ((struct touple*)n2)->a;
}

//  スタックの初期化
void init(QUEUE* pQueue)
{
    int i;
    for(i = 0; i < MAX_LENGTH; i++){
        pQueue->array[i] = 0;
    }
    //  最初と最後の位置を先頭に。
    pQueue->first = 0;
    pQueue->last = 0;
}
//  値のプッシュ
int enqueue(QUEUE* pQueue,int value)
{
    pQueue->array[pQueue->last] = value;          // キューに新しい値を入れる
    pQueue->last = (pQueue->last + 1) % MAX_LENGTH;   // lastの更新
    //  データを格納しきれなかった
    return 1;
}
//  値のポップ
int dequeue(QUEUE* pQueue,int* pValue)
{
    *pValue = pQueue->array[pQueue->first];           // いちばん先頭のキューを返す準備
    pQueue->first = (pQueue->first+1) % MAX_LENGTH;   // キューの先頭を次に移動する
    return 1;
}



Measured memory_bytes: 7800
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;++i)
		if(a[i]==a[i-1]){
			cout<<"NO";
			return 0;
		}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 1024
// Hacheylight
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void upd(T &a, T b) { a = (1ll * a + b) % MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }
template <class T> T read() {
    int f = 1 ; T x = 0 ;
    char ch = getchar() ;
    while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
    while (isdigit(ch)) { x = x * 10 + ch -'0' ; ch = getchar() ; }
    return x * f ;
}

int n, k, cnt ;
ll num[N] ;
ll dp[110][N], dp2[N] ;
// dp[i][j] 表示枚举到第i个位置，上一个位置的块在j的方案数

void fact() {
	int i = 1 ;
	while (i <= n) { // 分块
		int j = n / i ;
		if (i <= j) num[cnt++] = 1, i++ ;
		else num[cnt++] = n / j - i + 1, i = n / j + 1 ;
	}
}

signed main() {
	scanf("%d%d", &n, &k) ;
	fact() ;
	clr(dp) ; dp[1][0] = 1 ;
	rep(i, 1, k) {
		clr(dp2) ;
		rep(j, 1, cnt) dp2[j] = (dp2[j - 1] + dp[i][j - 1]) % MOD ;
		rep(j, 0, cnt - 1) dp[i + 1][j] = dp2[cnt - j] * num[j] % MOD ;
	}
	ll ans = 0 ;
	rep(j, 0, cnt) upd(ans, dp[k + 1][j]) ;
	printf("%lld\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/





Measured memory_bytes: 87424
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace ABC121B_CanYouSolveThis
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var input1 = Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToList();
            var N = input1[0];
            var M = input1[1];
            var C = input1[2];

            var B = Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToList();

            var count = 0;
            for (int i = 0; i < N; i++)
            {
                var A = Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToList();
                var sum = 0;
                for (int j = 0; j < M; j++)
                {
                    sum += A[j] * B[j];
                }

                sum += C;

                if (sum > 0)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    vi candidate = {1, 2, 3};
    int a, b; cin >> a >> b;
    rep(i,3) {
        if(candidate[i] != a and candidate[i] != b) {
            cout << candidate[i] << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	vi&a;
	vi&b;
	int k;
	int n, m;
	solve(vi&a, vi&b, int k):a(a), b(b), k(k), n(a.size()), m(b.size()){}
	ll operator()() {
		vll sa(n+1), sb(m+1);
		int ans=0;

		for(int i=0;i<n;i++) sa[i+1]=sa[i]+a[i];
		for(int i=0;i<m;i++) sb[i+1]=sb[i]+b[i];

		for(int i=0;i<=n;i++)
		{
			int r=k-sa[i];

			if(r<0) break;
			auto it=upper_bound(sb.begin(), sb.end(), r);
			int idx=it-sb.begin();
			if(max_u(ans, i+idx-1))
			{
//				cout << i << " " << (idx-1) << "\n";
			}
		}

		return ans;
	}
};

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	for(;;)
	{
		int n, m, k;
		cin >> n >> m >> k;
		if(cin.fail()) break;
		vi a(n), b(m);
		for(auto&ma:a) cin >> ma;
		for(auto&mb:b) cin >> mb;

		cout << solve(a, b, k)() << "\n";
	}
	return 0;
}


Measured memory_bytes: 7948
#include<bits/stdc++.h>
using namespace std;
double n,k;
int main()
{
	cin>>n>>k;
	int i,j;
	double sum=0,b=1.0;
	for(i=1;i<=n;i++)
	{
		double t=k/i;
		for(j=0;j<=20;j++)
		{
			if((1<<j)>=t) 
			{
				double y=(1<<j);
				sum+=b/y;
				break;
			}
		}
	}
	sum/=n;
	printf("%.12lf\n",sum);
	//cout.precision(12);
	//cout<<fixed<<sum<<endl;
}

Measured memory_bytes: 256
function Main(input) {
  var In = input.split(' ');
  var N = parseInt(In[0], 10);
  var A = parseInt(In[1], 10);
  var B = parseInt(In[2], 10);
  var sum = 0;
  
  for(var i = 1; i <= N; i++){
    var str = i.toString(10);
    var array = str.split('');
    var length = array.length;
    var strSum = 0;
    
    for(var j = 0; j < length; j++){
      var num = parseInt(array[j], 10);
      strSum += num;
    }
    
    if((A <= strSum) && (strSum <= B)){
      sum += i;
    }
  }
  
  console.log(sum);
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8368
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define REP(i, from, to) for (long long int i = (from); i < (to); i++)
#define LIN(a) \
    ll a;      \
    cin >> a;

typedef long long ll;

template <class T>
void puta(T &&t) { cout << t << "\n"; }
template <class H, class... T>
void puta(H &&h, T &&... t)
{
    cout << h << ' ';
    puta(t...);
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    LIN(n)
    ll ans = n;
    REP( i, 0, n + 1 ){
        ll cc = 0;
        ll t = i;
        while( t > 0 ) cc += t % 6, t /= 6;
        t = n - i;
        while( t > 0 ) cc += t % 9, t /= 9;
        if( ans > cc ) ans = cc;
    }
    puta( ans );
    return 0;
 }
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, k;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
      k += r - l + 1;
   // k += k;
  }
  cout << k;
}

Measured memory_bytes: 256
N, K = map(int,input().split())

A = []
num = [0]*N
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in A:
        if num[j-1] == 0:
            num[j-1] +=1

ans = 0
for i in num:
    if i == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;

int main(){
  string a,b;
  cin >> a >> b;
  for(int i=0;i<a.size()+b.size();i++){
    if(i%2==0)
      cout << a.at(i/2);
    else
      cout << b.at(i/2);
  }
  cout << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> C(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> C.at(i).at(j);
    }
  }
  for(int i=0;i<H;i++){
    for(int k=0;k<2;k++){
    	for(int j=0;j<W;j++){
      		cout << C.at(i).at(j);
      		if(j==W-1){
            	cout << endl;
      		}
        }    
    }
  }
}
  

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    REP(i, n) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define MAX_N 200000

using namespace std;

typedef long long lint;

const lint sqrInf = 1LL * (1e18);

struct elem
{
    lint s1 = sqrInf, s2 = 0;
};

elem st[MAX_N + 1];
elem dr[MAX_N + 1];

int n;

lint sum[MAX_N + 1];
int a[MAX_N + 1];

void getSums(elem st[], int loc, int pas)
{
    int mid = loc;
    lint sst = a[loc];
    lint sdr = a[loc + pas];
    st[loc + pas].s1 = sst;
    st[loc + pas].s2 = sdr;

    for(int i = loc + pas + pas; i <= n && i >= 1; i += pas)
    {
        sdr += a[i];

        st[i].s1 = sst;
        st[i].s2 = sdr;

        while(mid + pas != i && abs(st[i].s2 - st[i].s1) > abs((sst + a[mid + pas]) - (sdr - a[mid + pas])))
        {
            sst += a[mid + pas];
            sdr -= a[mid + pas];

            st[i].s1 = sst;
            st[i].s2 = sdr;

            mid += pas;
        }
    }
}

int main()
{
    cin >> n;

    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    getSums(st, 1, 1);
    getSums(dr, n, -1);

    lint rez = sqrInf;
    for(int i = 2; i <= n - 2; i ++)
    {
        lint s1 = st[i].s1;
        lint s2 = st[i].s2;
        lint s3 = dr[i + 1].s1;
        lint s4 = dr[i + 1].s2;
        lint mx = max(max(max(s1, s2), s3), s4);
        lint mn = min(min(min(s1, s2), s3), s4);

        rez = min(rez, mx - mn);
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (n); i++)
 
int main() {
	int N,M;
  	cin >> N >> M;
	cout << (((N*(N-1))/(1*2))+((M*(M-1))/(1*2))) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
//int dp[N][N][N];
int check[N];
int a[105];
int n, k;
int res(int q){
    if(check[q]!=-1)return check[q];
    check[q]=0;
    for(int i = 1;i<=n; i++)
    {
        if(q-a[i]<0)break;
        check[q] |= (res(q - a[i]) == 0);
    }
    return check[q];
}
int32_t main(){
      
    memset(check,-1,sizeof(check));
    cin >> n >> k;
    for(int i =1;i<=n;i++)cin>>a[i];
    if(res(k))cout<<"First";
    else cout<<"Second";
}

Measured memory_bytes: 4096
#include<iostream>
#include<cmath>

#define N 55
#define eps 1e-9

using namespace std;

struct Point
{
	double x, y;
	Point(): x(0.0), y(0.0){}
	Point(double _x, double _y) : x(_x), y(_y){}
	
	double dist(const Point& p) const{
		return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
	}
};

istream& operator>>(istream& in, Point& point){
	in >> point.x >> point.y;
	return in;
}

ostream& operator<<(ostream& out, Point& point){
	out << point.x << ' ' << point.y;
	return out;
}


int n;
Point p[N];

double calcMinRad(double cx, double cy)
{
	double radius = 0.0;
	Point center(cx, cy);
	for(int i = 0 ; i < n ; i++){
		radius = max(radius, center.dist(p[i]));
	}
	return radius;
}

double ternaryY(double cx, double minY, double maxY)
{
	double ans = calcMinRad(cx, minY);
	while(maxY - minY > eps)
	{
		double cy1 = minY + (maxY - minY) / 3.0;
		double cy2 = maxY - (maxY - minY) / 3.0;
		double r1 = calcMinRad(cx, cy1);
		double r2 = calcMinRad(cx, cy2);
		if(r1 < r2){
			maxY = cy2;
		}else{
			minY = cy1;
		}
		ans = min(r1, r2);
	}
	return ans;
}

double ternaryX(double minX, double maxX, double minY, double maxY)
{
	double ans = 0;
	while(maxX - minX > eps)
	{
		double cx1 = minX + (maxX - minX) / 3.0;
		double cx2 = maxX - (maxX - minX) / 3.0;
		double r1 = ternaryY(cx1, minY, maxY);
		double r2 = ternaryY(cx2, minY, maxY);
		if(r1 < r2){
			maxX = cx2;
		}else{
			minX = cx1;
		}
		ans = min(r1, r2);
	}
	return ans;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	double minX, minY, maxX, maxY;
	minX = minY = 10000;
	maxX = maxY = 0; 
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		cin >> p[i];
		minX = min(minX, p[i].x);
		minY = min(minY, p[i].y);
		maxX = max(maxX, p[i].x);
		maxY = max(maxY, p[i].y);
	}
	cout.precision(9);
	cout << fixed << ternaryX(minX, maxX, minY, maxY) << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long A[3][3];
	bool B[3][3] = {};
	long long N;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) cin >> A[i][j];
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		long long X;
		cin >> X;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (A[j][k] == X) B[j][k] = true;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		if (B[i][0] && B[i][1] && B[i][2]) {
			cout << "Yes" << endl;
			return 0;
		}
		if (B[0][i] && B[1][i] && B[2][i]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (B[0][0] && B[1][1] && B[2][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (B[0][2] && B[1][1] && B[2][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split(" "))
list = [0]*(M+1)
for i in range(N):
    A = input().split(" ")
    A = [int(i) for i in A]
    K = A[0]
    for j in range(K):
        list[A[j+1]] += 1
C = 0
for i in range(len(list)):
    if list[i] == N:
        C += 1
print(C)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;

    vector<double> p(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }

    vector<vector<double>> table(N + 1, vector<double>(N + 1, 0));
    table[0][0] = 1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            table[i + 1][j] += table[i][j] * (1 - p[i]);
            table[i + 1][j + 1] += table[i][j] * p[i];
        }
    }
    int idx = N;
    double ans = 0;
    while (idx > (N - idx))
    {
        ans += table.back()[idx];
        idx--;
    }

    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 70656
from math import floor, ceil 
N = int(input())
A = list(map(int, input().split()))

avg = sum(A) / N

ans1 = 0
ans2 = 0
x1 = floor(avg)
x2 = ceil(avg)

for a in A:
  ans1 += (a - x1) ** 2
  ans2 += (a - x2) ** 2
  
print(min(ans1, ans2))

Measured memory_bytes: 3064
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int H, W, K;
    string s[300];
    
    // 入力
    cin >> H >> W >> K;
    
    for (int i=0;i<H;i++) {
        cin >> s[i];
    }
    
    //cout << s[0][0] << endl;
    
    
    int result[300][300] = {};
    //cout << result[0][0] << endl;
    
    int result_index = 1;
    for (int i=0;i<H;i++) {
        int temp_index = 0;
        for (int j=0;j<W;j++) {
            if (s[i][j] == '#') {
                for (int k=temp_index;k<=j;k++) {
                    result[i][k] = result_index;
                    temp_index = j+1;
                }
                result_index += 1;
            }
        }
        if (temp_index != W and temp_index != 0) {
            for (int k=temp_index;k<W;k++) {
                result[i][k] = result_index - 1;
            }
        }
    }
    
    for (int i=0;i<H;i++) {
        if (result[i][0] == 0) {
            for (int j=i+1;j<H;j++) {
                if (result[j][0] != 0) {
                    for (int k=0;k<W;k++) {
                        result[i][k] = result[j][k];
                    }
                    break;
                }
            }
        }
        
        if (result[i][0] == 0) {
            for (int j=i-1;j>=0;j--) {
                if (result[j][0] != 0) {
                    for (int k=0;k<W;k++) {
                        result[i][k] = result[j][k];
                    }
                    break;
                }
            }
        }
    }
    
    for (int i=0;i<H;i++) {
        for (int j=0;j<W;j++) {
            cout << result[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll n,k;
	ll r,s,p;
	string t;
	ll i;
	cin >> n >> k >> r >> s >> p >> t;
	ll ans=0;
	ll w[n];
	for(i=0;i<n;i++){
		if(t[i]=='r'){
			if((i>=k && w[i-k]==1) && t[i-k]=='r'){
				w[i]=0;
			}else{
				ans+=p;
				w[i]=1;
			}
		}
		if(t[i]=='s'){
			if((i>=k && w[i-k]==1) && t[i-k]=='s'){
				w[i]=0;
			}else{
				ans+=r;
				w[i]=1;
			}
		}
		if(t[i]=='p'){
			if((i>=k && w[i-k]==1) && t[i-k]=='p'){
				w[i]=0;
			}else{
				ans+=s;
				w[i]=1;
			}
		}
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

bool from1[2505];
bool fromN[2505];
bool ok[2505];
vector<vl> G(2505);
vector<vl> rG(2505);



int main(){
    ll n; cin >> n;
    string s;
    ll div = -2;
    if(n==0) {puts("0"); return 0;}
    while(4*abs(n) >= abs(div)){
        ll r = n % div;
        ll t = r==0 ? 0 : 1;
        //cout << r << endl;
        if(n==div/-2) s.push_back('1');
        else s.push_back((char)(abs(t)+'0'));
        n += t==0 ? 0 : div/2;
        //cout << "n: " << n << endl;
        div *= -2;
    }
    reverse(all(s));
    cout << s << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,m;cin>>n>>m;
  if(n==1LL||m==1LL){
    cout<<1;return 0;
  }
  cout<<(n*m+1LL)/2;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: i64,
        x: i64,
    }
    for i in x - k + 1..x + k {
        print!("{} ", i);
    }
    println!();
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;

int main() {
  int t[26] = {0};

  string w;
  cin >> w;
  for (char c : w) {
    t[c - 'a']++;
  }

  bool beautiful = true;
  for (auto e : t) {
    if (e % 2 == 1) {
      beautiful = false;
      break;
    }
  }
  if (beautiful)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

vector<ll> edges_f[200000];
vector<ll> edges_t[200000];
ll counter[200000] = {};
ll ans[200000] = {};

int serch(int i, int value) {
	value += counter[i];
	ans[i] += value;
	for (auto x: edges_f[i]) {
		// cout << x << endl;
		serch(x, value);
	}
	return 0;
}

ll roots = 0;

int root(ll i) {
	if (edges_t[i].size() == 0) return i;
	else if (edges_t[i].size() == 1) {
		return root(edges_t[i][0]);
	}
}

int main() {
	ll N, Q;
	cin >> N >> Q;
	ll a[N-1], b[N-1];
	ll p[Q], x[Q];
	rep(i,0,N-1) cin >> a[i] >> b[i];
	rep(i,0,Q) cin >> p[i] >> x[i];

	rep(i,0,N-1) {
		// edge e = {a[i], b[i]};
		edges_f[a[i]-1].push_back(b[i]-1);
		edges_t[b[i]-1].push_back(a[i]-1);
	}
	rep(i,0,Q) {
		counter[p[i]-1] += x[i];
	}
	// rep(i,0,N) {
	// 	cout << counter[i] << endl;
	// }

	roots = root(0);
	// cout << roots << endl;
	serch(roots, 0);

	rep(i,0,N-1) {
		cout << ans[i] << " ";
	}
	cout << ans[N-1] << endl;
	return 0;
}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


void solve(std::string S){
    if(S == "Sunny") cout<<"Cloudy" << endl;
    if(S == "Cloudy") cout<<"Rainy" << endl;
    if(S =="Rainy") cout<<"Sunny" << endl;
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)

void resolve()
{
    int A, B;
    cin >> A >> B;

    int start = 1;
    while ((int)(start * 0.08) != A) start++;

    int end = start;
    while ((int)(end * 0.08) == A) end++;
    end--;

    int ans = -1;
    RPT(j, start, end)
    {
        if ((int)(j * 0.1) == B) {
            ans = j;
            break;
        }
    }

    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    resolve();
    return 0;
}


Measured memory_bytes: 256