akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main()
{
  char seq_word[10];
  char input_sen[1000];
  int counter_i = 0;
  int counter_j = 0;

  scanf("%s", seq_word);
  for( ; ; )
  {
    scanf("%s", input_sen);
    if(strcmp(input_sen, "END_OF_TEXT") == 0)
      break;

    for(counter_i = 0 ; input_sen[counter_i] != '\0' ; counter_i++)
      input_sen[counter_i] = tolower(input_sen[counter_i]);

    if(strcmp(input_sen, seq_word) == 0)
      counter_j += 1;
  }
  printf("%d\n", counter_j);
}



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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

long long pow_mod(long long n, long long p, long long mod) {
    if (p == 0) {
        return 1;
    } else if (p % 2 == 1) {
        return pow_mod(n, p - 1, mod) * n % mod;
    } else {
        long long s = pow_mod(n, p / 2, mod);
        return s * s % mod;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> s(n);
    int a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        s[i] = make_pair(a, b);
    }
    vector<pair<int, int>> p(m);
    int c, d;
    for (int i = 0; i < m; i++) {
        cin >> c >> d;
        p[i] = make_pair(c, d);
    }

    for (const auto t : s) {
        int dist = 1000000000;
        int idx = 0;
        for (int i = 0; i < m; i++) {
            if (dist > abs(t.first - p[i].first) + abs(t.second - p[i].second)) {
                dist = abs(t.first - p[i].first) + abs(t.second - p[i].second);
                idx = i + 1;
            }
        }
        cout << idx << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}


#define N 1010

ll inv[N], fact[N], ifact[N];
 
void init_fact(ll n = N){
    inv[1] = 1;
    for(int i = 2; i < n;i++) inv[i] = inv[mod%i] * (mod - mod/i) % mod;
	fact[0] = ifact[0] = 1;
	for(int i = 1; i < n; i++){
		fact[i] = (fact[i-1]*i)%mod;
		ifact[i]=(ifact[i-1]*inv[i])%mod;
	}
}

ll comb(ll a, ll b){
	return fact[a+b]*ifact[a]%mod*ifact[b]%mod;
}

ll comb_nk(ll n, ll k){
	return comb(n-k, k);
}

ll lcm(ll a, ll b){
    return a/__gcd(a, b)*b;
}

ll lambda(ll m){
    ll res = 1;
    if(m%8==0) m /= 2;
    for(ll i = 2; i*i <= m; i++){
        if(!(m%i)){
            ll r = i-1;
            m /= i;
            while(!(m%i)){
                m /= i;
                r *= i;
            }
            res = lcm(res, r);
        }
    }
    if(m>1) res = lcm(res, m-1);
    return res;
}

ll pow_mod(ll a, ll r, ll m){
	ll x = 1;
	while(r){
		if(r&1) (x*=a)%=m;
		(a*=a)%=m;
		r>>=1;
	}
	return x;
}

ll n, a, b, c, d, dp[N];

int main(){
	init_fact();
	cin>>n>>a>>b>>c>>d;
	dp[0] = fact[n];
	for(ll i = a; i <= b; i++){
		for(ll k = n; k >= i*c; k--){
			for(ll j = c, x = pow_mod(ifact[i], c, mod); j <= d; j++,x=x*ifact[i]%mod){
				if(k-i*j<0) break;
				dp[k] = (dp[k]+dp[k-i*j]*x%mod*ifact[j])%mod;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if (abs(a-b)>1000000000000000000){
    cout<<("Unfair");}
    else{
        if (k%2==0){
    cout<<(a-b);}
    else{
        cout<<(b-a);
    }
        
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[20];
	int i = 0;
	int len = 0;
	
	scanf("%s", str);
	
	while (str[len] != '\0'){
		len++;
	}
	
	for (i = len - 1; i >= 0; i--){
		printf("%c", str[i]);
	}
	printf("\n");
	return (0);
}

Measured memory_bytes: 1732
#include <stdio.h>

int cut(int n, int k) {
	int i;

	for (i = 0; i < k; i++) {
		n = n / 10;
	}
	return n;
}

int main(void)
{
	int a[5], i, n, k=10;

	scanf("%d", &n);

	for (i = 0; i < 4; i++) {
		a[i] = cut(n, i) % 10;
    }

	for (i = 0; i < 3; i++) {
		if (a[i] == a[i + 1]) {
			printf("Bad");
			break;
		}
	}

	if (i == 3)
		printf("Good");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
int W,H,x,y,r;
	scanf( "%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if( W>=x+r && H>=y+r && r<=x && r<=y && x>=0 && y>=0 )
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 2048
def valid(st):
    check_str = st[::-1]
    invalid_types = ["AGC", "A_GC", "GAC", "ACG", "AG_C"]
    for typ in invalid_types:
        typ = typ[::-1]
        i=0
        j=0
        if len(check_str) < len(typ):
            continue
        res = False
        for i in range(len(typ)):
            if typ[i] == '_':
                continue
            if typ[i] != check_str[i]:
                res = True
                break
        if res == False:
            return res
    return True

fsm = {}
index = 0
sigma = ["A", "C", "G", "T"]
for i in sigma:
    for j in sigma:
        for k in sigma:
            st = ''.join([i,j,k])
            if valid(st):
                fsm[st] = index
                index+=1
arr = [[],[]]
arr[0] = [0 for _ in range(len(fsm))]
arr[1] = [1 for _ in range(len(fsm))]
N = int(input())
for n in range(4, N+1):
    old = (n+1)%2
    nw = n%2
    visited = [False for x in range(len(fsm))]
    for state in fsm.keys():
        for y in sigma:
            if valid(state+y):
                if visited[fsm[state[1:]+y]]:
                    arr[nw][fsm[state[1:]+y]] = (arr[nw][fsm[state[1:]+y]]+arr[old][fsm[state]])%(10**9+7)
                else:
                    visited[fsm[state[1:]+y]] = True
                    arr[nw][fsm[state[1:]+y]] = arr[old][fsm[state]]
print(sum(arr[N%2])%(10**9+7))



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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;


void solve() {
	ll n,ans=1;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x&1^1) ans*=2;
	}
	cout<<ll(pow(3LL,n)-ans);

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
using namespace std;

int main()
{
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    if(N == 1){
        if(A == B)
            printf("1\n");
        else
            printf("0\n");
    }
    else{
        if(A > B)
            printf("0\n");
        else{
//            int max = A + B * (N - 1);
//            int min = A * (N - 1) + B;
//            printf("%lld\n",(long long)(max - min) +1);
            printf("%lld\n",(long long )(B-A)*(N-2)+1); 
        }

    }

    return 0;
}


Measured memory_bytes: 256
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n, m = map(int, input().split())

    concent = 1
    count = 0
    while concent < m:
        concent += n - 1
        count += 1

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
bitset<5010> can;
int fa[5010],a[5010],f[5010];
vector <int> des[5010];
int main()
{
	int n;scanf("%d",&n);
	for (int i=2;i<=n;i++) {scanf("%d",&fa[i]);des[fa[i]].push_back(i);}
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int s=n;s>=1;s--)
	{
		int all=0,ad=0;
		for (int k=0;k<des[s].size();k++)
		{
			all+=min(a[des[s][k]],f[des[s][k]]);
			ad+=max(a[des[s][k]],f[des[s][k]])-min(a[des[s][k]],f[des[s][k]]);
		}
		if (a[s]<all) {puts("IMPOSSIBLE");return 0;}
		can.reset();can[0]=1;
		for (int k=0;k<des[s].size();k++)
			can|=(can<<(max(a[des[s][k]],f[des[s][k]])-min(a[des[s][k]],f[des[s][k]])));
		for (int i=a[s]-all;i>=0;i--) if (can[i]) {f[s]=all+ad-i;break;}
		//cout<<s<<' '<<f[s]<<endl;
	}  
	puts("POSSIBLE");
} 

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    while(1) {
        int h, w;
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) {
            return 0;
        }
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2688
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN




int main(void){
	ll N,A[200010],X[200010];
	scanf("%lld",&N);
	rep(i,N){
		scanf("%lld",&A[i]);
		X[i]=A[i];
	}
	sort(A,A+N);//小→大
	rep(i,N){
		ll ans;
		if(A[N/2-1]>=X[i]){
			ans=A[N/2];
		}else{
			ans=A[N/2-1];
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  ll length = S.length();
  vector<ll> mod_map(2019, 0);
  ll cur_num = 0;
  ll base_10 = 1;
  for (ll i = 0; i < length; i++) {
    cur_num += (S[length - 1 - i] - '0') * base_10;
    mod_map[cur_num % 2019] += 1;
    base_10 = base_10 * 10 % 2019;
  }
  ll ans = mod_map[0];
  for (auto m : mod_map) {
    if (m > 1) ans += m * (m - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define pr pair<long long int, long long int>
using namespace std;
long long int mod = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], flag = 0;
    for (int i = 0; i < n; i++)
        a[i] = -1;
    for (int  i = 0; i < m; i++)
    {
        int s, c;
        cin >> s >> c;
        s--;
        if(a[s] == -1)
            a[s] = c;
        else if(a[s] == c)
            continue;
        else
        {
            flag = 1;
            break;
        }
    }
    if(flag != 1)
    {
        if(n == 1)
        {
            if(a[0] == -1)
                a[0] = 0;
        }
        else
        {
            if(a[0] == -1)
                a[0] = 1;
            else if(a[0] == 0)
                flag = 1;
            for (int j = 1; j < n; j++)
            {
                if(a[j] == -1)
                    a[j] = 0;
            }
            
        }
    }
    if(flag == 1)
        cout << "-1" << endl;
    else
    {
        for (int i = 0; i < n; i++)
        {
            cout << a[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r[n+1],g[n+1],b[n+1];
    r[0]=g[0]=b[0]=0;
    rep(i,n){
        r[i+1]=r[i];g[i+1]=g[i];b[i+1]=b[i];
        if(s[i]=='R') r[i+1]++;
        else if(s[i]=='G') g[i+1]++;
        else b[i+1]++;
    }
    int totalr = r[n];
    int totalg = g[n];
    int totalb = b[n];
    ll ans = 0;
    for(int i = 0;i<n-2;i++){
        for(int j = i+1;j<n-1;j++){
            if(s[i]==s[j]) continue;
            if(s[i]!='R' && s[j]!='R'){
                ans+=(totalr-r[j+1]);
                if((2*j-i)<n){
                    if(s[2*j-i]=='R') ans--;
                }
            }
            else if(s[i]!='G' && s[j]!='G'){
                ans+=(totalg-g[j+1]);
                if((2*j-i)<n){
                    if(s[2*j-i]=='G') ans--;
                }
            }
            else if (s[i]!='B' && s[j]!='B'){
                ans+=(totalb-b[j+1]);
                if((2*j-i)<n){
                    if(s[2*j-i]=='B') ans--;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
long long int dp[100 + 1][100000 + 1];
long long int knapSack(long long int w, long long int wt[],long long  int val[],long long  int n) 
{ 
  

    if (n == 0 || w == 0) 
        return 0; 
  
    if (dp[n][w] != -1) {
        return dp[n][w];
    }
    if (wt[n - 1] > w) 
        dp[n][w] =  knapSack(w, wt, val, n - 1); 
  
    
    else
        dp[n][w] = max( 
            val[n - 1] + knapSack(w - wt[n - 1],  
                                    wt, val, n - 1), 
            knapSack(w, wt, val, n - 1)); 
    return dp[n][w];
} 
int main() {
	// your code goes here
    int n,W;
    cin >> n >> W;
    long long int w[n + 1] = {0},v[n + 1] = {0}; 
    long long int weights[W] = {0};
    //pair <long long int,long long int> p[n];
    for (int i =0; i < n;i++) {
        cin >> w[i] >> v[i];
        //p.insert (make_pair(w[i],v[i]));
        //weights[w[i]] = max(v[i],weights[w[i]]);
    }
    
    for (long long int i = 0; i <= n;i++) {
        for (long long int j = 0; j <= W;j++)
            dp[i][j] = -1;
    }
    cout << knapSack(W,w,v,n) << endl;
    
    
}


Measured memory_bytes: 83284
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		String s = sc.next();
		int x = 0 ;
		for(int i = 0;i < n;i++) {
			char c = s.charAt(i);
			if(c == 'I') {
				x++;
			}else if(c == 'D') {
				x--;
			}
			if(x >= max) {
				max = x;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  ll S; cin >> S;

  ll sqS = ceil(sqrt(S));

  ll sub = sqS * sqS - S;

  cout << 0 << " " << 0 << " " << sqS << " " << sub << " " << 1 << " " << sqS << endl;

  return 0;
}

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

using namespace std;

int n, A, B;

int del(int x, int p) {
  int d = x & (1 << p) - 1;
  int u = x & (1 << 20) - (1 << p + 1);
  return (u >> 1) + d;  
}

int ins(int x, int p, int v) {
  int d = x & (1 << p) - 1;
  int u = x & (1 << 20) - (1 << p);
  return (u << 1) + v + d;
}

vector<int> solve(int n, int a, int b) {
  if (n == 1) {
    vector<int> res;
    res.push_back(a);
    res.push_back(b);
    return res;
  }
  int p = 0;
  for (; (a & (1 << p)) == (b & (1 << p)); p++);
  int x = del(a, p), y = del(b, p), z = x ^ 1;
  vector<int> resl = solve(n - 1, x, z);
  vector<int> resr = solve(n - 1, z, y);
  vector<int> res;
  for (int i = 0; i < (1 << (n - 1)); i++) res.push_back(ins(resl[i], p, a & (1 << p)));
  for (int i = 0; i < (1 << (n - 1)); i++) res.push_back(ins(resr[i], p, b & (1 << p)));
  return res;
}

int main() {
  cin >> n >> A >> B;
  if (__builtin_popcount(A ^ B) % 2 == 0) {
    puts("NO");
    return 0;
  }
  puts("YES");
  vector<int> ans = solve(n, A, B);
  for (int i = 0; i < (1 << n); i++) {
    printf("%d ", ans[i]);
  }
  puts("");
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    int dx[4] = {0, 0, 1, -1};
    int dy[4] = {1, -1, 0, 0};
    cin >> h >> w;
    char c[h][w];
    rep (i, h) {
        rep (j, w) {
            cin >> c[i][j];
        }
    }
    bool ok = true;
    rep (i, h) {
        rep (j, w) {
            if (c[i][j] == '#') {
                int cnt = 0;
                rep (k, 4) {
                    if (i + dx[k] >= 0 && i + dx[k] < h && j + dy[k] >= 0 && j + dy[k] < w) {
                        if (c[i + dx[k]][j + dy[k]] == '#') cnt++;
                    }
                }
                if (cnt == 0) ok = false;
            }
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}



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

int main()
{
    int h, w;
    while (std::cin >> h >> w) {
        if (h == 0 && w == 0) {
            break;
        }

        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (i % 2 == 0) {
                    if (j % 2 == 0) {
                        std::cout << "#";
                    } else {
                        std::cout << ".";
                    }
                } else {
                    if (j % 2 == 0) {
                        std::cout << ".";
                    } else {
                        std::cout << "#";
                    }
                }
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>

void process(int a, int b)
{
    if (a * b % 2 == 0)
        std::cout << "Even" << std::endl;
    else
        std::cout << "Odd" << std::endl;
}

int main()
{
    int a, b;
    std::cin >> a >> b;

    process(a, b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long Long;
Long a, b, c, x, y, ans = 1e18;
int main() {
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
	for (int i = 0; i <= 100000; ++i) {
		ans = min(ans, c * i * 2 + max(x - i, 0ll) * a + max(y - i, 0ll) * b);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll dp[110][2][5];
string s;
ll K;
ll rec(ll digit,ll tight,ll num){
    if(digit == s.size()){
        if(num == K)return 1;
        else return 0;
    }
    if(num > K)return 0;
    ll x = s[digit]-'0';
    ll right = tight?x:9;
    ll &res = dp[digit][tight][num];
    if(~res)return res;
    res = 0;
    for(ll i=0;i<=right;i++){
        res +=rec(digit+1,tight&&(i==right),((i==0)?num:num+1));
    }
    return res;
}
 
int main(void){
    cin>>s;
    ll n = s.length();
    cin>>K;
    for(ll i=0;i<110;i++){
        for(ll j=0;j<2;j++){
            for(ll k=0;k<5;k++){
                dp[i][j][k]=-1;
            }
        }
    }
   cout<<rec(0,1,0)<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i,n,A[1000000];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>=1)printf("parent key = %d, ",A[i/2]);
    if(2*i<=n)printf("left key = %d, ",A[2*i]);
    if((2*i+1)<=n)printf("right key = %d, ",A[2*i+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define N 2010
#define M 200010
#define int long long
#define INF 4611686018427387904LL
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
struct Point {
    int x,y,val;
}p[N];
struct opt {
    char ch; int x,y;
}a[N];
int tot=1;
int fir[N],nex[M],got[M],tak[M],cst[M];
inline void AddEdge(int x,int y,int z,int w) { 
    nex[++tot]=fir[x],fir[x]=tot,got[tot]=y,tak[tot]=z,cst[tot]=w;
}
inline void Add(int x,int y,int z,int w) {
    AddEdge(x,y,z,w),AddEdge(y,x,0,-w);
}
int xl[N],xr[N],yl[N],yr[N];
int vis[N],dis[N],pre[N],que[N];
inline int spfa(int s,int t) {
    int l=1,r=1;
    for (int i=1;i<=t;i++) vis[i]=false,dis[i]=-INF,pre[i]=0;
    que[1]=s,dis[s]=0;
    while (l<=r) {
        int x=que[l];
        for (int i=fir[x];i;i=nex[i]) {
            int y=got[i],w=cst[i];
            if (!tak[i] || dis[x]+w<=dis[y]) continue;
            dis[y]=dis[x]+w,pre[y]=i;
            if (!vis[y]) vis[y]=true,que[++r]=y;
        }
        ++l,vis[x]=false;
    }
    return dis[t]!=-INF;
}
inline int getflow(int s,int t) {
    int flow=INF;
    for (int i=t;i!=s;i=got[pre[i]^1]) {
        flow=min(flow,tak[pre[i]]);
    }
    return flow;
}
inline void update(int s,int t,int flow,int &Maxflow,int &Mincost) {
    Maxflow+=flow,Mincost+=flow*dis[t];
    for (int i=t;i!=s;i=got[pre[i]^1]) {
        tak[pre[i]]-=flow,tak[pre[i]^1]+=flow;
    }
}
inline int solve(int s,int t) {
    int Maxflow=0,Mincost=0;
    while (spfa(s,t)) {
        update(s,t,getflow(s,t),Maxflow,Mincost);
    }
    return Mincost;
}
signed main() {
    int n=read();
    for (int i=1;i<=n;i++)
        p[i].x=read(),p[i].y=read(),p[i].val=read();
    int m=read(),res=0;
    for (int i=1;i<=m;i++) {
        char ch=getchar();
        while (ch!='U' && ch!='D' && ch!='L' && ch!='R') ch=getchar();
        a[i].ch=ch,a[i].x=read(),a[i].y=read();
    }
    for (int k=1;k<=n;k++) {
        tot=1,memset(fir,0,sizeof(fir));
        int s=(k<<1)+(n<<1)+1,t=s+1;
        for (int i=1;i<=k;i++) Add(s,i,1,0);
        for (int i=k+2*n+1;i<=2*k+2*n;i++) Add(i,t,1,0);
        for (int i=k+1;i<=k+n;i++) Add(i,i+n,1,p[i-k].val);
        for (int i=1;i<=k;i++) xl[i]=yl[i]=0,xr[i]=yr[i]=INF;
        for (int i=1;i<=m;i++) {
            if (a[i].ch=='U') for (int j=1;j<=k-a[i].y;j++) yr[j]=min(yr[j],a[i].x-1);
            if (a[i].ch=='D') for (int j=a[i].y+1;j<=k;j++) yl[j]=max(yl[j],a[i].x+1);
            if (a[i].ch=='L') for (int j=a[i].y+1;j<=k;j++) xl[j]=max(xl[j],a[i].x+1);
            if (a[i].ch=='R') for (int j=1;j<=k-a[i].y;j++) xr[j]=min(xr[j],a[i].x-1);
        }
        for (int i=1;i<=k;i++) for (int j=1;j<=n;j++)
            if (xl[i]<=p[j].x && p[j].x<=xr[i]) Add(i,j+k,1,0);
        for (int i=1;i<=k;i++) for (int j=1;j<=n;j++)
            if (yl[i]<=p[j].y && p[j].y<=yr[i]) Add(j+k+n,i+k+2*n,1,0);
        res=max(res,solve(s,t));
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

struct UnionFind{
    vector<i64> par;
    i64 score;
    UnionFind(i64 n) : par(n, -1), score(0){
    }
    i64 Find(i64 x){return par[x] < 0 ? x : Find(par[x]);}
    void Unite(i64 x, i64 y){
        x = Find(x);
        y = Find(y);
        if(x == y)
            return ;
        score += par[x] * par[y];
        if(par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};

signed main(){
    i64 n, m;
    cin >> n >> m;
    vector<i64> a(m), b(m);
    for(i64 i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    UnionFind u(n);
    vector<i64> ans;
    for(i64 i = 0; i < m; ++i){
        ans.push_back(u.score);
        u.Unite(a[i], b[i]);
    }
    for(i64 i = m - 1; i >= 0; --i){
        i64 sc = ans[i];
        cout << n * (n - 1) / 2 - sc << endl;
    }
}


Measured memory_bytes: 4596
N, K = map(int,input().split())
H = list(map(int,input().split()))

dp = [1e9]*N
dp[0] = 0
for i, b in enumerate(H):
  if i != 0:
    x = max(0, i-K)
    dp[i] = min([abs(b-d)+p for d, p in zip(H[x:i], dp[x:i])])
print(dp[-1])


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

int main()
{
    int N,D,X,c=0,A[100];
    cin>>N;
    cin>>D>>X;
    for(int i=1;i<=N;i++)
    {
        cin>>A[i];
        for(int j=1;j<=D;j=j+A[i])
        {
            c++;

        }
    }
    cout<<(X+c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

ll n,W;
ll w[110],v[110];
ll dp[110][110000];
int main(){
  cin>>n>>W;
  rep(i,n){
   cin>>w[i+1]>>v[i+1]; 
  }
  //dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=W;j++){
       chmax(dp[i][j],dp[i-1][j]);
      if(j-w[i]>=0) chmax(dp[i][j],dp[i-1][j-w[i]]+v[i]);
    }
    
  }
  
  cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 87424
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, an=0, p=0, h=0, f=0;
    cin>>n;
    string s;
    vs v;
    for(i=0; i<n; i++){
        cin>>s;
        for(j=0; j<s.size()-1; j++){
            if(s[j]=='A' && s[j+1]=='B'){
                an++;
            }
        }
        if(s[0]=='B' && s[s.size()-1]=='A')p++;
        else if(s[0]=='B')h++;
        else if(s[s.size()-1]=='A')f++;
        else continue;
    }
    if(p>0){
        if(h>0 && f>0){
            an+=p+1;
            h--;
            f--;
            an+=min(h, f);
        }
        else if(h>0 || f>0){
            an+=p;
        }
        else{
            an+=p-1;
        }
    }
    else{
        an+=min(h, f);
    }
    cout<<an<<endl;
    return 0;
}



Measured memory_bytes: 3620
//こういうのをワーシャるフロイド法というらしい。頂点から頂点へ動くとき、最小で移動するときの距離を求める。
#include <bits/stdc++.h>

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int h , w ;
	cin>> h >> w ;
	int dist[10][10];
	rep(i,10) rep(j,10) cin >> dist[i][j];

	rep(k,10){
		rep(i,10){
			rep(j,10){
				dist[i][j] =  min(dist[i][j],dist[i][k] + dist[k][j]);
			}
		}
	}
	//最短求まった（らしい
	ll ans = 0 ;
	rep(i,h){
		rep(j,w){
			int a ;
			cin>> a ;
			if(a==-1) continue;
			else{
				ans += dist[a][1] ;
			}
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
use proconio::input;
use std::iter::successors;

fn main() {
    input!(k: usize);
    let ans = successors(Some(7 % k), |p| Some((p * 10 + 7) % k))
        .take(k)
        .position(|it| it == 0)
        .map_or(-1, |it| it as i32 + 1);
    println!("{}", ans)
}


Measured memory_bytes: 2176
#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 mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << 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 & (1ll << 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 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 -1;
}
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);
    ll X;
    cin >> X;
    ll a = X / 200;
    putout(10 - a);
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  int a, b;
  string input[1000];
  cin >> a >> b;
  int i = 0;
  for (i; i < a; i++){
    cin >> input[i];
  }
  i = 0; 
  for (i; i < a; i++){
    cout << input[i] << endl;
    cout << input[i] << endl;
  }
}


Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    string s;
    cin>>s;

    for(int i=0;i<s.length() - 1; i++){
        if(s[i] == s[i + 1]){
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
} 

Measured memory_bytes: 3592
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second

using ll = long long;
using ull = unsigned long long;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline void chmax(T &x, U y){ x = std::max<T>(x, y); }

template<typename T, typename U>
inline void chmin(T &x, U y){ x = std::min<T>(x, y); }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ sort(c); c.erase(std::unique(std::begin(c), std::end(c)), std::end(c)); }

// }}}

int n, u[2], m;
int a[2][500][500], b[100000];
int cx[2][500], cy[2][500], cz[2][2];
vector<int> vx[2][100000], vy[2][100000], vz[2][100000];

int main()
{
	cin >> n >> u[0] >> u[1] >> m;
	
	vector<int> z;
	rep(i, 2) rep(j, n) rep(k, n){
		cin >> a[i][j][k];
	}
	
	rep(i, m){
		cin >> b[i];
		z.pb(b[i]);
	}
	z.pb(INF);
	unique(z);

	rep(i, 2) rep(j, n) rep(k, n){
		int t = lower_bound(begin(z), end(z), a[i][j][k]) - begin(z);
		if (a[i][j][k] != z[t]) continue;
		vx[i][t].pb(j);
		if (n > 1){
			vy[i][t].pb(k);
			if (j == k) vz[i][t].pb(0);
			if (j + k == n - 1) vz[i][t].pb(1);
		}
	}

	string res = "DRAW";
	rep(i, m){
		int t = lower_bound(begin(z), end(z), b[i]) - begin(z);
		rep(j, 2){
			for (int k : vx[j][t]){
				if (++cx[j][k] == n) u[j]--;
			}
			for (int k : vy[j][t]){
				if (++cy[j][k] == n) u[j]--;
			}
			for (int k : vz[j][t]){
				if (++cz[j][k] == n) u[j]--;
			}
		}

		if (u[0] <= 0 && u[1] <= 0) break;
		if (u[0] <= 0){
			res = "USAGI";
			break;
		}
		if (u[1] <= 0){
			res = "NEKO";
			break;
		}
	}

	cout << res << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll a, b, c, d;
  string s;
  cin >> s;
  a = (ll)(s[0] - '0');
  b = (ll)(s[1] - '0');
  c = (ll)(s[2] - '0');
  d = (ll)(s[3] - '0');
  if (a + b + c + d == 7)
	cout << (string){s[0], '+', s[1], '+', s[2], '+', s[3], '=', '7'} << endl;
  else if (a + b + c - d == 7)
	cout << (string){s[0], '+', s[1], '+', s[2], '-', s[3], '=', '7'} << endl;
  else if (a + b - c + d == 7)
	cout << (string){s[0], '+', s[1], '-', s[2], '+', s[3], '=', '7'} << endl;
  else if (a - b + c + d == 7)
	cout << (string){s[0], '-', s[1], '+', s[2], '+', s[3], '=', '7'} << endl;
  else if (a + b - c - d == 7)
	cout << (string){s[0], '+', s[1], '-', s[2], '-', s[3], '=', '7'} << endl;
  else if (a - b + c - d == 7)
	cout << (string){s[0], '-', s[1], '+', s[2], '-', s[3], '=', '7'} << endl;
  else if (a - b - c + d == 7)
	cout << (string){s[0], '-', s[1], '-', s[2], '+', s[3], '=', '7'} << endl;
  else if (a - b - c - d == 7)
	cout << (string){s[0], '-', s[1], '-', s[2], '-', s[3], '=', '7'} << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> mp;
  rep(i, N) {
    cin >> A[i];
    mp[A[i]]++;
  }
  ll total = 0;
  for (auto p : mp) {
    ll x = p.second;
    total += x * (x-1) / 2;
  }
  rep(i, N) {
    ll y = mp[A[i]];
    ll ans = total - 2 * (y-1) / 2;
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 9776
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && a == c && b == c) return cout << (a % 2 ? 0 : -1) << '\n', 0;
	int answer = 0;
	while(!(a % 2) && !(b % 2) && !(c % 2))
	{
		++answer;
		int aa = 0, bb = 0, cc = 0;
		bb += a / 2;
		cc += a / 2;
		aa += b / 2;
		cc += b / 2;
		aa += c / 2;
		bb += c / 2;
		a = aa;
		b = bb;
		c = cc;
	}
	cout << answer;
}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

long long solve(long long a, long long x)
{
    if(a == -1)
        return 0;
    else
        return a / x + 1;
}

int main()
{
    long long a, b, x;
    cin >> a >> b >> x;

    long long ans = solve(b, x) - solve(a-1, x);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
#define M 998244353
const int x=300005;
using namespace std;
ll fac[x]={1,1},inv[x]={1,1},f[x]={1,1};
ll C(ll a,ll b){
    if(b>a)return 0;
    return fac[a]*inv[b]%M*inv[a-b]%M;
}
void init(){
    for(int i=2;i<x;i++){
        fac[i]=fac[i-1]*i%M;
        f[i]=(M-M/i)*f[M%i]%M;
        inv[i]=inv[i-1]*f[i]%M;
    }
}
int main()
{
    ll N,A,B,K;
    cin>>N>>A>>B>>K;
    init();
    ll i;long long j,sum,ans=0;
    for(i=0;i<=N;i++){
        sum=i*A;
            if((K-sum)>=0&&(K-sum)%B==0){
                j=(K-sum)/B;
                if(j>N) continue;
                ans=ans+C(N,i)*C(N,j);
                ans%=M;
            }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7296
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 2018-8-5 21:01:39
# Powered by Visual Studio Code
#

s = gets.chomp

if s[0] != 'A'
  puts "WA"
else
  cnt = 0
  s[2..-2].chars{|c|
    if c == 'C'
      cnt += 1
    end
  }
  if cnt != 1
    puts "WA"
  else
    t = s.downcase
    for i in 1...s.size
      if s[i] != t[i] && s[i] != 'C'
        puts "WA"
        exit
      end
    end
    puts "AC"
  end
end


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#include<iostream>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define VI vector<int>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=5005;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int coef[MAXN],encoef[MAXN],n,A,B;
//end is 0
void getcoef()
{
	coef[1]=1;
	for(int i=1;i<A;i++)
	{
		ad(coef[i+1],coef[i]); 
		for(int j=B;i+j<=A;j++)ad(coef[i+j+1],coef[i]),ad(encoef[i+j],coef[i]);
	}
}
int f[MAXN][2];//end with 0/1
int main()
{
	#ifdef Rose
		double BeginJudgeTime=clock();
	#endif
	n=read();A=read();B=read();if(A<B)swap(A,B);
	getcoef();
	for(int i=0;i<B;i++)f[i][1]=1;
	for(int i=1;i<A;i++)f[i][0]=encoef[i];
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<A&&i+j<=n;j++)
		{
			ad(f[i+j][0],1LL*f[i][1]*coef[j]%mod);
			if(i+j==n)ad(f[i+j][1],1LL*f[i][1]*encoef[j]%mod);
		}
		for(int j=1;j<B&&i+j<=n;j++)
			ad(f[i+j][1],f[i][0]);
	}
	int ans=1;
	for(int i=1;i<=n;i++)ans=2LL*ans%mod;
	dl(ans,f[n][0]);dl(ans,f[n][1]);
	pr2(ans);
	#ifdef Rose
		double EndJudgeTime=clock();
		cerr<<"JudgeTime is"<<" ";
		cerr<<(EndJudgeTime-BeginJudgeTime)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>

int main(void) {
  int KSET[31];
  int N,M,K;

  scanf("%d %d", &N, &M);
  for(int i=1;i<=M;i++) KSET[i] = 0;
  for(int human=0;human<N;human++) {
    scanf("%d", &K);
    for(int favorite=0;favorite<K;favorite++){
      int food;
      scanf("%d", &food);
      KSET[food]++;
    }
  }

  int result = 0;
  for(int i=1;i<=M;i++) {
    if(KSET[i] >= N) {
      result++;
    }
  }
  printf("%d\n", result);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nBuf,int N){
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        int tmp=atoi(ptr)-1;
        a[tmp]++;
        if(a[tmp] > 2)
            a[tmp]-=2;      //食べる
        ptr=strtok(NULL," ");
    }
    free(buf);
}

int main(void){
    int N,A[100000]={},cnt=0,Dup=0;

    scanf("%d%*c",&N);
    InputIntAry(A,7*100000,N);
    for(int i=0;i<100000;i++){
        cnt+=A[i];
        if(A[i]==2)
            Dup++;
    }
    if(Dup%2 == 0){
        cnt -= Dup;
    }
    else{
        cnt -= Dup+1;
    }
    printf("%d\n",cnt);

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N, M;
	get(N, M);
	
	int from, to;
	std::vector<int> balls(N, 1);
	std::set<int> red;

	red.insert(0);
	for (int i = 0; i < M; i++) {
		get(from, to); from--; to--;
		
		balls[from]--;
		balls[to]++;
		if (red.find(from) != red.end()) {
			red.insert(to);
			if (balls[from] == 0) {
				red.erase(from);
			}
		}
	}

	printf("%d\n", (int)red.size());
}


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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  vector<llint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<llint, llint> R, L;
  for (int i = 0; i < n; i++) {
    L[i + a[i]]++;
    if (i - a[i] >= 0) R[i - a[i]]++;
  }

  llint ans = 0;
  for (llint i = 1; i < n; i++) {
    ans += L[i] * R[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 38476