akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n;
      cin>>n;
      map<P,lint> mp;
      lint add=0;
      rep(i,n){
          lint a,b;
          cin>>a>>b;
          lint x;
          if(a>0&&b>0){
           x=gcd(a,b);
           mp[{a/x,b/x}]++; 
          }else if(a<0&&b>0){
           x=gcd(abs(a),abs(b));
           mp[{a/x,b/x}]++;
          }else if(a>0&&b<0){
            x=gcd(abs(a),abs(b));
            mp[{-a/x,-b/x}]++;
          } else if(a<0&&b<0){
           x=gcd(abs(a),abs(b));
           mp[{-a/x,-b/x}]++;
          } else if(a==0&&b==0){
            add++;
          }else if(a==0){
            mp[{0,-1}]++;
          }else mp[{1,0}]++;     
      }
      lint ans=1;
      for(auto t:mp){
          P p=t.first;
          lint h;
          if(p.first==0){
          h=mp[{1,0}];
          mp.erase({1,0});
          }else if(p.second==0){
          h=mp[{0,-1}];
          mp.erase({0,-1});
          }else if(p.first>0){
          h=mp[{-p.second,p.first}];
          mp.erase({-p.second,p.first});
          }else{
          h=mp[{p.second,-p.first}];
          mp.erase({p.second,-p.first});           
          }
          lint mul=modpow(2,h,MOD)+modpow(2,t.second,MOD)-1;
          mul+=MOD;
          mul%=MOD;
          ans*=mul;
          ans%=MOD;
      }
      ans+=add;
      ans--;
      ans+=MOD;
      ans%=MOD;
      cout<<ans<<endl;
      }
      

Measured memory_bytes: 16032
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {

	int num_problem, num_drink, sum_time = 0;

	cin >> num_problem;

	vector<int> problem_time(num_problem);
	for (int i = 0; i < num_problem; i++){

		cin >> problem_time[i];
	}

	cin >> num_drink;

	vector<pair<int, int>> drink(num_drink);

	for (int i = 0; i < num_drink; i++){

		cin >> drink[i].first >> drink[i].second;
	}

	for (int i = 0; i < num_problem; i++){

		sum_time += problem_time[i];
	}

	for (int i = 0; i < num_drink; i++) {

		cout << sum_time - problem_time[drink[i].first - 1] + drink[i].second << "\n";
	}

	return	0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];
int main() {
    int n,k,cnt = 0;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        if(h[i] >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ( ( a % 2 ) == 1 && ( b % 2 ) == 1 ) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	if(n == 1){
		print("YES")
		return 0;
	}
	
	ll a[n+1];
	ll sum = 0;
	rep(i, 1, n){
		cin >> a[i];
		sum += a[i];
	}
	
	if(sum%(n*(n+1)/2) != 0){
		print("NO")
	}
	else{
		ll da[n+1];
		rep(i, 1, n-1){
			da[i] = a[i+1]-a[i];
		}
		da[n] = a[1]-a[n];
		
		ll m = sum/(n*(n+1)/2);
		ll ans = 0;
		rep(i, 1, n){
			if(da[i] > m){
				print("NO")
				return 0;
			}
			
			if(da[i] < m){
				if((m-da[i])%n == 0){
					ans += (m-da[i])/n;
				}
				else{
					print("NO")
					return 0;
				}
			}
		}
		if(ans == m){
			print("YES")
		}
		else{
			print("NO")
		}
	}
	
	return 0;
}

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

using namespace std;
int main () {
  int n;
  cin>>n;
  ostringstream str1; 
  str1<<n;
  string n1=str1.str();
  int a=n1.size();int flag=0;
  int i;
  for(i=0;i<a;i++)
  {
  	if(n1[i]=='7')
  	{
  		flag=1;
  		break;
	  }
  }
  if(flag==1)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
struct Edge{
	int w,d;
	bool operator < (const Edge &b)const
	{
		return w<b.w;
	}
}a[MAXN<<1];
int n,m,limit[3][3],len[3];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&a[i].w),a[i].d=0;
	for(int i=1;i<=m;++i)scanf("%d",&a[i+n].w),a[i+n].d=1;
	int tot=n+m;
	sort(a+1,a+tot+1);
	++n,++m;
	long long ans=0;
	for(int i=1;i<=tot;++i){
		ans+=(long long)a[i].w*(a[i].d?n:m);
		a[i].d?--m:--n;
		m=max(m,0),n=max(n,0);
		if(!m && !n)break;
	}
	cout<<ans<<endl;
	return 0;
}


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

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

    static class CMinimization {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();

            int answer = (n - 1) / (k - 1);
            if (answer * (k - 1) < n - 1) answer++;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  string s,t;
  cin>>s>>t;
  int res=0;
  for(int i=0;i<Sz(s);++i){
    if(s[i]!=t[i])res++;
  }
  cout<<res<<'\n';
  
  return 0;
}
//2020.06.27 20:01:36


