akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;


ll tableF[200010];
ll tableI[200010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n < 0 || r < 0 || n < r){
      return 0;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約200ms
   fill(tableF,tableF+200010,-1);
   fill(tableI,tableI+200010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}


int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = 0,a = 1,b = 1;
    ans = modpow(2,N,MOD) - 1;
    rep(i,A){
        a *= (N-i);
        a %= MOD;
    }
    rep(i,B){
        b *= (N-i);
        b %= MOD;
    }
    modfill(MOD);
    a *= tableI[A];
    b *= tableI[B];
    a %= MOD;
    b %= MOD;
    ans -= (a + b);
    while(ans < 0) ans += MOD;
    cout << ans << endl;
}


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

int main(){
    string s;
    int t[26]={};
    while(getline(cin, s)){
        for(int i=0;i<s.size();i++){
            if('a'<=s[i] && s[i]<='z'){
                t[s[i]-'a']++;
            }else if('A'<=s[i] && s[i]<='Z'){
                t[s[i]-'A']++;
            }
        }
    }
    
    for(int i=0;i<26;i++){
        cout<<char('a'+i)<<" : "<<t[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define R register
typedef long long ll;
typedef double db;

const int MN = 4e3 + 10, P = 998244353;

int n, k, C[MN][MN], ans[MN];

void init() {
	for (R int i = 0; i < MN; ++i)
		C[i][0] = 1;
	for (R int i = 1; i < MN; ++i)
		for (R int j = 1; j <= i; ++j)
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j],
			C[i][j] >= P ? C[i][j] -= P : 0;
}

inline int solve(int x, int k, int n) {
	R int res = 0;
	for (R int i = 0; i <= std::min(x >> 1, n >> 1); ++i) {
		R int tmp = (ll)C[x >> 1][i] * C[n + k - i * 2 - 1][k - 1] % P;
		if (i & 1) (res -= tmp) < 0 ? res += P :0;
		else (res += tmp) >= P ? res -= P : 0;
	}
	return res;
}

int main() {
	scanf("%d %d", &k, &n);
	
	init();

	for (R int i = 1; i <= k; ++i)
		if (i & 1) ans[i] = solve(i, k - 1, n) + solve(i, k - 1, n - 1), ans[i] >= P ? ans[i] -= P : 0;
		else ans[i] = solve(i, k, n);

	for (R int i = 1; i <= k; ++i)
		printf("%d\n", ans[i]);

	for (R int i = k - 1; i; --i)
		printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 61568
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
  int N;

  cin >> N;

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

  int alice =0;
  int bob = 0;

  for (int i = 0; i < N; i=i+2) {
      alice += a[i];
      if(i+1<N) bob   += a[i+1];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,P; cin>>N>>P;
    vint a(N);
    REP(i,N) cin>>a[i];
    
    bool odd=0;
    REP(i,N) if(a[i]%2==1) odd=1;
    
    int ans=0;
    if(odd) ans=1LL<<(N-1);
    else{
        if(P==0) ans=1LL<<N;
        else ans=0;
    }
    cout<<ans<<endl;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)

using namespace std;

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

    int ans = 0, n, k; cin >> n >> k;
    int a[n]; REPI(i, n) cin >> a[i];

    REPI(i, n)
        ans += 2 * min(k - a[i], a[i]);
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main() {
    	int a, b, c, d;
    	scanf("%d%d%d%d", &a, &b, &c, &d);
    	if ((b <= c && d >= a) || (b >= c && d<= a)) {
    		printf("0\n");
    	}
    	else if (a <= c && b <= d) {
    		printf("%d\n", b - c);
    	}
    	else if (a >= c && b >= d) {
    		printf("%d\n", d - a);
    	}
    	else if (a <= c && b >= d) {
    		printf("%d\n", d - c);
    	}
    	else if (a >= c && b <= d) {
    		printf("%d\n", b - a);
    	}
    	return 0;
    }

Measured memory_bytes: 128
n=int(input())
m=list(input())
ans=0
for i in range(n-1):
    p=0
    x=list(set(m[:i+1]))
    y=list(set(m[i+1:]))
    for j in x:
        if j in y:
            p+=1
    ans=max(ans,p)
print(ans)            
            



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll, ll>
#define mii map<ll, ll>
#define mod 1000000007
ll power(ll a, ll b){
    ll res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin>>c;
    ++c;
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
int main() { 
	int t[4][3][10]={0}; 
	int b,f,r,v,i,j,k,n; 
	scanf("%d",&n);
	for(i=0;i<n;i++){ 
		scanf("%d%d%d%d",&b,&f,&r,&v);
		t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v; 
	} 
	for(i=0;i<4;i++){ 
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){ 
				printf(" %d",t[i][j][k]); 
			}
			printf("\n");
		} 
		if(i!=3)printf("####################\n"); 
	} 
	return 0; 
} 


Measured memory_bytes: 2120
N=int(input())
##c=list(map(int, input().split()))

a = [list(map(int, input().split())) for _ in range(N)]

k=0
for i in range(N):
    for j in range(N):
        if(i!=j):
            k=k+((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]))**0.5

print(k/N)




Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n;
ll a[410];
ll sum[410];
ll memo[410][410];

ll hoge(ll x,ll y){
    if(memo[x][y]!=0){
        return memo[x][y];
    }
    if(x==y){
        return 0;
    }
    ll ans=inf;
    rep(i,x,y-1){
        ans=min(hoge(x,i)+hoge(i+1,y)+sum[y]-sum[x-1],ans);
    }
    return memo[x][y]=ans;
    
}

int main(){fastio
    cin>>n;
    sum[0]=0;
    rep(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
        //cout<<sum[i]<<' ';
    }
    
    ll ans=hoge(1,n);
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if ("2019/04/30" < S)
    {
        cout << "TBD" << endl;
    }
    else
    {
        cout << "Heisei" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import accumulate
a,b = map(int, input().split())
c = str(input())
d = [list(map(int, input().split())) for i in range(0,b)]

flg = []
for i in range(a-1):
    moji = c[i:i+2]
    if moji == "AC":
        flg.append(1)
    else:
        flg.append(0)

flg2 = [0] + flg
flg2 = list(accumulate(flg2))

for a in d:
    print(flg2[a[1]-1] - flg2[a[0]-1])


Measured memory_bytes: 33172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool x = false;
  for (int i = 0; i < N; i++) {
   string S;
   cin >> S;
    if (S == "Y") x = true;
  }
  if (x) cout << "Four" << endl; 
  else cout << "Three" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

int main()
{
    int64_t A,B,K,C,ans;
    ans=0;
    cin >> A >> B >> C >> K;
    if(K<=A){
        ans=K;
    }else{
        if(K-A<=B)
        ans=A;
        else{
            ans=A-(K-A-B);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
/// You just can't beat the person who never gives up
/// ICPC next year


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
void offset(vector<int>&a,int x) {
    for(int i = 0; i < sz(a);i++) {
        a[i] = x;
    }
}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};


// auto cmp = [](pair<int,int>a,pair<int,int>b) {if(a.first==b.first)return a.second>b.second;
//      else return a.first > b.first;
//  };
//  multiset<pair<int,int>,decltype(cmp)>fc(cmp);
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash> safe_map;
};

const int MAXN = 2e5+ 10;

#define int long long
bool cmps(vi p1,vi p2) {
    return p1.size() > p2.size();
}
int32_t main() {
    fio
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = count(all(s),'R');
    int cnt = 0;
    for (int i = 0; i < x; ++i) {
        if(s[i] == 'W') {
            cnt++;
        }
    }
    cout << cnt << endl;


    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A.at(i);
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    ll res = A.at(0);
    ll cnt = N-2;
    // cnt is even
    rep1(i,(N-2)/2)res += A.at(i)*2;
    if(cnt%2==1)res += A.at(cnt/2+1);
    cout<<res<<endl;
}

Measured memory_bytes: 4844
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <sstream>
#include <cstdlib>
typedef long long  ll;
using namespace std;
int main()
{
	int N,K;
	cin >> N >> K;
	ll a[N];
	int ans=0;
	int mod=0;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	ans=(N-K)/(K-1)+1;
	mod=(N-K)%(K-1);
	if(mod==0){
		cout << ans << endl;
	}else{
		cout << ans+1 << endl;
	}
}


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

using pll = pair<long long, long long>;

int main() {
    int N; cin >> N;
    vector<pll> pos(N);
    for (int i = 0; i < N; ++i) cin >> pos[i].first >> pos[i].second;
    
    int par = (abs(pos[0].first) + abs(pos[0].second)) % 2;
    for (int i = 0; i < N; ++i) {
        int par2 = (abs(pos[i].first) + abs(pos[i].second)) % 2;
        pos[i] = pll(pos[i].first + pos[i].second, pos[i].first - pos[i].second);
        if (par2 != par) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    vector<long long> d;
    for (int i = 30; i >= 0; --i) d.push_back(1LL<<i);
    if (par % 2 == 0) d.push_back(1);
    cout << d.size() << endl;
    for (int j = 0; j < d.size(); ++j) cout << d[j] << " ";
    cout << endl;
        
    for (int i = 0; i < N; ++i) {
        int xdir, ydir;
        long long xsum = 0, ysum = 0;
        for (int j = 0; j < (int)d.size(); ++j) {
            if (xsum <= pos[i].first) xdir = 1, xsum += d[j];
            else xdir = -1, xsum -= d[j];
            if (ysum <= pos[i].second) ydir = 1, ysum += d[j];
            else ydir = -1, ysum -= d[j];
            
            if (xdir == 1 && ydir == 1) cout << "R";
            else if (xdir == 1 && ydir == -1) cout << "U";
            else if (xdir == -1 && ydir == -1) cout << "L";
            else cout << "D";
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
    int K;
    std::string S;
    
    std::cin >> K;
    std::cin >> S;
    
    if(S.length() <= K) {
        std::cout << S << std::endl;
    } else {
        std::cout << S.substr(0, K) << "..." << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int x, y, d;
	cin >> x >> y;
	while (1) {
		if (x < y)swap(x, y);
		d = x % y;
		if (d == 0)break;
		else x = d;
	}
	cout << y << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k,q; cin>>n>>k>>q;
	map<int,int> ct;
	for (int i=0; i<q; i++) {
		int x; cin>>x;
		ct[x]++;
	}
	for (int i=1; i<=n; i++)
		cout<<(k>q-ct[i]?"Yes":"No")<<"\n";
	return 0;
}


Measured memory_bytes: 5376
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {
	
	int n;
	scanf("%d", &n);
	int tmp;
	ll sum = 0;
	rep(i, n) {
		scanf("%d", &tmp);
		sum += tmp - i - 1;
	}
	printf("%lld\n", sum);

	Please AC;
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)

int main() {
    int H, W; cin >> H >> W;
    int a[H + 1][W + 1]; rep1(i, H) {rep1(j, W) cin >> a[i][j];}

    vector<vector<int>> op(0, vector<int>(4));

    rep1(i, H) {
        rep1(j, W - 1) {
            if (a[i][j]%2) {
                op.push_back({i, j, i, j + 1});
                a[i][j + 1]++;
            }
        }
    }

    rep1(i, H - 1) {
        if (a[i][W]%2) {
            op.push_back({i, W, i + 1, W});
            a[i + 1][W]++;
        }
    }

    cout << op.size() << endl;
    rep(i, op.size()) {
        rep(j, 3) cout << op[i][j] << " ";
        cout << op[i][3] << endl;
    }
    return 0;
}

Measured memory_bytes: 9904
#include <stdio.h>

int main(void) {
    long long X, b, i, j;
    scanf("%lld", &X);
    b=0;
    for (i=-5400; i<=5400; i++) {
        for (j=-5400; j<=5400; j++) {
            // printf("%lld^5-%lld^5=%lld\n", i, j, i*i*i*i*i);
            if (i*i*i*i*i-j*j*j*j*j==X) {
                b=1;
                break;
            }
        }
        if (b) break;
    }
    if (b) printf("%lld %lld", i, j);
    // else printf("%lld %lld", i, j);
    return 0;
}


Measured memory_bytes: 1732
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

bool p[1000][1000];

bool is_alphabet(char c){
  if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')){
    return true;
  }

  return false;
}

bool is_palindrome(string s){
  int len = s.length();
  for(int i = 0; i < len / 2; ++i){
    if(s[i] != s[len-i-1]){
      return false;
    }
  }
  return true;
}

int main(){

  string tmp;
  while(getline(cin, tmp)){
    vector<char> s;
    REP(i,tmp.length()){
      if(is_alphabet(tmp[i])){
        s.pb(toupper(tmp[i]));
      }
    }

    int len = s.size();
    REP(i,len){
      REP(j,len){
        p[i][j] = false;
      }
    }

    for(int w = 1; w < len; ++w){
      for(int i = 0; i + w < len; ++i){

        if(w == 1 || w == 2){
          if(s[i] == s[i+w]){
            p[i][i+w] = true;
            //cout << s[i] << " " << s[i + w] << endl;
          }

        }else{
          if(s[i] == s[i+w] && p[i+1][i+w-1]){
            //for(int l = 1; (i+w-l -(i+l) >= 1); ++l){
              //if(p[i+l][i+w-l-1] == false) break;            
            p[i+1][i+w-1] = false;
            //}
            p[i][i+w] = true;
          }
        }
      }
    }

    map<string, int> mp, check;
    REP(i,len-1){
      FOR(j,i+2,len){
        if(p[i][j]){
          string t(s.begin() + i, s.begin() + j + 1);
          string tt(s.begin()+i+1, s.begin() + j);
          mp[t]++;
          check[tt]++;
         }
      }
    }
    
    REPI(itr, mp){
      string tt = itr->first;
      for(int i = 1; (tt.length() - i - 1) - i > 1; ++i){
        string sb = tt.substr(i, tt.length()-i*2);
        if(sb == "") break;
        if(is_palindrome(sb)){
          if(mp.find(sb) != mp.end()){
            mp[sb] = 0;
          }
        }else{
          break;
        }
      }
    }

    REPI(itr, mp){
      if(itr->second != 0){
        cout << itr->first;
        auto itr_tmp = itr;
        itr_tmp++;
        if(itr_tmp != mp.end()){
          cout << " ";
        }
      }
      
    }
    cout << "\n"; 
    /*
    REPI(itr, s){
      cout << *itr;
    }
    cout << endl;
    */
  }
  return 0;
}




Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std ;
class Cube {
  public:
  int f[6] ;
  Cube(){}
  void roll_z(){ roll(1,2,4,3); }
  void roll_y(){ roll(0,2,5,3); }
  void roll_x(){ roll(0,1,5,4); }
  void roll(int i , int j , int k , int l ){
    int t = f[i] ; f[i] = f[j] ;f[j] = f[k] ;f[k]= f[l];f[l]= t;
  }
} ;
bool eq(Cube c1 , Cube c2 ){
  for(int i = 0 ; i < 6 ; i++ )
    if(c1.f[i] != c2.f[i]) return false ;
  return true ;
}
bool equal (Cube c1 , Cube c2 ){
  for(int i = 0 ; i < 6 ; i++ ){
    for(int j = 0 ; j < 4 ; j++ ){
      if(eq(c1 ,c2 )) return true ;
      c1.roll_z() ;
    }
    if ( i % 2 == 0 )c1.roll_y();
    else c1.roll_x();
  }
  return false  ;
}
/*int getRight(Cube c1 , int f1 ,int f2){
  for(int i = 0 ; i < 6 ; i++ ){
    for(int j = 0 ; j < 4 ; j++ ){
      if(c1.f[0] == f1 && c1.f[1]==f2) return c1.f[2] ;
      c1.roll_z() ;
    }
    if ( i % 2 == 0 )c1.roll_y();
    else c1.roll_x();
  }
  return -1 ;
}
*/
int main () {
  Cube c1 , c2 ;
  
  for(int i = 0 ; i < 6 ; i++ ) cin >> c1.f[i] ;
  for(int i = 0 ; i < 6 ; i++ ) cin >> c2.f[i] ;
  
  if(equal (c1,c2))cout << "Yes" << endl ;
  else cout << "No" << endl ;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=205;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,l[MAXN],ans;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();Rep(i,1,2*n)l[i]=read();
	sort(l+1,l+2*n+1);Rep(i,1,n)ans+=l[i*2-1];
	cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 3580
#include<stdio.h>
#include<iostream>
using namespace std;

main() {

  int m, f, r, sum;

  while(1){
    m = 0, f = 0, sum = 0;
    scanf("%d %d %d",&m, &f, &r);
    
    sum = m + f;

    if(m == -1 && f == -1 && r == -1){
      break;
    }else{

      if(m == -1 || f == -1){
	cout << "F\n";
      }else if(sum >= 80){
	cout << "A\n";
      }else if(sum >= 65 && sum < 80){
	cout << "B\n";
      }else if(sum >= 50 && sum < 65){
	cout << "C\n";
      }else if(sum >= 30 && sum < 50 && r < 50){
        cout << "D\n";
      }else if(sum >= 30 && sum < 50 && r >= 50){
	cout << "C\n";
      }else if(sum < 30){
	cout << "F\n";
      }

    }

  }

}


Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	int d[3];
	d[0]=abs(a-b);
	d[1]=abs(b-c);
	d[2]=abs(c-a);
	sort(d, d+3);
	cout << d[0]+d[1] << endl;
	return 0;
}


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

int main(){
	int n,sum=0;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(sum%10!=0){
			cout<<sum<<endl;
			return 0;
		}
		else
			for(int j=1;j<=n;j++)
				if(a[i]%10!=0){
					sum-=a[i];
					break;
				}
	}
	
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 3564
#D
from heapq import heappush,heappop,heapify
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
d=[]
for i in range(x):
    for j in range(y):
        if i*j>k:
            break
        for l in range(z):
            if i*j*l>k:
                break
            heappush(d,-a[i]-b[j]-c[l])
for i in range(k):
    print(-heappop(d))

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

int main() {
int a, b;
  cin >> a >> b;
  if(6 <= a && a <=12) cout << b/2 << endl;
 if(a>=13) cout << b << endl;
 if(a<= 5) cout << 0 << endl;
}

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

using namespace std;


int main(){

    int n, d, x;
    cin >> n >> d >> x;

    int ans = 0;

    for(int i = 0; i < n; i++){
         int a, k;
         cin >> a;

         k = (d - 1)/a;
         ans += (k + 1);
     }


     cout << (ans + x);
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int fact(int n){
	if(n == 1){
		return 1;
	}else{
		return n * fact(n-1);
	}
}

int main(void){
	int n;

	scanf("%d", &n);
	if(n <= 12){
		printf("%d\n", fact(n));
	}else{
		switch(n){
		case(13):
			printf("6227020800\n");
			break;
		case(14):
			printf("87178291200\n");
			break;
		case(15):
			printf("1307674368000\n");
			break;
		case(16):
			printf("20922789888000\n");
			break;
		case(17):
			printf("355687428096000\n");
			break;
		case(18):
			printf("6402373705728000\n");
			break;
		case(19):
			printf("121645100408832000\n");
			break;
		case(20):
			printf("2432902008176640000\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

bool Judge(string S,string T)
{
	for (int i = 0; i < S.length(); i++)
	{
		S = S.back()+ S.substr(0,S.size()-1);
		if (S == T)
			return true;
	}
	return false;
}

int main()
{
	string S,T;
	cin >> S >> T;
	if (S.size() != T.size())
	{
		cout << "No" << endl;
	}
	
	if (Judge(S,T))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 508
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
int main() {
    int a, b, x;
    cin >> a >> b >> x;
    double h = (double)x / (double)(a * a);
    cout << setprecision(15);
    if(h < (double)b / 2.0) {
        double x = (2.0 * (double)h * (double)a) / (double)b;        cout << atan2(b, x) * 180.0 / M_PI << endl;
    } else {
        cout << atan2((double)b - h, (double)a / 2) * 180.0 / M_PI << endl;
    }
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

// AGC040 A - ><
int main(){
  string s;
  cin >> s; // length: N-1
  // 2 <= N <= 5e5

  const int n = (int)s.length()+1;
  vector<int> nums(n+1, 0);

  char basech = '\0';
  int basei = 0;
  int renzoku = 0;
  rep(i,n) {
    if (renzoku == 0) {
      basech = s[i];
      basei = i;
      renzoku = 1;
    } else if (basech == s[i]) {
      ++renzoku;
    } else {
      if (basech == '<') {
        // 上昇列
        nums[basei] = max(nums[basei], 0); // 境界
        for(int j=1;j<=renzoku;++j) {
          nums[basei+j] = j;
        }
      } else {
        // 下降列
        nums[basei] = max(nums[basei], renzoku); // 境界
        for(int j=1;j<=renzoku;++j) {
          nums[basei+j] = renzoku-j;
        }
      }
      // 次の列
      basech = s[i];
      renzoku = 1;
      basei = i;
    }
  }
  /*rep(i,nums.size()) {
    cout << nums[i] << ",";
  }
  cout << endl;*/
  ll sum = accumulate(nums.begin(), nums.end(), 0L);
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 5852
import random
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top,   self.bottom = top, bottom
        self.right, self.left   = right, left
        self.front, self.back   = front, back

    def rot(self, d):
        if   d == "N":
            self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        elif d == "S":
            self.top, self.back, self.bottom, self.front = self.back, self.bottom, self.front, self.top
        elif d == "E":
            self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        elif d == "W":
            self.top, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.top

ref = {}
ls = map(int, raw_input().split())
dice = Dice(ls[0], ls[1], ls[2], ls[3], ls[4], ls[5])
for i in xrange(1000):
    d = "NSEW"[random.randint(0,3)]
    dice.rot(d)
    ref[(dice.top, dice.front)] = dice.right

for i in xrange(input()):
    a, b = map(int, raw_input().split())
    print ref[(a, b)]

Measured memory_bytes: 5420
#include <stdio.h>
#include <stdlib.h> 
#define MAX 2000000
#define NMAX 10000

void Countingsort(int [],int *,int);

int main(void){
  
  int *A = malloc(sizeof (int)*MAX);
  int *B = malloc(sizeof (int)*MAX);
  int n;
  int i;
  
  scanf("%d",&n);
  

  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  
  Countingsort(A,B,n);


  for(i=0;i<n-1;i++)
    printf("%d ",B[i]);
  printf("%d\n",B[i]);

  free(A);
  free(B);

  return 0;
}


void Countingsort(int A[],int *B,int k){

  int i,j;
  int C[NMAX+1];

  for(i=0;i<NMAX;i++)
    C[i] = 0;

  for(j=0;j<k;j++)
    C[A[j]]++;
  /* C[i]にはiの出現数が記録されている*/

  for(i = 1;i<NMAX;i++)
    C[i] = C[i] + C[i-1];
  /* C[i]にはi以下の数の出現数が記録されている*/

  for(j=k-1;j>=0;j--){
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16060
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int[] ws = sc.nextIntArray(N);
			final int sum = Arrays.stream(ws).sum();
			
			int left = 0, right = sum;
			int answer = sum;
			
			for(int i = 0; i < N; i++) {
				left += ws[i];
				right -= ws[i];
				
				answer = Math.min(answer, Math.abs((left - right)));
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

using namespace std;

struct point{
	double x;
	double y;
};

struct circle{
	point o;
	double r;
};

istream& operator >> ( istream& s , circle& x );
void swap( circle *a , circle *b );
double get_distance( const point& a , const point& b );

int main(void)
{
	circle a, b;
	int n;

	cin >> n;

	for( int i = 0 ; i < n ; i++ )
	{
		int flag = 0;
		int result;

		cin >> a >> b;

		if( a.r < b.r )
		{
			swap( a , b ); // 大きいほうの円は常にa
			flag = 1;
		}

		double distance = get_distance( a.o , b.o );
		double add_r = a.r + b.r;

		if( add_r < distance ){
			result = 0;
		}
		else{
			if( distance + b.r < a.r ){
				if( flag == 0 ) result = 2;
				else result = -2;
			}
			else result = 1;
		}
		cout << result << endl;
	}

	return 0;
}

istream& operator >> ( istream& s , circle& x )
{
	return s >> x.o.x >> x.o.y >> x.r;
}

void swap( circle *a , circle *b )
{
	circle temp;

	temp = *a;
	*a = *b;
	*b = temp;

	return;
}

double get_distance( const point& a , const point& b )
{
	return sqrt( pow( a.x-b.x , 2 ) + pow( a.y - b.y , 2 ) );
}

Measured memory_bytes: 1232
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int ans=0;
    for(int i=1; i<=n; i+=2) {
        int cnt=0;
        for(int j=1; j<=i; j++) if(i%j==0) cnt++;
        if(cnt==8) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lo long long int
#define pb push_back
using namespace std;

int main(){
    string x,y;
  cin>>x>>y;
  	for(int i=0;i<x.size();i++){
    if(x[i]!=y[i]){
    	cout<<"No";
      return 0;
    	}
    }
  cout<<"Yes";
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)

int main(){
    string a,b;
    cin >> a >> b;
    rp(i,a.size()-1){
        cout << a.at(i) << b.at(i);
    }
    cout << a.at(a.size()-1);
    if(a.size()==b.size()){
        cout << b.at(b.size()-1);
    }
    cout << endl;
}








Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

using namespace std;

int n,p[200005],ma;
class CLowElements {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		int mi=1e9,ans=0;
		f(i,0,n)
        {
            in >> p[i];
            if(p[i]<mi)
            {
                mi=p[i];
                ans++;
            }
        }
        out << ans << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	CLowElements solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	antenna := scanNums(5)
	k := nextInt()

	sort.Ints(antenna)

	if antenna[len(antenna)-1]-antenna[0] > k {
		fmt.Print(":(")
		os.Exit(0)
	}
	fmt.Print("Yay!")
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = nextInt()
		nums = append(nums, num)
	}
	return
}

func scanString() string {
	var s string
	fmt.Scan(&s)
	return s
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		str = nextString()
		strings = append(strings, str)
	}
	return
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 640
#include<stdio.h>
int gcd(int x, int y){
if(y==0) return x;
return gcd(y,x%y);}
int main()
{
    int a,i,j,k;
    long long int m=0,n=0;
    scanf("%d",&k);
    for(i=1;i<=k;i++){
        for(j=1;j<=k;j++){
            for(a=1;a<=k;a++){
                m =gcd(gcd(i,j),a);
                n=m+n;
            }
        }
    }
    printf("%lld\n",n);
    return 0;
}


Measured memory_bytes: 1704
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
long long gys(long long a,long long b)
{
    if(b == 0)
        return a;
    else
        return gys(b,a%b);
}
long long gbs(long long a,long long b)
{
    return b*(a/gys(a,b));
}
int main()
{
    int n;
    scanf("%d",&n);
    long long g = 1;
    while(n--)
    {
        long long a;
        scanf("%lld",&a);
        g = gbs(g,a);
    }
    printf("%lld\n",g);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;


int N, M;
int d[50][50];

bool checkGraph(vector<int>& a, vector<int>& b, int l) {
    REP(i, 50) REP(j, 50) {
        if (i == j)
            d[i][j] = 0;
        else
            d[i][j] = INF;
    }

    REP(i, M) {
        if (i != l) {
            int ai = a[i];
            int bi = b[i];
            d[ai][bi] = d[bi][ai] = 1;
        }
     }

    REP(k, N) REP(i, N) REP(j, N) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);        
    }
    

    REP(i, N) for (int j = 0; j < i; j++) {
        if (d[i][j] == INF)
            return true;
    } 
    return false;
}


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

    vector<int> a, b;
    REP(i, M) {
        int ai, bi;
        cin >> ai >> bi;
        a.push_back(ai - 1);
        b.push_back(bi - 1);
     }

    int count = 0;
    REP(i, M)
        if (checkGraph(a, b, i))
            count++;

    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSummerVacation solver = new DSummerVacation();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSummerVacation {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            ArrayList<DSummerVacation.Pair> a = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                int y = sc.nextInt();
                if (x > m) {
                    continue;
                }
                a.add(new DSummerVacation.Pair(x, y));
            }
            a.sort((a1, b) -> Integer.compare(b.r, a1.r));
            int s = 0;
            long ans = 0;
            if (a.size() == 0) {
                out.println(0);
                return;
            }
            n = a.size();
            TreeMap<Integer, Integer> map = new TreeMap<>();
            for (int i = 0; i <= m; i++) {
                map.put(i, 1);
            }
            for (int i = 0; i < n; i++) {
                Integer x = map.floorKey(m - a.get(i).d);
                if (x == null) {
                    continue;
                } else {
                    map.remove(x);
                    ans += a.get(i).r;
                }
            }
            out.println(ans);
        }

        static class Pair {
            int d;
            int r;

            Pair(int a, int b) {
                d = a;
                r = b;
            }

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 52992
N,M = (int(x) for x in input().split())
a_arr = [-1]
for _ in range(M):
    a_arr.append(int(input()))
a_arr.append(N+1)

n_dp_size = N+3
n_dp = [0]*(n_dp_size)
n_dp[0] = 1
n_dp[1] = 0
n_dp[2] = 1
for i in range(3,n_dp_size):
    n_dp[i] = (n_dp[i-2]+n_dp[i-1]) % 1000000007

ans = 1
for i in range(1,len(a_arr)):
    a_diff = a_arr[i]-a_arr[i-1]
    ans *= n_dp[a_diff]
    ans = ans % 1000000007

print(ans)


Measured memory_bytes: 11044
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	if (N < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}

	return 0;
}


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

int descending_compare( const void * a , const void * b ) {
  if (*(unsigned long*)a < *(unsigned long*)b) {
    return 1;
  }
  else
  if (*(unsigned long*)a == *(unsigned long*)b) {
    return 0;
  }
  return -1;
}

int ascending_compare( const void * a , const void * b ) {
  if (*(unsigned long*)a < *(unsigned long*)b) {
    return -1;
  }
  else
  if (*(unsigned long*)a == *(unsigned long*)b) {
    return 0;
  }
  return 1;
}


int lower_bound(unsigned long *a, int n, unsigned long key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long a[100000];
unsigned long b[100000];
unsigned long c[100000];

int main(void){
    int n;
    int i;
    unsigned long answer = 0;
    int ai, ci;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%ld", &a[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%ld", &b[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%ld", &c[i]);
    }

    qsort(a, n, sizeof(unsigned long), ascending_compare);
    qsort(b, n, sizeof(unsigned long), ascending_compare);
    qsort(c, n, sizeof(unsigned long), ascending_compare);

    
    for (i = 0; i < n; i++){
        ai = lower_bound(a, n, b[i]);
        ci = lower_bound(c, n, b[i]+1);
            answer += (unsigned long)(ai)*(n-ci);
        }

    printf("%ld\n", answer);
    return 0;
}


Measured memory_bytes: 3324