akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    Int(n);
    Int(k);
    Int(m);
    while (n) {
        queue<int> q;
        For(i, m, n+1) {
            q.push(i);
        }
        Rep(i, m) {
            q.push(i);
        }
        q.pop();
        while (q.size() != 1) {
            Rep(i, k) {
                int tmp = q.front();
                q.pop();
                q.push(tmp);
            }
            q.pop();
        }
        cout << q.front() << endl;
        cin >> n >> k >> m;
    }
    return 0;
}

Measured memory_bytes: 3196
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong A,B,C;
    llong K;
    cin >> A >> B >> C;
    cin >> K;
    while(K>0){
        if(B<=A){
            B = B * 2;
            K = K - 1;
            continue;
        }
        break;
    }
    while(K>0){
        if(C<=B){
            C = C * 2;
            K = K - 1;
            continue;
        }
        break;
    }
    if(A<B && B<C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 5;
int sparse[N][18], n, a[N], l, q;

int get (int x, int y) {
    int ans = 1;
    for (int i = 17; i >= 0; i--) {
        if (sparse[x][i] != -1 && sparse[x][i] < y) {
            x = sparse[x][i];
            ans = ans + (1 << i);
        }
    }

    return ans;
}

int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    scanf("%d", &l);
    scanf("%d", &q);

    memset(sparse, -1, sizeof(sparse));
    for (int i = 0; i < n; i++) sparse[i][0] = upper_bound(a, a + n, a[i] + l) - a - 1;
    for (int j = 1; j < 18; j++) {
        for (int i = 0; i < n; i++) {
            if (sparse[i][j - 1] != -1) sparse[i][j] = sparse[sparse[i][j - 1]][j - 1];
        }
    }

    while (q--) {
        int x, y;
        scanf("%d %d", &x, &y);
        if (x > y) swap(x, y);
        printf("%d\n", get(x - 1, y - 1));
    }
    return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> p(N);
    for (int i = 0; i < N; ++i){
        cin >> p[i].first;
        p[i].second = i+1;
    }
    sort(p.begin(), p.end());
    for (auto x : p) {
        cout << x.second << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  string n;
  cin >> n;
  string ans = "ABC" + n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,m,k;
    cin>>n>>m>>k;
    lli a[n],b[m];
    char c[n][m];
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        cin>>c[i][j];
    }
    lli sum;
    for (int i=0;i<n;i++)
    {sum=0;
        for (int j=0;j<m;j++)
        {
            if (c[i][j]=='#')
            sum++;
        }
        a[i]=sum;
    }
    for (int j=0;j<m;j++)
    {sum=0;
        for (int i=0;i<n;i++)
        {
            if (c[i][j]=='#')
            sum++;
        }
        b[j]=sum;
    }
    sum=0;
    for (int j=0;j<m;j++)
    {
        for (int i=0;i<n;i++)
        {
            if (c[i][j]=='#')
            sum++;
        }
    }
    //for (int i=0;i<n;i++)
    //cout<<a[i]<<" ";cout<<"\n";
    //for (int j=0;j<m;j++)
    //cout<<b[j]<<" ";cout<<"\n";
    //cout<<sum<<"\n";
    lli tum=0,ans=0;
    vll v,w;
    lli x,y;
    x=power(2,n);
    y=power(2,m);
    for (int i=0;i<x;i++)
    {v.clear();
        for (int j=0;j<6;j++)
        {if ((1LL<<j)&i) {v.pb(j);}}
        for (int j=0;j<y;j++)
        {w.clear();tum=0;
            
            for (int l=0;l<6;l++)
            {if ((1LL<<l)&j) w.pb(l);}
            
            for (int l=0;l<v.size();l++)
            {
                tum+=a[v[l]];}
            
            for (int l=0;l<w.size();l++)
            {
                tum+=b[w[l]];}
            
            for (int l=0;l<v.size();l++)
            {
                for (int t=0;t<w.size();t++)
                if (c[v[l]][w[t]]=='#')
                tum--;
            }
            //cout<<j<<" "<<tum<<" "<<sum-tum<<"\n";
            if (sum-tum==k)
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
def change(w,b):
    h = 0
    grid = []
    for i in range(50):
        if i % 3 == 0:
            grid.append([1 for j in range(100)])
        elif i % 3 == 1:
            grid.append([])
            for j in range(100):
                if w > 1 and j % 2 and j < 99:
                    grid[i].append(0)
                    w -= 1
                else:
                    # print(i)
                    grid[i].append(1)
        elif i % 3 == 2:
            grid.append([])
            for j in range(100):
                if w > 1 and j % 2 == 0 and j < 99:
                    grid[i].append(0)
                    w -= 1
                else:
                    grid[i].append(1) 
    b -= 1
    for i in range(50, 100):
        if i % 3 == 2:
            grid.append([0 for j in range(100)])
        elif i % 3 == 0:
            grid.append([])
            for j in range(100):
                if b > 0 and j % 2 and j < 99:
                    grid[i].append(1)
                    b -= 1
                else:
                    grid[i].append(0) 
        elif i % 3 == 1:
            grid.append([])
            for j in range(100):
                if b > 0 and j % 2 == 0 and j < 99:
                    grid[i].append(1)
                    b -= 1
                else:
                    grid[i].append(0) 

    print(100,100)
    d = {0:'.', 1:'#'}    
    [print(''.join(map(d.get,line))) for i,line in enumerate(grid)]

w,b = map(int, input().split())
# w=0, b=1
change(w,b)


Measured memory_bytes: 39792
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll l[300];
    std::cin >> n;
    for (int i = 0; i < 2*n; i++) {
        std::cin >> l[i];
    }
    sort(l,l+2*n);
    ll result = 0;
    
    for (int i = 0; i < n; i++) {
        result += l[i*2];
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
//
//  main.c
//  ITP1_8_A
//
//  Created by k16031kk on 2018/05/26.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    char str;
    int ch=0;
    while(1) {
        scanf("%c", &str);
        if(str=='\n') break;
        if('a'<=str && str<='z') {
            ch=(int)str;
            ch=str-32;
            printf("%c",ch);
        } else if('A'<=str && str<='Z') {
            ch=(int)str;
            ch=str+32;
            printf("%c",ch);
        } else {
            printf("%c",str);
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2040
import math
n,m=map(int,input().split())
if n<m-1 or m<n-1:
  print(0)
else:
  mod=10**9+7
  if n==m:
    print(((math.factorial(n)%mod)*(math.factorial(m)%mod)*2)%mod)
  else:
    print(((math.factorial(n)%mod)*(math.factorial(m)%mod))%mod)

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

int main(){
  long long a, b, n, x, mx=0, tmp;
  cin >> a >> b >> x;
  
  mx = floor(a*x/b)-a*floor(x/b);
  // cout << "[" << mx << "]" << "n=" << n;

  if(x > (a*x)%b){
    n = x-(a*x)%b;
    tmp = floor(a*n/b)-a*floor(n/b);
    mx = max(mx, tmp);
    // cout << "[" << mx << "]" << "n=" << n;
  }

  if(x > x%b+1){
    n = x-(x%b)-1;
    tmp = floor(a*n/b)-a*floor(n/b);
    mx = max(mx, tmp);
    // cout << "[" << mx << "]" << "n=" << n;
  }
  
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

typedef Point Vector;

struct Line{
  Point s,t;
  Line(){}
  Line(Point s,Point t) : s(s),t(t) {}
};

bool isOrthogonal(const Line &l1,const Line &l2){
  Vector a = l1.t-l1.s;
  Vector b = l2.t-l2.s;
  return equal(dot(a,b),0);
}

bool isParallel(const Line &l1,const Line &l2){
  Vector a = l1.t-l1.s;
  Vector b = l2.t-l2.s;
  return equal(cross(a,b),0);
}
 
int main(){
  int Q;
  cin >> Q;
  while(Q--){
    Line l1,l2;
    cin >> l1.s >> l1.t;
    cin >> l2.s >> l2.t;

    if(isOrthogonal(l1,l2)){
      cout << 1 << endl;
    }else if(isParallel(l1,l2)){
      cout << 2 << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define LL long long

int main(void) {
  LL int N;

  std::cin >> N;

  std::vector<LL int> A(N);

  for (LL int i=0; i < N; i++) {
    std::cin >> A[i];
  }

  LL int cnt = 0;

  for (LL int i=1; i < N; i++) {
    while (1)
    {
      if (A[i-1] > A[i]) {
        A[i]++;
        cnt++;
      }else if (A[i-1] <= A[i]) {
        break;
      }
      
    }
  }

  std::cout << cnt << std::endl;

}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ;
  intll ans = 0;
  
  rep(i,n+1){
    if(i%3 !=0  && i%5 != 0)
      ans += i;
  }
  
  cout << ans ;


}


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

typedef long long ll; 
ll m=1e9+7;
ll dp[1002][1002];


int main(){
  ll n,k;
  cin>>n>>k;
  dp[0][0]=1;

  for(int i=0;i<n;i++)
    for(int j=0;j<=k;j++){
      (dp[i+1][j]+=j*dp[i][j])%=m;
      (dp[i+1][j+1]+=dp[i][j])%=m;
    }
  ll ans=0;
  for(int i=0;i<=k;i++)(ans+=dp[n][i])%=m;
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 10864
dict={
  'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25,
}
l1=['']*26
l2=['']*26
s1=input()
s2=input()
f=0
for i in range(len(s1)):
  a=s1[i]
  b=s2[i]
  ind=dict[a]
  if l1[ind]=='':
    l1[ind]=b
  else:
    if l1[ind]!=b:
      f=1
      break
  ind=dict[b]
  if l2[ind]=='':
    l2[ind]=a
  else:
    if l2[ind]!=a:
      f=1
      break
if f==1:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3888
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int DX[4] = {-1, 0, 1, 0};
int DY[4] = {0, -1, 0, 1};

int H, W, K;
int SX, SY;
char A[800][800];
int D[800][800];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W >> K;
  rep(y, H) {
    rep(x, W) {
      cin >> A[x][y];
      if (A[x][y] == 'S') SX = x, SY = y;
    }
  }
  rep(y, H) {
    rep(x, W) {
      D[x][y] = INF;
    }
  }
  queue<P> q;
  q.push(P(SX, SY));
  D[SX][SY] = 0;
  while (!q.empty()) {
    int x = q.front()._1, y = q.front()._2;
    q.pop();

    int d = D[x][y];
    if (d == K) continue;

    rep(k, 4) {
      int nx = x+DX[k], ny = y+DY[k];
      if (nx<0||nx>=W||ny<0||ny>=H) continue;
      if (A[nx][ny] == '#') continue;
      if (D[nx][ny] > d+1) {
        D[nx][ny] = d+1;
        q.push(P(nx, ny));
      }
    }
  }
  rep(x, W) {
    if (D[x][0] < INF || D[x][H-1] < INF) {
      cout << 1 << "\n";
      return 0;
    }
  }
  rep(y, H) {
    if (D[0][y] < INF || D[W-1][y] < INF) {
      cout << 1 << "\n";
      return 0;
    }
  }
  int m = INF;
  rep(y, H) {
    rep(x, W) {
      if (D[x][y] < INF) {
        m = min(m, x);
        m = min(m, y);
        m = min(m, W-1-x);
        m = min(m, H-1-y);
      }
    }
  }
  int steps = 1 + (m+(K-1))/K;
  cout << steps << "\n";
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#define MAX 10001
using namespace std;

int search(int *S, int n, int key) {
    int i=0;
    S[n] = key;
    while(S[i] != key) i++;
    return i != n;
}

int main() {
    int n, q, i, key, cnt=0;
    int S[MAX];
    cin >> n;
    for(i=0; i < n; i++) {
        cin >> S[i];
    }
    cin >> q;
    for(i=0; i < q; i++) {
        cin >> key;
        if(search(S, n, key)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3056
import math
a,b,x = map(int,input().split())

if x <= a**2*b/2:
    y = 2*x/(a*b)

    theta = math.atan2(b,y)

    print(math.degrees(theta))
else:
    y = 2*x/(a**2)-b

    theta = math.atan2(b-y,a)
    print(math.degrees(theta))

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int a[maxn];
int vis[maxn];
bool check(int n)
{
	while(n)
	{
		if(vis[n%10])
			return false;
		n/=10;
	}
	return true;
}
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n,k;
	int x;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>x;
		vis[x]=1;
	}
	for(int i=n;;i++)
	{
		if(check(i))
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}

int main()
{
    ll N;
    cin >> N;
    vector<string> s(N);                       // power
    cin >> s;

    ll ans = 0;
    map<string, int> mp;
    for (ll i = 0; i < N; i++){
        mp[s[i]]++;
    }

    vector<pair<string,ll>> mps(mp.size());

    ll c = 0;
    for(auto i: mp){
        mps[c] = make_pair(i.first,i.second);
        c++;
    }


    sort(mps.begin(),mps.end(),[](const pair<string,ll>& l,const pair<string,ll>&  r){
        if (l.second != r.second){
            return l.second > r.second;
        }else{
            return l.first < r.first;
        }
    });
    
    ll maxcount = mps[0].second;
    for (ll i = 0; i < mp.size(); i++){
        if (mps[i].second < maxcount )break;
        cout << mps[i].first << endl;
    }
    
    
}


Measured memory_bytes: 29952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
#define SIZE 100005
ll arr[SIZE];
ll gcd(ll a, ll b) 
{ 
	if (b == 0) 
		return a; 
	return gcd(b, a % b); 
} 
ll findlcm(ll n) 
{ 
	// Initialize result 
	ll ans = arr[0]; 

	// ans contains LCM of arr[0], ..arr[i] 
	// after i'th iteration, 
	for (ll i = 1; i < n; i++) 
		ans = (((arr[i] * ans)) / 
				(gcd(arr[i], ans))); 

	return ans; 
} 
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll N,M;
	cin>>N>>M;
	for(ll i=0;i<N;++i){
		cin>>arr[i];
		arr[i]=arr[i]/2;
	}
	ll lcm=findlcm(N);
	for(ll i=0;i<N;++i){
		ll num=lcm/arr[i];
		if(num%2==0){
			cout<<0<<endl;
			return 0;
		}
	}
	ll mul=M/lcm;
	cout<<(mul+1)/2;
}

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

int main() {
    int a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }

    sort(a, a + 3);

    if ( a[0]+a[1] == a[2] )  {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N; cin >> N;
    int a[N], mx=0; REP(i,N){cin >> a[i]; chmax(mx, a[i]);}

    int num[mx]; REP(i,mx+1) num[i] = 0;
    REP(i,N) num[a[i]]++;

    int ans=1;

    if(mx < 3){
        cout << N << endl;
        return 0;
    }
    FOR(i,1,mx){
        chmax(ans, num[i-1]+num[i]+num[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
typedef long long ll;
typedef pair<ll,ll> P;
struct edge{
  ll to,cost;
  edge(ll t,ll c){
    to=t,cost=c;
  }
};
struct state{
  ll pos,flg,cost;
  state(ll p,ll f,ll c){
    pos=p,flg=f,cost=c;
  }
  bool operator < (const state &p)const{
    return cost > p.cost;
  }
};
 
vector<P> t[MAX][2];
ll W,H,K,X[MAX],Y[MAX];
ll d[MAX][2];
vector<edge> G[MAX][2];
 
ll solve(){
  if(t[1][0].empty())return -1;
  for(int i=0;i<MAX;i++)d[i][0]=d[i][1]=10000000000000000LL;
  priority_queue< state > Q;
  P p=t[1][0][0];
  Q.push( state( p.second, 0, p.first-1 ) );
  d[p.second][0]=p.first-1;
   
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.pos][s.flg])continue;
    for(int f=0;f<2;f++){
      int nf=(s.flg+f)%2;
      for(int i=0;i<(int)G[s.pos][nf].size();i++){
        edge e=G[s.pos][nf][i];
        ll ncost=s.cost+e.cost+f;
        if(e.cost==0)ncost=s.cost;
        if(ncost<d[e.to][nf]){
          d[e.to][nf]=ncost;
          Q.push( state(e.to,nf,ncost) );
        }
      }
    }
  }
  ll res=min(d[K][0],d[K][1]);
  if(res==10000000000000000LL)return -1;
  else return res;
}
       
int main(){
  scanf("%lld %lld %lld",&W,&H,&K);
  for(int i=0;i<K;i++){
    scanf("%lld %lld",&X[i],&Y[i]);
    t[X[i]][0].push_back(P(Y[i],i));
    t[Y[i]][1].push_back(P(X[i],i));
  }
  t[W][0].push_back(P(H,K));
  t[H][1].push_back(P(W,K));
  X[K]=W;
  Y[K]=H;
  for(int i=1;i<=100000;i++){
    for(int f=0;f<2;f++){
      vector<P> &vec=t[i][f];
      sort(vec.begin(),vec.end());
      int size=vec.size();
      for(int j=0;j<size;j++){
        P p=vec[j],q;
        if(0<j){
          q=vec[j-1];
          G[p.second][f].push_back( edge(q.second,p.first-q.first) );
        }
        if(j+1<size){
          q=vec[j+1];
          G[p.second][f].push_back( edge(q.second,q.first-p.first) );
        }
      }
    }
  }
  cout<<solve()<<endl; 
  return 0;
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x)
{
	bool f = 0;
	x = 0;
	char c = getchar();
	while(c != '-' && (c < '0' || c > '9')) c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	if(f) x = -x;
	return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
	scf(x);
	return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
	scf(x);
	scf(y);
	return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
	scf(x);
	scf(y);
	scf(z);
	return scf(w);
}

inline char mygetchar()
{
	char c = getchar();
	while(c == ' ' || c == '\n') c = getchar();
	return c;
}

template <typename T> inline bool chkmax(T &x, const T &y)
{
	return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y)
{
	return y < x ? x = y, 1 : 0;
}

#ifdef King_George
#define DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

LL n;
LL cnt[300];
char s[200100];

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	LL ans = n * (n - 1) / 2 + 1;
	forn(i, 1, n) ++cnt[s[i]];
	forn(i, 'a', 'z') ans -= cnt[i] * (cnt[i] - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      int Y = sc.nextInt();
      int Z = sc.nextInt();
      int a = Z;
      int b = X;
      int c = Y;
      System.out.println(a+" "+b+" "+c);
    }
}

Measured memory_bytes: 39416
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(0,min(b,d)-max(a,c))<<endl;

    return 0;
}


Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = map(int, input().split())
x_3 = x_2 - y_2 + y_1
y_3 = y_2 + x_2 - x_1
x_4 = x_3 - x_2 + x_1
y_4 = y_3 - y_2 + y_1
print(x_3, y_3, x_4, y_4)

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

ll mod = 1000000007;

int main() {
    ll N, A, ans;
    cin >> N;
    map<int, int> mp;
    rep(i,N) {
        cin >> A;
        ++mp[A];
    }
    if (N % 2 == 0) {
        bool ok = true;
        for (auto x : mp) {
            if (x.first % 2 != 1) ok = false;
            if (x.second != 2) ok = false;
        }
        if (ok) {
            ans = 1;
            rep(i,N/2) ans = (ans * 2) % mod;
            cout << ans << endl;
        } else cout << 0 << endl;
    } else {
        bool ok = true;
        for (auto x : mp) {
            if (x.first == 0) {
                if (x.second != 1) ok = false;
            } else {
                if (x.first % 2 != 0) ok = false;
                if (x.second != 2) ok = false;
            }
        }
        if (ok) {
            ans = 1;
            rep(i,N/2) ans = (ans * 2) % mod;
            cout << ans << endl;
        } else cout << 0 << endl;
    }
    
    
}



Measured memory_bytes: 6536
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, m, k;

vint shu(vint vec, int k) {
    vint res(n*2);
    if (k == 0) {
        for (int i = 0; i < n; ++i) {
            res[i*2] = vec[i];
            res[i*2+1] = vec[i+n];
        }
    }
    else {
        for (int i = 0; i < n*2-k; ++i) res[i] = vec[i+k];
        for (int i = n*2-k; i < n*2; ++i) res[i] = vec[i-n*2+k];
    }
    return res;
}

int main() {
    while (cin >> n >> m) {
        vint vec(n*2);
        for (int i = 0; i < n*2; ++i) vec[i] = i+1;
        for (int i = 0; i < m; ++i) {
            cin >> k; 
            vec = shu(vec, k);
        }
        for (int i = 0; i < n*2; ++i) cout << vec[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <array>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 998244353;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(3e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int n;
    map<int,ll> cnt;
    cin >> n;
    REP(i,n){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    vector<ll> ls;
    for(auto i: cnt){
        if(i.second>=2){
            ls.push_back(i.first);
            if(i.second>=4){
                ls.push_back(i.first);
            }
        }
    }
    sort(ls.begin(),ls.end());
    if(ls.size()<2)
        cout << 0 << endl;
    else {
        cout << ls[ls.size()-1]*ls[ls.size()-2] << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

int MOD;

inline void add(int &x,int y) {
  ((x+=y)>=MOD)?x-=MOD:0;
}

int f[2][155][155],g[155][155];

int dp1(int n,int m) {
  if (m>n-2) {
  	int s=1;
  	for(int i=1;i<=n;i++) s=s*2LL%MOD;
  	return s;
  }
  m>>=1;
  int u=((n+1)>>1),v=n-u,cur=0;
  for(int i=0;i<=u;i++) f[0][i][0]=1;
  for(int i=1;i<=m;i++) {
  	cur^=1;
  	memset(f[cur],0,sizeof(f[cur]));
  	for(int j=0;j<=u;j++)
  	for(int k=0;k<i;k++)
  	  if (f[cur^1][j][k]) {
  	  	  add(f[cur][j][0],f[cur^1][j][k]);
  	  	  add(f[cur][j][k+1],f[cur^1][j][k]);
		}
  }
  for(int i=m+1;i<=v;i++) {
  	cur^=1;
  	memset(f[cur],0,sizeof(f[cur]));
  	int r=u-i+m+1;
  	for(int j=1;j<=r;j++)
  	for(int k=0;k<i;k++)
  	  if (f[cur^1][j][k]) {
  	  	  add(f[cur][j-1][0],f[cur^1][j][k]);
  	  	  if (2*m-k+2>j) add(f[cur][j-1][k+1],f[cur^1][j][k]);
		}
	for(int j=0;j<r;j++)
	for(int k=0;k<i;k++)
	  if (f[cur^1][0][k]) {
	  	  add(f[cur][j][0],f[cur^1][0][k]);
	  	  add(f[cur][j][k+1],f[cur^1][0][k]);
	  }
  }
  for(int i=v-m+1;i<=u;i++) {
  	cur^=1;
  	memset(f[cur],0,sizeof(f[cur]));
  	int r=u-i+1;
  	for(int j=1;j<=r;j++)
  	for(int k=0;k<=v;k++)
  	  if (f[cur^1][j][k]) add(f[cur][j-1][k],f[cur^1][j][k]);
  	for(int j=0;j<r;j++)
  	for(int k=0;k<=v;k++)
  	  if (f[cur^1][0][k]) add(f[cur][j][k],f[cur^1][0][k]);
  }
  int ans=0;
  for(int i=0;i<=v;i++) add(ans,f[cur][0][i]);
  return ans;
}

int dp2(int n,int m) {
  memset(g,0,sizeof(g));
  g[0][0]=1;
  for(int i=0;i<n;i++)
    for(int j=0;j<=i;j++)
      if (g[i][j]) {
      	add(g[i+1][0],g[i][j]);
      	if (j<m) add(g[i+1][j+1],g[i][j]);
	  }
  int ans=0;
  for(int i=0;i<=n;i++) add(ans,g[n][i]);
  return ans;
}

int main() {
  int n,m;
  scanf("%d%d%d",&n,&m,&MOD);
  if (m&1) printf("%d\n",dp1(n,m));
  else printf("%lld\n",(ll)dp2((n+1)>>1,m>>1)*dp2(n>>1,m>>1)%MOD);
  return 0;
}

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

using ll = long long;
using namespace std;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}


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

class dice{
private:
	int D1;
	int D2;
	int D3;
	int D4;
	int D5;
	int D6;
public:
	dice(int d1,int d2,int d3,int d4,int d5,int d6){
	D1=d1;
	D2=d2;
	D3=d3;
	D4=d4;
	D5=d5;
	D6=d6;
	}
	void turn(char a){
		int front=D2;
		int back=D5;
		int top=D1;
	        int botton=D6;
		int right=D3;
		int left=D4;
		if(a=='E'){
			top=D4;
			right=D1;
			left=D6;
			botton=D3;
		}
		if(a=='N'){
			top=D2;
			front=D6;
			botton=D5;
			back=D1;
		}
		if(a=='S'){
			top=D5;
			front=D1;
			botton=D2;
			back=D6;
		}
		if(a=='W'){
			top=D3;
			left=D1;
			botton=D4;
			right=D6;
		}
		D1=top;
		D2=front;
		D3=right;
		D4=left;
		D5=back;
		D6=botton;
	}
	
	int output(){
	 	return D1;
	}

};

int main(){
	int d[6];
	string n;
	int front,back,right,left,top,botton;
	
	for(int i=0;i<6;i++)
		cin>>d[i];
	
	dice p(d[0],d[1],d[2],d[3],d[4],d[5]);
	cin>>n;	
	for(int i=0;n[i]!='\0';i++)
		p.turn(n[i]);
	
	cout<<p.output()<<endl;		
}

Measured memory_bytes: 1204
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	long long x, t;
	cin >> x >> t;
	cout << max(0LL, x - t) << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

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

    ll t=1; 
    vector<ll> bitcnt(30);
    for(int bit=0; bit<30; bit++){
        for(int i=0; i<n; i++){
            a[i]%=2*t;
            b[i]%=2*t;
        }

        sort(b.begin(), b.end());

        ll sum=0;
        for(int i=0; i<n; i++){
            sum+=(lower_bound(b.begin(), b.end(), 2*t-a[i])-lower_bound(b.begin(), b.end(), t-a[i]));
            sum+=(lower_bound(b.begin(), b.end(), 4*t-a[i])-lower_bound(b.begin(), b.end(), 3*t-a[i]));
        }
        bitcnt[bit]=sum;

        for(int i=0; i<n; i++){
            a[i]=c[i];
            b[i]=d[i];
        }
        t*=2;
    }

    ll ans=0, num=1;
    for(int bit=0; bit<30; bit++){
        if(bitcnt[bit]%2==1) ans+=num;
        num*=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
N = int(input())
A = [int(input()) for _ in range(N)]
Max = max(A)
Index = [i for i, x in enumerate(A) if x == Max]
if len(Index) != 1:
    for i in range(N):
        print(Max)
else:
    Copy = A[:]
    Copy[Index[0]] = 0
    Ans = [Max for i in range(N)]
    Ans[Index[0]] = max(Copy)
    for i in range(N):
        print(Ans[i])

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

int main(void){
   long long N,K,S;
   cin>>N>>K>>S;
   vector<long long> ans(N);
   if(S<1000000000){
      for(int i=0;i<N;i++){
         if(i<K) ans[i]=S;
         else ans[i]=S+1;
      }
   }else{
      for(int i=0;i<N;i++){
         if(i<K) ans[i]=S;
         else ans[i]=S-1;
      }
   }
   for(int i=0;i<N;i++){
      cout<<ans[i]<<" ";
   }
   cout<<endl;
   return 0;
}


Measured memory_bytes: 4036
n, m = gets.split.map(&:to_i)
ps = m.times.map{gets.split}.group_by{|a| a[0].to_i}

succ = 0
pena = 0
1.upto(n) do |i|
  pena_ = 0
  next if !ps.has_key?(i)
  ps[i].each do |_, str|
    if str == 'WA'
      pena_ += 1
    else
      succ += 1
      pena += pena_
      break
    end
  end
end

puts "#{succ} #{pena}"

Measured memory_bytes: 31484
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef long long ll;
typedef pair<long long,long long> ll2;
const ll LLINF = LLONG_MAX;
const ll MOD = 1000000007;
 
enum Symbol { EXPS,EXPE,TERMS,TERME,FACTOR };
 
int exp(string &s,int &cur){
 
  stack<Symbol> sstack;
  stack<ll2> vstack;
  stack<char> ostack;
  sstack.push(EXPS);
  ostack.push('@'); // dammy;
  while( !sstack.empty() ){
    Symbol syb = sstack.top();
    char opr;
    int itmp;
    ll2 v1,v2,value,tmp;
 
    switch(syb){
    case EXPS:
      sstack.pop();
      sstack.push(EXPE);
      sstack.push(TERMS);
      break;
 
    case EXPE:
      opr = ostack.top();
      if( opr == '|' ) {
        ostack.pop();
        v1 = vstack.top(); vstack.pop();
        v2 = vstack.top(); vstack.pop();
        tmp = ll2(0,0);
        ( tmp.first  = v1.first  * v2.first  ) %= MOD;
        ( tmp.first += v1.first  * v2.second ) %= MOD;
        ( tmp.first += v1.second * v2.first  ) %= MOD;
        ( tmp.second = v1.second * v2.second ) %= MOD;
        vstack.push(tmp);
      }
      if( s[cur] == '|' ){
        sstack.push(TERMS);
        ostack.push(s[cur++]);
      } else {
        sstack.pop();
      }
      break;
 
    case TERMS:
      sstack.pop();
      sstack.push(TERME);
      sstack.push(FACTOR);
      break;
 
    case TERME:
      opr = ostack.top();

      if( opr == '&' ) {
        ostack.pop();
        v1 = vstack.top(); vstack.pop();
        v2 = vstack.top(); vstack.pop();
        tmp = ll2(0,0);
        ( tmp.first   = v1.first  * v2.first  ) %= MOD;
        ( tmp.second  = v1.first  * v2.second ) %= MOD;
        ( tmp.second += v1.second * v2.first  ) %= MOD;
        ( tmp.second += v1.second * v2.second ) %= MOD;
        vstack.push(tmp);
      }
 
      if( s[cur] == '&' ) {
        sstack.push(FACTOR);
        ostack.push(s[cur++]);
      } else {
        sstack.pop();
      }
      break;
 
    case FACTOR:
      if( s[cur] == '(' ){
        ++cur;
        sstack.push(EXPS);
        ostack.push('(');
      } else if( s[cur] == ')' ){
        sstack.pop();
        ostack.pop();

        itmp = 0;
        while( !ostack.empty() && ostack.top() == '~' ){
          ostack.pop();
          itmp++;
        }
        tmp = vstack.top(); vstack.pop();
        if( itmp & 1 ) swap(tmp.first,tmp.second);
        vstack.push(tmp);
        ++cur;
      } else if( s[cur] == 'x' ) {
        cur++;
        while( '0' <= s[cur] && s[cur] <= '9' )cur++;
        while( !ostack.empty() && ostack.top() == '~' ) ostack.pop();
        vstack.push(ll2(1,1));
        sstack.pop();
      } else if( s[cur] == '~' ) {
        ++cur;
        ostack.push('~');
      } else assert(false); // invalid form

      break;
 
    default:
      break;
    }
 
  }
  assert(vstack.size() == 1);
  return vstack.top().first;
}
 
int main(){
  string s;
  int cur = 0;
  getline(cin,s);
  cout << exp(s,cur) << endl;
  return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a == c-b)
		cout << "YES\n";
	else
		cout << "NO\n";	
	return 0;
}

Measured memory_bytes: 256
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

int main()
{
    int n, k;
    std::cin >> n >> k;

    if (n * (n - 1) / 2 - (n - 1) < k)
    {
        std::cout << -1 << std::endl;
        return 0;
    }

    int cnt = n * (n - 1) / 2 - (n - 1);
    std::cout << n - 1 + cnt - k << std::endl;

    for (int i = 2; i <= n; i++)
    {
        std::cout << 1 << " " << i << std::endl;
    }

    int i = 2;
    int j = i + 1;
    while (cnt > k)
    {
        std::cout << i << " " << j << std::endl;
        cnt--;
        if (j++ == n)
        {
            i++;
            j = i + 1;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  bool istrue = true;
  rep(i,n){
    if(a.at(i)%2==0){
      if(a.at(i)%3!=0&&a.at(i)%5!=0){
        istrue=false;
      }
    }
  }
  if(istrue){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,i=2;
    scanf("%d",&N);
    i=N;
    while(1){
        if(((i%2)==0) && ((i%N)==0)){
            break;
        }
        i=i*2;
    }
    printf("%d",i);
    return 0;    
}

Measured memory_bytes: 128
using System;
using System.Linq;

class abc121_AA
{
    static void Main(string[] args)
    {
        var line1 = readInts();
        var line2 = readInts();

        var QH = line1[0];
        var QW = line1[1];
        var Qh = line2[0];
        var Qw = line2[1];

        Console.WriteLine(QH*QW - Qh*QW - Qw*QH + Qh*Qw);
    }

    
    static int readInt() { return int.Parse(Console.ReadLine()); }

    static int[] readInts() { return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); }

    static long readLong() { return long.Parse(Console.ReadLine()); }

    static long[] readLongs() { return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); }

}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,count=0;
  cin>>n;
  int b[n];
  for(i=0;i<n;i++){
    int a,c;
    cin>>a>>c;
  if(a==c)b[i]=1;
  else b[i]=0;}
  for(i=1;i<n-1;i++){
    if(b[i]==1){
      if(b[i-1]==1&&b[i+1]==1){
        count++;
      break;}}}
  if(count>0)cout<<"Yes";
      else cout<<"No";
      return 0;
}
 
  

Measured memory_bytes: 3632
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

from itertools import permutations

zembu=list(permutations(range(1,N+1)))

a=b=-1
for i in range(len(zembu)):
  if zembu[i]==P:
    a=i
  
  if zembu[i]==Q:
    b=i
  
  if a!=-1 and b!=-1:
    print(abs(a-b))
    break

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S;
  string s;
  for (int i=0; i<N; i++) {
    cin >> s;
    S.push_back(s);
  }
  sort(S.begin(), S.end());
  for (int i=0; i<N; i++)
    cout << S[i];
  return 0;
}

Measured memory_bytes: 3556
n = gets.chomp.to_i

hash = Hash.new([])
n.times do |i|
  s, point = gets.chomp.split(' ')
  point = point.to_i
  hash[s] = hash[s] + [[(i + 1), point]]
end
hash.to_a.sort_by { |s, arr| s }.each do |s, point_arr|
  point_arr.sort_by { |i, point| -1 * point }.each { |i, point| puts i }
end


Measured memory_bytes: 1788