akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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 nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 2010;
const int INF = 1001001001;
int N, K, Q;
int A[MAX_N];

int solve(int X) {
  vector<int> v;
  int last = -1;
  REP(i, N+1) {
    if (A[i] < X) {
      vector<int> t;
      for (int j = last + 1; j < i; j++) {
        t.push_back(A[j]);
      }
      sort(ALL(t));
      REP(i, (int)t.size() - K + 1) {
        v.push_back(t[i]);
      }
      last = i;
    }
  }
  // cout << "--" << endl;
  // cout << X << endl;
  // pv(A, A+N);
  // pv(w, w+N);
  // pv(ALL(v));
  if ((int)v.size() < Q) return INF;
  sort(ALL(v));
  int res = v[Q-1] - v[0];
  // cout << res << endl;
  return res;
}

int main2() {
  N = nextInt();
  K = nextInt();
  Q = nextInt();
  REP(i, N) A[i] = nextInt();

  if (Q == 1) {
    cout << 0 << endl;
    return 0;
  }

  int ans = INF;
  REP(i, N)
    chmin(ans, solve(A[i]));
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,x,y;
int main()
{
	cin>>a>>b>>c>>d;
	x=c/b+(c%b!=0);
	y=a/d+(a%d!=0);
	if(x<=y)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n + 1);
	rep (i, n) cin >> a[i + 1];
	vector<int> res(n + 1);
	int cnt = 0;
	for (int i = n; i > 0; --i) {
	  int sum = 0;
	  for (int j = i + i; j < n + 1; j += i) sum += res[j];
	  
	  if (sum % 2 == a[i]) {
		res[i] = 0;
	  } else {
		res[i] = 1;
		cnt++;
	  }
	}
	cout << cnt << endl;
	rep (i, n) if (res[i + 1]) cout << i + 1 << endl;
    
    return 0;
}



Measured memory_bytes: 4744
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int i,j,num,*arr,count,temp;
	scanf("%d",&num);
	arr = (int*)malloc(num*sizeof(int));
	for(i=0;i<num;i++) scanf("%d",&arr[i]);
	for(i=0;i<num;i++){
		for(j=i;j>0;j--){
			if(arr[j] < arr[j-1]){
				temp = arr[j];
				arr[j] = arr[j-1];
				arr[j-1] = temp;
				count++;
				}
			}
		}		
	for(i=0;i<num;i++){
		i != num-1 ? printf("%d ",arr[i]):printf("%d\n",arr[i]);
		}		
	printf("%d\n",count);
	free(arr);
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;

namespace _0049
{
    class Program
    {
        static void Main(string[] args)
        {
            var bloodGroup = new Dictionary<string, int>() 
            {
            { "A", 0 }, 
            { "B", 0 }, 
            { "AB", 0 }, 
            { "O", 0 } 
            };

            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    break;
                }
                var inputs = input.Split(',');
                bloodGroup[inputs[1]]++;
            }
            foreach(var bloodType in bloodGroup)
            {
                Console.WriteLine(bloodType.Value);
            }
        }
    }
}

Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    vector<pair<int,int>> A;
    A.push_back({0,0});
    rep(i,N){
        if(S[i] == 'W') A.push_back({A[i].first+1,A[i].second});
        else A.push_back({A[i].first,A[i].second+1});
    }
    A.push_back({A.back().first, A.back().second});
    
    int ans = 10000000;
    for (int i = 1; i <= N; i++) ans = min(ans,A[i-1].first+A.back().second-A[i].second);
    cout << ans << endl;
    
    
    return 0;
}



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

