akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
int gcd(int x, int y)
{
    if(y==0)
        return x;
    return gcd(y, x%y);
}

 long long numbers[500005];

//int a[100005];

 int main(){

  long long a,b,c;
  cin>>a>>b>>c;

  if(a== b && b == c && a%2 == 0){
    cout<<"-1"<<endl;
    return 0;
  }

  long long cnt=0;

  while(a%2 == 0 && b%2 == 0&& c%2 == 0 ){
    long long A = a/2,B=b/2,C=c/2;
    a = B+C;
    b = A+C;
    c = A+B;
   cnt++;
  }

  cout<<cnt<<endl;

 return 0;
 }

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int ans = 0;
	
	int n;
	cin >> n;
	vector<int> a(n);
	for(int& x : a) cin >> x;
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			ans += a[i] * a[j];
		}
	}
	cout << ans << endl;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x,y,z;
  x = max(a,b) - min(a,b);
  y = max(a,c) - min(a,c);
  z = max(b,c) - min(b,c);
  
  if(y > d){
    if(x > d || z > d){
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else {
    cout << "Yes" << endl;
  }
}


  


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


int main( )
{
	int n;
	scanf("%d",&n);
	int flag=0;
	for(int i=1;i<=9;i++)
	{
		if((n%i)==0 && (n/i)<=9 && (n/i)>=1)
		{
			flag=1;
		}
	}
	if(flag)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, x;

    cin >> n;

    int num = 1;

    for(int i = 0; i < n; i++){
    	cin >> x;

    	if(x == num){
    		num++;
    	}
    }

   	int ans = n - (num-1);

   	if(ans == n)
   	cout << -1 << endl;
   	else
   	cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
AC=Counter(A)

goukei=sum(list(AC.values()))
shurui=len(AC.keys())
yobun=goukei-shurui
if yobun%2==0:
    print(shurui)
else:
    print(shurui-1)

Measured memory_bytes: 18656
#200404B
N, M = map(int, input().split())
A = list(map(int,input().split()))
B = sorted(A)
flag = 1
for i in range(M):
    #print(B[len(B)-i-1])
    #print(sum(A)/4/M)
    if B[len(B)-i-1] < sum(A)/4/M:
        flag = 0

if flag == 0:
    print('No')
else:
    print('Yes')

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

int search(vector<int> A, int n, int key){
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main(void){
    vector<int> A(10001);
    int n, q, key, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> A[i];
    cin >> q;
    for (int i = 0; i < q; i++){
        cin >> key;
        if (search(A, n, key))  sum++;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main( void ){
  //それぞれのマスをTRUEとしたときに、島が一つであるか
  //島が人である場合が存在　-> YES
    int n; cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    int first = a[n-1];
    int tmp;
    if(first % 2 == 0){
      tmp = first/2;
    }else{
      tmp = first/2 + 1;
    }
    int second = a[n-2];
    rep(i, n-2){
      if(abs(a[i]-tmp) < abs(second -tmp)){
        second = a[i];
      }
    }
    cout << first << " " << second << "\n";
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <queue>

#define INF 214748364000

using namespace std;

struct edge { int from,to,cost;};

int main(){
	int V,E,r,
	    s,t,d;
long long int score[100][100];
	vector<edge> G;
	bool nl=true;
	
	scanf("%d %d",&V,&E);
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			score[i][j] = INF;
		}
	}
	for(int i=0;i<E;i++){
		scanf("%d %d %d",&s,&t,&d);
		score[s][t] = d;
	}
	for(int i=0;i<V;i++) score[i][i] = 0;
	
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			for(int k=0;k<V;k++){
				if(score[j][i]!=INF && score[i][k]!=INF){
					score[j][k] = min(score[j][k],score[j][i] + score[i][k]);
				}
			}
		}
	}
	for(int i=0;i<V;i++){
		if(score[i][i]<0){
			nl=false;
			break;
		}
	}
	
	
	if(nl){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				if(score[i][j]==214748364000) printf("INF");
				else printf("%d",score[i][j]);
				if(j!=V-1) printf(" ");
			}
			printf("\n");
		}
	}
	else printf("NEGATIVE CYCLE\n");
		
	return 0;
}


Measured memory_bytes: 3272
#include <iostream>

using namespace std;

class priorityQueue {
private:
    long *queueArray;
    long size;
public:
    priorityQueue() {
        this->queueArray = new long[2000001];
        this->size = 0;
    }

    void insert(long num) {
        this->queueArray[size+1] = num;
        size++;
        heapfyInsert();
    }

    void clean(){
        delete[] this->queueArray;
        size=0;
    }

    long remove() {
        long max = queueArray[1];
        queueArray[1] = queueArray[size];
        size--;
        heapfyRemove();
        return max;
    }