Measured memory_bytes: 3884
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
int a[man];

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("in.txt", "r", stdin);
		//freopen("out.txt","w",stdout);
	#endif
	int n,m;
	cin >> n >> m;
	ll sum = 0;
	for(int i = 1;i <= n;i++){
		cin >>a[i];
		sum += a[i];
	}	
	double p = 1.0 * sum / 4 / m;
	int res = 0;
	for(int i = 1;i <= n;i++){
		if(a[i]>=p){
			res++;
		}
	}
	if(res>=m)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[300][2],a,b,sum;
main(){
  cin>>a>>b;
  dp[0][1]=1;
  for(int i=0;i<=100;i++){
    for(int j=0;j<2;j++){
      if(dp[i][j]){
        if(j)dp[i+b][j^1]+=dp[i][j];
        dp[i+1][j^1]+=dp[i][j];
      }
    }
  }
  for(int i=1;i<=a;i++) sum+=dp[i][0];
  cout<<sum<<endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=100009;
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n,f=0;
	cin >> n;
	map <int,int> m;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		m[a]++;
		if(m[a]>=2){
			f=1;
		}
	}
	if(f)cout << "NO";
	else cout << "YES";
}

Measured memory_bytes: 12800
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

ll gcd(ll x, ll y)
{
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

int main()
{

  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll cnt = B - A + 1;

  // Cで割り切れる
  // 全体
  ll bdc = B / C;

  // A未満
  ll adc = (A - 1) / C;

  // Dで割り切れる
  // 全体
  ll bdd = B / D;

  // A未満
  ll add = (A - 1) / D;

  // CでもDでも割り切れる
  ll g = gcd(C, D);
  ll l = C * D / g;

  // 全体
  ll bdcd = B / l;

  // A未満
  ll adcd = (A - 1) / l;

  cout << cnt - (bdc - adc) - (bdd - add) + (bdcd - adcd);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt();
        String s;
        if(a==b)s="==";
        else if(a>b)s=">";
        else s="<";
        System.out.printf("a %s b\n",s);
    }
}


Measured memory_bytes: 26208
#include <stdio.h>


int A[1000000],n;

//二分探索  
int binarysearch(int k){
  int left=0;
  int mid;
  int right=n;

  while(left<right){
    mid=(left+right)/2;
    if(k==A[mid]) return 1;
    if(k<A[mid]) right=mid;
    else if(k>A[mid])left=mid+1;
  }
  return 0;
	 
}

