akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string S, T;
    cin >> S >> T;

    cout << T << S << endl;
    
}

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

using namespace std;

int main(){
  string s;
  long long k;
  cin >> s;
  cin >> k;
  long long one = 0;
  for (auto c: s){
    if (c=='1'){
      one++;
    } else {
      break;
    }
  }
  if (k <= one){
    cout << "1";
  }else{
    cout << s[one];
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int A1;
  int A2; 
  int A3;
  int Total;
  scanf("%d", &A1);
  scanf("%d", &A2);
  scanf("%d", &A3);
  Total = A1 + A2 + A3;
  if(Total>=22){
  	printf("bust\n");
  }
  else{
  	printf("win\n");
  }
	 
  return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long

int main() {
	int n, h[110] = { 0 }, ans = 0, now = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> h[i];

	while (1) {
		if (h[now] > 0) {
			int j = now;
			while (h[j] > 0) {
				h[j]--;
				j++;
			}
			ans++;
		}
		else {
			now++;
		}
		if (now == n)break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};


int main(){
    ll n, d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> v(n);
    REP(i, n){
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    vector<ll> x(n), h(n);
    REP(i, n){
        x[i] = v[i].first;
        h[i] = v[i].second;
    }
    LazySegmentTree tree(h);
    ll ans = 0;
    REP(i, n){
        ll hp = tree.getsum(i, i + 1);
        if(hp <= 0) continue;
        ll k = (hp % a == 0)? hp / a : hp / a + 1;
        ans += k;
        ll itr = lower_bound(x.begin(), x.end(), x[i] + d + d + 1) - x.begin();
        tree.add(i, itr, -(a * k));
    }
    cout << ans << endl;
}

Measured memory_bytes: 16256
from itertools import permutations
from math import sqrt

N = int(input())
X = [0] * N
Y = [0] * N
for i in range(N):
    X[i], Y[i] = map(int, input().split())

d = []
for route in permutations(range(N), N):
    dist = 0
    for i, j in zip(range(N - 1), range(1, N)):
        dist += sqrt((X[route[j]] - X[route[i]]) ** 2 + (Y[route[j]] - Y[route[i]]) ** 2)
    d.append(dist)
print(sum(d) / len(d))


Measured memory_bytes: 42332
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    READ(n);
    vector <vi> adj(n + 1), adjt(n + 1);
    FOR (i, 1, n)
    {
        READ(x);
        FOR (j, 1, x)
        {
            int a, b;
            cin >> a >> b;
            if (b) adj[i].pb(a);
            else adjt[i].pb(a);
        }
    }
    
    int ans = 0;
    FOR (i, 0, (1LL << n) - 1)
    {
        vi lis;
        FOR (j, 0, 14)
            if ((i >> j) & 1) lis.pb(j + 1);
        
        int br = 0, m[16] = {};
        for (int j: lis) m[j] = 1;
        
        for (int j: lis)
        {
            for (int x: adj[j])
                if (!m[x]) {br = 1; break;}
            
            for (int x: adjt[j])
                if (m[x]) {br = 1; break;}
            
            if (br) break;
        }
        
        if (br) continue;
        ans = max(ans, (ll)(lis.size()));
    }
    
    cout << ans;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
edges = [[] for _ in range(n + 1)]
for _ in range(n - 1):
	u, v, w = list(map(int, input().split()))
	edges[u].append([v, w % 2])
	edges[v].append([u, w % 2])


bw = [-1 for i in range(n + 1)]
bw[1] = 0

def dfs(frm):
	for ne in edges[frm]:
		if bw[ne[0]] >= 0:
			continue
		else:
			bw[ne[0]] = abs(bw[frm] - ne[1])
			dfs(ne[0])

dfs(1)
for i in range(1, n + 1):
	print(bw[i])


Measured memory_bytes: 83028
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


int main() {
  string s; cin >> s;
  int Q; cin >> Q;

  deque<char> S;
  for (const char e : s) S.push_back(e);

  bool is_rev = false;
  rep(i, Q) {
    int t; cin >> t;
    if (t == 1) {
      is_rev = !is_rev;
    } else {
      int f; char c; cin >> f >> c;
      --f;
      if (is_rev) f = 1 - f;
      if (f == 0)
        S.push_front(c);
      else
        S.push_back(c);
    }
  }
  while (!S.empty()) {
    char c;
    if (is_rev) {
      c = S.back(); S.pop_back();
    } else {
      c = S.front(); S.pop_front();
    }
    cout << c;
  }
  cout << endl;


  return 0;
}


Measured memory_bytes: 896
// abc132_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int ans = 0;
    REP(i, N-2){
        vector<int> v{A[i], A[i+1], A[i+2]};
        sort(ALL(v));
        if (v[1] == A[i+1]){
            ans++;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, BufRead, BufReader};

fn main() {
    let input = BufReader::new(stdin());
    for line in input.lines() {
        let v: Vec<f32> = line.unwrap()
            .split_whitespace()
            .filter_map(|x| x.parse::<f32>().ok())
            .collect();
        let x = (v[2] * v[4] - v[1] * v[5]) / (v[0] * v[4] - v[1] * v[3]);
        let y = (v[2] * v[3] - v[0] * v[5]) / (v[1] * v[3] - v[0] * v[4]);
        println!("{:.3} {:.3}", x, y);
    }
}



Measured memory_bytes: 5060
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		long sum = 0;
		for (int i = 0; i < n - k; i++) {
		    sum += arr[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 87180
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define pll pair<ll,ll>
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
#define PI 3.141592653589
const ll INF = 1e18l+10,N = 1e5+10,MAX = 2e5+10;

int main()
{
    SPEED
    ll n,i,j;
    cin>>n;
    double p;
    double dp[n+1];
    memset(dp, 0, sizeof(dp));
    dp[0] =1.0;
    f(n) {
        cin>>p;
        for(j=i+1;j>=0;j--){
        if(j)
        dp[j] = dp[j-1]*p + dp[j]*(1.0-p);
        if(!j)
        dp[j]*=(1.0 - p);
        }        
    }

    double ans = 0;
    for(i=n/2+1;i<=n;i++)ans+=dp[i];
    cout<<fixed<<setprecision(10)<<ans<<'\n';

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  string a,b,c;
  int n,x=0;
  cin>>n>>a>>b>>c;
  for(int i=0;i<n;i++){
    if(a[i]==b[i] and a[i]==c[i]){
      x+=0;
    }
    else if(a[i]!=b[i] and a[i]!=c[i] and b[i]!=c[i]){
      x+=2;
    }
    else
      x+=1;
  }
  cout<<x<<endl;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long long> B(N+1,0);
  int mod = 1000000007;
  
  for(int i = 0;i<N;i++){
    cin >> A.at(i);
    B.at(i+1) = B.at(i)+A.at(i);
  }
  long long ans = 0;
  for(int i = 0;i<N;i++){
    long long sum = (B.at(N)-B.at(i+1))%mod;
    ans += A.at(i)*sum;
    ans %= mod;
  }
  cout << ans;
}

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

int main(void){
    ll n;
    cin >> n;
    int ans = 0, x;
    bool flag = false;
    while (n != 0){
        x = n % 10;
        n /= 10;
        if (x != 9 && n != 0) flag = true;
        if (n > 0) ans += 9;
        else ans += x;
    }
    cout << ans - flag << endl;
    return 0;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 10001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

const double PI = acos(-1);
typedef pair<int, int> P;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int main()
{
    string S;
    string T;
    cin >> S >> T;
    cout << T << S << endl;
}

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

int main() {
 int N;
 
 cin >> N;
  vector<int> a(N), b(N), c(N - 1);

  for(int i = 0; i < N; i++) {
    cin >> a[i];
    a[i]--;
  }

  for(int i = 0; i < N; i++) {
    cin >> b[i];

  }

  for(int i = 0; i < N - 1; i++) {
    cin >> c[i];

  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    ans += b[a[i]];
   
  }

  for(int i = 0; i < N - 1; i++) {
    if(a[i] + 1 == a[i + 1]) ans += c[a[i]];
  }


  cout << ans;
 return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <climits>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define M 1000000007
int main() {
    int n;cin>>n;
    int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(i==1)
        {
            c=(2*(n-2))+1;
        }
        else
        {
            for(int j=i;j<=(n/i);j++)
            {
                
                if(j*i==n)
                {
                    continue;
                }
                else if(((j*i)!=n)&&(j!=i))
                {
                    c+=2;
                }
                else if(j==i)
                {
                    c++;
                }
            }
        }    
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3192
from collections import deque
H,W,K = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
sx-=1;sy-=1;gx-=1;gy-=1
Pond = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp = list(temp)
  Pond.append(temp)
#print(Pond)
Q = deque([])
Q.append((sx,sy))
reach = [[INF]*W for _ in range(H)]
reach[sx][sy] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
while Q:
  nx,ny = Q.popleft()
  step = K
  for i in range(4):
    for fac in range(1,K+1):
      tx = nx + fac*dxdy[i][0]
      ty = ny + fac*dxdy[i][1]
      #print(i,tx,ty)
      if 0>tx or tx>=H or 0>ty or ty>=W or Pond[tx][ty] == "@": #or reach[tx][ty] != INF:
        #print(i,tx,ty,reach[2][0])
        break #範囲外やハスがあった、到達済みの場合には終了
      #print(i,tx,ty)
      if reach[nx][ny] + 1 > reach[tx][ty]: #もし現時点よりもステップが大きい場合はだめ。
        #同じ場合は向き的に得している場合もあるので残す。
        break
      if reach[nx][ny] + 1 == reach[tx][ty]:
        #同じときはQに加える必要はないが、そのまま先に進んだら得の場合があるのでContinue
        continue
      reach[tx][ty] = reach[nx][ny] + 1
      Q.append((tx,ty))
      if tx == gx and ty == gy:
        print(reach[gx][gy])
        exit()
#print(reach)
#ans = reach[gx][gy]
#if ans == INF:
print(-1)
#else:
#  print(ans)

Measured memory_bytes: 135148
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
res = A[0]
i = 1
c = 2
while c < N:
    res = res + A[i]
    c = c + 1
    if c >= N:
        break
    res = res + A[i]
    c = c + 1
    if c >= N:
        break
    i = i + 1
    
print(res)

Measured memory_bytes: 31376
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	ll N; cin >> N;
	vector<bool> is_prime(101,true);
	vector<ll> v(101, 0);
	is_prime[1] = false;
	for (int i = 2; i < 101; i++) {
		for (int j = 2; j < sqrt(i) +1; j++) {
			if (i % j == 0) {
				is_prime[i] = false;
			}
		}
	}
	is_prime[2] = true;

	rep(i, N+1) {
		ll n = i;
		ll k = 1;
		while (n > 1) {
			while (not is_prime[k])k++;
			while (n % k == 0) {
				v[k]++;
				n /= k;
			}
			k++;
		}
	}

	sort(all(v));
	reverse(all(v));
	ll num74 = 0;
	ll num24 = 0;
	ll num14 = 0;
	ll num4 = 0;
	ll num2 = 0;
	ll ans = 0;
	for (auto a : v) {
		if (a >= 74) num74++;
		if (a >= 24) num24++;
		if (a >= 14) num14++;
		if (a >= 4) num4++;
		if (a >= 2) num2++;
		else break;
	}
	ans += num74;
	ans += num24 * (num2 - 1);
	ans += num14 * (num4 - 1);
	ans += num4 * (num4 - 1) * (num2-2)/2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  string s; cin >> s;
  vector <ll> x = {1, 1, -1, -1};
  vector <ll> y = {1, -1, 1, -1};
  bool flag = 1;
  rep(i, 4) {
    vector <ll> v(n);
    v.at(0) = x.at(i), v.at(1) = y.at(i);
    for (ll j = 1; j < n-1; j++) {
      if (v.at(j) > 0) {
        if (s.at(j) == 'o') v.at(j+1) = v.at(j-1);
        else v.at(j+1) = -v.at(j-1);
      } else {
        if (s.at(j) == 'o') v.at(j+1) = -v.at(j-1);
        else v.at(j+1) = v.at(j-1);
      }
    }
    bool sub_flag = 1;
    if (v.at(n-1) > 0) {
      if (s.at(n-1) == 'o') {
        if (v.at(n-2) == v.at(0)) sub_flag = 0;
      } else {
        if (v.at(n-2) != v.at(0)) sub_flag = 0;
      }
    } else {
      if (s.at(n-1) == 'o') {
        if (v.at(n-2) != v.at(0)) sub_flag = 0;
      } else {
        if (v.at(n-2) == v.at(0)) sub_flag = 0;
      }
    }
    if (!sub_flag) {
      if (v.at(0) > 0) {
        if (s.at(0) == 'o') {
          if (v.at(n-1) == v.at(1)) flag = 0;
        } else {
          if (v.at(n-1) != v.at(1)) flag = 0;
        }
      } else {
        if (s.at(0) == 'o') {
          if (v.at(n-1) != v.at(1)) flag = 0;
        } else {
          if (v.at(n-1) == v.at(1)) flag = 0;
        }
      }
    }
    if (!flag) {
      rep(i, n) {
        if (v.at(i) > 0) cout << 'S';
        else cout << 'W';
      }
      cout << endl;
      break;
    }
  }
  if (flag) cout << -1 << endl;
}

Measured memory_bytes: 4572
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);


void solve() {
   int a[3][3];
   for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>a[i][j];
   int n;cin>>n;
   int b[3][3];
   memset(b,0, sizeof(b));
   for(int i=0;i<n;i++){
       int x;cin>>x;
       for(int j=0;j<3;j++){
           for(int k=0;k<3;k++){
               if(x==a[j][k])b[j][k]=1;
           }
       }
   }
   bool ans=0;
   for(int i=0;i<3;i++){
       int an1=1,an2=1;
       for(int j=0;j<3;j++){
           an1&=b[i][j];
           an2&=b[j][i];
       }
       if(an1 || an2){
           ans=1;
       }
   }
   bool test1=b[0][0]&b[1][1]&b[2][2];
   bool test2=b[0][2]&b[1][1]&b[2][0];
   if(test1 || test2)ans=1;

   if(ans)
       cout<<"Yes";
   else cout<<"No";
}

int32_t main() {
    IOS;
    int test = 1;
    //cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(1341398)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD

N, K = map(int, readline().split())

if K == 1:
    ans = N*(N-1)
else:
    ans = 1
    for x in range(1, min(N, K) + 1):
        ans = (ans + comb(N, x)*comb(x+N-x-1, N-x-1))%MOD
print(ans)
    

Measured memory_bytes: 82984
#include <iostream>
#include <queue>
using namespace std;
int dis[200005],End[400005],Last[400005],Next[400005],len[400005],n,m;
bool flag[200005];
queue<int>q;
void spfa(int s)
{
	int i,t,j,b;
	for(i=1;i<=n;i++)dis[i]=99999999;
	dis[s]=0;flag[s]=true;q.push(s);
	while(q.size())
	{
		j=q.front();
		q.pop();
		flag[j]=false;
		t=Last[j];
		while(t)
		{
			b=End[t];
			if(dis[b]>dis[j]+len[t])
			{
				dis[b]=dis[j]+len[t];
				if(flag[b]==false)
				{
					flag[b]=true;
					q.push(b);
				}
			}
			t=Next[t];
		}
	}
}
int main()
{
	int i,a,b,k=0;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>a>>b;
		End[++k]=b;
		Next[k]=Last[a];
		Last[a]=k;
		len[k]=1;
		End[++k]=a;
		Next[k]=Last[b];
		Last[b]=k;
		len[k]=1;
	}
	spfa(1);
	if(dis[n]>2)cout<<"IMPOSSIBLE";
	else cout<<"POSSIBLE";
}

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i=l;i<=r;++i) if(i%d==0) ++ans;
  cout << ans << endl;
}


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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	ll h,a;
	in h >> a;
	ll ans = 0;
	for (ll i = 0; h > 0; h -= a)
	{
		ans++;
	}
	out ans en;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    string S; cin >> S;
    ll K; cin >> K;
    
   for (ll i=0; i<min((ll)S.size(),K); i++){
       if(S[i]>='2'){
           cout << S[i] << endl;
           return 0;
       }
   }
    cout << '1' << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	long long res = 0;
	for (int a = 1; a <= n; ++a) {
		for (int b = 1; b <= n; ++b) {
			for (int c = 1; c <= n; ++c) {
				res += gcd(a, gcd(b, c));
			}
		}
	}
	cout << res << '\n';
	return 0;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    int num = std::stoi(a + b);

    bool flag = false;
    for (int i = 0; i < 334; i++) {
        if (i * i == num) {
            flag = true;
            break;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n,m;
char mp[15][15];
bool canmatn[15][15];
bool canmatm[15][15];
int cnt[30];
bool vis1[15];
int mat1[15];
bool issig1;
int fg=-1;
bool vis2[15];
int mat2[15];
bool issig2;
void dfs2(int x)
{//cout<<"A"<<x<<endl;
	if(x==m)
	{
		if((m&1) && !issig2)	return;
		fg=1;
		return;
	}
	if(vis2[x])
	{
		dfs2(x+1);
		return;
	}
	if(fg!=-1)	return;
	if((m&1) && !issig2)
	{
		mat2[x]=x;
		vis2[x]=1;
		issig2=1;
		dfs2(x+1);
		issig2=0;
		vis2[x]=0;
	}
	if(fg!=-1)	return;
	vis2[x]=1;
	for(int j=x+1;j<m && fg==-1;j++)
		if(!vis2[j] && canmatm[x][j])
		{
			vis2[j]=1;
			mat2[x]=j;
			mat2[j]=x;
			dfs2(x+1);
			vis2[j]=0;
		}
	vis2[x]=0;
}
void dfs1(int x)
{//cout<<"EM"<<x<<' '<<issig1<<endl;
//for(int i=0;i<n;i++)	cout<<i<<' '<<mat1[i]<<endl;
	if(x==n)
	{
		if((n&1) && !issig1)	return;
		memset(canmatm,0,sizeof(canmatm));
		for(int i=0;i<m;i++)
			for(int j=0;j<m;j++)
			{
				canmatm[i][j]=1;
				for(int k=0;k<n;k++)
					if(mp[k][i]!=mp[mat1[k]][j])
					{
						canmatm[i][j]=0;
						break;
					}
			}//cout<<"AA"<<endl;
//		for(int i=0;i<n;i++)	cout<<i<<' '<<mat1[i]<<endl;
//		for(int i=0;i<m;i++)
//			for(int j=0;j<m;j++)	cout<<i<<' '<<j<<' '<<canmatm[i][j]<<endl;
		dfs2(0);
		return;
	}
	if(vis1[x])
	{
		dfs1(x+1);
		return;
	}
	if(fg!=-1)	return;
	if((n&1) && !issig1)
	{
		mat1[x]=x;
		vis1[x]=1;
		issig1=1;
		dfs1(x+1);
		issig1=0;
		vis1[x]=0;
	}
	if(fg!=-1)	return;
	vis1[x]=1;
	for(int j=x+1;j<n && fg==-1;j++)
		if(!vis1[j] && canmatn[x][j])
		{
			vis1[j]=1;
			mat1[x]=j;
			mat1[j]=x;
			dfs1(x+1);
			vis1[j]=0;
		}
	vis1[x]=0;
}
int main()
{
	read(n);
	read(m);
	for(int i=0;i<n;i++)
		scanf("%s",mp[i]);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			memset(cnt,0,sizeof(cnt));
			for(int k=0;k<m;k++)
				cnt[mp[i][k]-'a']++;
			for(int k=0;k<m;k++)
				cnt[mp[j][k]-'a']--;
			canmatn[i][j]=1;
			for(int k=0;k<26;k++)
				if(cnt[k])	canmatn[i][j]=0;
		//	if(canmatn[i][j])	cout<<i<<' '<<j<<endl;
		//	cout<<"MATARR"<<i<<" "<<j<<" "<<canmatn[i][j]<<endl;
		}
	dfs1(0);
	if(fg==1)	printf("YES\n");
	else	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
// C - Not so Diverse
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vector<int> C(N+1);
	rp(i, 0, N){ int a; cin>>a; C[a]++; }
	sort(C.rbegin(), C.rend());
	int c = 0;
	rp(i, 0, K) c += C[i];
	cout<< N-c <<endl;
}

Measured memory_bytes: 1024
import java.io.*
import java.util.*

fun solve(N: Int, Q: Int, a: IntArray, b: IntArray, p: IntArray, x: IntArray) {
    // score(i) = score(i.parent) + x[pi = i]
    data class Node(val edges: ArrayDeque<Int>, var score: Int = 0)
    val nodes = Array(N) { Node(ArrayDeque<Int>()) }
    for (i in 0 until N - 1) {
        nodes[a[i] - 1].edges.add(b[i] - 1)
        nodes[b[i] - 1].edges.add(a[i] - 1)
    }
    val scores = mutableMapOf<Int, Int>()
    repeat(Q) {
        scores[p[it] - 1] = x[it] + scores.getOrElse(p[it] - 1) { 0 }
    }
    val root = 0
    val queue = ArrayDeque<Pair<Int, Int>>()
    val isCalced = BooleanArray(N){ false }
    queue.addLast(root to 0)
    while (queue.size > 0) {
        val (nd, s) = queue.removeFirst()
        if (isCalced[nd]) continue
        nodes[nd].score = s + scores.getOrElse(nd) { 0 }
        isCalced[nd] = true
        nodes[nd].edges.filter{ !isCalced[it] }.forEach { queue.addLast(it to nodes[nd].score) }
    }
    println(nodes.map { it.score }.joinToString(separator = " "))
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val Q = sc.next().toInt()
    val a = IntArray((N - 1))
    val b = IntArray((N - 1))
    for (i in 0 until (N - 1)) {
        a[i] = sc.next().toInt()
        b[i] = sc.next().toInt()
    }
    val p = IntArray(Q)
    val x = IntArray(Q)
    for (i in 0 until Q) {
        p[i] = sc.next().toInt()
        x[i] = sc.next().toInt()
    }
    solve(N, Q, a, b, p, x)
}


Measured memory_bytes: 153708
import bisect
n = int(input())
L = list(map(int, input().split()))
L.sort()

count = 0
for i in range(0, n-2):
  for j in range(i+1, n-1):
    t = L[i] + L[j]
    idx = bisect.bisect_left(L, t)
    count += idx - (j+1)

print(count)


Measured memory_bytes: 42972
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int x[10][10];

int main()
{
    int n, d;
    cin >> n >> d;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int dsq = 0;
            for (int k = 0; k < d; k++)
            {
                int dif = x[i][k] - x[j][k];
                dsq += dif * dif;
            }

            int dist = floor(sqrt(dsq));
            if (dist * dist == dsq)
            {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a)
a = [i if i <= x else x for i in a]
for i in range(n-1):
    if a[i]+a[i+1] > x:
        a[i+1] = x-a[i]
print(ans-sum(a))

Measured memory_bytes: 19988
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define drep(i,l,r) for(int (i)=(l);(i)>=(r);(i)--)
using namespace std;
int main(){
    ll n,k,ans=0;
    ll sc[3],win[1000];
    string t;
    cin>>n>>k;
    cin>>sc[0]>>sc[1]>>sc[2];//r s p
    cin>>t;
    vector<int> same(n); // r s p
    win['r']=2,win['s']=0,win['p']=1;
    rep(i,0,n){
        if(i>=k&&t[i]==t[i-k]&&!same[i-k])same[i]=1;
    }
    rep(i,0,n){
        if(!same[i])ans+=sc[win[t[i]]];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
 
int main() { 
  int N; cin >> N;
  string s = "";
  while (N) {
    if (N%-2) {
      N--;
      s = "1"+s;
    } 
    else {
      s = "0"+s;
    }
    N/=-2;
  }
 if (s == "") {
   s = "0";
 }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
J, I, X, Y, N, M, A['   '];
main() {
  scanf("%d%d", &N, &M);
  for (; ~scanf("%d%d", &X, &Y);) {
    int b = Y + 1;
    for (J = 1; J * J <= M; J++) {
      int tx = (X + J - 1) / J, ty = Y / J;
      A[tx]++;
      A[ty + 1 < b ? ty + 1 : b]--;
      b = tx;
    }
    for (I = 1; I < b; I++) {
      if ((X - 1) / I < Y / I) {
        A[I]++;
        A[I + 1]--;
      }
    }
  }
  for (I = 1; I <= M; I++) {
    A[I] += A[I - 1];
    printf("%d\n", A[I]);
  }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, d, r;
    double A, B, f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    A = a;
    B = b;
    f = A / B;
    cout << d << " " << r << " " << fixed << f << endl;
    return 0;
}


Measured memory_bytes: 3268
fun main(args: Array<String>) {
    val Q = readLine()!!.toInt()

    fun sqrt(t: Long): Long {
        var l = 1L
        var u = 2e9.toLong()

        while (u - l > 1) {
            val c = (l + u) / 2

            if (c * c > t) {
                u = c
            } else {
                l = c
            }
        }

        return l
    }

    for (q in 1..Q) {
        val (A, B) = readLine()!!.split(" ").map{it.toLong()}

        if (Math.max(A, B) == 1L) {
            println(0)
            continue
        }

        val M = A * B - 1
        val L = sqrt(M)
        var T = L * 2

        if (L == M / L) {
            T -= 1L
        }
        if (Math.min(A, B) <= L) {
            T -= 1L
        }

        println(T)
    }
}


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

int main(){
  int K, N;
  cin >> K >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  int m = 0;
  for (int i = 0; i < N - 1; i++){
    m = max(m, a[i + 1] - a[i]);
  }
  m = max(m, K - a[N - 1] + a[0]);
  cout << K - m;
}
  


Measured memory_bytes: 4412
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<deque>
#include<set>
#define inf 1e9
#define eps 1e-6
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
struct edge
{
	int next,to;
}e[N<<1];
int head[N],cnt;
int n,k,ans,maxn[N];
inline void add_edge(int from,int to){e[++cnt]=(edge){head[from],to};head[from]=cnt;}
void dfs(int now,int father)
{
	for(register int i=head[now];i;i=e[i].next)
	{
		dfs(e[i].to,now);maxn[now]=max(maxn[e[i].to]+1,maxn[now]);
	}
	if(maxn[now]==k-1&&father!=1){ans++;maxn[now]=-1;}
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),k=read();
	for(register int i=1;i<=n;i++)
	{
		int x=read();
		if(i==1)ans+=(x!=1),maxn[1]=inf;
		else add_edge(x,i);
	}
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11496
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
main(){
scanf("%lld",&n);
int ans = 0;
int rem = 0;
for (int x = 0; x<n; x++){
    int t;
    scanf("%lld",&t);
    if (rem!=0 && t>0){
        t--;
        rem = 0;
        ans++;
    }
    ans += t/2;
    rem = t%2;

}
printf("%lld",ans);
}


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

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if(500 * i + 100 * j + 50 * k == X){ ans++; }
      }
    }
  }

  cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,ans=1e12;
    cin>>n;
    for(int i=1;i<=1e6;i++)
        if(n%i==0)
            ans=min(ans,i+n/i-2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(b/a!=c/a)  puts("OK");
	else if(b%a==0||c%a==0) puts("OK");
	else puts("NG");
	return 0; 
} 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin>>S;
    vector<int> sum((int)S.size());
    int N = S.size();
    int R=1,L=0;
    int i = 0;
    int j=0;
    while(i<N){
        while(S[i+1]=='R' && i<N-1) R++,i++;
        j = i;
        while(S[i+1]=='L' && i<N-1) L++,i++;
        //cout<<j<<":"<<i<<endl;
        //cout<<R<<":"<<L<<endl;
        sum[j] += (R+1)/2;
        sum[j+1] += R/2;
        sum[j+1] += (L+1)/2;
        sum[j] += L/2;
        if(i==N-1){
            break;
        }
        R = 0;
        L = 0;
    }
    REP(i,N) cout<<sum[i]<<" "<<endl;
}


Measured memory_bytes: 1232
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    int n; cin >> n;
    int four = 0,two = 0;
    rep(i,n){
        ll a; cin >> a;
        if(a % 4 == 0) four++;
        if(a % 2 == 0) two++;
    }
  	two -= four;

    if(four >= n / 2){
        cout << "Yes" << endl;
        return 0;
    }else if(two == n){
        cout << "Yes" << endl;
        return 0;
    }else if(two + four >= n / 2 + 1 && (n - 2 * four) == two){
      cout << "Yes" << endl;
      return 0;
    }

    cout << "No" << endl;
}

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

int main() {
    string s,t;
    cin>>s>>t;
    bool canmake=true;
    //sから始める
    int it=-1;
    for (int i = 1; i < s.size(); i+=2) {
        bool f=false;
        for (int j = 0; j < t.size(); ++j) {
            if(t[j]==s[i]&&j>=(i-1)/2&&j>it){
                f=true;
                it=j;
                break;
            }
        }
        canmake=f;
        if(!canmake)break;
    }
    if(canmake){
        cout<<"Yes"<<endl;
        return 0;
    }
    //ｔから始める
    it=-1;
    for (int i = 0; i < s.size(); i+=2) {
        bool f=false;
        for (int j = 0; j < t.size(); ++j) {
            if(t[j]==s[i]&&j>=i/2&&j>it){
                f=true;
                it=j;
                break;
            }
        }
        canmake=f;
        if(!canmake)break;
    }
    if(canmake)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3228
n, k = map(int, input().split())

A = []

for i in range(n):
    c = []
    a, b = map(int, input().split())
    c.append(a)
    c.append(b)
    A.append(c)

A.sort(key=lambda x:x[0])


f = k
i = 0
while f > 0:
    f -= A[i][1]
    i += 1

print(A[i-1][0])

Measured memory_bytes: 22912
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    vec x(5);
    loop(i, 5) cin >> x[i];
    loop(i, 5)
    {
        if (x[i] == 0)
            putout(i + 1);
    }
    return 0;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    int p[] = new int[8];
    int q[] = new int[8];
    s = r.readLine();
    sl = s.split(" ");

    for(int i = 0; i < n; i++)
    {
      p[i] = Integer.parseInt(sl[i]) - 1;
    }

    s = r.readLine();
    sl = s.split(" ");

    for(int i = 0; i < n; i++)
    {
      q[i] = Integer.parseInt(sl[i]) - 1;
    }

    int pp = 0;
    int qq = 0;
    boolean fp[] = new boolean[8];
    boolean fq[] = new boolean[8];
    int z = 1;
    for(int i = 1; i < n; i++)
    {
      z *= i;
    }

    //System.out.println(z);

    for(int i = 0; i < n - 1; i++)
    {
      for(int j = 0; j < p[i]; j++)
      {

        if(!fp[j])
        {
          //System.out.println("a " + z);
          pp += z;
        }
      }
      fp[p[i]] = true;

      for(int j = 0; j < q[i]; j++)
      {
        if(!fq[j])
        {
          qq += z;
        }
      }
      fq[q[i]] = true;

      z /= n - i - 1;
    }

    //System.out.println(Math.abs(pp));

    //System.out.println(Math.abs(qq));

    System.out.println(Math.abs(pp - qq));
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 21332
#include "bits/stdc++.h"
using namespace std;
#define Fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int m = 1e9 + 7;
vector<vector<int>> adj;
vector<vector<int>> dp;
int dfs(int cur, int par, int col) {
	if (~dp[cur][col])
		return dp[cur][col];
	int ans = 1;
	if (col == 1) {
		//prev black
		for (auto i : adj[cur]) {
			if (i != par) {
				//paint cur white
				ans *= dfs(i, cur, 0);
				ans %= m;
			}
		}
	}
	else {
		//prev white
		for (auto i : adj[cur]) {
			if (i != par) {
				ans *= dfs(i, cur, 1) + dfs(i, cur, 0);
				ans %= m;
			}
		}
	}
	return dp[cur][col] = ans;
}


int32_t main() {
	Fast_IO
	int n; cin >> n;
	adj = vector<vector<int>>(n + 1);
	dp = vector<vector<int>>(n + 1, vector<int>(2, -1));
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cout << (dfs(1, -1, 0) + dfs(1, -1, 1)) % m;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll ans, mx = 0, mn = INF, mnn;
  rep(i, n) cin >> a[i], mx = max(mx, a[i]);

  rep(i, n) if (abs(mx / 2 - a[i]) < mn && a[i] != mx) mn = abs(mx / 2 - a[i]),
                                                       mnn = a[i];

  cout << mx << " " << mnn << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;

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

    int size = N.size();
    int a[size];

    for (int i = 0; i < size; i++)
    {
        a[i] = (int)(unsigned char)N[i] - '0';
    }

    int b = 0;

    for (int i = 0; i < size; i++)
    {
        b += a[i];
    }

    if (b % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 4472