akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define NODE_NUM 100000
struct node_t {
    int key;
    struct node_t *next;
};
typedef struct node_t Node;
 
Node *insert_value(Node *node, int value) {
    Node *p;
 
    p = malloc(sizeof(Node));
    p->key = value;
    p->next = node;
    return p;
}
 
int find_value(Node *node, int value) {
    Node *p;
 
    for (p = node; p != NULL; p = p->next) {
        if (p->key == value)
            return 1;
    }
    return 0;
}
 
int get_key(char str[15]) {
    static int code['T'+1] = {['A']=1, ['C']=2, ['G']=3, ['T']=4};
    int i, s = 0, p = 1;
 
    for (i = 0; str[i] != '\0'; i++) {
        s += p * code[(int)str[i]];
        p *= 5;
    }
    return s;
}
 
int main(void) {
    Node *nodes[NODE_NUM] = {0};
    int num_cmd, key, index;
    char cmd[15], str[15];
 
    scanf("%d ", &num_cmd);
    while (num_cmd--) {
        scanf("%s %s", cmd, str);
        key = get_key(str);
        index = key % NODE_NUM;
        if (cmd[0] == 'i') {
            nodes[index] = insert_value(nodes[index], key);
        } else {
            if (find_value(nodes[index], key)) {
                puts("yes");
            } else {
                puts("no");
            }
        }
    }
    return 0;
}

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

using namespace std;
//typedef long long ll;
typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {
    string s;
    cin >> s;

    int l = s.size() % 2 == 0;
    int se = s.front() == s.back();
    int ans = !((l) xor (se));

    cout << (ans ? "First" : "Second") << endl;

}


Measured memory_bytes: 512
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

A = attrs[0][0].to_i
B = attrs[0][1].to_i
C = attrs[0][2].to_i
K = attrs[0][3].to_i

sum = 0
num = K
if K <= A then
  sum = K
else
  sum = A
  num = K - A
  if num > B then
    sum -= num - B
  end
end
puts sum

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}


int main() {
    int h, w, n; cin >> h >> w >> n;
    int a = max(h,w);
    if (n % a == 0) cout << n / a << endl;
    else cout << n / a + 1 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
l = input().strip().split()
W = int(l[0])
H = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])
if(x - r >= 0 and y - r >= 0 and x + r <= W and y + r <= H):
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 7676
#include <cstdio>
#define max 102
#define f(ss, nn) for(int i = ss;i < nn;i++)
#define p(x) printf("%s\n", x)

struct trip{
	int p;int s;
};

int Sort(struct trip a[max], int left, int mid, int right){
	struct trip l[max/2+2], r[max/2+2];
	int ln = 0, rn = 0;
	for(int i = left;i < mid;i++)l[i-left] = a[i];
	for(int i = mid;i < right;i++)r[i-mid] = a[i];
	for(int i = left;i < right;i++){
		if((l[ln].p >= r[rn].p && ln < mid - left) || rn >= right - mid)a[i] = l[ln++];
		else a[i] = r[rn++];
	}
	return 0;
}

int MergeSort(struct trip a[max], int left, int right){
	if(left + 1 >= right)return 0;
	int mid = (left + right) / 2;
	MergeSort(a, left, mid);
	MergeSort(a, mid, right);
	Sort(a, left, mid, right);
	return 0;
}

int main(){
	int n, m, a[1002][max];
	struct trip b[max];
	//int i;n = 10;
	
	/*f(5, n)p("fuck");
	for(int i = 5;i < n;i++)printf("fuck\n");*/
	
	while(scanf("%d %d", &n, &m) && n != 0 && m != 0){
		for(int i = 0;i < m;i++)b[i].p = 0, b[i].s = i + 1;
		for(int i = 0;i < n;i++)
			for(int j = 0;j < m;j++)scanf("%d", &a[i][j]);
		for(int i = 0;i < m;i++)
			for(int j = 0;j < n;j++)b[i].p += a[j][i];
		//for(int i = 0;i < m;i++)printf("%d ", b[i].s);
		MergeSort(b, 0, m);
		//printf("   m == %d\n", m);
		for(int i = 0;i < m - 1;i++)printf("%d ", b[i].s);
		printf("%d\n", b[m - 1].s);
	}
	return 0;
}

/*
4 6
 1 0 1 0 1 1
1 1 0 1 0 0
 1 1 1 0 0 0
 1 0 1 0 1 0
*/