int main(){
  int i,q,key,sum=0;

  //数列Sを決定
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  //数列Tを決定
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(binarysearch(key)== 1) sum++;
  }

  printf("%d\n",sum);
  
  return 0;
}

  
		 



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
#define fi first
#define sec second
#define INF 1000000000
int N,M;
vector<int> g[100100];
int match[100100];
bool used[100100];
void add_edge(int a,int b){
	g[a].pb(b);
	g[b].pb(a);
}
bool dfs(int v){
	used[v] = true;
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		int w = match[u];
		if(w<0 ||!used[w]&&dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}
int bipartite(){
	int res = 0;
	memset(match,-1,sizeof(match));
	for(int v=0;v<2*N;v++){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}
void efs(int v){
	used[v] = true;
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(used[u])continue;
		efs(u);
	}
	return;
}
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int x,y;
		cin >> x >> y;
		x--;y--;
		add_edge(x,y+N);
	}
	int cmp = 0;
	memset(used,false,sizeof(used));
	for(int i=0;i<2*N;i++){
		if(!used[i]){
			if(g[i].size()==0)continue;
			efs(i);
			cmp++;
		}
	}
	cout << M-bipartite() << ' ' << M-cmp << endl;
	return 0;
}




Measured memory_bytes: 6012
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

vector< vector<int> > MakeCombination1(vector< vector<int> >);
void MakeCombination1Inner(int, vector<int>, vector< vector<int> >, vector< vector<int> >&);
vector< vector<int> > MakeCombination2(int, int);
void MakeCombination2Inner(int, vector<int>&);
int CardPair(vector<string>, vector< vector<int> >, vector< vector<int> >);

int main(){
  int i, n, k;
  string s;
  vector<string> str;
  vector< vector<int> > data1, data2[3];

  data2[0] = MakeCombination1(data2[0]);
  data2[1] = MakeCombination1(data2[0]);
  data2[2] = MakeCombination1(data2[1]);

  while(1){
    cin >> n >> k;
    if(n == 0 && k == 0) break;
    data1 = MakeCombination2(n, k);

    for(i=0; i<n; ++i){
      cin >> s;
      str.push_back(s);
    }
    cout << CardPair(str, data1, data2[k-2]) << endl;
    str.clear();
  }
  return 0;
}

vector< vector<int> > MakeCombination1(vector< vector<int> > original){
  int i;
  vector<int> _data;
  vector< vector<int> > data;

  if(original.empty()){
    _data.push_back(0);
    _data.push_back(1);
    data.push_back(_data);
    _data.clear();
    _data.push_back(1);
    _data.push_back(0);
    data.push_back(_data);
  }else{
    _data = original[0];
    _data.push_back(original[0].size());

    for(i=_data.size()-1; i>=0; --i){
      MakeCombination1Inner(i, _data, original, data);
    }
  }
  return data;
}

void MakeCombination1Inner(int m, vector<int> num, vector< vector<int> > original, vector< vector<int> >& data){
  int i, j, n;
  vector<int> _data;
  n = num[m];
  num.erase(num.begin() + m);

  for(i=0; i<original.size(); ++i){
    for(j=0; j<original[i].size(); ++j)
      _data.push_back(num[original[i][j]]);

    _data.push_back(m);
    data.push_back(_data);
    _data.clear();
  }
}

vector< vector<int> > MakeCombination2(int n, int m){
  int i;
  vector<int> _data;
  vector< vector<int> > data;

  for(i=0; i<m; ++i)
    _data.push_back(i);
  data.push_back(_data);

  while(1){
    MakeCombination2Inner(n, _data);
    data.push_back(_data);

    if(_data[0] == n-m && _data[_data.size()-1] == n-1)
      break;
  }
  return data;
}

void MakeCombination2Inner(int n, vector<int>& data){
  int i, j;
  for(i=data.size()-1, j=1; i>=0; --i, ++j){
    if(data[i] != n-j){
      ++data[i];
      for(j=i+1; j<data.size(); ++j)
        data[j] = data[j-1]+1;
      return;
    }
  }
}

int CardPair(vector<string> str, vector< vector<int> > data1, vector< vector<int> > data2){
  int i, j, k;
  string s;
  vector<string> str1;
  set<string> str2;
  for(i=0; i<data1.size(); ++i){
    for(j=0; j<data1[i].size(); ++j){
      str1.push_back(str[data1[i][j]]);
    }
    for(j=0; j<data2.size(); ++j){
      for(k=0; k<data2[j].size(); ++k){
	s += str1[data2[j][k]];
      }
      if(str2.find(s) == str2.end()) str2.insert(s);
      s.clear();
    }
    str1.clear();
  }
  return str2.size();
}