    void heapfyInsert() {
        bool heap = false;
        long pos = size;
        while (!heap && pos > 1) {
            if (queueArray[pos] < queueArray[pos / 2]) {
                heap = true;
            } else {
                long aux = queueArray[pos];
                queueArray[pos] = queueArray[pos / 2];
                queueArray[pos / 2] = aux;
                pos = pos / 2;
            }
        }
    }

    void heapfyRemove() {
        bool heap = false;
        long pos = 1;
        long maxPos;
        while(!heap && pos < size) {
            if (pos * 2 <= size && queueArray[2 * pos] > queueArray[pos] && queueArray[2 * pos] > queueArray[2 * pos + 1]) {
                maxPos = 2 * pos;
            }else if(pos * 2 + 1 <= size && queueArray[2 * pos + 1] > queueArray[pos]){
                maxPos = 2*pos+1;
            }else{
                maxPos = pos;
            }
            if(maxPos != pos) {
                long aux = queueArray[pos];
                queueArray[pos] = queueArray[maxPos];
                queueArray[maxPos] = aux;
                pos = maxPos;
            }else{
                heap = true;
            }
        }
    }
};


int main() {
    auto heap = new priorityQueue();
    string operation;
    long n;
    while (cin >> operation && operation != "end") {
        if (operation == "insert") {
            cin >> n;
            heap->insert(n);
        } else {
            long aux = heap->remove();
            cout << aux << endl;
        }
    }
    heap->clean();
    delete heap;
    return 0;
}


Measured memory_bytes: 10800
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;
  vector<long long> A(N + 1, 0), B(M + 1, 0);
  copy_n(istream_iterator<long long>(cin), N, next(begin(A)));
  copy_n(istream_iterator<long long>(cin), M, next(begin(B)));
  partial_sum(cbegin(A), cend(A), begin(A));
  partial_sum(cbegin(B), cend(B), begin(B));
  iterator_traits<decltype(B)::const_iterator>::difference_type ans = 0;
  auto last = upper_bound(cbegin(A), cend(A), K);
  for (auto iterA = cbegin(A); iterA != last; ++iterA) {
    ans = max(ans, distance(cbegin(A), iterA) +
                       distance(cbegin(B),
                                upper_bound(cbegin(B), cend(B), K - *iterA)) -
                       1);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 6328
#include<stdio.h>
#include<string.h>
 
int main(){
 
  char S[51];
  char T[51];
  scanf("%s %s",S,T);
 
  int Slen;
  int Tlen;
  int i;
  int j;
  int flag=0;
  int n = 0;
  Slen = strlen(S);
  Tlen = strlen(T);
  for(i = Slen - Tlen; i >= 0 ; --i){
    n = 0;
    for(j = 0; j < Tlen; ++j){
      if( (S[i+j] != T[j]) && (S[i+j] != '?') )
        n = 1;
    }
 
    if(n == 0){
      flag = 1;
      for(j = 0; j < Tlen; ++j){
        if(S[i+j] == '?'){
          S[i+j] = T[j];
        }
      }
      break;
    }
  }
 
  if( flag == 0 ){
    printf("UNRESTORABLE\n");
    return 0;
  }
 
  for(i = 0; i < Slen; ++i){
    if(S[i] == '?') S[i] = 'a';
  }
  printf("%s\n",S);
  return 0;
}

Measured memory_bytes: 128
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    char ch;
    cin>>ch;
    printf("%c",ch+1);
   
End;
}


Measured memory_bytes: 3652
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

n,X,Y,Z=MI()
t=1<<(X+Y+Z)
haiku=( (1<<(X+Y+Z)) + (1<<(Y+Z)) + (1<<Z) )>>1
dp=[[0]*t for _ in range(n+1)]
dp[0][0]=1

for i in range(n):
    for k in range(t):
        for d in range(10):
            m=((k<<(d+1))+(1<<d))
            if m&haiku == haiku:
                continue
            else:
                dp[i+1][int(m)%t]+=dp[i][k]
                dp[i+1][int(m)%t]%=mo
sub=0
for i in range(t):
    sub+=dp[n][i]
ans=pow(10,n,mo)-sub
print(ans%mo)

Measured memory_bytes: 86364
#include<stdio.h>
int main() {
	int i, N, A[101], B[101], sum = 0;
	scanf("%d", &N);
	for (i = 0; i < N - 1; i++)
		scanf("%d", &B[i]);
	A[0] = B[0];
	A[N - 1] = B[N - 2];
	for (i = 0; i < N - 2; i++) {
		if (B[i] > B[i + 1])
			A[i + 1] = B[i + 1];
		else
			A[i + 1] = B[i];
	}
	for (i = 0; i < N; i++) {
		sum += A[i];
	}
	printf("%d", sum);
	return 0;
}







Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

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

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

// a と b の最大公約数を返す関数
ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

const int MAX = 1000010;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

long long POWN(int x, ll y){
  ll tmp = 1;
  rep(i,y){
    tmp *= x;
    tmp %= MOD;
  }
  return tmp;
}