int main()
{
    int a,b,k,t=0;
    cin>>a>>b>>k;
    while(k)
    {
        if(t%2==0)
        {
            if(a%2==0)
            {
                b+=a/2;
                a=a/2;
            }
            else
            {
                a=a-1;
                b+=a/2;
                a=a/2;
            }
        }
        else
        {
            if(b%2==0)
            {
                a+=b/2;
                b=b/2;
            }
            else
            {
                b=b-1;
                a+=b/2;
                b=b/2;
            }
        }
        t++;
        k--;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}

/* main */

signed main(){
    ll N[4];
    FOR(i,0,4)cin >> N[i];
    ll c[10] = {0};
    FOR(i,0,4)c[N[i]]++;
    YES(c[1]&&c[9]&&c[7]&&c[4]);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,MOD;
ll fac[SZ],rfac[SZ];
ll qp(ll a,ll b)
{
	ll x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
ll rw[4];
ll C(int a,int b)
{
	return fac[a]*rfac[a-b]%MOD*rfac[b]%MOD;
}
ll f[6005][2005*6];
int main()
{
	cin>>n>>MOD;
	fac[0]=1;
	for(int i=1;i<SZ;++i)
		fac[i]=fac[i-1]*i%MOD;
	rfac[SZ-1]=qp(fac[SZ-1],MOD-2);
	for(int i=SZ-1;i;--i)
		rfac[i-1]=rfac[i]*i%MOD;
	int N=n*3;
	f[0][N]=1;
	for(int i=0;i<N;++i)
		for(int j=0;j<=N*2;++j) if(f[i][j])
			for(int s=1;s<=3&&i+s<=N;++s)
				(f[i+s][j+(s==1)-(s==2)]+=f[i][j]*fac[i+s-1]%MOD*rfac[i])%=MOD;
	ll aa=0;
	for(int j=N;j<=N*2;++j)
		(aa+=f[N][j])%=MOD;
	aa=(aa%MOD+MOD)%MOD;
	cout<<aa<<"\n";
}


Measured memory_bytes: 573056
def getval():
    n,k = map(int,input().split())
    return n,k 

def main(n,k):
    f = [1]
    for i in range(n):
        f.append(f[i]*(i+1))
    maxpair = f[n-1]//(f[2]*f[n-3])
    if k>maxpair:
        print(-1)
    else:
        pair = maxpair
        ans = []
        for i in range(n-1):
            ans.append([1,i+2])
        for i in range(2,n+1):
            for j in range(i,n+1):
                if pair==k:
                    break
                if i==j:
                    continue
                ans.append([i,j])
                pair -= 1
        print(len(ans))
        for i in ans:
            print(str(i[0]) + " " + str(i[1]))

if __name__=="__main__":
    n,k = getval()
    main(n,k)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> x(6);
    for (int i = 1; i <= 5; i++) {
        cin >> x[i]; 
    }
    for (int i = 1; i <= 5; i++) {
        if (!x[i]) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N;string S,T;cin>>N>>S>>T;
  REP(i,0,N)S.insert(2*i+1,1,T.at(i));
  print(S)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,b,v,w,t;
  cin>>a>>v>>b>>w>>t;
  ll sa=v-w;
  ll nsa=abs(a-b);
  ll sum=sa*t;
  if(nsa-sum<=0){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <unordered_map>
// #include <unordered_set>
using namespace std;
class Pos {
  public:
    int y;
    int x;
    size_t hashed;
    Pos(int _y, int _x):
      y(_y),
      x(_x) {
      hashed = 0;
    }
    bool operator==(Pos right) const {
      return (y == right.y && x == right.x);
    }
    // bool operator<(Pos right) const {
    // }
};
 
namespace std {
  template <>
  struct hash<Pos> {
    size_t operator()(Pos const &pos) const {
      return pos.hashed;
    }
  };
}
 
int main() {
  int H, W;
  while(cin >> W >> H, W || H) {
    unordered_map<Pos, unordered_set<Pos> > loads;
    for(int h = 0; h < H; ++h) {
      for(int w = 0; w < W - 1; ++w) {
        bool isHrizWall;
        cin >> isHrizWall;
        if(!isHrizWall) {
          Pos a = Pos(h, w);
          Pos b = Pos(h, w + 1);
          loads[a].insert(b); 
          loads[b].insert(a);
        }
      }
      if(h < H - 1) for(int w = 0; w < W; ++w) {
        bool isVertWall;
        cin >> isVertWall;
        if(!isVertWall) {
          Pos a = Pos(h, w);
          Pos b = Pos(h + 1, w);
          loads[a].insert(b);
          loads[b].insert(a);
        }
      }
    }
    Pos goal = Pos(H - 1, W - 1);
    unordered_map<Pos, int> marked;
    queue<Pos> bfq;
    bfq.push(Pos(0, 0));
    marked[Pos(0, 0)] = 1;
    bool answered = false;
    while(!bfq.empty()) {
      Pos crtPos = bfq.front();
      bfq.pop();
      if(crtPos == goal) {
        answered = true;
        cout << marked[crtPos] << endl;
        break;
      }
      for(auto i = loads[crtPos].begin(); i != loads[crtPos].end(); ++i) {
        // cout << (*i).y << ',' << (*i).x << endl;
        if(marked.count(*i) == 0) {
          marked[*i] = marked[crtPos] + 1;
          bfq.push(*i);
        }
      }
    }
    if(!answered) cout << 0 << endl;
  // for(auto i = marked.begin(); i != marked.end(); ++i) {
  //   cout << (*i).first.y << ',' << (*i).first.x << ':' << (*i).second << endl;
  // }
  //
  // for(auto i = loads.begin(); i != loads.end(); ++i) {
  //   for(auto j = i->second.begin(); j != i->second.end(); ++j) {
  //     cout << i->first.y << ',' << i->first.x << ':' << j->y << ',' << j->x << ' ';
  //   }
  //   cout << endl;
  // }
  }
  return 0;
}

Measured memory_bytes: 1560
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	char a[10], b[10], c[10];
	
	scanf("%s %s %s", &a, &b, &c);
	
	a[0] -= 32;
	b[0] -= 32;
	c[0] -= 32;
	
	printf("%c%c%c", a[0], b[0], c[0]);
}

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

const int N = 1e9+7;

int main()
{
    int n,m;
    cin>>n>>m;
    if(abs(n-m)>=2)
    {
        cout<<0<<endl;
        return 0;
    }
    long long mn=1,mp=1;
    for(int i=1;i<=n;i++)
    {
        mn*=i;
        mn=mn%N;
    }
    for(int i=1;i<=m;i++)
    {
        mp*=i;
        mp=mp%N;
    }
   long long sum=mp*mn;
   sum=sum%N;
   if(n==m)sum=2*sum;
   sum=sum%N;
   cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define clrbit(s, b) (s &= ~(1<<b))


int main() {

	int n, r = 0;
	scanf("%d", &n);
	// while(n > 0) {
	// 	r = (r*10) + (n%10);
	// 	n /= 10;
	// } 

	int dig = n%10;
	if(dig == 0 || dig == 1|| dig == 6|| dig == 8) {
		printf("pon\n");
	}  else if(dig == 2 || dig == 4|| dig == 5|| dig == 7|| dig == 9) {
		printf("hon\n");
	} else {
		printf("bon\n");
	}

	return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>

int main(){
   int n;scanf("%d",&n);
   int l[1000],r[1000];for(int i = 0;i < n;i++)scanf("%d%d",&l[i],&r[i]);
   int ans=0;
   for(int i = 0;i < n;i++)ans+=r[i]-l[i]+1;
   printf("%d",ans);
}

Measured memory_bytes: 128
from bisect import bisect_left as bl
n,d,a=map(int,input().split())
s=sorted([list(map(int,input().split()))for i in range(n)])
c=0
p=[0]
q=[0]
for i in range(n):
    g=bl(q,s[i][0])
    s[i][1]-=a*(p[-1]-p[g-1])
    if s[i][1]>0:
        t=((s[i][1]-1)//a+1)
        c+=t
        p.append(p[-1]+t)
        q.append(s[i][0]+2*d)
print(c)

Measured memory_bytes: 105176
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

static const char *s = "01235789";

main {
  int n;
  while (cin >> n, n) {
    string t;
    for (; n; n /= 8) t = string(1, s[n % 8]) + t;
    cout << t << endl;
  }
}

Measured memory_bytes: 3112
#include <stdio.h>

main(){
    int w, n, a, b, i, data[31];
    scanf("%d %d", &w, &n);
    for(i = 1; i <= w; ++i){
        data[i] = i;
    }
    for(i = 1; i <= n; ++i){
        scanf("%d,%d", &a, &b);
        data[a] = data[a] ^ data[b];
        data[b] = data[a] ^ data[b];
        data[a] = data[a] ^ data[b];
    }
    for(i = 1; i <= w; ++i){
        printf("%d\n", data[i]);
    }
    return 0;
}

Measured memory_bytes: 0
import sys
from collections import deque
si = sys.stdin.readline


def main():
    ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
    n = int(si())
    while n > 0:
        n -= 1
        s = si()[:-1]
        ans[s] += 1

    print('AC x '+str(ans['AC']))
    print('WA x '+str(ans['WA']))
    print('TLE x '+str(ans['TLE']))
    print('RE x '+str(ans['RE']))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9480
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans=0,tans=0;
    rep(i,n) {
        if (s[i]=='I') ++tans;
        else --tans;
        ans=max(ans,tans);
    }
    cout << ans << endl;
     
    return 0;   
}

Measured memory_bytes: 3624
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    // 値に対して個数を持つ。ペアとして使用する際に個数を数える。
    vector<int> v(n);

    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(ALL(v));

    // 大きい値から順に処理する
    while (!v.empty()) {
        // 昇順ソートした末尾（一番大きい値）を取得
        int x = *(v.rbegin());
        // 末尾を除去
        v.pop_back();
        // xより大きい２のべき乗を作成
        ll p = 1;
        while (p <= x)
            p *= 2;
        int y = p - x; // ペアとなるyは1通り
        auto it = lower_bound(v.begin(), v.end(), y);
        if (it != v.end() && *(it) == y) {
            v.erase(it);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    string S;
    cin >> S;

    if((int)S.size() >= 3 && S[0] == 'A' && count(S.begin() + 2, S.end() - 1, 'C') == 1 && count_if(allof(S), [](char c){return c == toupper(c);}) == 2){
        cout << "AC";
    } else {
        cout << "WA";
    }
}


Measured memory_bytes: 256
# 解説AC
M,K = map(int, input().split())

if M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    if (1 << M) <= K:
        print(-1)
    else:
        ans = [n for n in range(1 << M) if n != K]
        ans.append(K)
        ans += [n for n in range((1 << M) - 1, -1, -1) if n != K]
        ans.append(K)
        print(*ans)

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

using namespace std;
using ll = long long;

int main(){
    char a, b, c; cin >> a >> b >> c;
        if(a == '7' || b == '7' || c == '7'){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1000
using vi = vector<int>;

int main()
{
  int X, N; cin >> X >> N;
  set<int> Set;
  REP( i, N ) {
    int a; cin >> a;
    Set.insert( a );
  }
  int ans = INF;
  for( int x = -1; x <= 101; x++ ) {
    if( !Set.count(x) ) {
      if( abs( X-x ) < abs( X-ans ) )
        ans = x;
      else
        break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
def str2int(s):
  res = ''
  dict = {}
  index = 0
  for c in s:
    if not c in dict.keys():
      dict[c] = index
      index += 1
    res = res + str(dict[c])
  return res
    
s = input()
t = input()
print('Yes' if str2int(s) == str2int(t) else 'No')
  

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

const int MAXN = 310;
const int mod = 998244353;

int n, m;
std::bitset<MAXN> bs[MAXN];
int pow2[MAXN];

int main() {
    pow2[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        pow2[i] = 2 * pow2[i - 1] % mod;
    }
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        for (int j = 0, x; j < m; ++j) {
            scanf("%d", &x);
            if (x) {
                bs[i].set(j);
            }
        }
    }
    int k = 0;
    for (int i = 0; i < m; ++i) {
        int j = k;
        for (; j < n && !bs[j][i]; ++j);
        if (j == n) {
            continue;
        }
        std::swap(bs[j], bs[k]);
        for (j = k + 1; j < n; ++j) {
            if (bs[j][i]) {
                bs[j] ^= bs[k];
            }
        }
        ++k;
    }
    int ans = ((pow2[n] - pow2[n - k]) % mod + mod) % mod;
    ans = 1ll * ans * pow2[m - 1] % mod;
    printf("%d\n", ans);
    return 0;
}


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

int main() {
    string str;
    while(getline(cin, str), str != ".") {
        bool is_ok = [str]() {
            stack<char> before_par_type;
            for(int i=0; i<str.size(); ++i) {
                char c = str[i];
                if(c == '[' || c == '(') {
                    before_par_type.push(c);
                } else if(c == ']') {
                    if(before_par_type.size() == 0) return false;
                    if(before_par_type.top() == '[') {
                        before_par_type.pop();
                    } else {
                        return false;
                    }
                } else if(c == ')') {
                    if(before_par_type.size() == 0) return false;
                    if(before_par_type.top() == '(') {
                        before_par_type.pop();
                    } else {
                        return false;
                    }
                }
            }
            return before_par_type.size() == 0;
        }();
        
        cout << (is_ok ? "yes" : "no") << endl;
    }
}


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

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

    ll i,j,tot=0;
    for(i=1;i<n;i++)
    {
        for(j=1;j*i<n;j++)
            tot++;
    }
    cout<<tot;
    return 0;
}


Measured memory_bytes: 3588
n, k = map(int, input().split())
l = list(map(int, input().split()))

ptns = []
for i in range(n-k+1):
    ptns.append(abs(0 -l[i]) + abs(l[i] - l[i+k-1]))
    ptns.append(abs(0 -l[i+k-1]) + abs(l[i+k-1] - l[i]))

print(min(ptns))

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    vector<ll> sum(n+1);
    ll res = 1e18;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    // どこで切りましょうかね〜
    for (int i = 1; i < n-2; i++) {
        ll lmin,lmax;
        ll lsum = sum[i+1];
        ll rsum = sum[n]-sum[i+1];
        // inまで含む 実際のindex 0からi
        auto in = distance(sum.begin(), lower_bound(sum.begin()+1,sum.begin()+i,lsum/2));
        // inかin--
        // まずin
        lmin = min(lsum-sum[in],sum[in]);
        lmax = max(lsum-sum[in],sum[in]);
        ll ldif = lmax -lmin;
        in--;
        if(in!=0 && ldif > max(lsum-sum[in],sum[in])-min(lsum-sum[in],sum[in]) ){
            lmin = min(lsum-sum[in],sum[in]);
            lmax = max(lsum-sum[in],sum[in]);
        }
        ll rmin,rmax;
        // inまで含む,iより大きい。
        in = distance(sum.begin(), lower_bound(sum.begin()+i+2,sum.begin()+n-1,lsum+rsum/2));
        rmin = min(sum[n]-sum[in],sum[in]-lsum);
        rmax = max(sum[n]-sum[in],sum[in]-lsum);
        ll rdif = rmax-rmin;
        in--;
        if(in!=i+1 && rdif > max(sum[n]-sum[in],sum[in]-lsum)-min(sum[n]-sum[in],sum[in]-lsum)){
            rmin = min(sum[n]-sum[in],sum[in]-lsum);
            rmax = max(sum[n]-sum[in],sum[in]-lsum);
        }
        res = min(res,max(rmax,lmax)-min(rmin,lmin));
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
const ll llMIN=-9223372036854775808LL;
ll n,k,x,y;
 
int main(){
  
  ll ans=llMIN;
  cin >> n >> k;
  
  vi p(n),c(n);
  REP(i,n){
    cin>>p[i];
    p[i]--;
    }
  REP(i,n) cin>>c[i];
 
  vvi data(n, vi(n));  // N * M の2次元配列
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      data[i][j]=llMIN;
    }
  }
 
  ll nowmasu=-1;
  ll score=0;
  for(ll i=0;i<n;i++){//最初に選ぶマス
    nowmasu=i;
    score=0;
    //data[i][i]=0;//score
    ll cnt=0;
    for(ll j=0;j<min(k,n);j++){
      if (data[i][p[nowmasu]]!=llMIN)break;
      nowmasu=p[nowmasu];
      score+=c[nowmasu];
      cnt++;
      data[i][nowmasu]=score;
      ans=max(ans,score);
    }
    //今のnowmasuは必ず最初の地点
    if (k!=cnt){
      ll nnum=(k-cnt)/cnt;
      score*=nnum;
      if (nnum!=0)ans=max(ans,score);
      ll kk=k-nnum*cnt;
      
      for(ll j=0;j<kk;j++){
        nowmasu=p[nowmasu];
        score+=c[nowmasu];
        ans=max(ans,score);
      }
    }
 
    
 
  }
 
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 198872
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> to[200005];
    vector<int> ans(n, -1), visited(n,0);

    rep(i,0,m-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    int par = -1;
    while(!q.empty()){
        int now = q.front();q.pop();
        for(auto child : to[now]){
            if(ans[child] == -1){
                ans[child] = now+1;
                q.push(child);
            }
        }

    }
    rep(i,1,n-1){
        if(ans[i] == -1){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    rep(i,1,n-1){
        cout << ans[i] << endl;
    }
    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 13080
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++) {
    cin >> a[i];
  }

  vector<int> ball(N);

  int totalBall = 0;
  int h = N / 2;
  for(int i=h;i<N;i++) {
    ball[i] = a[i];
    if(ball[i] == 1) totalBall++;
  }

  for(int i=h-1;i>=0;i--) {
    int num = i+1;
    int total = 0;
    for(int j=i;j<N;j=j+num) {
      total += ball[j];
    }
    int mod2 = total % 2;
    if((mod2 + a[i]) % 2 == 0) {
      ball[i] = 0;
    } else {
      ball[i] = 1;
    }

    totalBall += ball[i];
  }

  cout << totalBall << endl;

  for(int i=0;i<N;i++) {
    if(ball[i] == 1) {
      cout << i+1 << endl;
    }
  }

  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String line = input.readLine();
		String[] str = line.split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);

		double rad = 0 ,s = 0 , l = 0 , h = 0 ;

		rad = c * Math.PI / 180 ;

		s = a * b * Math.sin(rad) / 2 ;
		l = a + b + Math.sqrt(a*a + b*b - 2*a*b*Math.cos(rad));
		h = 2 * s / a ;

		System.out.println(s + "\n" + l + "\n" + h);

	}

}

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

vector<vector<ll>>adj,tree;
vector<ll>cnt;
vector<pair<ll,ll>>query;

void make_tree(ll prev,ll now){
  for(auto next:adj[now]){
    if(prev==next)continue;
    tree[now].push_back(next);
    make_tree(now,next);
  }
}
void dfs(ll now,ll cost){
  cnt[now]+=cost;
  for(auto next:tree[now]){
    dfs(next,cnt[now]);
  }
}

main(){
  ll N,Q;cin>>N>>Q;
  adj.resize(N);
  tree.resize(N);
  cnt.resize(N);
  for(ll i=0;i<N-1;++i){
    ll a,b;cin>>a>>b;
    a--;b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for(ll i=0;i<Q;++i){
    ll p,x;cin>>p>>x;
    p--;
    query.emplace_back(p,x);
  }
  for(auto q:query){
    cnt[q.first]+=q.second;
  }
  for(auto next:adj[0]){
    tree[0].push_back(next);
    make_tree(0,next);
  }
  dfs(0,0);
  for(auto ans:cnt)cout<<ans<<" ";
  cout<<endl;
}

Measured memory_bytes: 41968
#include <iostream>

int main() {
  long a, b;

  std::cin >> a;
  std::cin >> b;

  long const pos_b = b - a;
  long height_b = 0;

  for (long i=0; i<pos_b; i++) {
    height_b+=i+1;
  }

  std::cout << height_b - b << std::endl;

  return 0;
}


Measured memory_bytes: 256
//Moh_K_Imar .......
//28/08/2020  ... 11,10.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a;
    cin>>a;
    cout<<3*(a*a)<<endl;

    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  int n;
  cin >> n;
  vector<P> x(n);
  rep(i,n){ cin>>x[i].F; x[i].S=i; }
  sort(x.begin(),x.end());
  set<int> st;
  rep(i,n/2){ st.insert(x[i].S); }
  rep(i,n){
    if(st.find(i)!=st.end()){ cout<<x[n/2].F<<endl; }else{ cout<<x[n/2-1].F<<endl; }
  }
  return 0;
}

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


int main()
{
    int n;
    cin>>n;
    long long int ans =0;
    for(int i=1;i<=n;i++)
    {
        long long int terms = n/i;
        long long int sum = terms*(i + terms*i)/2;
        ans = ans + sum ;
    }
    cout<<ans;
}


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

int main(void){

    int x, y, z;
    int temp;
    cin >> x >> y >> z;

    temp = y;
    y = x;
    x = temp;

    temp = z;
    z = x;
    x = temp;

    cout << x << ' ' << y << ' ' << z << endl;

    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

static const llint MAX = 1e5 + 5;
// static const int NIL = -1;
// static const llint INF = 1<<21;
static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

llint fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void init_combination() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
llint combination(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    llint n, k;
    cin >> n >> k;
    init_combination();

    vector<llint> a(n);
    for(int in=0;in<n;++in) {
        cin >> a[in];
    }
    sort(a.begin(), a.end());

    llint ans = 0, anstmp;
    for(int in=0;in<n;++in) {
        anstmp = combination(n-1-in, k-1);
        anstmp *= a[n-in-1];
        anstmp %= MOD;
        ans += anstmp;
        ans %= MOD;
    }

    for(int in=0;in<n;++in) {
        anstmp = combination(n-1-in, k-1);
        anstmp *= a[in];
        if(anstmp<0) anstmp += MOD;
        anstmp %= MOD;
        ans -= anstmp;
        ans %= MOD;
        if(ans<0) ans += MOD;
    }

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


Measured memory_bytes: 6244
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    string S;
    cin >> S;
    cout << S.substr(0, 3) << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int ans = 1;
		boolean flg = true;
		boolean h = false;

		for (int i = 0; i < n; i++) {
			if (i == n - 1)
				continue;

			if (flg) {
				if (a[i] < a[i + 1])
					h = true;
				else if (a[i] > a[i + 1])
					h = false;
				else {
					continue;
				}
				flg = false;
				continue;
			}

			if (h) {
				if (a[i] > a[i + 1]) {
					ans++;
					flg = true;
				}
			} else {
				if (a[i] < a[i + 1]) {
					ans++;
					flg = true;
				}
			}

		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 48132
n = int(input())
word_dict = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for _ in range(n):
  word = str(input())
  if word in word_dict:
    word_dict[word] += 1
  else:
    word_dict[word] = 1
for k, v in word_dict.items():
  print(k, 'x', v)

Measured memory_bytes: 9100
#include<iostream>
using namespace std;
int main()
{


  int a,b;
 
  cin >>a>>b;
  
  if( a > b ){
  
    cout<<"a > b"<<endl;

  }else if(a<b){

    cout<<"a < b"<<endl;

  }else{
  
      cout<<"a == b"<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
int n;
int a[200];

int main()
{
    cin>>n;
    for (int i=0; i<n; ++i)
        cin>>a[i];
    sort(a,a+n);
    int s=0;
    for (int i=0; i<n-1; ++i)
        s+=a[i];
    if (s>a[n-1])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
def cmd():
    A, B, C, X, Y = map(int, input().split())
    buyAB = A*X + B*Y
    if X == Y:
        buyminC = C*2*min(X,Y)
    elif X > Y:
        buyminC = C*2*min(X,Y) + A*(X-Y)
    else:
        buyminC = C*2*min(X,Y) + B*(Y-X)
    buymaxC = C*2*max(X,Y)
    #print("buyAB:{}, buyminC:{}, buymaxC:{}".format(buyAB, buyminC, buymaxC))
    print(min(buyAB, buyminC, buymaxC))

if __name__ == "__main__":
    cmd()


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

int main() {
    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 2 != 0) {
            int count = 0;
            for (int k = 1; k <= i; k++) {
                if (i % k == 0) count++;
            }
            if (count == 8) ans++;
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int w, h, n, ara[102][102] = {0};
    scanf("%d%d%d", &w, &h, &n);
    for(int i = 0; i < n; i++)
    {
        int x, y, a, s1, s2, e1, e2;
        scanf("%d%d%d", &x, &y, &a);
        if(a == 1)
        {
            s1 = 0, s2 = 0;
            e1 = h, e2 = x;
        }
        else if(a == 2)
        {
            s1 = 0, s2 = x;
            e1 = h, e2 = w;
        }
        else if(a == 3)
        {
            s1 = h-y, s2 = 0;
            e1 = h, e2 = w;
        }
        else
        {
            s1 = 0, s2 = 0;
            e1 = h-y, e2 = w;
        }
        for(int j = s1; j < e1; j++)
            for(int k = s2; k < e2; k++)ara[j][k]++;
    }
    int ans = 0;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            //printf("%d ", ara[i][j]);
            if(ara[i][j] == 0)ans++;
        }
        //printf("\n");
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int m;
    cin >> m;

    vector<int64_t> ds(m), cs(m);
    int64_t sum = 0;
    int64_t ans = 0;

    for (int i = 0; i < m; i++)
    {
        cin >> ds[i] >> cs[i];
        sum += ds[i] * cs[i];
        ans += cs[i];
    }
    ans--;
    ans += (sum - 1) / 9;

    cout << ans << endl;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int F[MAXN*2],par[MAXN],arr[MAXN],n;
void upd(int x){
	x+=MAXN;
	for(;x<MAXN*2;x+=x&(-x))
		F[x]++;
}
int tap(int x){
	x+=MAXN;
	int res=0;
	for(;x;x-=x&(-x))
		res+=F[x];
	return res;	
}
ll f(int x){
	memset(F,0,sizeof F);
	ll ans=0;
	for(int i=1;i<=n;i++){
		upd(par[i-1]);	
		par[i]=par[i-1];
		if(x>arr[i])
			par[i]++;
		else
			par[i]--;
		ans+=tap(par[i]-1);
	}
	return ans;
}
int main(){
    //~ freopen("file.in", "r", stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",arr+i);
	ll need=(n*1LL*(n+1))/2;
	need=(need+2)/2;
	int st=1,en=INF;
	while(st+1<en){
		int mid=(st+en)>>1;
		if(f(mid)>=need)
			en=mid;
		else
			st=mid;
	}
	if(f(st)>=need)
		en=st;
	printf("%d\n",en-1);	
	return 0;
}


Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	n := nextInt()


	fmt.Println(3 * n*n)
}

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


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

int main(){
	int n;
	cin >> n;

	double x[10];
	string u[10];
	double sum=0;
	for(int i = 0; i < n; ++i){
		cin >> x[i] >> u[i];

		if(u[i] == "JPY") sum += x[i];
		else sum += 380000.0*x[i];
	}

	printf("%.6f\n", sum);
}

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

using namespace std;

int main(){
    int n,ans = 100000,sum = 0;
    cin >> n;

    vector<int>v(n);

    for(int i = 0;i < n;i++){
         cin >> v[i];
         sum += v[i];
    }

    for(int i = 0;i <= n;i++){
        int count = 0;
        for(int j = 0;j < n;j++){
            if(j <= i)count += v[j];
        }
        ans = min(ans,abs((sum-count*2)));
    }

    cout << ans << endl;


    return 0;
}

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


vector<int>p(11),sw(11);
int n,m;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k,s,ans=0;
    bool f;
    cin>>n>>m;
    vector<int> d[m];
    rep(i,0,m){
        cin>>k;
        rep(j,0,k){
            cin>>s;
            s--;
            d[i].push_back(s);
        }
    }
    rep(i,0,m){
        cin>>p[i];
    }
    vector<int>count(m,0);
    rep(i,0,1<<n){
        f=true;
        rep(j,0,m){count[j]=0;}
        rep(j,0,n){if(i>>j&1){sw[j]=1;}else{sw[j]=0;}}
        rep(j,0,m){
            rep(l,0,d[j].size()){
                if(sw[d[j][l]]){count[j]++;}
            }
        }
        rep(j,0,m){
            if((count[j]%2)!=p[j]){f=false;}
        }
        if(f){ans++;}
    }
    cout<<ans<<endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> b(n-1);
	for(int i = 0; i < n - 1; i++) {
		cin >> b[i];		
	}
	int sum = 0;
	for(int i = n - 1; i >= 0; i--) {
		if(i == n - 1) {
			sum += b[i - 1];			
		}
		else if(i == 0) {
			sum += b[i];
		}		
		else {
			sum += min(b[i], b[i-1]);	
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println((a-c)*(b-d));
		sc.close();
	}

}

Measured memory_bytes: 26964
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

ll n;
string s;
vi ss;

bool dfs(ll i, vi& sw, int p, int c) {
    if (i == n) return (c == sw[0] && ss[0] * p * c == sw[1]);

    sw[i] = c;
    return dfs(i + 1, sw, c, ss[i] * p * c);
}

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

    cin>>n;
    cin>>s;
    ss = vi(n);
    rep(i, n) ss[i] = (s[i] == 'o') ? 1 : -1;

    vi sw1(n);
    sw1[0] = 1;
    if (dfs(1, sw1, 1, 1)) {
        rep(i, n) cout<<(sw1[i] == 1 ? 'S' : 'W');
        cout<<endl;
        return 0;
    }
    vi sw2(n);
    sw2[0] = 1;
    if (dfs(1, sw2, 1, -1)) {
        rep(i, n) cout<<(sw2[i] == 1 ? 'S' : 'W');
        cout<<endl;
        return 0;
    }
    vi sw3(n);
    sw3[0] = -1;
    if (dfs(1, sw3, -1, 1)) {
        rep(i, n) cout<<(sw3[i] == 1 ? 'S' : 'W');
        cout<<endl;
        return 0;
    }
    vi sw4(n);
    sw4[0] = -1;
    if (dfs(1, sw4, -1, -1)) {
        rep(i, n) cout<<(sw4[i] == 1 ? 'S' : 'W');
        cout<<endl;
        return 0;
    }
    cout<<-1<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> cnt;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
    }

    ll mod = 1e9 + 7;
    ll ans = 1;
    for (auto p : cnt) {
        if ((N - p.first) % 2 != 1) {
            cout << 0 << endl;
            return 0;
        } else if (p.first != 0 && p.second != 2) {
            cout << 0 << endl;
            return 0;
        } else if (p.first == 0 && p.second != 1) {
            cout << 0 << endl;
            return 0;
        }
        if (p.first != 0) {
            ans *= 2;
            ans %= mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll x;
	cin >> x;
	int cnt = 0;
	ll m = 100;
	while (m < x) {
		m *= 1.01;
		cnt++;
	}
	cout << cnt << '\n';
}

Measured memory_bytes: 3692