Measured memory_bytes: 1520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	int N = S.size();
	int rcnt = 0;
	int lcnt = 0;
	vector<pair<int,P>> v;
	//rとlの境界線
	int x = 0;
	rep(i,N){
		if(S[i] == 'R'){
			rcnt++;
		}
		else{
			lcnt++;
		}
		if(i == N-1){
			v.push_back({x,{rcnt,lcnt}});
			continue;
		}
		if(S[i] == 'R'&&S[i+1] == 'L'){
			x = i;
		}
		if(S[i] == 'L'&&S[i+1] == 'R'){
			v.push_back({x,{rcnt,lcnt}});
			rcnt = 0;
			lcnt = 0;
		}
	}
	//
/*	rep(i,v.size()){
		if(i == 0)cerr<<"[";
		cerr<<"{"<<v[i].first<<", {"<<v[i].second.first<<", "<<v[i].second.second<<"}}, ";
	}
	cerr<<"]"<<endl;
	//*/
	vector<ll> ans(N);
	rep(i,v.size()){
		x = v[i].first;
		rcnt = v[i].second.first;
		lcnt = v[i].second.second;
		if((rcnt + lcnt)%2 == 0){
			ans[x] = ans[x+1] = (rcnt+lcnt)/2;
		}
		else{
			int longcnt = max(rcnt,lcnt);
			int large = (lcnt+rcnt)/2 + 1;
			int small = lcnt + rcnt - large;
			if(longcnt%2 == 0){
				if(rcnt > lcnt){
					ans[x] = small;
					ans[x+1] = large;
				}
				else{
					ans[x] = large;
					ans[x+1] = small;
				}
			}
			else{
				if(rcnt > lcnt){
					ans[x] = large;
					ans[x+1] = small;
				}
				else{
					ans[x] = small;
					ans[x+1] = large;
				}
			}
		}
	}
	rep(i,N){
		cout<<ans[i];
		if(i == N-1)cout<<endl;
		else cout<<" ";
	}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int a, b, c, k, ans=0;
	cin>> a >> b >> c >> k;

	while(b<=a){
		b*=2;
		ans++;
	}

	while(c<=b){
		c*=2;
		ans++;
	}

	if(ans<=k) cout<< "Yes" <<endl;
	else cout<< "No" <<endl;
 
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint a[200005];
llint dif[200005], sum[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 1; i <= min(400LL, k); i++){
		for(int j = 1; j <= n; j++) dif[j] = 0;
		for(int j = 1; j <= n; j++){
			dif[max(1LL, j-a[j])]++, dif[min(j+a[j], n)+1]--;
		}
		for(int j = 1; j <= n; j++) a[j] = a[j-1] + dif[j];
	}
	
	for(int i = 1; i <= n; i++)  cout << a[i] << " "; cout << endl;
	
	return 0;
}

