akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int maxn=2e5+5;
const int mod=1e9+7;
#define ll long long
using namespace std;
int s[maxn];
int main(){
    int n,t;
    ios::sync_with_stdio(false);
    cin>>n>>t;
    int i;
    ll sum=0;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    for(int i=2;i<=n;i++){
        if(s[i]-s[i-1]>=t){
            sum+=t;
        }
        else{
            sum+=s[i]-s[i-1];
        }
    }
    cout<<sum+t<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>

#define INF 100000000000000
using namespace std;
typedef long long llong;

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

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

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

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

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

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

//priority_queueクラス

int main(){
    //bit全探索
    llong N;
    cin >> N;
    vector<vector<pair<llong, bool> > > Table(N);
    llong A;
    llong x,y;
    llong maxv = INF*-1;
    llong cnt;
    pair<llong, bool> X;
    unsigned char flg;
    for(int i=0; i<N; i++){
        cin >> A;
        for(int j=0; j<A; j++){
            cin >> x >> y;
            if(y==1){
                X.second = true;
            }else{
                X.second = false;
            }
            X.first = x-1;
            Table[i].push_back(X);
        }
    }
    for(int i=0; i<pow(2,N); i++){
        vector<bool> list(N, false);
        for(int j=0; j<N; j++){
            if((i>>j)&1){
                list[j] = true;
            }
        }
        cnt = 0;
        flg = 0;
        for(int i=0; i<N; i++){
            for(int j=0; j<Table[i].size(); j++){
                if(list[i] && list[Table[i][j].first]!=Table[i][j].second){
                    flg = 1;
                }
            }
        }
        if(flg==0){
            for(int i=0; i<N; i++){
                if(list[i]==true){
                    cnt++;
                }
            }
            maxv = max(maxv, cnt);
        }
    }
    cout << maxv << endl;
    return 0;
}





Measured memory_bytes: 3320
import math as math

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
for i in range(math.floor(N/2)+1,N):
    ANS[i] = A[i]

fnum=math.floor(N/2)
for i in range(fnum,-1,-1):
    j = i + 1
    tsum=A[i]
    for k in range(j,N+1,j):
        tsum+=ANS[k-1]
    ANS[i]=tsum%2

#print(ANS)
anslist=[]
for i in range(N):
    if ANS[i]==1:
        anslist.append(i+1)
 
print(len(anslist))
for s in anslist:
    print(s, end =" ")



Measured memory_bytes: 12084
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, K, C; std::cin >> N >> K >> C;
  std::string S; std::cin >> S;

  std::vector<int> L(K+1), R(K+1);
  int last = -C-1;
  int cnt = 1;
  rep(i,N) {
    if ( S[i] == 'o' && (i - last) > C ) {
      L[cnt] = i;
      last = i;
      cnt++;
    }
    if ( cnt > K ) break;
  }

  cnt = K;
  last = C + N + 1;
  rep(i,N) {
    if ( S[N-1-i] == 'o' && (last-(N-1-i)) > C ) {
      R[cnt] = N-1-i;
      last = N-1-i;
      cnt--;
    }
    if ( cnt < 0 ) break;
  }

  for(int i=1; i<=K; i++) {
    if ( L[i] == R[i] ) std::cout << L[i]+1 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3348
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	map<string,int> mp;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		mp[s]++;
	}
	map<string,int>::iterator it;
	int maxn=-1;
	for(it=mp.begin();it!=mp.end();it++)
	{
		if(it->second>maxn)
		{
			maxn=it->second;
		}
	}
	string arr[200020];
	int i=0;
	for(it=mp.begin();it!=mp.end();it++)
	{
		if(it->second==maxn)
		{
			arr[i++]=it->first;
		}
	}
	sort(arr,arr+i);
	for(int j=0;j<i;j++)
	{
		cout<<arr[j]<<endl;
	}
	return 0;
}

Measured memory_bytes: 26752
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <functional>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
	int h, m, s, A;
	cin >> A;

	h = A / 3600;
	m = (A - h * 3600) / 60;
	s = A % 60;

	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