Measured memory_bytes: 2972
#include<bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define fr first
#define sc second
#define sz size()
#define smin(x,y) ((x)=min((x),(y)))
#define smax(x,y) ((x)=max((x),(y)))
#define all(x) x.begin(),x.end()
#define CS ios_base::sync_with_stdio(false);
#define show(x) cerr << #x << " is " << x <<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi; 
const int M=2e5+5;
int a[M];
int ans[M];
int32_t main()
{
	int n; cin>>n;
	string s; cin>>s;
	for(int i=0;i<n;i++) if(s[i]=='o') a[i]=0; else a[i]=1;
	for(int mask=0;mask<4;mask++){
		for(int j=0;j<2;j++) ans[j] = (int)((mask)&(1<<j)) ? 1 : 0;
		for(int k=1;k<n-1;k++)
			ans[k+1] = (int)(ans[k]^a[k]^ans[k-1]);
		if( (int)(ans[n-1]^ans[1]^a[0]^ans[0]) | 
			(int)(ans[n-2]^ans[0]^a[n-1]^ans[n-1])
		) continue;
		for(int i=0;i<n;i++) if(ans[i]) cout<<"W"; else cout<<"S"; 
		cout<<endl;
		return 0;
	}
	return cout<<-1<<endl,0;
}


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    string s;
    cin>>s;
    if(((s.find("N") == std::string::npos) == (s.find("S") == string::npos)) && ((s.find("E") == string::npos) ==(s.find("W") == string::npos))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

using namespace std;


void solve() {
    int N, R; cin >> N >> R;
    int ans;
    if (N >= 10) ans = R;
    else ans = R + 100 * (10 - N);

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
my $input = <stdin>;
chomp($input);
my ($n, $m) = split(' ', $input);

my $x =
    $n == $m ? 2:
    abs($n - $m) == 1 ? 1:
    0;

my $mod = 10 ** 9 + 7;
sub fact {
    my $r = 1;
    $r = ($r * $_) % $mod for (2..$_[0]);
    return $r;
}

print ($x == 0 ? 0 : (fact($n) * fact($m) * $x) % $mod);

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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

int main(void)
{
	string s;
	cin >> s;
	int n = s.size();
	vector<int> dist(n, -10);

	for (int i = 0; i < n; i++) {
		int j = i;
		while (s[j] == 'R') {
			j++;
		}
		while (j != i) {
			dist[i] = j;
			i++;
		}
	}
	for (int i = n-1; i >= 0; i--) {
		int j = i;
		while (s[j] == 'L') {
			j--;
		}
		while (j != i) {
			dist[i] = j;
			i--;
		}
	}
	vector<int> c(n, 0);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			auto d = dist[i];
			if (((d - i) % 2) == 0) c[d]++;
			else c[d - 1]++;
		}
		else 
		{
			auto d = dist[i];
			if (((d - i) % 2) == 0) c[d]++;
			else c[d + 1]++;
		}
	}
	for (auto e : c) {
		cout << e << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1408
def main():
    n = int(input())
    s = input()
    t = input()
    mod = 10 ** 9 + 7

    p = {"||": 2, "==": 3, "|=": 2, "=|": 1, "|": 3, "=": 6}
    ans = 1
    bf = ""
    it = iter(range(n))
    for i in it:
        if s[i] == t[i]:
            nw = "|"
        else:
            nw = "="
            it.__next__()

        ans *= p[bf + nw]
        bf = nw

    print(ans % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from heapq import heappush, heappop

def dijkstra(edges, size, source):
    distance = [float('inf')] * size
    distance[source] = 0
    visited = [False] * size
    pq = []
    heappush(pq, (0, source))
    while pq:
        dist_v, v = heappop(pq)
        visited[v] = True
        for u, weight in edges[v]:
            if not visited[u]:
                new_dist = dist_v + weight
                if distance[u] > new_dist:
                    distance[u] = new_dist
                    heappush(pq, (new_dist, u))
    return distance

N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    G[a].append((b, c))
    G[b].append((a, c))
Q, K = map(int, input().split())
dist = dijkstra(G, N+1, K)
for _ in range(Q):
    x, y = map(int, input().split())
    print(dist[x] + dist[y])

Measured memory_bytes: 93344
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int h,w,a[505][505];
bool o=false;
vector<P>ans;
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]%2)o=true;
        }
    }
    if(!o){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                if(a[i][j]%2==1){
                    if(j+1<w){
                        ans.PB(P(i+1,j+1));
                        ans.PB(P(i+1,j+2));
                        a[i][j+1]++;
                    }else if(i+1<h){
                        ans.PB(P(i+1,j+1));
                        ans.PB(P(i+2,w));
                        a[i+1][j]++;
                    }
                }
            }
        }else{
            for(int j=w-1;j>=0;j--){
                if(a[i][j]%2==1){
                    if(j-1>=0){
                        ans.PB(P(i+1,j+1));
                        ans.PB(P(i+1,j));
                        a[i][j-1]++;
                    }else if(i+1<h){
                        ans.PB(P(i+1,j+1));
                        ans.PB(P(i+2,1));
                        a[i+1][0]++;
                    }
                }
            }
        }
    }
    cout<<ans.size()/2<<endl;
    for(int i=0;i<ans.size();i+=2){
        cout<<ans[i].F<<' '<<ans[i].S<<' '<<ans[i+1].F<<' '<<ans[i+1].S<<endl;
    }
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