Measured memory_bytes: 6748
#include<iostream>
#include<vector>
using namespace std;
vector<int> edge[100005];
int n,m;
int main(){
    cin>>n>>m;
    int h[100005];
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        bool flag=true;
        for(int j=0;j<edge[i].size()&&flag;j++){
            if(h[i]<=h[edge[i][j]]){
                flag=false;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout<<ans<<"\n";
    return(0);
}

Measured memory_bytes: 9160
import copy
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
M=list(map(int,input().split()))
dp=list()
S=sum(A)
dp.append([1]+[0]*S)
for i in range(N):
  dp.append(copy.copy(dp[-1]))
  for j in range(S-A[i]):
    dp[i+1][j+A[i]]=dp[i+1][j+A[i]]+dp[i][j]
L=list()
for i in range(N+1):
  for j in range(len(dp[i])):
    if dp[i][j]!=0:
      L.append(j)
L=set(L)
for i in range(Q):
  if M[i] in L:
    print('yes')
  else:
    print('no')


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

int x, y;
int ans;
int s[] = { 0, 300000, 200000, 100000 };

int main() {
	scanf("%d%d", &x, &y);
	if (x <= 3) ans += s[x];
	if (y <= 3) ans += s[y];
	if (x == 1 && y == 1) ans += 400000;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
while 1:
    n = input()
    if n == 0:break
    D = range(1,7)
    ans = 1
    for i in range(n):
        c = raw_input()[0]
        if c == "N":
            D = [D[1],D[5],D[2],D[3],D[0],D[4]]
        elif c == "S":
            D = [D[4],D[0],D[2],D[3],D[5],D[1]]
        elif c == "E":
            D = [D[3],D[1],D[0],D[5],D[4],D[2]]
        elif c == "W":
            D = [D[2],D[1],D[5],D[0],D[4],D[3]]
        elif c == "R":
            D = [D[0],D[2],D[4],D[1],D[3],D[5]]
        elif c == "L":
            D = [D[0],D[3],D[1],D[4],D[2],D[5]]
        ans += D[0]
    print ans

Measured memory_bytes: 4396
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		long[][] a = new long[n][];
		for (int i = 0; i < n; i++) {
			a[i] = new long[m];
			for (int j = 0; j < m; j++) {
				a[i][j] = scan.nextInt();
			}
		}
		long[][] b = new long[m][];
		for (int i = 0; i < m; i++) {
			b[i] = new long[l];
			for (int j = 0; j < l; j++) {
				b[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				long c = 0;
				for (int k = 0; k < m; k++) {
					c += a[i][k] * b[k][j];
				}
				if (j == 0) {
					System.out.print(c);
				} else System.out.print(" " + c);
			}
			System.out.println();
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 53272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

// int N = 4;
// int K = 150;
// int h[] = {150, 140, 100, 200};
int N, K;
int h[100000];

int main() {

    cin >> N >> K;
    rep(i, N) {
        cin >> h[i];
    }
    int ans = 0;
    rep(i, N) {
        if (K <= h[i]) ans++;
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 640
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);
        int mod = 10007;

        int n = sc.nextInt();
        int[] tanto = new int[n];
        char[] line = sc.next().toCharArray();
        for(int i=0; i<n; i++){
            if(line[i]=='J') tanto[i] = 0;
            if(line[i]=='O') tanto[i] = 1;
            if(line[i]=='I') tanto[i] = 2;
        }
        
        int[][] dp = new int[2][1<<3];
        dp[0][0] = 1;
        int idx = 1;
        int cnt = 0;
        for(int i=0; i<n; i++){
            for(int bit=0; bit<(1<<3); bit++){
                if((bit&(1<<tanto[i]))==0) continue;
                if(i==0){
                    if((bit&1)>0) dp[idx][bit] = 1;
                    continue;
                }
                for(int bit2=0; bit2<(1<<3); bit2++){
                    if((bit&bit2)>0){
                        dp[idx][bit] += dp[1-idx][bit2];
                        dp[idx][bit] %= mod;
                    }
                }
                if(i==n-1) cnt = (cnt + dp[idx][bit]) % mod;
            }
            idx = 1-idx;
            dp[idx] = new int[1<<3];
        }
        System.out.println(cnt);
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

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

  set<int> s, g;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    if (a == 1)
      s.insert(b);
    if (b == N)
      g.insert(a);
  }

  for (auto i : s) {
    if (g.find(i) != g.end()) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 9600
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    s = S()

    print(s[:3])



if __name__ == '__main__':
    main()


Measured memory_bytes: 9944
import sys
import bisect
from collections import deque
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(readline())
MOD = 998244353

XD = [[int(x) for x in readline().split()] for _ in range(N)]
XD.sort()
#X = [x for x, _ in XD]

NXT = deque()
E = [[] for _ in range(N)]

for i in range(N - 1, -1, -1):
    x, d = XD[i]

    while NXT:
        j, nx = NXT.pop()

        if nx < x + d:
            E[i].append(j)
        else:
            NXT.append((j, nx))
            break

    NXT.append((i, x))


def dfs(i):
    rtn = 1
    for v in E[i]:
        rtn *= dfs(v)
        rtn %= MOD
    return rtn + 1


ans = 1
for i, x in NXT:
    ans *= dfs(i)
    ans %= MOD

print(ans % MOD)


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

d = list()

A_list = list()

for a in range(0, k):
    d.append(int(input()))
    A_list.append(list(map(int, input().split())))

count = [0]*n

for a in A_list:
    for b in a:
        count[b-1] += 1

print(len(list(filter(lambda x: x == 0, count))))


Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    int i;
    for(i = 0;i < n;++i){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    int ans = 0;
    for(i = 0;i < k;++i){
        ans += l.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll a[5];
  for (ll i = 0; i < 5; i++) {a[i] = 0;}
  for (ll i = 0; i < N; i++) {
    string s; cin >> s;
    if (s[0] == 'M') {a[0]++;}
    if (s[0] == 'A') {a[1]++;}
    if (s[0] == 'R') {a[2]++;}
    if (s[0] == 'C') {a[3]++;}
    if (s[0] == 'H') {a[4]++;}
  }
  
  ll res = 0;
  for (ll bits = 0; bits < (1 << 5); bits++) {
    if (__builtin_popcountl(bits) == 3) {
      ll num = 1;
      for (ll i = 0; i < 5; i++) {
        if (bits>>i&1) {num*=a[i];}
      }
      res += num;
    }
  }
  cout << res << endl;
}

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

signed
main() {
		ll N;
		cin >> N;

		int ans = MAX;
		ll left, right;
		for(left=1;left*left<=N;left++)
		{
				if(N%left!=0) continue;

				right = N / left;
				string ls = to_string(left), rs = to_string(right);

				ans = min(ans, max((int)ls.size(), (int)rs.size()));

		}

		cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
	int n,m;
	vector<int> adj[100005];
	int dp[100005];
	int longpath(int node){
		if(dp[node]!=-1)
		return dp[node];
		int ans=0;
		for(auto i:adj[node]){
			ans=max(ans, 1+longpath(i));
		}
		return dp[node]=ans;
	}
int main(){
	IOS;

	cin>>n>>m;
	for(int i=0,x,y;i<m;i++){
		cin>>x>>y;
		adj[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	adj[0].push_back(i);
	memset(dp, -1, sizeof(dp));
	
	cout<<longpath(0)-1;
}

Measured memory_bytes: 11436
//Keep pluggin',this is your only outlet.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cctype>
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define fi first
#define mp make_pair
#define se second
using namespace std;
//#define int long long

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int quickmul(int x,int y,int mod){return (x*y-(int)((long double)x/mod*y)*mod+mod)%mod;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x * f;
}
const int MAXN = 1e5 + 100;
int n,c,k,a[MAXN];
///------------------head------------------
signed main(signed argc, char *argv[]){
    n = read(),c = read(),k = read();
    rep(i,1,n) a[i] = read();
    sort(a+1,a+n+1);
    int ans = 0,cur = 0,tcur;
    for (int i = n; i; --i) {
        if (!cur) cur = 1,++ans,tcur = a[i];
        else {
            if (cur == c) ++ans,cur = 1,tcur = a[i];
            else {
                if (tcur - a[i] > k) ++ans,cur = 1,tcur = a[i];
                else ++cur;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 640
#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)||(x-r)<0){
    printf("No\n");
  }else if(h<(y+r)||(y-r)<0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <string.h>
 
char dict[30600000];
 
char word[26];
 
long encode(const char *key){
  int n=strlen(key),i;
  long sum=0;
  long keta=1;
  for(i=0;i<n;i++){
    int keyi=key[i];
    sum = sum + keta * word[keyi];
    keta=(keta<<2)+keta;
  }
  return (sum);
}
 
void insert(const char *key2) {
  long key=encode(key2);
  long keta=key/8;
  dict[keta]=(dict[keta]|(1<<(key%8)));
}
 
int find_h(const char *key2) {
  long key=encode(key2);
  return (dict[key/8] & 1<<(key%8));
}
 
int main(void) {
  long n,i;
  word['A'] = 1;
  word['C'] = 2;
  word['G'] = 3;
  word['T'] = 4;
  scanf("%ld\n",&n);
  for(i=0;i<n;i++){
    char cmd[8], str[14]; scanf("%s %s\n",cmd, str);
    if(cmd[0]=='i') {
      insert(str);
    }
    else {
      if(find_h(str)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1432
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n 
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[-1])

Measured memory_bytes: 20552
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>
 
using namespace std;
 
#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll; 

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

int main(){
	int n;
	cin >> n;
	vector<int> da(n);
	rip(i,n,0){
		cin >> da[i];
	}
	vector<int> a(n),b(n);
	rip(i,n,0){
		a[i]=i*n+1;
		b[n-i-1]=i*n+1;
	}
	rip(i,n,0){
		a[da[i]-1]+=i;
		b[da[i]-1]+=i;
	}
	vdeb(a);
	vdeb(b);
}

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

int main() {
	string S;
	cin >> S;
	if (S.size() == 2) cout << S;
	else cout << S[2] << S[1] << S[0];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

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

using namespace std;

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

int main()
{
  int N,M,X,Y;cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i,N) cin >> x[i];
  rep(i,M) cin >> y[i];

  if (*max_element(x.begin(),x.end()) < *min_element(y.begin(),y.end()) && 
        *min_element(y.begin(),y.end()) > X && *max_element(x.begin(),x.end()) < Y)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  
  return 0;
}


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

bool gt(int a, int b)
{
    return a > b;
}

int main()
{
    int n,t;
    vector<int> nums;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> t;
        nums.push_back(t);        
    }
    sort(nums.begin(), nums.end(), gt);

    int ans = 0;
    int tans = 0;
    for(int sc : nums)
    {
        ans += sc;
        if(ans % 10 != 0)
        {
            tans = ans;
        }
        else if(sc%10==0)
        {
            if((tans+sc)%10 != 0)
            {
                tans += sc;
            }
        }
        //cout << ans << endl;
    }
    if(ans % 10 == 0)
    {
        ans = tans;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  if (n == 2) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", a+b);
  } else {
    printf("Hello World\n");
  }
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef vector<pair<char, char>> vcc;

#define max(x, y) (((x) > (y)) ? (x) : (y))

signed main(void){
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vcc qs = vcc(q);
    rep (i, q) {
        char t, d;
        cin >> t >> d;
        qs[i] = pcc(t, d);
    }
    reverse(qs.begin(), qs.end());

    int l = 0, r = n;
    rep (i, q) {
        char t, d;
        t = qs[i].fs;
        d = qs[i].sd;
        if (d == 'L') {
            if (0 <= l && l < n && s[l] == t) l++;
            if (0 <= r && r < n && s[r] == t) r++;
        } else {
            if (0 < r && r <= n && s[r - 1] == t) r--;
            if (0 < l && l <= n && s[l - 1] == t) l--;
        }
        if (r > n) r = n;
        if (l < 0) l = 0;
    }
    cout << max((r - l), 0) << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	int a[100005];
	vector<int> A[2];

	cin >> N;
	rep(i,N){
		cin >> a[i];
		A[i%2].push_back(a[i]);
	}
	rep(i,2) sort(all(A[i]));
	sort(a, a+N);

	map<int,int> mp;
	rep(i,N) if(i%2 == 0){
		mp[a[i]]++;
	}
	for(auto t: A[0]) mp[t]--;

	for(auto p: mp) ans += abs(p.Y);
	ans /= 2;

	// int bf = -1;
	// int pos[2]={};
	// rep(i,N){
	// 	if( A[0][pos[0]] == A[1][pos[1]] ){
	// 		pos[i%2]++;
	// 	}else if( A[0][pos[0]] < A[1][pos[1]] ){
	// 		pos[0]++;
	// 		if( i%2 != 0 ) ans++;
	// 	}else{
	// 		pos[1]++;
	// 		if( i%2 != 1 ) ans++;
	// 	}
	// }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5756
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, M;
  cin >> N >> M;
  int mx = M / N;
  rrep(i, mx + 1){
    if(M % i == 0){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[][] d = new int[n][2];
    for(int i=0; i<n; i++){
      d[i][0] = sc.nextInt();
      d[i][1] = sc.nextInt();
    }
    
    int cnt = 0;
    for(int i=0; i<n; i++){
      if(cnt>=3)  break;
      if(d[i][0]==d[i][1])  cnt++;
      else  cnt = 0;
    }
    
    if(cnt>=3){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35908
#include <iostream>

using namespace std;

int W[101], P[101], n, k;
long long dp[105][100100];

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> W[i] >> P[i];

    for(int i=1; i<=n; i++)
    {
        for(int cw=1; cw<=k; cw++)
            {   if(cw - W[i] < 0) dp[i][cw] = dp[i-1][cw];
                else dp[i][cw] = max(dp[i-1][cw], dp[i-1][cw-W[i]] + P[i]);
            }
    }

    cout << dp[n][k] << '\n';
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define X real()
#define Y imag()

typedef array<int, 3> tri;
typedef long long ll;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; cout << '\n'; return O;}


void _main() {
        int k; cin >> k;
        //7777 = 7 * 1000 + 7 * 100 + 7 * 10 + 7 * 1
        int pow = 1;
        ll cnt = 0;
        int num = 0;
        while (1) {
                ++cnt;
                (num += 7 * pow) %= k;
                if (num == 0) {
                        cout << cnt;
                        return;
                }

                if (cnt == 2e6) break;
                (pow *= 10) %= k;
        }

        cout << -1;
}

int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

main(void) {

  int i , num , total , x;
 
  string number;

  i = total = num =0;

  while(1) {

    cin >> number;

    if(number == "0") break;

    x = number.size();

    for(i = 0; i < x; i++) {

      num = number[i] - '0';

      total += num;

    }

    cout << total << "\n";

    total = 0;

  }

}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL a, b, n;
  cin >> a >> b >> n;
  LL x = min(b - 1, n);


  cout << (a * x) / b - x / b << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char X;
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>X;
    if(X=='Y'){
     cout<<"Four"<<endl; 
      break;
    }
    if(i==N-1)cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
from itertools import accumulate
from collections import Counter

N, M = map(int, input().split())
As = list(map(int, input().split()))

As = [accA % M for accA in accumulate(As)]
cnt = Counter(As)

ans = 0
key = 0
for A in As:
    ans += cnt[key]
    cnt[A] -= 1
    key = A

print(ans)


Measured memory_bytes: 14788
a, b, m = map(int, input().split())

aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

mm = list()
for ii in range(0,m):
    mm.append(list(map(int, input().split())))

prices = list()

prices.append(int(min(aa)) + int(min(bb)))

for ml in mm:
    prices.append(aa[ml[0]-1] + bb[ml[1]-1] - ml[2])

print(min(prices))


Measured memory_bytes: 42408
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n,r;
  cin >> n >> r;
  if(n >= 10){
    cout << r << endl;
  }else{
    cout << r+100*(10-n) << endl;
  }
}

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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r) {
    if (l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    rec(0, n);
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main(void) {
    int k;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> k;
        pre.push_back(k);
    }
    for (int i = 0; i < n; i++) {
        cin >> k;
        in.push_back(k);
    }

    solve();

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  vector<string> W = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int t = 0;
  for(int i=0;i<7;i++){
    if(S == W.at(i)){
      t= i;
    }
  }
  cout <<7-t <<endl;
}


Measured memory_bytes: 256