double dist(int x1, int y1, int x2, int y2) {
    int diffX = x1 - x2;
    int diffY = y1 - y2;
    return (sqrt(diffX * diffX + diffY * diffY));
}
double d[1010];
typedef pair<int, double> P;
double G[1010][1010];
int used[1010];
int N; 
void dijkstra(int s) {
    rep(i, 1010) d[i] = INF2;
    d[s] = 0;
    while(true) {
        int v = -1;
        rep(i, N + 2) {
            if (!used[i] && (v == -1 || d[i] < d[v])) v = i;
        }
        //cout << v << endl;
        if (v == -1) break;
        used[v] = true;
        rep(i, N + 2) {
            d[i] = min(d[i], d[v] + G[v][i]);
        } 
    }
    
}


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

    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    cin >> N;
    int x[1010], y[1010], r[1010];
    rep(i, N) {
        cin >> x[i] >> y[i] >> r[i];
    }
    x[N] = xs; 
    y[N] = ys;
    r[N] = 0;
    x[N + 1] = xt; 
    y[N + 1] = yt;
    r[N + 1] = 0;
    rep(i, 1010) rep(j, 1010) G[i][j] = INF2;
    rep(i, N + 2) {
        rep(j, N + 2) {
            if (i == j) continue;
            double cost = max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]);
            G[i][j] = cost;
            //cout << i << " " << j << " " << cost << endl;
        }
    }
    dijkstra(N);
    cout << fixed << setprecision(12) << d[N + 1] << endl;
    


    return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<string>
using namespace std;
int main() {
	string str, tmp1,tmp2,tmp3,tmp4;
	int n;
	cin >> n;
	str = to_string(n);
	tmp1 = str.substr(0, 1);
	tmp2 = str.substr(1, 1);
	tmp3 = str.substr(2, 1);
	tmp4 = str.substr(3, 1);

	if (tmp1 == tmp2 && tmp3 == tmp2 || tmp3 == tmp2 && tmp3 == tmp4) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int64_t n,k;
    cin>>n>>k;
    vector<int64_t> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    vector<int> place(3*n);
    map<int,int> p;
    place[0]=0;
    p[0]++;
    int i=1;
    int cycle;
    int first;
    bool f = false;
    for(int i=1;i<=3*n;i++){
        place[i] = a[place[i-1]];
        p[place[i]]++;
        if(p[place[i]]==2 && !f){
            first = i;
            f = true;
            //break;
        }
        if(p[place[i]]==3){
            cycle = i-first;
            break;
        }
    }
    //cout<<"first:"<<first<<endl;
    //cout<<"cycle:"<<cycle<<endl;
    if(k-first<=0){
        cout<<place[k]+1<<endl;
    }
    else{
        int64_t ans = (k-first)%cycle; //サイクルの中の何個目か
        cout<<place[first+ans]+1<<endl;
    }

}

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

int main() {
    int n, k;
    cin >> n >> k;
    
    int p = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            p = p * k;
        } else {
            p = p * (k - 1);
        }
    }
    
    cout << p << endl;
    
    return 0;
}


Measured memory_bytes: 256
def dfs(h, w): 
    m = -1
    visited = [[-1] * W for _ in range(H)]
    stack = []
    visited[h][w] = 0
    stack.append([h, w])
    while stack:
        h, w = stack.pop()
        for i in range(4):
            nh = h + dy[i]
            nw = w + dx[i]
            if nh >= H or nh < 0 or nw >= W or nw < 0:
                continue
            if s[nh][nw] == "." and visited[nh][nw] == -1:
                visited[nh][nw] = visited[h][w] + 1
                stack.append([nh, nw])
            if s[nh][nw] == "." and visited[nh][nw] != -1:
                if visited[nh][nw] > (visited[h][w]+1):
                    visited[nh][nw] = visited[h][w] + 1
                    stack.append([nh, nw])
    for i in range(H):
        if m <= max(visited[i]):
            m = max(visited[i])
    return m

H, W = map(int, input().split())
s = [input() for _ in range(H)]
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
m = -1
dist = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            dist = dfs(i, j)
            if m <= dist:
                m = dist
print(m)

Measured memory_bytes: 50652
suits = "SHCD"
cards = [0] * 52

n = int(input())
for _ in range(n):
    l, r = input().split()
    i = suits.find(l)*13 + int(r)-1
    cards[i] = 1;

for i in range(52):
    if cards[i] == 0:
        print("{} {}".format(suits[i//13], i%13+1))



Measured memory_bytes: 5600
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Integer[] input = readInput();
        int a = input[0];
        int b = input[1];
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }

    public static Integer[] readInput() {
        List<Integer> l = new ArrayList<Integer>();

        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            l.add(sc.nextInt());
        }
        return l.toArray(new Integer[l.size()]);
    }
}

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

#define fi first
#define se second
#define ll long long

const int N = 303;

using namespace std;