int main() {
  ll N;
  cin >> N;
  ll x[200010];
  ll y[200010];
  
  rep(i,N){
    cin >> x[i] >> y[i];
  }
  
  ll xmax = x[0]-y[0];
  ll xmin = x[0]-y[0];
  ll ymax = x[0]+y[0];
  ll ymin = x[0]+y[0];
  
  
  rep(i,N-1){
    ll tmp1 = x[i+1]-y[i+1];
    ll tmp2 = x[i+1]+y[i+1];
    
    xmax = max(xmax, tmp1);
    xmin = min(xmin, tmp1);
    ymax = max(ymax, tmp2);
    ymin = min(ymin, tmp2);
  
  }
  
  ll ans = max(xmax-xmin, ymax-ymin);
  
  cout << ans << endl;

}

Measured memory_bytes: 6744
S=input()
a=[]
b=[]
s=list(S)
flag=True
for i in range(len(S)):
   
    if flag:
        a.append('0')
        b.append('1')
        flag=False
    else:
        a.append('1')
        b.append('0')
        flag=True
    
a_count=0
b_count=0
for i in range(len(s)):
    if s[i]==a[i]:
        a_count+=1
    if s[i]==b[i]:
        b_count+=1
print(min(a_count,b_count))

Measured memory_bytes: 5620
#include "bits/stdc++.h"
using namespace std;


bool ok(vector< int> xs, int start_x, int target) {
    set< int> s;
    s.emplace(start_x);

    for(int d: xs) {
        set< int> tmp;
        for(int x: s) {
            tmp.emplace(x + d);
            tmp.emplace(x - d);
        }
        s = tmp;
    }
    return s.find(target) != s.end();
}

int main() {
    string s;
    int tx, ty;
    cin >> s >> tx >> ty;

    int start_x = 0;
    for(char c: s) {
        if(c == 'T') break;
        start_x++;
    }

    int d = 0;
    int total = 0;

    vector< int> xs, ys;
    s += "T";

    for(int i = start_x; i < (int) s.size(); i++) {
        char c = s[i];
        if(c == 'T') {
            if(d == 0 and total != 0) xs.emplace_back(total);
            if(d == 1 and total != 0) ys.emplace_back(total);
            total = 0;
            d = 1 - d;
        }
        else
            total ++;
    }

    if(ok(xs, start_x, tx) and ok(ys, 0, ty)) puts("Yes");
    else puts("No");
}

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

# define All(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using ull = unsigned long long;
using ld  = long double;


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll x;
    cin >> x;

    ll ans = 1000*(x/500);
    x %= 500;

    ans += 5*(x/5);

    cout << ans << endl;

    return 0;
}


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double student;
	int count[6];
	int n, i;
	
	for (i = 0; i < 6; i++){
		count[i] = 0;
	}
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%lf", &student);
		if (student < 165.0){
			count[0]++;
		}
		else if (student < 170.0){
			count[1]++;
		}
		else if (student < 175.0){
			count[2]++;
		}
		else if (student < 180.0){
			count[3]++;
		}
		else if (student < 185.0){
			count[4]++;
		}
		else {
			count[5]++;
		}
	}
	
	for (i = 1; i <= 6; i++){
		printf("%d:", i);
		while (count[i - 1] > 0){
			printf("*");
			count[i - 1]--;
		}
		printf("\n");
	}
	
	return (0);
	
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = a; i < n; ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int n;
int x[500010];

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

    cin >> n;
    REP(i, n) cin >> x[i];
    int z = 1;
    set<int> st;
    REP(i, n) {
        if (st.count(0) || x[i] < z - 1) {
            cout << "No" << endl;
            continue;
        }
        if (x[i] == z - 1 && st.size() != z - 1) {
            cout << "No" << endl;
            continue;
        }
        cout << "Yes" << endl;
        int cur = x[i];
        while (st.count(cur)) {
            st.erase(cur);
            --cur;
        }
        st.insert(cur);
        while (st.count(z)) ++z;
    }
}


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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
int n;
int a, b, c;