ull p = 1000000007ull;
signed main(){
  int n, m; cin >> n >> m;
  string s; cin >> s;
  vector<ull> hash(n+1), pow(n+1);
  hash[0] = 0;
  pow[0] = 1;
  rep(i, n){
    hash[i+1] = hash[i] * p + s[i];
    pow[i+1] = pow[i] * p;
  }
  set<ull> res;

  int l = 0, r = 1;
  rep(i,m){
    string q; cin >> q;
    if(q == "R++") r++;
    if(q == "R--") r--;
    if(q == "L++") l++;
    if(q == "L--") l--;
    res.insert(hash[r] - hash[l] * pow[r - l]);
  }
  cout << res.size() << endl;
}

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

int main(void) {
    int N,K,Q;cin>>N>>K>>Q;
    map<int, int> mp;
    for (int i = 1; i <= N; i++) mp[i] = 0;
    for (int i = 1; i <= Q; i++) {
        int A;cin>>A;
        mp[A] += 1;
    }
    // 結果出力
    for (int i = 1; i <= N; i++) {
        if (K - Q + mp[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

int main() {

    int a,b;
    cin >> a >> b;

    if(a+b > a-b && a+b > a*b){
        cout << a+b << endl;
    }else if(a-b > a*b){
        cout << a-b << endl;
    }else cout << a*b << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

#define MOD 1000000007

int main(){
	long long n,m,X=0,Y=0;
	scanf("%lld%lld",&n,&m);
	for(long long i=1;i<=n;i++){
		long long x;
		scanf("%lld",&x);
		X+=x*(i-1)-x*(n-i);
		X%=MOD;
	}
	for(long long i=1;i<=m;i++){
		long long y;
		scanf("%lld",&y);
		Y+=y*(i-1)-y*(m-i);
		Y%=MOD;
	}
	printf("%lld\n",(X*Y)%MOD);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl
#define P pair<lint,lint>

int main() {
	lint L, R, D;
	cin >> L >> R >> D;
	lint cnt = 0;
	for (lint i = L; i <= R; i++) {
		if (i % D == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

 using namespace std;

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

   vector<double> A(N);
   for (int i = 0; i < N; i++) {
     int tmp;
     cin >> tmp;
     A.at(i) = (double)(1.0 / tmp);
   }
   double div;

   for (int i = 0; i < N; i++) div += A.at(i);

   cout << fixed << setprecision(6) << (double)(1.0 / div) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <numeric>

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

using namespace std;

int n,k,a[500];

bool check(int d){
	int b[500];
	rep(i,n) b[i]=a[i]%d;
	sort(b,b+n);

	int sum=accumulate(b,b+n,0);
	return accumulate(b,b+n-sum/d,0)<=k;
}

int main(){
	scanf("%d%d",&n,&k);
	rep(i,n) scanf("%d",&a[i]);

	int ans=0,sum=accumulate(a,a+n,0);
	for(int d=1;d*d<=sum;d++) if(sum%d==0) {
		if(check(  d  )) ans=max(ans,  d  );
		if(check(sum/d)) ans=max(ans,sum/d);
	}
	printf("%d\n",ans);

	return 0;
}


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


int main(void){

int a,b,c,anser;
anser = 0;
cin >> a >> b>>c;

for(int i = 0; a <= b; i++)
{
    
    if(c%a ==0)
    {
        anser++;
    }
    a += 1 ;
}
 cout << anser << endl;
}


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

int main() {
  int n;
  cin >> n;
  n++;
  ll nnum = 1;
  ll fsum = 0;
  ll sum = 0;
  bool exist = true;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    fsum += a[i];
  }
  rep(i, n) {
    if (!exist) continue;
    sum += nnum;
    nnum -= a[i];
    if (nnum < 0) exist = false;
    fsum -= a[i];
    if (nnum * 2 <= fsum)
      nnum *= 2;
    else
      nnum = fsum;
  }
  if (!exist)
    cout << -1 << endl;
  else
    cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
#define WHITE 0
#define GRAY 1
typedef long long LL;
const int MAXN = 60;
int w,h,ans, mapp[MAXN][MAXN], color[MAXN][MAXN];
vector<int> v_ans;

void dfs_visit(int u,int k) {

	color[u][k] = GRAY;//参照したことを示す


	if(mapp[u][k + 1] == 1 && color[u][k + 1] == WHITE) {//右
		dfs_visit(u,k + 1);
	}

	if(mapp[u + 1][k + 1] == 1 && color[u + 1][k + 1] == WHITE) {//右下
		dfs_visit(u + 1,k + 1);
	}

	if(mapp[u + 1][k] == 1 && color[u + 1][k] == WHITE) {//下
		dfs_visit(u + 1,k);
	}

    if(k > 0){
        if(mapp[u + 1][k - 1] == 1 && color[u + 1][k - 1] == WHITE) {// 左下
            dfs_visit(u + 1,k - 1);
        }
    }

    if(k > 0){
        if(mapp[u][k - 1] == 1 && color[u][k - 1] == WHITE) {// 左
            dfs_visit(u,k - 1);
        }
    }

    if(u > 0){
        if(mapp[u - 1][k] == 1 && color[u - 1][k] == WHITE) {// 上
            dfs_visit(u - 1,k);
        }
    }

    if(u > 0){
        if(mapp[u - 1][k + 1] == 1 && color[u - 1][k + 1] == WHITE) {// 右上
            dfs_visit(u - 1,k + 1);
        }
    }

    if(u > 0 && k > 0){
        if(mapp[u - 1][k - 1] == 1 && color[u - 1][k - 1] == WHITE) {// 左上
            dfs_visit(u - 1,k - 1);
        }
    }


}

void dfs() {
    int ans = 0;
	for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++){
            if(mapp[i][j] == 1 && color[i][j] == WHITE ) {//未探訪の島なら探索

                dfs_visit(i,j);
                ans += 1;
            }
        }

	}

	v_ans.push_back(ans);

}

int main() {

    while(1){
        memset(mapp, 0, sizeof(mapp));//木情報をリセット
        memset(color, 0, sizeof(color));//探訪情報をリセット
        cin >> w >> h;
        if(w == 0) break;
        for(int i = 0; i < h; i++){

            for(int j = 0; j < w; j++){
                cin >> mapp[i][j];
            }

        }
        dfs();
    }
    rep(i,v_ans.size()) cout <<v_ans[i] <<endl;
	return 0;
}




Measured memory_bytes: 3300
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;

vector<int>v;
priority_queue<int>que;
vector<int>A, B, C;
int X, Y, Z, K;
vector<int>v1,v2,v3;
void solve() {
	REP(i, X)REP(j, 70)REP(k, 70) {
		v1.pb(A[i] + B[j] + C[k]);
	}
	REP(i, 70)REP(j, Y)REP(k, 70) {
		v2.pb(A[i] + B[j] + C[k]);
	}
	REP(i, 70)REP(j, 70)REP(k, Z) {
		v3.pb(A[i] + B[j] + C[k]);
	}
	VSORT(v1); VREVERSE(v1);
	VSORT(v2); VREVERSE(v2);
	VSORT(v3); VREVERSE(v3);
	if (v1[K - 1] > v2[K - 1] && v1[K - 1] > v3[K - 1]) {
		REP(i, K)print(v1[i]);
	}
	else if (v2[K - 1] > v3[K - 1]) {
		REP(i, K)print(v2[i]);
	}
	else REP(i, K)print(v3[i]);
	/*if (A[99] >= B[99] && A[99] >= C[99]) {
		REP(i, X)REP(j, 100)REP(k, 100) {
			que.push(A[i] + B[j] + C[k]);
		}
	}
	else if (B[99] >= C[99]) {
		REP(i, 100)REP(j, Y)REP(k, 100) {
			que.push(A[i] + B[j] + C[k]);
		}
	}
	else {
		REP(i, 100)REP(j, 100)REP(k, Z) {
			que.push(A[i] + B[j] + C[k]);
		}
	}
	REP(i, K) {
		print(que.top()); que.pop();
	}*/
}
signed main() {
	 cin >> X >> Y >> Z >> K;
	A.resize(X); B.resize(Y); C.resize(Z);
	REP(i, X)cin >> A[i];
	REP(i, Y)cin >> B[i];
	REP(i, Z)cin >> C[i];
	VSORT(A); VREVERSE(A);
	VSORT(B); VREVERSE(B);
	VSORT(C); VREVERSE(C);
	if (X <= 100 || Y <= 100 || Z <= 100) {
		REP(i, X) {
			REP(j, Y) {
				REP(k, Z) {
					que.push(A[i] + B[j] + C[k]);
				}
			}
		}
		REP(i, K) {
			print(que.top()); que.pop();
		}
	}
	//全部100個以上ある場合、二種類は必ず上位60個以内に収まる
	else {
		solve();
	}
}

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

string s;
int k;
set<string> hav;
vector<string> table;

int main()
{
    cin >> s;
    cin >> k;
    for(int i=0;i<s.length();++i)
    {
        table.push_back(string(s,i,s.length()-i));
    }
    sort(table.begin(),table.end());
    // for(auto i : table)cout << i << endl;
    int cnt=0,now=0,index=0;
    while(cnt<k)
    {
        if(now==table[index].length()){
        now=0;
        ++index;
        }
        ++now;
        if(hav.find(string(table[index],0,now))==hav.end())
        {hav.insert(string(table[index],0,now));       ++cnt;
        }
    }
    // cout << table[k-1];
    cout << string(table[index],0,now);
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define watch(x) cout<<"->"<<#x<<": "<<x<<endl;
// #define int long long
const int INF = 1000000000;
const int MOD = 1000000007;
const long long INFLL = 1e18;
const double PI = 2*acos(0.0);
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	string res="";
	for(int i=0;i<n;i++)
		if(s[i]!=res.back())
			res+=s[i];
	cout<<res.size()<<endl;
	return 0;	
}

Measured memory_bytes: 592
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;
	if (s.size() >= 4 && s.substr(0, 4) == "YAKI")
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 764
import java.util.*;
public class Main {



    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();

        int ans = 0;
        for (int i = 0; i < S.length(); i++) {
            if(S.charAt(i)!=T.charAt(i)) ans++;
        }


        System.out.println(ans);


    }

}


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> h(n);
    for (size_t i = 0; i < n; i++) cin >> h[i];

    vector<int> ans(n);
    ans[n-1] = 0;
    for (int i = n-2; i >= 0; i--) {
        if (h[i] >= h[i+1]) ans[i] = ans[i+1] + 1;
        else ans[i] = 0;
    }

    cout << *max_element(ans.begin(), ans.end()) << endl;
    return 0;
}


Measured memory_bytes: 4064
object Main extends App {
  override def main(args: Array[String]): Unit = {
    import scala.io.{StdIn => in}
    Iterator
      .continually(in.readLine())
      .takeWhile(_ != "0 0")
      .map(str =>
        for (x <- 1 to str.split(" ")(0).toInt) yield in.readLine()
      ).map(solve).foreach(println)
  }

  def solve(input: Seq[String]): String = {
    val list = makeString(toArray(input)).sorted
    val ans = list.zip(list.drop(1)).map(s => getDuplicate(s._1, s._2)).max(new StringComparator)
    if (ans.size < 2) "0" else ans
  }

  class StringComparator extends Ordering[String] {
    override def compare(x: String, y: String) = {
      if (x.length != y.length) {
        x.length.compare(y.length)
      } else {
        y.compareTo(x)
      }
    }
  }

  def toArray(input: Seq[String]): Array[Array[Char]] = {
    val h = input.size
    val w = input(0).size
    val ret = Array.ofDim[Char](h, w)
    for (i <- 0 until h; j <- 0 until w) {
      ret(i)(j) = input(i)(j)
    }
    ret
  }

  def makeString(arr: Array[Array[Char]]): Seq[String] = {
    val h = arr.size
    val w = arr(0).size
    val direction = List((0, 1), (1, 0), (-1, 0), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1))
    for (starti <- 0 until h; startj <- 0 until w; d <- direction) yield {
      arr(starti)(startj) + Iterator
        .iterate(((starti + d._1 + h) % h, (startj + d._2 + w) % w))(pos => ((pos._1 + d._1 + h) % h, (pos._2 + d._2 + w) % w))
        .takeWhile(_ != (starti, startj))
        .map(pos => arr(pos._1)(pos._2))
        .mkString("")
    }
  }

  def getDuplicate(str1: String, str2: String): String = {
    str1.zip(str2).takeWhile(c => c._1 == c._2).map(_._1).mkString("")
  }
}

Measured memory_bytes: 273256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n;
    cin >> n;
    vector<int> s(1 << n);
    for (int i = 0; i < (1 << n); i++) {
        cin >> s[i];
    }
    sort(all(s));  reverse(all(s));

    vector<int> t(1 << n, -1);
    /*
    int i = 0;
    u.push_back(n);
    while (u.size() != i) {
        for (int j = 0; j < u[i]; j++) {
            u.push_back(u[i] - j - 1);
        }
        i++;
    }
    int l = 0, k = 1;
    for (int i = 0; i < n; i++) {
        sort(u.begin() + l, u.begin() + l + k);
        reverse(u.begin() + l, u.begin() + l + k);
        l += k;
        k = k * (n - i) / (i + 1);
    }*/
    /*for (auto i : u) cout << i << " ";
    cout << endl;*/

    priority_queue<int> pq;
    pq.push(n);

    int idx = 0, cap = 1;
    while (idx < (1 << n)) {
        ll sub = 0, sum = 0;
        vector<int> nxt;
        while (s[idx] == s[idx + sub]) {
            if (pq.empty()) {
                cout << "No" << endl;
                return 0;
            }
            sum += pq.top();
            nxt.push_back(pq.top());
            pq.pop();
            sub++;
        }
        for (auto i : nxt) {
            for (int j = 0; j < i; j++) {
                pq.push(j);
            }
        }
        idx += sub;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3576
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    m,k = LI()
    if k == 0:
        print(*[i>>1 for i in range(1<<(m+1))])
        return
    if 1<<m <= k or m == k == 1:
        print(-1)
    else:
        ans = [k]+[i for i in range(1<<m) if i != k]+[k]+[i for i in range(1<<m)[::-1] if i != k]
        print(*ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 67312
from collections import Counter
from functools import reduce
n=int(input())
l=[]

for j in range(2,n+1):
  b=j
  for i in range(2,j+1):
    while not b%i:
      l.extend([i])
      b//=i
o=Counter(l)
p=int(1e9+7)
if n!=1:
  v=reduce(lambda x,y:x*y,map(lambda x:x+1,o.values()))%p
else:
  v=1
print(v)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<61);

int main() {
  ll n, ans = 1;
  cin >> n;
  vl t(n), a(n); ina(t,n); ina(a,n);
  vl mns(n,1), mxs(n,INFL);
  mns[0] = mxs[0] = t[0];
  REP(i,1,n) {
    if (t[i] != t[i-1]) {
      mxs[i] = mns[i] = t[i];
    } else {
      mxs[i] = t[i];
    }
  }
  
  if (a[n-1] < mns[n-1] || a[n-1] > mxs[n-1]) {
    cout << 0 << endl;
    return 0;
  }

  mns[n-1] = mxs[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) {
    if (a[i] != a[i+1]) {
      if (mns[i] <= a[i] && a[i] <= mxs[i]) {
          mns[i] = mxs[i] = a[i];
      } else {
        ans = 0;
      }
    } else {
      mxs[i] = min(mxs[i], a[i]);
    }
  }
  outa(mxs, n);
  outa(mns, n);
  rep(i,n) {
    ans *= (mxs[i] - mns[i] + 1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>

using namespace std;

void Solution()
{
    int n;
    
    cin>>n;
    
    cout<<n * n * n<<endl;
}



int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main() {
    int r, c, s[101][101], ans;
    cin >> r >> c;
    
    for (auto i = 0; i < r; i++) for (auto j = 0; j < c; j++) cin >> s[i][j];

    for (auto i = 0; i < r; i++) {
        ans = 0;
        for (auto j = 0; j < c+1; j++){
            if (j == c) s[i][j] = ans;
            else ans += s[i][j];
        }
    }
    
    for (auto i = 0; i < c+1; i++) {
        ans = 0;
        for (auto j = 0; j < r+1; j++){
            if (j == r) s[j][i] = ans;
            else ans += s[j][i];
        }
    }
    
    for (auto i = 0; i < r+1; i++) {
        for (auto j = 0; j < c+1; j++) {
            if (j == c) cout << s[i][j];
            else cout << s[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
     
    int main(void) {
        int a[10000];
    	int n,k;
    	int count = 0;
    	scanf("%d",&n);
    	for(int i = 0; i < n ; i++)
    		scanf("%d",&a[i]);
    	for(int i = 0; i < n ; i++) {
        while (a[i]%2==0){
        a[i]=a[i]/2;
        count+=1;
        }
    }
    printf("%d",count);
    return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
using Graph = vector<vector<int>>;
typedef long long int ll;


int main(){
    ll n,ans=0;
    cin >> n;
    for(int i=(int)sqrt(n);i>=1;i--){
        if(n%i==0){
            ans=i+n/i-2;
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-17 14:31:56
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 3000+5;
int ha;
int n;
int S[MAXN][MAXN],fac[MAXN],inv[MAXN],facfac[MAXN];

inline int qpow(int a,int n=ha-2,int mod=ha){
    int res = 1;
    while(n){
        if(n & 1) res = 1ll*res*a%mod;
        a = 1ll*a*a%mod;
        n >>= 1;
    }
    return res;
}

inline void prework(){
    fac[0] = 1;
    FOR(i,1,MAXN-1) fac[i] = 1ll*fac[i-1]*i%ha;
    inv[MAXN-1] = qpow(fac[MAXN-1]);
    ROF(i,MAXN-2,0) inv[i] = 1ll*inv[i+1]*(i+1)%ha;
    S[0][0] = 1;
    FOR(i,1,MAXN-1){
//        S[i][0] = 1;
        FOR(j,1,i){
            S[i][j] = (S[i-1][j-1]+1ll*j*S[i-1][j]%ha)%ha;
        }
    }
    FOR(i,0,MAXN-1) facfac[i] = qpow(2,qpow(2,i,ha-1));
}

inline int C(int n,int m){
    return 1ll*fac[n]*inv[m]%ha*inv[n-m]%ha;
}

int main(){
    scanf("%d%d",&n,&ha);
    prework();int ans = facfac[n];
    FOR(i,1,n){
        int gx = 0,t1 = 1,b1 = qpow(2,n-i);
        FOR(j,0,i){
            //(gx += 1ll*qpow(2,qpow(2,n-i,ha-1))*qpow(qpow(2,n-i),j)%ha*S[i+1][j+1]%ha) %= ha;
            (gx += 1ll*facfac[n-i]*t1%ha*S[i+1][j+1]%ha) %= ha;
            t1 = 1ll*t1*b1%ha;
        }
        gx = 1ll*gx*C(n,i)%ha;
        if(i&1) gx = ha-gx;
        (ans += gx) %= ha;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 34304
#include <iostream>
#include <algorithm>
#include <cmath>
#define N 100000
using namespace std;

int main() {
        int n, h;
        cin >> n >> h;
        int a = 1, b[N];

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

        int att = 0, thr = 0;
        while (h > 0) {
                if (thr == n || a >= b[thr]) {
                        att += ceil(h / (double)a);
                        break;
                } else {
                        h -= b[thr++];
                        att++;
                }
        }
        cout << att << endl;
        return 0;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll tmp = 0;
    rep(i, 0, n){
        cin >> a[i];
        if(i == 0) tmp = a[0];
        else tmp = a[i] - tmp;
    }
    cout << tmp;
    rep(i, 1, n){
        cout << ' ' << 2 * a[i - 1] - tmp;
        tmp = 2 * a[i - 1] - tmp;
    }
}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int H, W;
char grid[MAX][MAX];

int main() {
  // 入力
  cin >> H >> W;
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> grid[i][j];
    }
  }

  bool ans = true;
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (grid[i][j] == '.') continue;

      bool flag = false;
      for (int k = 0; k < 4; k++) {
        int nx = j + dx[k];
        int ny = i + dy[k];
        if (grid[ny][nx] == '#') flag = true;
      }

      if (!flag) ans = false;
    }
  }

  // 解答
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <functional>
#include <ios>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
const ll InF = 1e15;

int main() {
  int n,max1_val,max2_val;
  cin>>n;
  vector<int> flag1(1e5 + 1),flag2(1e5 + 1);
  max1_val = max2_val = 0;
  int max1_1,max1_2,max2_1,max2_2;
  max1_1 = max1_2 = max2_1 = max2_2 = 0;
  for (int i = 0; i < n; i++) {
    int v; cin>>v;
    if (i % 2 == 0) {
      flag1[v]++;
      if (flag1[v] > max1_1) {
        max1_val = v;
        max1_1 = flag1[v];
      } else if (flag1[v] > max1_2) max1_2 = flag1[v];
    } else {
      flag2[v]++;
      if (flag2[v] > max2_1) {
        max2_val = v;
        max2_1 = flag2[v];
      } else if (flag2[v] > max2_2) max2_2 = flag2[v];
    }
  }
  int ans = 0;
  if (max1_val != max2_val) ans = n - max1_1 - max2_1;
  else ans = min(n - max1_2 - max2_1, n - max1_1 - max2_2);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

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

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	s := make([][]byte, H)
	for i := 0; i < H; i++ {
		var line string
		fmt.Scan(&line)
		s[i] = []byte(line)
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == '.' {
				continue
			}
			var find bool
			for d := 0; d < 4; d++ {
				ny := i + dy[d]
				nx := j + dx[d]
				if ny < 0 || ny >= H || nx < 0 || nx >= W {
					continue
				}
				if s[i][j] == s[ny][nx] {
					find = true
				}
			}
			if !find {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll N;cin>>N;
    cout<<N*(N-1)/2<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b;
    cin >> a >> b;
    int x,y;
    cin >> x >> y;
    string c;
    cin >> c;
    if (a==c) x--;
    else y--;

    cout << x << " " << y << endl;
}




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

int main(){
    string s;
    string ans = "";
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        switch (s[i]) {
            case '0':
                ans.push_back('0');
                break;
            case '1':
                ans.push_back('1');
                break;
            case 'B':
                if(ans != ""){
                    ans.pop_back();
                }
                break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
var a:array[0..250,0..250]of int64;
    v:array[0..50]of boolean;
    i,j,k:longint;
    n,m,r:longint;
    x,y,z:longint;
    go:array[0..50]of longint;
    ans:int64;
procedure dfs(dep,last:longint;sum:int64);
var i:longint;
begin
  if sum>=ans then exit;
  if dep=r then
  begin
    if sum<ans then ans:=sum;
    exit;
  end;
  for i:=1 to r do
  if not v[i] then
  begin
    v[i]:=true;
    dfs(dep+1,i,sum+a[go[last],go[i]]);
    v[i]:=false;
  end;
end;
begin
  read(n,m,r);
  for i:=1 to n do
  for j:=1 to n do
  a[i,j]:=maxlongint;
  for i:=1 to n do
  begin
    a[0,i]:=0;
    a[i,0]:=0;
  end;
  for i:=1 to r do
  read(go[i]);
  for i:=1 to m do
  begin
    read(x,y,z);
    a[x,y]:=z;
    a[y,x]:=z;
  end;
  ans:=maxlongint;
  for k:=1 to n do
  for i:=1 to n do
  for j:=1 to n do
  if a[i,k]+a[j,k]<a[i,j] then a[i,j]:=a[i,k]+a[j,k];
  dfs(0,0,0);
  writeln(ans);
end.


Measured memory_bytes: 512
#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)

int main() {
	int d,c[27],s[366][27]={0},t[366],last[27]={0},sat=0;
	scanf("%d",&d);
	rep(i,26)scanf("%d",c+i+1);
	rep(i,d)rep(j,26)scanf("%d",&s[i+1][j+1]);
	
	rep(i,d){
		int ms=1,mt=1;
		rep(j,26)if(s[i+1][j]>ms){mt=j;ms=s[i+1][j];}
		t[i+1]=mt;
	}

	int x=100000;
	while(x--){
		int a=rand()%365+1,b=rand()%365+1,satt=0,tmp;
		tmp=t[a];t[a]=t[b];t[b]=tmp;
		rep(i,d){
			satt+=s[i+1][t[i+1]];
			last[t[i+1]]=i+1;
			rep(j,26)satt-=c[j+1]*(i+1-last[j+1]);
		}
		if(satt>sat)sat=satt;
		else {tmp=t[a];t[a]=t[b];t[b]=tmp;}
	}
	rep(i,d)printf("%d\n",t[i+1]);
}

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

char kati(char a)
{
    if (a == 'r')
    {
        return 'p';
    }

    if (a == 'p')
    {
        return 's';
    }

    if (a == 's')
    {
        return 'r';
    }
}

int R, S, P;

int katitoku(char a)
{
    if (a == 'r')
    {
        return R;
    }

    if (a == 'p')
    {
        return P;
    }

    if (a == 's')
    {
        return S;
    }   
}



int main()
{
    int N, K;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    int ans = 0;

    for (int i = 0; i < T.size(); i++)
    {
        T.at(i) = kati(T.at(i));
        ans += katitoku(T.at(i));
    }
    
    for (int i = K; i < T.size(); i++)
    {
        if (T.at(i) == T.at(i-K))
        {
            ans -= katitoku(T.at(i));
            T.at(i) = 'z';
        }
        
    }

    cout << ans;
    
}

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

typedef long long ll;
const int mod = 1e9 + 7;


int N;
int dp[101][4][4][4];

int main() {
    cin >> N;

    dp[0][3][3][3] = 1;
    for (int len = 0; len < N; len++) {
        for (int c1 = 0; c1 < 4; c1++) {
            for (int c2 = 0; c2 < 4; c2++) {
                for (int c3 = 0; c3 < 4; c3++) {
                    if (dp[len][c1][c2][c3] == 0) continue;

                    for (int a = 0; a < 4; a++) {
                        if (a == 2 && c1 == 1 && c2 == 0) continue;
                        if (a == 2 && c1 == 0 && c2 == 1) continue;
                        if (a == 1 && c1 == 2 && c2 == 0) continue;
                        if (a == 2 && c1 == 1 && c3 == 0) continue;
                        if (a == 2 && c2 == 1 && c3 == 0) continue;

                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int c1 = 0; c1 < 4; c1++) {
        for (int c2 = 0; c2 < 4; c2++) {
            for (int c3 = 0; c3 < 4; c3++) {
                ans += dp[N][c1][c2][c3];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<string, string> P;

int main(int argc, char *argv[])
{
  int sum=0;
  string s;
  cin >> s;
  for(int i=0;s.size()>i;i++){
    s[i]=='+' ? sum++ : sum--;
  }
  cout << sum << endl;
  return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> a, b;
  Solver(LL n) : n(n), a(n), b(n){};

  void solve() {
    vector<LL> cnta(29), cntb(29);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      for (int j = 0; j < 28; ++j) {
        cnta[j] += ((a[i] >> j) & 1);
      }
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i];
      for (int j = 0; j < 28; ++j) {
        cntb[j] += ((b[i] >> j) & 1);
      }
    }
    LL ans = 0;
    for (int i = 0; i < 29; ++i) {
      LL carry = calc_carry(i);
      DBG(i, carry)
      ans += (((carry + cnta[i] * (n - cntb[i]) + cntb[i] * (n - cnta[i])) % 2) << i);
    }
    cout << ans << endl;
  }
  LL calc_carry(int d) {
    if (d == 0) return 0;
    vector<int> A(n), B(n);
    for (int i = 0; i < n; ++i) {
      A[i] = a[i] % (1 << d);
      B[i] = b[i] % (1 << d);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    LL ret = 0;
    for (int i = 0; i < n; ++i) {
      ret += distance(lower_bound(B.begin(), B.end(), (1 << d) - A[i]), B.end());
    }
    return ret;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 5012