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

int main(void) {
	int i,joi,ioi = 0;
	char s[11000];
	while (scanf("%s",s) != EOF){
		joi = 0;
		ioi = 0;
		for(i = 0;i <= 10997;i++){
			if(s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I'){
				joi++;
			}
			if(s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I'){
				ioi++;
			}
		}
		printf("%d\n%d\n",joi,ioi);
		for (i = 0;i <= 10999;i++){
			s[i] = '0';
		}
	}
	return 0;
}

Measured memory_bytes: 984
#!/usr/bin/env python3

def main():
    H, W = map(int, input().split())
    h, w = map(int, input().split())
    all_cells = H * W
    black_cells = h * W + w * H - (h * w)
    print(all_cells - black_cells)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  string s; cin>>s;
  int n,upper=0,sum=0;
  n=s.size();
  for(int i=2;i<n-1;i++){
    if(s[i]=='C')sum++;
  }
  for(int i=0;i<n;i++){
    if(s[i]>='A' && s[i]<='Z')upper++;
  }
  if(s[0]=='A' && sum==1 && upper==2){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
typedef struct Data{
  int area,pos;
} Data;
 
Data t[20000];
 
int u[20000];
 
int n,i;
 
char str[20001];
 
int T,U;
 
int ans,A;
 
Data B,X;
 
void D_push(Data data){
  t[T++]=data;
}
 
Data D_pop(){
  return t[--T];
}
 
void push(int x){
  u[U++]=x;
}
 
int pop(){
  return u[--U];
}
 
 
void init(){
  ans=T=U=0;
}
 
Data makeData(int x,int y){
  Data res;
  res.area=x;
  res.pos=y;
  return res;
}
 
int main(){
  init();
  scanf("%s",str);
  n=strlen(str);
 
  for(i=0;i<n;i++){
 
    if(str[i]=='/'){
 
      if(U==0)continue;
      A=pop();
      X=makeData(i-A,A);
      ans+=i-A;
      while(T>0){
    B=D_pop();
    if(B.pos<A){
      D_push(B);
      break;
    }
    X.area+=B.area;
    if(B.pos<X.pos)X.pos=B.pos;
      }
      D_push(X);
    }else if(str[i]=='\\'){
      push(i);
    }
 
  }
   
  printf("%d\n%d",ans,T);
  for(i=0;i<T;i++){
    printf(" %d",t[i].area);
  }
  printf("\n");
  return 0;
}
 
  

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

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



int main() {
    int h,w; cin >> h >> w;
    vector<vector<char>> c(h, vector<char>(w, '-'));
    rep(i, h) rep(j, w) cin >> c[i][j];


    vector<vector<char>> ans(2*h, vector<char>(w, '-'));


    int ans_i=0;
    rep(i, h) {
        rep(j, w) {
            ans[ans_i][j] = c[i][j];
            ans[ans_i+1][j] = c[i][j];
        }
        ans_i+=2;
    }

    rep(i, 2*h) {
        rep(j, w) {
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
    
}


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

int main () {
  int a, b, c; cin >> a >> b >> c;
  for (int i=0; i<=b; i++) {
    if ((i*a)%b == c) {
      cout << "YES" << endl;
      return 0;
    }
  } cout << "NO"  << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
using Graph = vector<vector<int>>;

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

  int n, m;
  cin >> n >> m;

  Graph G(n);
  FOR(i, 1, m) {
    int a, b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  vector<int> dist(n, -1);
  queue<int> que;

  dist[0] = 0;
  que.push(0);

  // BFS
  while (!que.empty()) {
      int v = que.front();
      que.pop();

      for (int nv : G[v]) {
          if (dist[nv] != -1) continue;

          dist[nv] = v+1;
          que.push(nv);
      }
  }

  bool flag = true;
  FOR(i, 1, n-1){
    if (dist[i]==-1){
      cout << "No" << "\n";
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << "\n";
    FOR(i, 1, n-1){
      cout << dist[i] << "\n";
    }
  }


}


Measured memory_bytes: 10216
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int ans=0;
    for(int n=2; n<=N; n++) {
        int cnt=0;
        for(int i=1; i*i<n; i++) {
            if(n%i==0) {
                cnt++;
                cnt++;
            }
        }
        if(cnt==8 && n%2) {
            ans++;
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=2019;
signed main(){
    string s;
    cin>>s;
    int pow10[200000];
    pow10[0]=1;
    for(int i=1;i<s.size();i++)
        pow10[i]=pow10[i-1]*10%mod;
    int arr[200001];
    arr[0]=0;
    for(int i=0;i<s.size();i++)
        arr[i+1]=(arr[i]+pow10[i]*(s[s.size()-1-i]-'0'))%2019;
    int cnt[2019]={};
    for(int i=0;i<=s.size();i++)
        cnt[arr[i]]++;
    int ans=0;
    for(int i=0;i<2019;i++)
        ans+=cnt[i]*(cnt[i]-1)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 6856
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void)
{
    string w;
    cin >> w;
    map<char, int> a_map;
    bool isBeautiful = true;
    for (int i = 0; i < w.size(); i++)
    {
        auto itr = a_map.find(w[i]);
        if (itr != a_map.end())
        {
            a_map[itr->first] = itr->second + 1;
        }
        else
        {
            a_map[w[i]] = 1;
        }
    }
    for (auto itr = a_map.begin(); itr != a_map.end(); itr++)
    {
        // cout << itr->first << ":" << itr->second << endl;
        if (itr->second % 2 != 0)
        {
            isBeautiful = false;
            break;
        }
    }
    if (isBeautiful)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        long sumA = 0;
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            sumA += a[i];
        }
        long sumB = 0;
        for (int i = 0; i < N; i++) {
            b[i] = sc.nextInt();
            sumB += b[i];
        }

        long op = sumB - sumA;
        if (op < 0) {
            System.out.println("No");
            return;
        }

        long opA = 0;
        for (int i = 0 ; i < N; i++) {
            if (a[i] < b[i]) {
                int c = (b[i]-a[i]+1)/2;
                opA += c;
                a[i] += c*2;
            }
        }

        long opB = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] > b[i]) {
                opB += a[i]-b[i];
            }
        }

        System.out.println(opA <= op && opB <= op && (op-opA)*2 == op-opB
                           ? "Yes" : "No");
    }
}



Measured memory_bytes: 44484
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };

struct dice{
	int face[6];
	int top;
	int front;
	int right;
	int left;
	int back;
	int bottom;
	int n;
	void init(){
		top=face[0];
		front=face[1];
		right=face[2];
		left=face[3];
		back=face[4];
		bottom=face[5];
	}
	void spin(char x){
		if(x=='E'){
			n=top;
			top=left;
			left=bottom;
			bottom=right;
			right=n;
		}
		if(x=='W'){
			for(int i=0;i<3;i++){
				spin('E');
			}
		}
		if(x=='S'){
			n=top;
			top=back;
			back=bottom;
			bottom=front;
			front=n;
		}
		if(x=='N'){
			for(int i=0;i<3;i++){
				spin('S');
			}
		}
		if(x=='R'){
			n=front;
			front=left;
			left=back;
			back=right;
			right=n;
		}
	}
};

int main() {
	dice p[2];
	for(int i=0;i<2;i++){
		for(int j=0;j<6;j++){
			cin>>p[i].face[j];
		}
		p[i].init();
	}
	for(int j=0;j<4;j++){
		p[0].spin('R');
		if(p[0].front==p[1].front) break;
		if(j==3){
			for(int k=0;k<4;k++){
				p[0].spin('S');
				if(p[0].front==p[1].front) break;
			}
		}
	}
	for(int j=0;j<4;j++){
		p[0].spin('E');
		if(p[0].top==p[1].top){
			break;
		}
	}
	/*for(int i=0;i<2;i++){
		cout<<p[i].top<<endl;
		cout<<p[i].front<<endl;
		cout<<p[i].right<<endl;
		cout<<p[i].left<<endl;
		cout<<p[i].back<<endl;
		cout<<p[i].bottom<<endl;
	}*/
	if(p[0].right != p[1].right){
		cout<<"No"<<endl;
		return 0;
	}
	if(p[0].left != p[1].left){
		cout<<"No"<<endl;
		return 0;
	}
	if(p[0].back != p[1].back){
		cout<<"No"<<endl;
		return 0;
	}
	if(p[0].bottom != p[1].bottom){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3100
#include <stdio.h>

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

    return 0;
}

Measured memory_bytes: 2584
#include<iostream>

using namespace std;

int main()
{
  int K,N,i,d,l;
  
  cin>>K>>N;
  int A[N];
  
  for(i=0;i<N;i++) cin>>A[i];
  
  d=A[0]+K-A[N-1];
  for(i=0;i<N-1;i++)
  {
    l=A[i+1]-A[i];
    if(l>d) d=l;
  }
  cout<<K-d;
  
}
    


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int c[3][3], a[3], b[3];

int main() {
	inc(i, 3) {
	inc(j, 3) {
		cin >> c[i][j];
	}
	}
	
	a[0] = 0;
	a[1] = c[1][0] - c[0][0] + a[0];
	a[2] = c[2][0] - c[1][0] + a[1];
	
	b[0] = c[0][0];
	b[1] = c[0][1] - c[0][0] + b[0];
	b[2] = c[0][2] - c[0][1] + b[1];
	
	bool f = true;
	inc(i, 3) {
	inc(j, 3) {
		if(a[i] + b[j] != c[i][j]) { f = false; }
	}
	}
	
	cout << (f ? "Yes" : "No") << endl;
	
	return 0;
}


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

#include <iostream>
using namespace std;
int main() {
  int64_t n, a, b;
  cin >> n >> a >> b;
  int64_t sum = a + b;
  int64_t quotient = n / sum;
  int64_t remainder = n % sum;
  cout << quotient * a + min(remainder, a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; 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<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T,class U> ostream& operator<<(ostream &os, const tuple<S,T,U> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class S, class T,class U,class V> ostream& operator<<(ostream &os, const tuple<S,T,U,V> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<","<<get<3>(t)<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
#else
#define out
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	vector<int> vs(3);
	rep(i,3) cin>>vs[i];
	sort(all(vs));
	int t=vs[1]-vs[0];
	cout<<vs[2]-vs[1]+t/2+(t%2*2)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	char op;
	while(true){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?') break;
		switch(op){
		case '+':
			printf("%d\n",a+b);
			break;
		case '-':
			printf("%d\n",a-b);
			break;
		case '/':
			printf("%d\n",a/b);
			break;
		case '*':
			printf("%d\n",a*b);
			break;
		}
	}
}



Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  int n;cin>>n;
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s.substr(i,3)=="ABC")ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int n;
int64_t k;
vector<int64_t> A;
vector<int64_t> F;
vector<int64_t> M;

bool check(int64_t ma){
    int64_t remain = k;
    for (int i = 0; i < n; i++){
        if (M[i] <= ma)
            continue;
        remain -= A[i] - ma / F[i];
    }

    return remain >= 0;
}

int main(){
    cin >> n;
    cin >> k;
    A.resize(n);
    F.resize(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    copy_n(istream_iterator<int64_t>(cin), n, F.begin());

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<int64_t>());
    M.resize(n);
    
    for (int i = 0; i < n; i++)
        M[i] = A[i] * F[i];

    int64_t ng = -1, ok = 1e12 + 1;
    while (abs(ok - ng) > 1){
        int64_t mid = (ok + ng) / 2;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok << endl;
}

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



int main() {
    long long int N;

    cin >> N;

    int fl = 0;
    string ans = "No";
    rep(i, N){
        long long int D1, D2;
        cin >> D1 >> D2;
        if(D1 == D2){
            fl++;
        }else{
            fl = 0;
        }

        if(fl >= 3){
            ans = "Yes";
        }

    }    

    cout << ans;

    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N, K;
vector<long long> A;

#define DIV 1000000007

long long kaidan[10000000];

void kaical(long long n){
	kaidan[0] = 1;
	for(long long i = 1; i < n; i++){
		kaidan[i] = kaidan[i-1] * i;
		kaidan[i] %= DIV;
	}
}

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

//nCk
long long combination(long long n, long long k){
	if(n == 0 && k == 0)return 1;
	if(n < k || n < 0)return 0;
	long long n_kai = kaidan[n];
	long long k_kai = kaidan[k];
	long long nmk_kai = kaidan[n-k];

	long long ans = n_kai * modpow(k_kai, DIV - 2);
	ans %= DIV;
	ans *= modpow(nmk_kai, DIV-2);
	ans %= DIV;
	return ans;
}


int main(){
	cin >> N >> K;
	rep(i, N) {
		long long tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	sort(A.begin(), A.end());

	long long ans = 0;
	kaical(N+5);

	rep(i, N) {
		long long num = A[i];;

		ans += (num * combination(i, K - 1))%DIV;
		ans += DIV;
		ans %= DIV;
		ans -= (num * combination(N-1-i, K - 1))%DIV;
		ans += DIV;
		ans %= DIV;
	}
	cout << ans << endl;
}



Measured memory_bytes: 4696
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
 
int main(){
	int n;
	cin >> n;
	ll a[n];
	for (ll i = 0; i < n; i++) cin >> a[i];

	ll ans = 0;
	for (ll i = 0; i < n; i++){
		while(1){
			if (a[i] % 2 == 1) break;
			a[i] /= 2;
			ans++;
		}
	}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 2000010
//#define int long long
#define INF 1e9
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
inline int read()
{
	register char cc = getchar();register int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus; 
}
bool flag[N];
int wa[N], ac[N];
queue<int> q;
signed main()
{
	int n, m;
	int ac1(0), wa1(0);
	n = read();
	m = read();
	while(m -- )
	{
		string st;
		int num;
		num = read();
		cin >> st;
		if(st == "AC") 
		{
			if(!flag[num]) 
			{
				flag[num] = 1;
				q.push(num);
				ac1 ++;
			}
		}
		if(st == "WA")
		{
			if(!flag[num]) 
			{
				wa[num] += 1;
			}
		}
	}
	while(!q.empty())
	{
		int u = q.front();
		q.pop();
		wa1 += wa[u];
	}
	printf("%d %d\n",ac1,wa1);
	return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a , int b){
  if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
int inv(int a , int b){
  return binpow(a,b-2,b);
}
int32_t main() 
{ 
  fast;
  int h,k,w;
  cin >> h >> w >> k;
  char arr[7][7];
  for(int i = 0 ; i < h ; i++){
    for(int j = 0 ; j < w ; j++) cin >> arr[i][j]; 
  }
int ans = 0;
  for(int i = 0 ; i < (1<<h) ; i++){
    for(int j = 0; j < (1<<w) ; j++){
      char tmp[7][7];
      for(int row = 0 ;row < h ;row++){
        for(int col = 0 ; col < w ; col++) tmp[row][col] = arr[row][col];
      }
      for(int row= 0 ; row < h ; row++){
        if(((1<<row) & i ) > 0 ) {
          for(int ok = 0 ; ok < w ; ok++) tmp[row][ok] = 'r';
        }  
      }
      for(int row= 0 ; row < w ; row++){
        if(((1<<row) & j ) > 0 ) {
          for(int ok = 0 ; ok < h ; ok++) tmp[ok][row] = 'r';
        }  
      }
      int count = 0;
      for(int row= 0 ; row < h ; row++){
        for(int col = 0 ; col < w ; col++) {
          if(tmp[row][col] == '#') count++;
        }
      }
      if(count == k) ans++;
    }
  }
  cout << ans << "\n";
  return 0; 
}

///   11111111

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define Intmax 1000000007
int arr[101];
 int dp[100001];
 int k;
 void fun(int n)
 {   
     for(int i=1;i<arr[1];i++)
     {
         dp[i]=0;
     }
     for(int i=arr[1];i<=k;i++)
     {
         int j=1;
         bool yes=0;
         while(i-arr[j]>=0 && j<=n)
         {
             if(dp[i-arr[j]]==0)
             {
                 yes=1;
                 break;
             }
             j++;
         }
         dp[i]=(int)yes;
    }
    return;
 }
int main()
{
  int n;
  cin>>n;
  cin>>k;

  for(int i=1;i<=n;i++)
  {
      cin>>arr[i];
  }
  for(int i=0;i<n+1;i++)
      dp[i]=0;
      fun(n);
      if(dp[k]==1)
      cout<<"First"<<endl;
      else
      cout<<"Second"<<endl;
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 1024;
int N;
LL a[MC];
bool b[MC];

int main(){
	cin >> N;
	repp(i,0,N) cin >> a[i];
	LL ans0 = 0 , ans1 = 0;
	bool c = 0;
	for(int i = 0 ; i < N ; i += 2){
		if(a[i] > 0){
			ans0 += a[i];
			b[i] = 1;
			c = 1;
		}
	}
	for(int i = 1 ; i < N ; i += 2){
		if(a[i] > 0){
			ans1 += a[i];
			b[i] = 1;
			c = 1;
		}
	}
	if(c){
		if(ans0 > ans1){
			for(int i = 1 ; i < N ; i += 2) b[i] = 0;
		} else {
			for(int i = 0 ; i < N ; i += 2) b[i] = 0;
		}
		cout << max(ans0,ans1) << endl;
	} else {
		int d = 0;
		repp(i,1,N){
			if(a[d] < a[i]) d = i;
		}
		cout << a[d] << endl;
		b[d] = 1;
	}
	vector<int> V;
	int p = 0 , r = 0;
	while(!b[p]){
		V.PB(1);
		++p;
		++r;
	}
	while(p < N){
		int q = p+1;
		while(!b[q] && q < N) ++q;
		if(q == N) break;
		repm(i,(q-p)/2,0){
			V.PB(p+1-r+i);
		}
		r += q-p;
		p = q;
	}
	repm(i,N-r,1) V.PB(i);
	cout << V.size() << endl;
	for(auto u : V) cout << u << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int main(){
    int n;
    while(cin>>n){
        int ans = 0;
        int x = 0;
        if(n>3000)x = n-3000;

        for(int i=x;i<1001&&i<=n;i++){
            //cout<<i<<"-"<<endl;
            int y = 0;
            if(n-i>2000)y = n-i-2000;

            for(int j=y;j<1001&&i+j<=n;j++){
                //cout<<j<<"--"<<endl;
                //if(n-i-j>=2001)continue;
                int z = 0;
                if(n-i-j>1000)z = n-i-j-1000;

                int zz = 1001;
                if(1001>n-i-j+1) zz = n-i-j+1;

                ans += zz-z;

            }
        }


        cout<<ans<<endl;

    }
    return 0;
}

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

int main()
{
    string ans=":(";
    int n,i=0;
    cin >>n;
    while(i<=n){
        if(floor(i*1.08) ==n){
            ans = to_string(i);
            break;
        }
        i++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; ++i)
        if (i % d == 0) ++ans;
    cout << ans << '\n';
}

Measured memory_bytes: 3644
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N[] = new int[9999];
    int X[] = new int[9999];
    int i=0,S=0;

    do{
      N[i] = scanner.nextInt();
      X[i] = scanner.nextInt();
      i++;
    }while(!(N[i-1]==0&&X[i-1]==0));

    for(int j=0;j<i-1;j++){
      S = 0;
      for(int x=1;x<=N[j];x++){
        for(int y=1;y<=N[j];y++){
          for(int z=1;z<=N[j];z++){
            if(x+y+z==X[j]&&x!=y&&x!=z&&y!=z){
              S++;
            }
          }
        }
      }
      System.out.println(S/6);
    }


  }
}


Measured memory_bytes: 27032
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
int p[200100],q[200100],c[200100];
vector<P> g[200100];
vector<int> cs[200100];
int sz[200100];
vector<P> G[600100];
int dist[600100];
int id;
int new_node(){
	return id++;
}
void add_edge(int i,int ci,int j,int cj,int cost){
	int a,b;
	if(ci!=-1)a = sz[i]+ci;
	else a = i;
	if(cj!=-1)b = sz[j]+cj;
	else b = j;
	//printf("%d -> %d : %d\n",a,b,cost);
	G[a].pb(P(b,cost));
}
void dijkstra(int s){
	for(int i=0;i<id;i++)dist[i]=INF;
	priority_queue<P,vector<P>,greater<P> > q;
	dist[s]=0;
	q.push(P(0,s));
	while(!q.empty()){
		P a = q.top();
		q.pop();
		int v = a.sec;
		if(dist[v]<a.fi)continue;
		for(int i=0;i<G[v].size();i++){
			int u = G[v][i].fi;
			int c = G[v][i].sec;
			if(dist[u]>a.fi+c){
				dist[u]=a.fi+c;
				q.push(P(dist[u],u));
			}
		}
	}
	return;
}
int main(){
	scanf("%d %d",&N,&M);
	for(int i=0;i<M;i++){
		scanf("%d %d %d",&p[i],&q[i],&c[i]);
		p[i]--;q[i]--;c[i]--;
		g[p[i]].pb(P(q[i],c[i]));
		g[q[i]].pb(P(p[i],c[i]));
		cs[p[i]].pb(c[i]);
		cs[q[i]].pb(c[i]);
	}
	cs[0].pb(INF);
	for(int i=0;i<N;i++){
		sort(all(cs[i]));
		cs[i].erase(unique(all(cs[i])),cs[i].end());
		sz[i+1]=cs[i].size();
	}
	for(int i=1;i<=N;i++)sz[i]+=sz[i-1];
	id = sz[N];
	for(int i=0;i<N;i++){
		int tmp = new_node();
		for(int j=0;j<cs[i].size();j++){
			if(cs[i][j]==INF)continue;
			add_edge(i,j,tmp,-1,1);
		}
		for(int j=0;j<g[i].size();j++){
			int v = g[i][j].fi;
			int c = g[i][j].sec;
			int idx = lower_bound(all(cs[i]),c)-cs[i].begin();
			int vdx = lower_bound(all(cs[v]),c)-cs[v].begin();
			if(idx<cs[i].size())add_edge(i,idx,v,vdx,0);
			add_edge(tmp,-1,v,vdx,0);
		}
	}
	for(int i=0;i<g[0].size();i++){
		int v = g[0][i].fi;
		int c = g[0][i].sec;
		int vdx = lower_bound(all(cs[v]),c)-cs[v].begin();
		add_edge(0,sz[1]-1,v,vdx,1);
	}
	dijkstra(sz[1]-1);
	int ans = INF;
	for(int i=0;i<cs[N-1].size();i++){
		ans = min(ans,dist[sz[N-1]+i]);
	}
	if(ans==INF)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 58324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int d = 1;
bool D[10001];
int H[10001], topo[10001];
pair<int, int> E[20002];
void dfs(int A) {
	if (!D[A]) {
		D[A] = true;
		topo[A] = d;
		d++;
		for (int i = H[A]; i; i = E[i].second) {
			dfs(E[i].first);
		}
	}
}

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	for (int i = 2; i < 2 * N; i += 2) {
		int a = getint(), b = getint();
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}

	int C[10000];
	int goukei = 0;
	int saidai = 0;
	rep(i, N) {
		C[i] = getint();
		goukei += C[i];
		saidai = max(saidai, C[i]);
	}
	sort(C, C + N);

	dfs(1);

	const int dm = 1 << 17;
	char dn[dm], *di = dn;
	int X = goukei - saidai;
	int keta = 0;
	char c[10];
	while (X) {
		*(c + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(c + i));
	*di++ = '\n';
	rep1(i, N) {
		X = C[N - topo[i]];
		keta = 0;
		while (X) {
			*(c + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--) *di++ = (*(c + i));
		*di++ = ' ';
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 896
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            l = max(0, j - 1)
            r = min(j + 2, w)
            if i == 0:
                if h == 1:
                    s[i][j] = s[i][l:r].count('#')
                else:
                    s[i][j] = s[i][l:r].count('#') + s[i + 1][l:r].count('#')
            elif i == h - 1:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#')
            else:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#') + s[i + 1][l:r].count('#')
    print(*s[i], sep='')


Measured memory_bytes: 3444
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 673;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

long long modpow(long long a, long long n, long long MOD) {//a^n(MOD)を求める
    long long res = 1%MOD;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;//次の準備
        n >>= 1;
    }
    return res;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s;cin>>s;
  ll n=siz(s);
  V<int> v(siz(s));
  rep(i,0,siz(s)){
    v[i]=s[i]-'0';
  }

  V<ll> sum(siz(s)+1,0),pro(n+1,0);
  rep(i,0,n)sum[i+1]+=(sum[i]+v[i])%3;
  rep(i,0,n)pro[i+1]=(pro[i]+v[i]*modpow(10,n-1-i,mod))%mod;

  VV<int> num(673,V<int>(3,0));
  rep(i,0,n+1){
    num[pro[i]][sum[i]]++;
  }

  ll ans=0;
  rep(i,0,673)rep(j,0,3){
    ans+=num[i][j]*(num[i][j]-1)/2;
  }
  cout<<ans<<ENDL;

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?


Measured memory_bytes: 7520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n,sum=0;
        for(int i=0;i<n;i++)cin>>num[i];
        for(int i=0;;i++){
            bool kawa=1;
            if(i==10000){
                cout<<-1<<endl;
                break;
            }
            for(int j=0;j<co&&kawa;j++)if(num[j]!=j+1)kawa=0;
            if(kawa){
                cout<<i<<endl;
                break;
            }
            for(int j=0;j<co;j++)num[j]-=1;
            num[co]=co;
            for(int j=0;j<=co;j++){
                if(num[j]==0){
                    for(int k=j+1;k<=co;k++){
                        if(num[k]!=0){
                            swap(num[j],num[k]);
                            break;
                        }
                    }
                }
            }
            for(int j=0;j<=co+1;j++){
                if(num[j]==0||j==co+1){
                    co=j;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long l, r, i, j, k, best;
	cin >> l >> r;
	if (r - l > 2020) r = l + 2020;
	best = 1LL << 60;
	for (i = l; i < r; i++) {
		for (j = i + 1; j <= r; j++) {
			best = min(best, (i * j) % 2019);
		}
	}
	cout << best << "\n";

	return 0;
}


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

int main() {
    ll x;
    cin >> x;
    ll n = 0;
    while(n * (n + 1) / 2 <= x) n++;
    if(n * (n - 1) / 2 == x) n--;
    cout << n << endl;
}

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left = 2 * i + 1, right = 2 * i + 2;
    let largest = i;
    if (left < n && arr[left] > arr[largest]) largest = left;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 140156
#include<iostream>

using namespace std;

int main() {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if( x-r>=0 && x+r<=W && y-r>=0 && y+r<=H ){
    cout << "Yes" << endl;
  } else { 
    cout << "No" << endl;
  }

  return 0;
}



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

int main() {
	long long int n;
	cin>>n;
	long long int ans = 0;
	int i= 0;
	while(n!=0){
	    ans += pow(2,i++);
	    n = n/2;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
bool flag[10000001];

int main(){
    int n=0,ans=0,ana=0;
	for(int i=0;i <= 1000000;i++){
		if(i<=1)flag[i]=false;
		else flag[i]=true;
	}
	for(int i=2;i <= 1001 ;i++){
		if(flag[i]==true){
			for(int j=i*2 ; j<=1000000 ; j=j+i){
				flag[j] = false;
			}
		}
	}
    while(cin>>n){
		ans=0,ana=0;
		for(int i=n+1;;i++){
			if(flag[i]==true){
				ans=i;
				break;
			}
		}
		for(int i=n-1;;i--){
			if(flag[i]==true){
				ana=i;
				break;
			}
		}
		cout<<ana<<" "<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2136
<?php
$stdin = file_get_contents('php://stdin');
list($num, $feet) = explode(" ", trim($stdin));
$f = $num * 4 - $feet;
if ($f % 2 === 0 && $f / 2 >= 0 && $f / 2 <= $num) {
  echo "Yes";
} else {
  echo "No";
}

Measured memory_bytes: 16188
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define mid (l+r>>1)
#define M 202
#define mod 998244353
using namespace std;
LL read(){
	LL nm=0,fh=1;char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
bool vis[M];
LL n,m,C[M][M],X[M],Y[M],T[M],ans;
bool ol(LL t1,LL t2,LL t3){return (Y[t1]-Y[t2])*(X[t1]-X[t3])==(Y[t1]-Y[t3])*(X[t1]-X[t2]);}
int main(){
	memset(vis,false,sizeof(vis));
	n=read(),T[0]=1;
	for(LL i=1;i<=n;i++) T[i]=(T[i-1]<<1)%mod,X[i]=read(),Y[i]=read();
	ans=T[n],ans+=mod-n-1,ans%=mod;
	for(LL i=1;i<=n;i++){
		memset(vis,false,sizeof(vis));
		for(LL j=i+1;j<=n;j++){
			if(vis[j]) continue;
			vis[j]=true;
			LL sum=2;
			bool fg=true;
			for(LL k=1;k<i;k++) if(ol(i,j,k)) fg=false;
			if(!fg) continue;
			for(LL k=j+1;k<=n;k++) if(ol(i,j,k)) sum++,vis[k]=true;
			ans-=T[sum]-sum-1,ans+=mod,ans%=mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = a + b + c + (9 * max(c,max(a, b)));
	cout << ans;
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
int dyy[]={1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1};
int dxx[]={0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1};

int N,M;
struct UF{
    vector<int>par,sz;
    void init(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int a[100010],b[100010];

signed main() {
    IOS();
    cin>>N>>M;
    rep(i,0,M){
        cin>>a[i]>>b[i];
    }
    UF uf;
    uf.init(N+1);
    vint ans(M+1);
    int tmp=N*(N-1)/2;
    ans[M]=tmp;
    rrep(i,1,M){
        if(!uf.same(a[i],b[i])){
            tmp-=uf.size(a[i])*uf.size(b[i]);
            uf.unite(a[i],b[i]);
        }
        ans[i]=tmp;
    }
    rep(i,1,M+1){
        cout<<ans[i]<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W ;
  string str="#";
  vector< string > vec(W*H);

    for (int i = 0; i < (W+2);i++){
       cout << str ;
         }
    cout << endl;
  
    for (int ii = 0;ii < H; ii++){
  		cout << str;
  		for (int i = 0; i < 1; i++) {
    		cin >> vec.at(i);
            cout << vec.at(i);
    		}
        cout << str << endl;
           }
  
   for (int i = 0; i < (W+2);i++){
    cout << str;
          }
    cout << endl;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x<r)||(x>H-r))printf("No\n");
	else if((y<r)||(H-r<y))printf("No\n");
	else printf("Yes\n");

	return 0;
}


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


int main(){
  int n;
  cin >> n;
  vector<int>vec(n);
  for (int i = 0; i< n ; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int s=0;
  for (int j = 1; j< n; j++){
    s+= vec.at(j);
  }
  if(s > vec.at(0)){
    cout << "Yes"<< endl;
  }
  else
    cout << "No" <<endl;
}
    

           
        

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn min(a: i32, b: i32) -> i32 {
    return if a > b { b } else { a };
}

fn main() {
    let (A, B, C): (i32, i32, i32) = (read(), read(), read());
    println!("{}", min(B / A, C))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	bool ans = true;
	int n;
	cin >> n;
	string s;
	cin >> s;
	vs ss;
	ss.push_back(s);
	char c = s.back();
	rep(i, n-1) {
		cin >> s;
		rep(j,ss.size()) {
			if (ss[j] == s)ans = false;
		}
		ss.push_back(s);
		if (s[0] != c)ans = false;
		c = s.back();
	}
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256