//function---------------------------------------------------------------------------------------------------------------------
int main() {
	scanf( "%d", &n );
	rep( i, n ) {
		scanf( "%d %d %d", &a, &b, &c);
		int ans = 0;
		while ( true ) {
			if ( a >= 1 && b >= 1 && c >= 1 ) {
				ans++;
				a--;
				b--;
				c--;
				continue;
			}
			if ( a >= 2 && b >= 1 ) {
				ans++;
				a -= 2;
				b--;
				continue;
			}
			if ( a >= 3 ) {
				ans++;
				a -= 3;
				continue;
			}
			break;
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vll A(N);
  rep(i, N) {
    cin >> A[i];
    A[i] -= i + 1;
  }
  
  //中央値を求める
  sort(all(A));
  ll mv;
  if(N%2==0) {
    mv = (ll)((double)(A[N/2-1] + A[N/2]) / 2 + 0.5);
  } else {
    mv = A[N/2];
  }
  
  ll v = 0;
  rep(i, N) {
    v += abs(A[i] - mv);
  }
  fin(v);
  
  
  // //Aの平均
  // ll asum = 0;
  // rep(i, N) asum += A[i];
  
  // asum /= N;
  
  // //Nだけループ
  // ll minv = LLINF;
  // for(int j=asum+N/2-100; j<=asum+N/2+100; j++) {
  //   ll s = 0;
  //   rep(i, N) {
  //     s += abs(A[i] - (j + i + 1));
  //   }
  //   chmin(minv, s);
  // }
  // fin(minv);
  
  // //傾きは，1で固定
  
  // //切片を求める
  // //平均
  // ll sumy = 0;
  // ll sumx = 0;
  // rep(i, N) {
  //   sumx += (i + 1);
  //   sumy += A[i];
  // }
  
  // //ll b = (sumy / N) - 1 * (sumx / N);
  // ll b = (sumy - sumx) / N;
  
  // //整数なので，bとb+1で調べる
  // ll diff1 = 0;
  // rep(i, N) {
  //   diff1 += abs(A[i] - (b + 1));
  // }
  
  // ll diff2 = 0;
  // rep(i, N) {
  //   diff2 += abs(A[i] - (b + 1 + 1));
  // }
  
  // if(diff1 < diff2) {
  //   fin(diff1); 
  // }else {
  //   fin(diff2);
  // }
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INF 100000000
typedef long long ll;

using namespace std;

ll n, s,ans=0;
vector<int> a, b, c;
ll sum[100000], sum2[100000], sum3[100000];;

int main()
{

    cin >> n;
    REP(i, n) {
        cin >> s;
        a.pb(s);
    }
    REP(i, n) {
        cin >> s;
        b.pb(s);
    }
    REP(i, n) {
        cin >> s;
        c.pb(s);
    }
    sort(all(a));sort(all(b));sort(all(c));
    int cnt = 0;
    REP(i, n) {
        while (true) {
            if(b[i]<c[cnt]){
                sum2[i] = n - cnt;
                break;
            }
            else {
                cnt++;
                if (cnt == n) {
                    i = n;
                    break;
                }
            }
        }
    }
    for(int i=n-1;i>=0;i--) {
        sum3[i] = sum2[i] + ((i == n - 1) ? 0 : sum3[i + 1]);
    }
    cnt = 0;
    REP(i, n) {
        while (true) {
            if (a[i]<b[cnt]) {
                sum[i] = sum3[cnt];
                break;
            }
            else {
                cnt++;
                if (cnt == n) {
                    i = n;
                    break;
                }
            }
        }
    }
    REP(i, n)ans += sum[i];
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3832
def solve():
    N, M = map(int, input().split())
    Count = [0] * (N + 1)
    for i in range(M):
        l, r = map(int, input().split())
        Count[l-1] += 1
        Count[r] -= 1
    ans = 0
    if Count[0] == M: ans = 1
    for i in range(1, N):
        Count[i] += Count[i-1]
        if Count[i] == M: ans += 1
    print(ans)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 12828
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
//#include <unordered_set>
//#include <unordered_map>
//#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    typename vector<T>::iterator it,endit=vec.end();
    os << "[";
    for(it=vec.begin();it!=endit;it++){
        os << " " << *it << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}



int main(){
	int n,a,b;
	int Pa,Pb;
	for(;;){
		n=input<int>();
		if(n==0)
			break;
		Pa=0,Pb=0;
		repeat(i,n){
		a=input<int>();b=input<int>();
		if(a>b)
			Pa+=a+b;
		else if(a==b){
			Pa+=a;Pb+=b;
		}else if(a<b)
			Pb+=a+b;
		}
		cout << Pa << " " << Pb << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long a,b,c,d,res,res1;
cin>>a>>b>>c>>d;
res=a*b;
res1=c*d;
if(res>=res1)
    cout<<res<<endl;
else
    cout<<res1<<endl;

    return 0;
}


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

long long gcd(long long a,long long b)
{
    if(b == 0)
    {
        return a;
    }
    else
    {
        return gcd(b,a%b);
    }
        
}


int main()
{
    int N;
    cin >> N;
    vector<long long> T(N);
    for(int i = 0;i<N;i++)
    {
        cin >> T[i];
    }
    
    long long temp = 1;
    
    for(int i = 0;i<N;i++)
    {
        long long tx = gcd(temp,T[i]);
        temp = temp / tx * T[i] ;
    }
    
    
    cout << temp << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> P;
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > k(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        k[a].push_back(b);
        k[b].push_back(a);
    }
 
    vector<int> C(n);
    int q;
    cin >> q;
    vector<int> vq(q), dq(q), cq(q);
    for (int i = 0; i < q; i++) cin >> vq[i] >> dq[i] >> cq[i];
    vector<vector<int> > dp(n, vector<int>(11));
    while (q--) {
        int v, d, c;
        v = vq[q], d = dq[q], c = cq[q];
        v--;

        queue<P> que;
        que.push(P(v,0));
        while (que.size()) {
            P now = que.front(); que.pop();
            if (!C[now.first]) C[now.first] = c;
            if (dp[now.first][d - now.second]) continue;
            dp[now.first][d - now.second] = true;
 
            for (auto next : k[now.first]) {
                if (d - now.second && !dp[next][d - (now.second + 1)]) {
                    que.push(P(next, now.second + 1));
                }
            }
        }
    }
 
    for (auto i : C) {
        cout << i << endl;
    }
 
    return 0;
}


Measured memory_bytes: 17916
#include <iostream>
#include <string>

using namespace std;

constexpr int MaxN = 100000 + 10;
int table[MaxN];

int main()
{
	int n, q;
	string s;
	cin >> n >> q >> s;

	for (size_t i = 1; i < s.length(); i++)
	{
		table[i] = table[i - 1];

		if (s[i - 1] == 'A' && s[i] == 'C')
		{
			table[i]++;
		}
	}

	for (int i = 0; i < q; i++)
	{
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		cout << (table[r] - table[l]) << endl;
	}
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, p int
	fmt.Scan(&n, &p)
	m := [2]int{}
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		m[a%2]++
	}

	if m[1] == 0 {
		if p == 0 {
			fmt.Println(int(math.Pow(2, float64(m[0]))))
		} else {
			fmt.Println(0)
		}
		return
	}

	fmt.Println(int(math.Pow(2, float64(n-1))))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 622222
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
 
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
vector<pii> v[N];
int a[N];
int main()
{
	int n, q;
	cin >> n >> q;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i <= q; i ++)
	{
		int x, y;
		cin >> x >> y;
		v[y].pb(M(x, i));
	}
	vi ans (q + 1, 0);
	map<int, int> mp;
	indexed_set s;
	for(int i = 1; i <= n; i ++)
	{
		if(mp.count(a[i]))
		{
			s.erase(mp[a[i]]);
		}
		s.insert(i);
		mp[a[i]] = i;
		for(auto it : v[i])
		{
			int u = s.order_of_key(it.F-1);
			int e = *s.find_by_order(u);
			u ++;
			u -= (e > it.F-1);
			ans[it.S] = s.size() - u;
		}
	}
	for(int i = 1; i <= q; i ++)
		cout << ans[i] << '\n';
	
 
 
 
 
 
	
 
 
 
 
 
	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 79072
S = input()

N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
    bit = '{:010b}'.format(i)[11 - N:]
    formula = S[0]
    for j in range(len(bit)):
        if bit[j] == '1':
            formula += '+'
        formula += S[j + 1]
    ans += eval(formula)
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void) {

	double l;
	double x=0.000001, y=0.000001, z=0.000001, max=0;

	scanf("%lf", &l);

	

	printf("%lf", pow((l/3.0),3));

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(i,N){R(x)V.push_back(x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL0(line)
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N)R(K)RV(a,N);
  std::vector<i8t> s;
  i8t sum = 0;
  s.push_back(0);
  F(i,N){
    auto d = a[i] - K;
    sum+=d;
    s.push_back(sum);
  }

  struct tt{i8t index,value;};
  std::vector<tt> ss;
  F(i,N+1){
    tt v;
    v.index=i;
    v.value=s[i];
    ss.push_back(v);
  }
  std::sort(ss.begin(),ss.end(),[](auto const& lhs,auto const& rhs){return lhs.value!=rhs.value?lhs.value<rhs.value:lhs.index<rhs.index;});

  i8t count = 0;

  //N <= 2e5 = 200000 <= 1024 * 200 <= 2^18
  std::vector<std::vector<i8t> > tbl(18);
  for(int i = 0;i<18;i++){tbl[i].resize(std::pow(2, 18-i),0);}

  F(i,N+1){s[ss[i].index]=i;}
  F(i,N+1){
    i8t ind=s[i];
    i8t c1=0;
    for(i8t j=0;j<18;j++,ind>>=1){
      if(ind&1)c1+=tbl[j][ind&~1];
      tbl[j][ind]++;
    }
    count+=c1;
  }
  P(count);
  return 0;
}


Measured memory_bytes: 11628
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> cnt(26, 100);
    string S;
    for (int i = 0; i < N; i++) {
        vector<int> tmp(26, 0);
        cin >> S;
        for (int i = 0; i < S.size(); i++) tmp[S[i] - 'a']++;
        for (int i = 0; i < 26; i++) cnt[i] = min(cnt[i], tmp[i]);
    }
    for (int i = 0; i < 26; i++) {
        if (cnt[i] > 0) {
            for (int j = 0; j < cnt[i]; j++) printf("%c", i + 'a');
        }
    }
    cout << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define Size 50
using namespace std;
int main()
{
    int n;
    cin>>n;
    pair<pair<string,int>,int>s[n];
    for(int i=0;i<n;i++){
        cin>>s[i].first.first;
        int t;
        cin>>t;
        s[i].first.second=-t;
        s[i].second=i+1;
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        cout<<s[i].second<<endl;
    }
   return 0;
}


Measured memory_bytes: 256
module app;

import std.array;
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto input = parseInput();
    writefln("%d", main2(input));
}

auto main2(Input input)
{
    int count = 0;
    int lastIndex = -2;
    for (int i = 0; i < input.n; i++)
    {
        auto index = input.a[i] - 1;
        count += input.b[index];
        if (lastIndex + 1 == index)
        {
            count += input.c[lastIndex];
        }
        lastIndex = index;
    }
    return count;
}

unittest
{
    Input input = {3,[3,1,2],[2,5,4],[3,6]};
    auto result = main2(input);
    writefln("%d", result);
    assert(result == 14);
}

unittest
{
    Input input = {4,[2,3,4,1],[13,5,8,24],[45,9,15]};
    auto result = main2(input);
    writefln("%d", result);
    assert(result == 74);
}

struct Input
{
	int n;
    int[] a;
    int[] b;
    int[] c;
}

auto parseInput()
{
	Input input = void;
	input.n = readln().strip().to!int;
    input.a = readln().strip().split().map!(a=>a.to!int).array();
    input.b = readln().strip().split().map!(a=>a.to!int).array();
    input.c = readln().strip().split().map!(a=>a.to!int).array();
	return input;
}


Measured memory_bytes: 256
// Aizu 1118: Nets of Dice
// 2017.9.16 bal4u@uu

#include <stdio.h>
#include <string.h>

char net[5][5];
int f[7];
char pat[11][3][5] = { 
	{{1,0,0,0},{2,3,2,3},{1,0,0,0}}, {{1,0,0,0},{2,3,2,3},{0,1,0,0}}, {{1,0,0,0},{2,3,2,3},{0,0,1,0}},
	{{1,0,0,0},{2,3,2,3},{0,0,0,1}}, {{0,1,0,0},{2,3,2,3},{0,1,0,0}}, {{0,1,0,0},{2,3,2,3},{0,0,1,0}},
	{{1,2,1,0,0},{0,0,3,2,3},{0 }},  {{1,2,0,0},{0,3,1,3},{0,2,0,0}}, {{1,3,0,0},{0,2,1,2},{0,0,3,0}},
	{{1,3,0,0},{0,2,1,2},{0,0,0,3}}, {{1,2,0,0},{0,3,1,0},{0,0,2,3}}};
int spec[11][3] = { {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},	{1,3,4}, 
					{1,3,4}, {0,2,5}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4} };

void rot90()
{
	int r, c; char t[5][5];
	for (r = 0; r < 5; r++) for (c = 0; c < 5; c++) t[r][c] = net[c][4-r];
	memcpy(net, t, sizeof(net));
}

void rev()
{
	int r, c; char t[5][5];
	for (r = 0; r < 5; r++) for (c = 0; c < 5; c++) t[r][c] = net[r][4-c];
	memcpy(net, t, sizeof(net));
}

int match()
{
	int i, j, r, c, r2, c2, rr, cc, x, y;

	for (r = 0; r < 4; r++) for (c = 0; c < 3; c++) {
		if (!net[r][c]) continue;
		for (i = 0; i < 11; i++) {
			rr = r, cc = c;	if (spec[i][0]) if (cc == 0) continue; else cc--;
			if (rr + spec[i][1] > 5 || cc + spec[i][2] > 5) continue;
			memset(f, 0, sizeof(f));
			for (y = 0; y < spec[i][1]; y++) for (x = 0; x < spec[i][2]; x++) {
				r2 = rr + y, c2 = cc + x;
				if (!net[r2][c2] && pat[i][y][x] > 0 ||
					net[r2][c2] > 0 && !pat[i][y][x]) goto Next;
				f[pat[i][y][x]] += net[r2][c2];
			}
			for (j = 1; j <= 3; j++) if (f[j] != 7) break;
			if (j > 3) return 1;
			Next:;
		}
	}
	return 0;
}

int check()
{
	int i;
	if (match()) return 1;
	for (i = 0; i < 3; i++) { rot90(); if (match()) return 1; }
	rot90(), rev();
	if (match()) return 1;
	for (i = 0; i < 3; i++) { rot90(); if (match()) return 1; }
	return 0;
}

int main()
{
	int n, r, c, x;

	scanf("%d", &n); while (n-- > 0) {
		memset(f, 0, sizeof(f));
		for (r = 0; r < 5; r++) for (c = 0; c < 5; c++) {
			scanf("%d", &x), net[r][c] = x, f[x]++;
		}
		for (x = 1; x <= 6; x++) if (f[x] != 1) break;
		if (x <= 6) puts("false");
		else puts(check() ? "true" : "false");
	}
	return 0;
}

Measured memory_bytes: 1604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	string s; cin >> s;
	bool hasNine = false;
	for (char c : s) if (c == '9') hasNine = true;
	cout << (hasNine ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
m, d = gets.split.map(&:to_i)
ans = 0
(1..m).each do |mon|
  (1..d).each do |day|
    day_s = day.to_s
    if day_s[0].to_i >= 2 && day_s[1].to_i >= 2 && day_s[0].to_i * day_s[1].to_i == mon
      ans += 1
    end
  end
end
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;


int main(){
    long A,B;cin >> A >> B;
    long ans = A * B;
    if(A < B){
        long buf = A;
        A = B;
        B = buf;
    }


    long R = A % B;
    while(R!=0){
        A = B;
        B = R;
        R = A % B;
    }

    ans = ans/B;


    cout << ans;
}


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

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

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

string acgt = "ACGT";

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

  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (acgt.find(s[i]) != string::npos) {
      int tmp = 0;
      for (int j = i; j < s.size(); j++) {
        if (acgt.find(s[j]) != string::npos) tmp++;
        else break;
      }
      ans = max(ans, tmp);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
program candies
	implicit none
    integer,allocatable :: Masu(:,:)
	integer :: length,num_can,turning,i,j,tmp_can
	
    read(*,*) length
    allocate(Masu(2,length))
    read(*,*) Masu(1,:) 
    read(*,*) Masu(2,:) 
    
    num_can=0
    do turning=1,length
    	tmp_can=0
    	do i=1,turning
        	tmp_can=tmp_can+Masu(1,i)
        end do
        do i=turning,length
        	tmp_can=tmp_can+Masu(2,i)
        end do
        if(num_can.lt.tmp_can) then
        	num_can=tmp_can
        endif
    end do
    write(*,'(i0)') num_can
    deallocate(Masu)

end program candies

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    bitset<30> b(0);
    Rep(i, N) {
        cin >> A[i];
        bitset<30> a(A[i]);
        b = b ^ a;
    }
    Rep(i, N) {
        bitset<30> a(A[i]);
        a = b ^ a;
        if (i) cout << " ";
        cout << a.to_ullong();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
const long long INF = 100000010010000;

struct node{
    long long cost;
    long long v;
    bool isarrive;
    int n;
};

bool operator<(const node& a, const node& b) { return a.cost < b.cost; }
bool operator>(const node& a, const node& b) { return a.cost > b.cost; }


int main(){

    int n, m; cin >> n >> m;
    vector<vector<pair<int, int> > > adjlist(n);
    
    for(int i = 0; i < m; i++){
        int x, y, t; cin >> x >> y >> t;
        x--;
        y--;
        adjlist[x].push_back({t, y});
        adjlist[y].push_back({t, x});

    }

    long long v; cin >> v;
    long long a, b, c; cin >> a >> b >> c;
    vector<vector<vector<long long> > > result(c, vector<vector<long long> > (2, vector<long long> (n, INF)));
    priority_queue<node> wait;
    node _node;
    _node.n = 0;
    _node.cost = 0;
    _node.isarrive = 0;
    _node.v = v;
    result[v][0][0] = 0;
    wait.push(_node);

    while(!wait.empty()){

        int now_n = wait.top().n;
        long long now_cost = -wait.top().cost;
        long long now_v = wait.top().v;
        bool now_isarrive = wait.top().isarrive;        
        wait.pop();
        //cout << now_n << " " << now_cost << " " << now_v << " " << now_isarrive << endl;
        if(result[now_v][now_isarrive][now_n] < now_cost) continue;
    
    
        //隣接している頂点をすべて舐める
        for(int i = 0; i < adjlist[now_n].size(); i++){
            int next_n = adjlist[now_n][i].second;
            long long next_v = (a * now_v + b) % c;            
            long long next_cost = now_cost + adjlist[now_n][i].first * now_v;
            bool next_isarrive = (now_isarrive || (next_n == n - 1));

            if(result[next_v][next_isarrive][next_n] > next_cost){
                result[next_v][next_isarrive][next_n] = next_cost;
                node next_node;
                next_node.cost = -next_cost;
                next_node.n = next_n;
                next_node.v = next_v;
                next_node.isarrive = next_isarrive;
                wait.push(next_node);
            } 
        }
    }

    long long ans = INF;
    for(int i = 0; i < c; i++){
        ans = min(ans, result[i][1][0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9428
#C - : (Colon)

import math


I = input().split()
A = int(I[0])
#hour hand length cm
B = int(I[1])
#minute hand length cm
H = int(I[2])
#hours
M = int(I[3])
#key?
#mins

tha = 30*H + .5*M
thb = 6*M
diff= (math.pi/180)*(tha-thb)
Q = math.cos(diff)
#(theta, radius)
d = math.sqrt(A**2 + B**2 - 2*A*B*Q)



print(d)

Measured memory_bytes: 9460
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std ;

typedef long long LL ;
const int N=1e5+10 ;

struct State 
{
	LL A , B , C ;
	int id ;
	bool operator < ( const State x ) const { return A-B<x.A-x.B; }
};
State a[N] ;
int x , y , z , n ;
LL res ;

multiset<LL>S;
LL f[N] ;

int main ()
{
	int i ;
	scanf("%d%d%d",&x,&y,&z),n=x+y+z;
	for ( i=1 ; i<=n ; i++ ) scanf("%lld%lld%lld",&a[i].A,&a[i].B,&a[i].C),a[i].A-=a[i].C,a[i].B-=a[i].C,res+=a[i].C,a[i].id=i;
	sort(a+1,a+n+1);
	// for ( i=1 ; i<=n ; i++ ) printf("%d ",a[i].id); puts("");
	for ( i=1 ; i<=y ; i++ ) S.insert(a[i].B),f[y]+=a[i].B;
	for ( i=y+1 ; i<=n-x ; i++ ) 
	{
		multiset<LL>::iterator B=S.begin() ;
		LL Min=*B , X=a[i].B;
		if ( Min<X ) f[i]=f[i-1]+X-(*B),S.insert(X),S.erase(B);
		else f[i]=f[i-1];
	}
	S.clear();
	LL ans=0 , sum=0 ;
	for ( i=n ; i>n-x ; i-- ) S.insert(a[i].A),sum+=a[i].A;
	ans=sum+f[n-x];
	for ( i=n-x ; i>y ; i-- ) 
	{
		multiset<LL>::iterator B=S.begin();
		LL Min=*B , X=a[i].A;
		if ( Min<X ) sum=sum+X-(*B),S.insert(X),S.erase(B);
		ans=max(ans,sum+f[i-1]);
	}
	printf("%lld\n",res+ans);
	return 0 ;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
//in the name of god;;
using namespace std;
////////////////////////////////////////////////////////
typedef long long ll;                                 //
typedef long double ld;                               //
////////////////////////////////////////////////////////
#define pb push_back                                  //
#define vc vector<ll>                                 //
#define vpl vector<pair<ll, ll> >                     //
#define d double                                      //
#define So(v) sort(v.begin(), v.end())                //
#define Y cout << "YES\n"                             //
#define N cout << "NO\n"                              //
#define rep(x, n) for(ll i = x; i <= n; ++i)          //
#define repp(x, n) for(ll i = n; i >= x; --i)         //
////////////////////////////////////////////////////////
const ll MAXN = 1e6;                                 ///
//////////////////////////////////////////////////////// 
 
 int main(){
    ll n, ans = 0;
    cin >> n;
  //  1| 1 2 3 4 5 6 7 8 ... 99; 99;
  //  2| 1 2 3 4 5 6 7 8 ... 49; 49;
  //  3| 1 2 3 4 5 6 7 8 ... 33; 33;
  //  ...
  //  99 1;
  for(ll i = 1; i < n; ++i){
  	ll g = (n % i == 0 ? n/i-1 : n/i);
  	ans += (g < 0 ? 2 : g);
  }
    cout << ans;
 }

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

const double EPS = 1e-10;
const int INF = 100000000;
const ll MOD = 1000000007;

int n, m;
vector<P> e[100000];
int dis[100000];

bool dfs(int v) {
    rep(i,e[v].size()) {
        if (dis[e[v][i].first] != INF) {
            if (dis[v]-dis[e[v][i].first] != e[v][i].second) {
                return false;
            }
            continue;
        }
        dis[e[v][i].first] = dis[v]-e[v][i].second;
        if (!dfs(e[v][i].first)) return false;
    }
    return true;
}

int main(){
    cin >> n >> m;
    rep(i,n) dis[i] = INF;
    rep(i,m) {
        int r, l, d;
        cin >> l >> r >> d;
        r--; l--;
        e[r].push_back(P(l,d));
        e[l].push_back(P(r,-d));
    }
    rep(i,n) {
        if (dis[i] != INF) continue;
        dis[i] = 0;
        if (!dfs(i)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
































Measured memory_bytes: 12032
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		//入力
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		sc.close();

		//処理
		
		//出力
		PrintWriter out = new PrintWriter(System.out);
		for(int i = 0; i < 2 * k - 1; i++){
			int t = x - k + 1 + i;
			out.print(t);
			if(i == 2 * k - 2) out.println();
			else out.print(" ");
		}
		out.flush();
	}
}

Measured memory_bytes: 22868