int n;
int a[N][N];
bool dead[N][N];

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n;
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= n; j++){
                        cin >> a[i][j];
                }
        }
        long long res = 0;
        for(int i = 1; i <= n; i++){
                if(a[i][i]){
                        res = -1;
                }
                for(int j = 1; j <= n; j++){
                        if(i == j){
                                continue;
                        }
                        for(int h = 1; h <= n; h++){
                                if(h == j || h == i){
                                        continue;
                                }
                                if(a[i][j] + a[j][h] < a[i][h]){
                                        res = -1;
                                } else if(a[i][j] + a[j][h] == a[i][h]){
                                        dead[i][h] = dead[h][i] = 1;
                                }
                        }
                }
        }
        if(res == -1){
                cout << res << "\n";
                return 0;
        }
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= n; j++){
                        if(!dead[i][j]){
                                res += a[i][j];
                        }
                }
        }
        cout << res / 2 << "\n";

}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int main(){
  ll k,n; cin >> k >> n;
  vector<ll> a(n),b(n+1);
  rep(i,0,n){
    cin >> a[i];
  }
  ll mi = INF;
  ll ma = 0;
  b[0] = a[0];
  rep(i,1,n){
    b[i] = a[i] - a[i-1];
  }
  b[n] = k - a[n-1];
  ll sum = 0;
  rep(i,0,n+1){
    sum += b[i];
    ma = max(b[i], ma);
  }
  if(ma > k-a[n-1]+ a[0]){
    cout << sum - ma << endl;
  }else{
    cout << a[n-1] - a[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
int parent[2][200005];
void ufinit(void){
    rep(i,2)rep(j,200005){
        parent[i][j]=j;
    }
}

int root(int a, int n){
    if(parent[a][n]==n){return n;}
    return parent[a][n] = root(a, parent[a][n]);
}

void unite(int a, int x, int y){
    if(root(a, x)!=root(a, y)){
        parent[a][root(a, x)] = root(a, y);
        root(a, x);
        root(a, y);
    }
}

string ptos(int a, int b){
    return "a"+to_string(a)+"b"+to_string(b);
}

int main(void) {
    int n,k,l;
    cin>>n>>k>>l;
    int p[k],q[k],r[l],s[l];
    rep(i,k){cin>>p[i]>>q[i];}
    rep(i,l){cin>>r[i]>>s[i];}
    unordered_map<string, int> counts;
    ufinit();
    rep(i,k){
        unite(0, p[i], q[i]);
    }
    rep(i,l){
        unite(1, r[i], s[i]);
    }
    for(int i=1;i<=n;i++){
        DEBUG{cout << ptos(root(0, i), root(1, i)) << endl;}
        counts[ptos(root(0, i), root(1, i))]++;
    }
    for(int i=1;i<=n;i++){
        cout << counts[ptos(root(0, i), root(1, i))];
        if(i<n){cout << " ";}
        else { cout << endl;}
    }
    return 0;
}


Measured memory_bytes: 25800
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    rep(i, n) {
        cin >> c[i];
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));
    int ans = 0;
    rep(i, n) {
        ans += (lower_bound(all(a), b[i]) - a.begin()) * (c.end() - upper_bound(all(c), b[i]));
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main(){
    string str;
    int q;
    cin >> str >> q;
    while(q--){
        string command;
        int a, b;
        cin >> command >> a >> b;
        if(command=="print"){
            cout << str.substr(a,b-a+1) << endl;
        }
        else if (command=="reverse"){
            while(a<b){
                swap(str[a++],str[b--]);
            }
        }
        else if (command=="replace"){
            string strReplace;
            cin >> strReplace;
            str.replace(a,b-a+1,strReplace);
        }
    }
    return 0;  
}


Measured memory_bytes: 3168
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

# 約数全列挙
def divisors(n):
    i = 1
    ans = []
    while i*i <= n:
        if n % i == 0:
            ans.append(i)
            if i*i != n: ans.append(n // i)
        i += 1
    ans.sort()
    return ans

a = divisors(N)
m = len(a)

if m % 2 == 1:
    print(2*a[m//2] - 2)
else:
    print(a[m//2-1] + a[m//2] - 2)

Measured memory_bytes: 77188
#include <stdio.h>

int main(void){
    int a,b,c,d,i;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    for(i=0;i<10000000;i++){
        c=c-b;
        if(c<=0){
            break;
        }        
        a=a-d;
        if(a<=0){
            break;
        }
    }

    if(a<=0){
        printf("No\n");
    }
    if(c<=0){
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 3164
mod=1000000007
N,M=map(int,input().split())
s=0
k=0
L=list(map(int,input().split()))
R=list(map(int,input().split()))
for i in range(N):
  s+=L[i]*(2*i-N+1)
for j in range(M):
  k+=R[j]*(2*j-M+1)
print((k%mod*s%mod)%mod)

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

using namespace std;


int main() {

  string S, s;
  int N;
  
  s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  cin >> N;
  cin >> S;
  
  for(int i=0; i<S.length(); i++){
    for(int n=0; n <26; n++){
      if(S[i] == s[n]){
        if(n + N >= 26){
          cout << s[(n + N) - 26];
        }else{
        cout << s[n + N];
        }
      }
    }
  }
}

Measured memory_bytes: 256
a,b = map(int,input().split())

if a>0 and b>0:
  print("Positive")
  exit()
elif a<=0 and b>=0:
  print("Zero")
  exit()
elif a==0 or b==0:
  print("Zero")
elif a<0 and b<0:
  if (abs(a-b)+1)%2==0:
    print("Positive")
    exit()
  else:
    print("Negative")
    exit()

Measured memory_bytes: 38588
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
using namespace std;
typedef long long int llint;
const llint big=((llint)1<<(llint)30);
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pub push_back
#define res resize
//JOI 2017 semiexp O(NlogN)
//3:25~4:40
//Tmin 
int main(void){
	queue<int>que;
	vector<int> ba;
	int N,C,K,i,minz=big,nin=0,ans=0;
	cin>>N>>C>>K;
	ba.res(N);
	for(i=0;i<N;i++){
		cin>>ba[i];
	}
	sort(ba.begin(),ba.end());
	for(i=0;i<N;i++){
		if(nin==0){minz=ba[i];nin++;}
		else if(minz+K<ba[i]){
			ans++;nin=1;minz=ba[i];
		}else{
			nin++;
		}
		if(nin>=C){ans++;nin=0;}
	}
	if(nin>0){ans++;}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    j = str(i)
    
    if len(j)!=N:
        continue
    
    for s, c in sc:
        s -= 1
        
        if j[s]!=str(c):
            break
    else:
        print(j)
        exit()

print(-1)

Measured memory_bytes: 38704
/**
 * D - Sum of Large Numbers
 * https://atcoder.jp/contests/abc163/tasks/abc163_d
 *
 * TODO: 未完成です 
 */
#include <bits/stdc++.h>
using namespace std;

// 和としてあり得るものの個数を mod(109+7) で出力せよ。
long long mod = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7;
 
int main() {
    // 10100, 10100+1, ..., 10100+N の N+1 個の数があります。
    // この中から K 個以上の数を選ぶとき、その和としてあり得るものの個数を mod(109+7) で求めてください。
    long long N, K;
    cin >> N >> K;

    long long pattern = 0;
    for (long long i = K; i <= N + 1; i++) {
        // 最大の数と最小の数を求める
        // 最大と最小の間は、すべての値をとることができる
        // min = 0,1,2...i - 1;
        // long long min = i * (i - 1) / 2;
        // min = N,N-1...N - i + 1;
        // long long max = i * (2 * N - i + 1) / 2;
        // cout << i << " "  << min << " " << max << endl;

        // 途中の計算省略過程
        // pattern += ((i * (2 * N - i + 1) - (i * (i - 1)) / 2) + 1;
        // pattern += ((2 * N * i - i * i + i) - (i * i - i)) / 2) + 1;
        // pattern += (2Ni - ii + i - ii + i) / 2) + 1;

        pattern += (N - i + 1) * i + 1;
        pattern = pattern % mod;
    }

    cout << pattern << endl;
}
 

Measured memory_bytes: 3596
#include <iostream>

int main() {
	bool p[1000000];
	p[0] = p[1] = true;
	for( int i=2; i<1000000; i++) p[i] = false;
	
	int q[1000000];
	for( int i=2; i<1000; i++) if(!p[i]) for( int j=i*i; j<1000000; j+=i) p[j] = true;
	
	int sum = 0;
	for( int i=0; i<1000000; i++) {
		if(!p[i]) sum++;
		q[i] = sum;
	}
	
	int n;
	while( std::cin >> n) {
		std::cout << q[n] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 6040
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    string S,T;
    cin >>S>>T;
    cout<<T<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[200001];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}

long long nCr(long long n, long long r) {
    if (r > n) return 0;
    return (fac[n] * modInverse(fac[r]) % MOD * modInverse(fac[n - r]) % MOD) % MOD;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 1; i < n; i += 2) sum -= a[i] * 2ll;
    vector<int> x(n);
    x[0] = sum;
    for (int i = 1; i < n; i++) {
        x[i] = 2 * a[i-1] - x[i - 1];
    }
    for (int i = 0; i < n; i++) cout << x[i] << " ";

    return 0;
}

Measured memory_bytes: 4048
N,C=gets.chomp.split.map(&:to_i)
M = 200002
s = []
t = []
c = []
N.times do
    ss,tt,cc = gets.chomp.split.map(&:to_i)    
    s << ss
    t << tt
    c << cc
end

u = Array.new(M)
z = Array.new(M,0)
ans = 0
1.upto(C) do |i|
    0.upto(M-1) {|j| u[j] = 0}
    0.upto(N-1) do |j|
        if c[j] == i
            u[s[j]*2 - 1] += 1
            u[t[j]*2 + 1] -= 1
        end
    end
    1.upto(M-1) do |j|
         u[j] += u[j-1]
         if u[j] > 0
            z[j] += 1
         end
    end
end

puts z.max


Measured memory_bytes: 7492
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n, k;
    cin >> n >> k;
    int ans = (int)pow(n / k, 3);
    if (k % 2 == 0) {
        ans += (int)pow((n + (k / 2)) / k, 3);
    }
    cout << ans << "\n";
}

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

int main(){
    long long n, x;cin>>n>>x;
    vector<long long> nums(n);
    for (long long i=0;i<n;i++){
        cin>>nums[i];
    }    

    long long acc = 0;
    if(nums[0] > x){
        acc += nums[0] - x;
        nums[0] = x;
    }
    for (long long i=0;i<n-1;i++){
        long long temp = (nums[i] + nums[i+1]) - x;
        
        if (temp > 0){
            acc += temp;
            nums[i+1] -= temp;
        }
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    op = input().split()
    if   op[0] == 'insert'     : dl.appendleft(op[1]) 
    elif op[0] == 'delete'     :
        if op[1] in dl: dl.remove(op[1])
    elif op[0] == 'deleteFirst': dl.popleft() 
    elif op[0] == 'deleteLast' : dl.pop() 
print(*dl)

Measured memory_bytes: 71868
#include <iostream>

int main() {
    int N, K;
    std::cin >> N >> K;

    int M = N * (N - 1) / 2 - K;

    if (M < N - 1) {
        std::cout << "-1\n";
        return 0;
    }

    std::cout << M << "\n";

    for (int i = 2; i <= N; i++)
        std::cout << 1 << " " << i << "\n";

    int count = N - 1;
    for (int i = 2; i <= N - 1; i++)
        for (int j = i + 1; j <= N; j++) {
            if (M <= count)
                break;
            std::cout << i << " " << j << "\n";
            count++;
        }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1);
vector<ll> pw10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	string A,B,C; cin>>A>>B>>C;
	ll ra=0,rb=0,rc=0;
	ll sign=0;//A:0 B:1 C:2
	while(1){
		if(sign==0){
			if(ra==A.sz){
				cout<<"A";
				return 0;
			}

			if(A[ra]=='a') sign=0;
			else if(A[ra]=='b') sign=1;
			else sign=2;

			ra++;
		}
		else if(sign==1){
			if(rb==B.sz){
				cout<<"B";
				return 0;
			}

			if(B[rb]=='a') sign=0;
			else if(B[rb]=='b') sign=1;
			else sign=2;

			rb++;
		}
		else{
			if(rc==C.sz){
				cout<<"C";
				return 0;
			}

			if(C[rc]=='a') sign=0;
			else if(C[rc]=='b') sign=1;
			else sign=2;

			rc++;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct Fordfulkerson{
  const int INF = 1 << 28;
  struct edge{
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> used;
  
  Fordfulkerson(){}
  Fordfulkerson(int sz):n(sz),G(n),used(n){}
  
  void add_edge(int from,int to,int cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
 
  int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to] && e.cap > 0 ){
	int d=dfs(e.to,t,min(f,e.cap));
	if(d>0){
	  e.cap-=d;
	  G[e.to][e.rev].cap+=d;
	  return d;
	}
      } 
    }
    return 0;
  }
 
  int max_flow(int s,int t){
    int flow=0;
    for(;;){
      fill(used.begin(),used.end(),0);
      int f=dfs(s,t,INF);
      if(f==0) return flow;
      flow+=f;
    }
  }
};
//END CUT HERE

signed main(){
  int V,E;
  cin>>V>>E;
  Fordfulkerson ford(V);
  for(int i=0;i<E;i++){
    int u,v,c;
    cin>>u>>v>>c;
    ford.add_edge(u,v,c);
  }
  cout<<ford.max_flow(0,V-1)<<endl;
  return 0;
}

/*
verified on 2017/10/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
*/

Measured memory_bytes: 3084
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


int main() {
    int N;
    int A,B;
    cin>>N;
    if(N==1){
        std::cout<<"Hello World";
    }else if(N==2){
        cin>>A>>B;
        cout<<A+B;
    }
     return 0;
}



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

int main(){
    const int64_t mod = 1e9 + 7;
    int n; cin >> n; vector<int> m(n);
    for (auto i = 0; i < n; i++) {
        int a; cin >> a; m[a]++;
    }
    if(n % 2 != 0 and m[0] != 1) {
        cout << 0 << endl; return 0;
    }

    int64_t ans = 1;
    for (auto i = 0; i < n; i++) {
        if(m[i] == 2) ans = (ans * 2) % mod;
        if(m[i] > 2) {
            ans = 0; break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t;
	t=1;
	while(t--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<(a*b)/__gcd(a,b);
    }
}


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

main()
{
  int n,h;
  int ans=0;
  int a_max=0;
  int a,b;

  priority_queue<int>que;

  cin >> n >> h;

  for(int i=0;i<n;i++){
    cin >> a >> b;
    a_max=max(a,a_max);
    que.push(b);
  }
  
  while(que.top()>a_max&&(!que.empty())&&h>0){
    ans++;
    h-= que.top();
    que.pop();
  }

  if(h>0){
    int d=h/a_max;
    if(d*a_max<h)
      ans++;
    ans+=d;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 892
#include<iostream>

using namespace std;

int main(){

int A,B,C,D;
int S1,S2;
cin >> A >> B >> C >> D;
  
S1=A*B;
S2=C*D;

if(S1==S2){

  cout << S1 << endl;
}else if(S1<S2){

cout << S2 << endl;
}
 else if(S2<S1){

cout << S1 << endl;
}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
       ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
       string a, b;
       cin >> a >> b;
       int flag=0;
       for (int i=0; i<a.size(); i++)
       {
             if (a[i]!=b[i]) flag++;
       }cout << flag << endl;
	return 0;
}



Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a;cin >> a; 
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define output(answer) cout << answer << endl;
#define f(i,s,e) for(int i=s; i<=e; i++)

int main()
{
    //input
    inputInt(N); //スイッチ
    inputInt(M); //電球
    int k[M]={0};//繋がっているスイッチの個数
    int s[M][N]={0};//どこに繋がっているか
    for(int i=0; i<M; i++){
      cin >> k[i];
      for(int j=0; j<k[i]; j++){
        cin >> s[i][j];
      }
    }
    inputIntArray(p,M);
  
    //main
    int ans = 0;
    //スイッチの押し方を全探索→押し方を固定した時に全ての電球について条件を満たすかを全探索
    for(int a=0; a<(1<<N); a++){ //bit探索
      int countLight=0;
      for(int c=0; c<M; c++) {//電球について全探索
        int countSwitch = 0;
        for(int i=0; i<N; i++){
          if((a>>(N-s[c][i]))%2 == 1 && i<k[c])countSwitch++;//%2を忘れないようにシフト演算子を用いるべき。
        }
        if(countSwitch%2 == p[c])countLight++;//スイッチが条件を満たす時ついている電球の数+1
        
      }
      if(countLight == M)ans++;//全ての電球がついている時+1
    }

    // 出力
    output(ans);
    
    return 0;
}

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

int main() {

    int n;
    cin >> n;

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

    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        mp[a[i]] ++;
        mp[a[i]+1] ++;
        mp[a[i]-1] ++;
    }

    int ans = 0;
    for (int i = 0; i < 100001; i++) {
        ans = max(ans, mp[i]);
    }

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

Measured memory_bytes: 5376
n = int(input())
A = []
for _ in range(n):
  x, y = map(int, input().split())
  A.append((x, y))
maxc = 0
for i in range(n):
  for j in range(n):
    c = 0
    if i == j:
      continue
    dx = A[i][0] - A[j][0]
    dy = A[i][1] - A[j][1]
    for k in range(n):
      for l in range(n):
        if k == l:
          continue
        if A[k][0] + dx == A[l][0] and A[k][1] + dy == A[l][1]:
          c += 1
    if maxc < c:
      maxc = c
print(n-maxc)
    
    



Measured memory_bytes: 9232
N=int(input())
if N==1:
    print(0)
    exit()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
nprime=factorization(N)
ans=0
for t in nprime:
    now=1
    count=0
    while t[1]>=now:
        t[1]-=now
        now+=1
        count+=1
    ans+=count
print(ans)
    


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,x=0,f=0,n;cin>>N>>T;
  for(int i=0;i<N;i++){
    cin>>n;
    if(n<f)x+=n+T-f;
    else x+=T;
    f=n+T;
  }
  cout<<x<<endl;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  map<ll,ll> mp;
  ll N; cin >> N;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    if (mp[a] == 0) mp[a] = 1;
    else mp[a] = 0;
  }
  ll cnt = 0;
  for (auto p : mp) {
    ll x, c;
    tie(x, c) = p;
    cnt += c;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
    int r,c;
    cin >> r >> c;
    int S[r+1][c+1] ={};
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> S[i][j];
        }
    }
    
    //計算
    for(int k=0;k<c;k++){
        for(int l=0;l<r;l++){
            S[r][k] += S[l][k];
        }
    }
    
    for(int m=0;m<r+1;m++){
        for(int n=0;n<c;n++){
            S[m][c] += S[m][n];
        }
    }
    
    //出力
    for(int o=0;o<r+1;o++){
        for(int p=0;p<c+1;p++){
            if(p==0){
                cout << S[o][p];
            }
            else{
                cout << " " << S[o][p];
            }
        }
        cout << endl;
    }
    
}


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

int main()
{
  int n,m;
  cin >> n >> m;
  int a[51],b[51];
  for(int i=1;i<=n;++i)
  {
    int c=0;
    for(int j=0;j<m;++j)
    {
      cin >> a[j] >> b[j];
      if(a[j]==i || b[j]==i){
        ++c;
      }
    }
      cout << c << endl;
    }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define sc(x) scanf("%d", &x)
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define fastio ios::sync_with_stdio(0),cin.tie(0)
template<class T>T gcd(T a, T b){return b?gcd(b, a%b):a;}
string s;

int main()
{
    int k;
    cin >> s >> k;
    for(int i = 0; i < SZ(s); i++){
        if(i == k-1 || s[i] != '1'){
            putchar(s[i]);
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
    static void Main()
    {
        string line = Console.ReadLine().Trim();

        int result = 0;
        var orikaesi = Math.Ceiling((decimal)line.Length / 2);

        for (int i = 1; i <= orikaesi; i++)
        {
            if (line.Substring(i - 1, 1) == line.Substring(line.Length - i, 1)) continue;

            result++;
        }

        Console.WriteLine(result.ToString());
    }
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    int a , b ;
    cin >> a >> b ;

    cout << (3 * a + b ) / 2 ;

    return 0 ;
}



Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))[: : -1]
dp = [0] * N
for i in range(1, N):
  if H[i] >= H[i - 1]:
    dp[i] += dp[i - 1] + 1
  else:
    dp[i] = 0
print(max(dp))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
main()
{
    int n,k,i,x;
    while(~scanf("%d%d",&n,&k))
    {
        for(i=0;i<n;i++) scanf("%d",&x);
        n-=k;
        printf("%d\n",(n+k-2)/(k-1)+1);
    }
    return 0;
}

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

const int nmax=8;
bool graph[nmax][nmax];

int pass(int v,int N,bool checked[nmax]){//頂点vに至るまでの経路の個数
    //以下すべて到達済みの時の処理
    bool allchecked =true;
    for(int i=0;i<N;i++){
        if(checked[i]==false) allchecked=false; 
    }
    if(allchecked) return 1;
    //処理終わり
    //以下到達済みでない場合
    int ret=0;
    for(int i=0;i<N;i++){
        if(graph[v][i]==false) continue;//頂点vの隣接する頂点に関し検索する
        if(checked[i]) continue;//調べた頂点が到達済みならその頂点をスキップする
        checked[i]=true;//到達済みにする
        ret += pass(i,N,checked);
        checked[i]=false;
    }
    return ret;
}
int main(){
    int N,M;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        graph[a-1][b-1]=graph[b-1][a-1]=true;
    }
   bool checked[nmax];
   for(int i=0;i<N;i++) checked[i]=false;
   checked[0]=true;
   cout << pass(0,N,checked) << endl;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    for a in range(1, 3501):
        for b in range(1, 3501):
            L = 4*a*b - (a+b)*N
            R = a*b*N
            if L <= 0:
                continue
            if R % L == 0:
                c = R // L
                print(a, b, c)
                exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 65368
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[500005];
signed main(){
	int n,sum;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i==0){
			sum=a[i]; continue;
		}
		sum^=a[i];
	}
	for(int i=0;i<n;i++){
		int k=sum^a[i];
		cout<<k<<' ';
	}
	return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  string S;
  cin >> S;

  //SOLVE
  string ans;

  if (S[0] == 'S') {
    ans = "Cloudy";
  } else if (S[0] == 'C') {
    ans = "Rainy";
  } else {
    ans = "Sunny";
  }



  //OUTPUT
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll h,n;
    cin>>h>>n;
    int a[n];
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

#define rep(i, N) for(int (i) = 0; (i) < (N); i++)
#define all(v) v.begin(), v.end()
using i64 = int_fast64_t;

int main(){
    int A, B;
    cin >> A >> B;
    if(A == 1){
        if(B == 2) cout << 3 << endl;
        else cout << 2 << endl;
    }else if(A == 2){
        if(B == 1) cout << 3 << endl;
        else cout << 1 << endl;
    }else {
        if(B == 1) cout << 2 << endl;
        else cout << 1 << endl;
    }
    
}

Measured memory_bytes: 256
main = interact $ unlines.map (unwords.map show.lookups 1.flip zip weights.int2bin.read).lines

weights = [1,2,4,8,16,32,64,128,256,512]

int2bin :: Int -> [Int]
int2bin 0 = []
int2bin n = n `mod` 2 : int2bin (n `div` 2)

lookups :: Eq a => a -> [(a,b)] -> [b]
lookups _ []     = []
lookups n (x:xs) = if fst x == n then snd x : lookups n xs
                                 else lookups n xs

Measured memory_bytes: 3784
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

struct Vertex {
  int64_t distance{0};
  vector<int64_t> nexts;
};

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

  int64_t N, M;
  cin >> N >> M;
  vector<Vertex> vertices(N);
  for (int64_t i = 0; i < M; ++i) {
    int64_t x, y;
    cin >> x >> y;
    vertices[x - 1].nexts.emplace_back(y - 1);
  }
  int64_t result = 0;

  auto Dfs = [&](auto &&Func, const int64_t t) -> void {
    if (vertices[t].distance > 0) {
      return;
    }
    for (const int64_t n : vertices[t].nexts) {
      Func(Func, n);
      const int64_t c_distance = vertices[n].distance + 1;
      vertices[t].distance = max(vertices[t].distance, c_distance);
      result = max(result, vertices[t].distance);
    }
  };

  for (int64_t v = 0; v < N; ++v) {
    Dfs(Dfs, v);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 12888
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Union_Find_Tree{
	public:
	vi p,r,s;
	Union_Find_Tree(int n){
		p=r=vi(n);
		s=vi(n,1);
		for(int i=0;i<n;i++) p[i]=i;
	}
	int Par(int x){
		if(p[x]==x) return x;
		return p[x]=Par(p[x]);
	}
	int Size(int x){return s[Par(x)];}
	bool Unite(int x,int y){
		x=Par(x);
		y=Par(y);
		if(x==y) return 0;
		if(r[x]<r[y]){
			p[x]=y;
			s[y]+=s[x];
		}
		else{
			p[y]=x;
			s[x]+=s[y];
			if(r[x]==r[y]) r[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){return Par(x)==Par(y);}
};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	vi a(m),b(n,-1);
	vvi g(n,vi(k));
	for(int i=0;i<m;i++){
		cin>>a[i];
		a[i]--;
		b[a[i]]=i;
	}
	for(int i=0;i<n;i++) for(int j=0;j<k;j++){
		cin>>g[i][j];
		g[i][j]--;
	}
	queue<P> q;
	q.push({(1<<m)-1,0});
	vi dis(1<<m,inf);
	dis[(1<<m)-1]=0;
	while(!q.empty()){
		P p=q.front();q.pop();
		int S=p.first,d=p.second;
		for(int i=0;i<k;i++){
			int T=0;
			for(int j=0;j<m;j++) if(S&1<<j){
				int nx=b[g[a[j]][i]];
				if(nx>=0) T|=1<<b[g[a[j]][i]];
			}
//			cout<<S<<' '<<T<<endl;
			if(dis[T]==inf){
				q.push({T,d+1});
				dis[T]=d+1;
			}
		}
	}
//	for(auto i:dis) cout<<i<<' ';cout<<endl;
	cout<<dis[0]<<endl;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void D();

int main()
{
	D();
	fflush(stdout);
	return 0;
}

static void D()
{
	int R, G, B, N;
	get(R, G, B);
	get(N);

	LLONG ans = 0;
	for (int r = 0; r * R <= N; r++) {
		for (int g = 0; ((g * G + r * R) <= N); g++) {
			int bcnt = N - (r * R) - (g * G);
			int b = bcnt / B;
			if ((bcnt % B == 0) && (b >= 0)) {
				ans++;
			}
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3700
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
#include<vector>
#include<tuple>
using namespace std;

int main(){
    int input;
    cin >> input;
    int N = input;
    int digit = 10;
    int res = 0;
    int tot = 0;
    while(input >= 1){
        res = input % digit;
        tot += res;
        input -= res;
        input /= digit;
    }
    if (N % tot == 0) cout << "Yes";
    else cout << "No";
    return 0;
}
















Measured memory_bytes: 256