akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> X(M);
    for (int i = 0; i < M; i++) cin >> X[i];
    if(N>=M){
        cout <<0 << endl;
        return 0;
    }
    sort(X.begin(), X.end());
    vector<ll> dif(M - 1);
    for (int i = 0; i < M - 1; i++){
      dif.push_back(X[i + 1] - X[i]);
    }
    sort(dif.begin(), dif.end(), greater<ll>());
    ll out = 0;
    for (int i = 0; i < N - 1; i++) out += dif[i];
    cout << X[M-1]-X[0]-out << endl;
    return 0;
}

Measured memory_bytes: 5512
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int flag;
    int num;
} b[100009];
int main()
{
    int n,m,ans=0,ans1=0;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
        b[i].flag=0,b[i].num=0;
    for(int i=0; i<m; i++)
    {
        int x;
        char a[5];
        scanf("%d%s",&x,a);
        getchar();
        if(a[0]=='A')
            b[x].flag=1;
        else
        {
            if(b[x].flag==0)
                b[x].num++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(b[i].flag==1)
        {
            ans++;
            ans1+=b[i].num;
        }
    }
    printf("%d %d",ans,ans1);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);


int main (){
  ll a,b,c;
  cin>>a>>b>>c;
  if(a<b&&b<c){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}



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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

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

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

char s[1<<21];
int n,K,dp[25][1<<21];
int main() {
	scanf("%d%d",&n,&K);
	for(int i=0;i<=n;++i){
		scanf("%s",s);
		for(int j=0;j<=(1<<i)-1;++j){
			if(s[j]=='1')dp[i][j|(1<<i)]=1;
		}
	}
	for(int i=n;i>=1;--i){
		for(int j=i;j<=n;++j){
			int b=(1<<j);
			for(int k=0;k<b;++k){
				int tmp=dp[i][k|b],p=-1,q=-1;
				for(int t=i;t>=1;--t)if(((k>>(t-1))&1)==1){p=t;break;}
				for(int t=i;t>=1;--t)if(((k>>(t-1))&1)==0){q=t;break;}
				dp[0][(k+b)>>i]+=tmp;
				if(p!=-1)dp[p-1][(k&((1<<(p-1))-1))|(((k>>i)<<1|1)<<(p-1))|(b>>(i-p))]+=tmp;
				if(q!=-1)dp[q-1][(k&((1<<(q-1))-1))|(((k>>i)<<1)<<(q-1))|(b>>(i-q))]+=tmp;
			}
		}
	}
	for(int i=n;i>=0;--i){
		for(int j=0;j<(1<<i);++j){
			if(dp[0][j|(1<<i)]>=K){
				for(int k=i-1;k>=0;--k)if((j>>k)&1)putchar('1');else putchar('0');
				puts("");
				return 0;
			}
		}
	}
	assert(0);
	return 0;
}

Measured memory_bytes: 174336
n,x0 = map(int,input().split( ))
*x_, = map(int,input().split( ))

x = [x_[i]-x0 for i in range(n)]

from fractions import gcd

g = x[0]

for i in range(1,n):
    g = gcd(g,x[i])
print(abs(g))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    ll X;
    cin >> X;

    ll ans = 0;
    ll current = 100;
    while (current < X)
    {
        current += current / 100;
        ans++;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const 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 true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    vector<pair<int,int>> A,B;
    rep(i,N){
        int x,y;cin>>x>>y;
        A.push_back({y,x});
    }
    rep(i,N){
        int x,y;cin>>x>>y;
        B.push_back({x,y});
    }
    sort(all(A), greater<pair<int, int>>());
    sort(all(B));
    vector<bool> f(N, false);
    //cの小さい順
    rep(i,N){
        int c = B[i].first;
        int d = B[i].second;
        //bの大きい順
        rep(j,N){
            int a = A[j].second;
            int b = A[j].first;
            if(f[j])continue;
            if(a < c && b < d){
                f[j] = true;
                break;
            }
        }
    }
    int cnt =0;
    rep(i,N){
        if(f[i])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
# bを必要なだけ(strideの分)右にずらせばよい
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ai, bi = 0, 0
    stride = 0
    while ai < n and bi < n:
        ax, bx = a[ai], b[bi]
        if ax == bx:
            cnt = 2

            ai += 1
            while ai < n and a[ai] == ax:
                cnt += 1
                ai += 1

            bi_copy = bi
            bi += 1
            while bi < n and b[bi] == bx:
                cnt += 1
                bi += 1

            if cnt > n:
                print('No')
                exit()

            if stride < ai - bi_copy:
                stride = ai - bi_copy

        elif ax < bx:
            ai += 1
        else:
            bi += 1

    print('Yes')
    print(' '.join(map(str, b[n-stride:] + b[:n-stride])))

main()

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

int x[10000];
int main() {
  for(int i=0; i<10000; i++) {
    cin >> x[i];
    if(x[i] == 0) break;
  }
  for(int i=0; i<10000; i++) {
    if(x[i] == 0) return 0;
    cout << "Case " << i+1 << ": " << x[i] << endl;
  }
}



Measured memory_bytes: 3064
s = input()
K = int(input())

def f(s, K):
    known = set()
    for i in range(len(s)):
        for j in range(min(len(s), i + 5), i, -1):
            ss = s[i:j]
            if ss in known:
                break
            known.add(ss)
    return sorted(known)[K -1]

print(f(s, K))


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  vector<unsigned long long int> dp(W+1,0);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  for (int i = 0; i < N; i++) { 
    for (int j = W-w[i]; j >= 0; j--) {
       dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
    }
  }
  unsigned long long int answer = 0;
  for (int i = 0; i <= W; i++) {
    answer = max(dp[i],answer);
  }
  cout << answer;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define N 3010
using namespace std;
struct edges{
	int to,pre;
}e[N<<1];int h[N],etop,a[N];
inline int add_edge(int u,int v)
{	return e[++etop].to=v,e[etop].pre=h[u],h[u]=etop;	}
int can(int x,int fa=0)
{
	for(int i=h[x];i;i=e[i].pre)
	{
		int y=e[i].to;if(y==fa) continue;
		if(a[x]>a[y]&&!can(y)) return true;
	}
	return false;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(can(i)) printf("%d ",i);
	return !printf("\n");
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())

ans = 0
te = ["" for _ in range(n)]
for i in range(n):
	if t[i] == "r" and te[i - k] != "p":
		ans += p
		te[i] = "p"
	elif t[i] == "s" and te[i - k] != "r":
		ans += r
		te[i] = "r"
	elif t[i] == "p" and te[i - k] != "s":
		ans += s
		te[i] = "s"

print(ans)

Measured memory_bytes: 4212
def main():
    from itertools import starmap

    N, M = map(int, input().split())

    s = []
    for _ in range(N):
        a, b = map(int, input().split())
        s.append((a, b))

    p = []
    for _ in range(M):
        c, d = map(int, input().split())
        p.append((c, d))

    def dist(t1, t2):
        return sum(starmap(lambda a, b: abs(a - b), zip(t1, t2)))

    ans = []
    for s_ in s:
        d = 4 * 10 ** 8 + 1
        idx = -1
        for i, p_ in enumerate(p):
            t = dist(s_, p_)
            if t < d:
                d = t
                idx = i
        ans.append(idx + 1)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

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

using namespace std;

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

// 最大公約数を計算
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

// 素因数を列挙
vector<pair<ll, ll>> enumeratePrimeFactors(ll n) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0) {
      continue;
    }
    ll ex = 0; // 指数
    // 割れるだけ割る
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    res.emplace_back(a, ex);
  }
  // nが一度も割られなかった場合
  if (n != 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto gg = enumeratePrimeFactors(g);

  cout << gg.size() + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
x = [tuple(input().split()) for _ in range(q)]

l = 0
r = n
while r-l > 1:
    m = (l+r)//2
    c = s[m]
    idx = m
    for j in range(q):
        if x[j][0] == c:
            if idx == 0 and x[j][1] == "L":
                l = m
                break
            elif idx == n-1 and x[j][1] == "R":
                r = m
                break
            else:
                if x[j][1] == "L":
                    c = s[idx-1]
                    idx -= 1
                else:
                    c = s[idx+1]
                    idx += 1

        if j == q-1:
            r = m
idx1 = l

l = 0
r = n
while r-l > 1:
    m = (l+r)//2
    c = s[m]
    idx = m
    for j in range(q):
        if x[j][0] == c:
            if idx == 0 and x[j][1] == "L":
                l = m
                break
            elif idx == n-1 and x[j][1] == "R":
                r = m
                break
            else:
                if x[j][1] == "L":
                    c = s[idx-1]
                    idx -= 1
                else:
                    c = s[idx+1]
                    idx += 1

        if j == q-1:
            l = m
idx2 = r
print(max(n-(idx1+1)-(n-idx2), 0))


Measured memory_bytes: 96588
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

float myabs(float a){
  return a>0 ? a : -a;    
}

int main(){
  double a,b,c,s,l,h;
  cin >> a >> b >> c;
  c = M_PI*(c/180);
  s = a*b*sin(c)/2;
  l = a+b+sqrt(a*a+b*b-2*a*b*cos(c));
  h = b*sin(c);
  printf("%.8lf\n",s);
  printf("%.8lf\n",l);
  printf("%.8lf\n",h);

}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int a[500001];
int all;
void MaxHeap(int n);

void buileMaxHeap(int n) {
	int k = n / 2;
	for (int i = k; i >= 1; i--) {
		MaxHeap(i);
	}
}
void MaxHeap(int n) {
	int left = n * 2;
	int right = n * 2 + 1;
	int largest;
	if (left <= all && a[left] > a[n]) largest = left;
	else largest = n;
	if (right <= all && a[right] > a[largest]) largest = right;
	if (largest != n) {
		swap(a[n], a[largest]);
		MaxHeap(largest);
	}
}
int main(void) {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	all = n;
	buileMaxHeap(n);
	for (int i = 1; i <= n; i++) {
		cout <<" "<<a[i];
	}
	cout << endl;
}


Measured memory_bytes: 5004
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}



fn main(){
    input!{
        r: f64,
    }
    println!("{}",r * 2.0 * std::f64::consts::PI);
}



Measured memory_bytes: 2228
#include <bits/stdc++.h>
#include<algorithm>
#define ll long long
#define pb push_back
#define popb pop_back
#define ull unsigned long long 
#define beg begin
using namespace std;
 
int main(void) {
     ios::sync_with_stdio(0);
     ll n , sum = 0;
     cin >> n ;
     ll k = n ;
     while(n>0)
     {
          sum += n%10 ;
          n = n / 10 ;
     }
     if(k%sum == 0)
          cout << "Yes" ;
     else
          cout << "No" ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B;
  cin >> A >> B;

  if(A <= B) cout << "unsafe" << "\n";
  else cout << "safe" << "\n";


  return 0;
}

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

int main(){
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  if(s2.at(0) == '+'){
     cout << stoi(s1) + stoi(s3) << endl;
  }else{
     cout << stoi(s1) - stoi(s3) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

/*bool func(long long n) {
    string s = "";
    while(n > 0) {
        s += ('0' + n%10);
        n /= 10;
    }
    bool is = true;
    for(int i = 0; i < s.size()-1; i++) {
        if(abs((s[i]-'0') - (s[i+1]-'0')) > 1)
            is = false;
    }
    return is;
}*/

string func(string ss) {
    string s = ss;
    //cout << s << endl;

    bool done = false;
    for(int i = s.size()-1; i >= 0; i--) {
        //cout << "i" << endl;
        if(s[i] == '9') continue;

        vector<char> v;
        if(i+1 < s.size()) v.push_back(s[i+1]);
        if(i-1 >= 0) v.push_back(s[i-1]);
        bool can_inc = true;
        for(char c : v) {
            can_inc &= (abs(s[i]+1 - c) <= 1);
        }
        if(!can_inc) continue;
        s[i] = s[i] + 1;
        for(int j = i+1; j < s.size(); j++) {
            s[j] = (s[j-1] == '0' ? '0' : (s[j-1] - 1));
        }
        done = true;
        break;
    }
    if(done) {
        //cout << "d" << endl;
        return s;
    }
    else {
        //cout << "nd" << endl;
        string res(ss.size(), '0');
        res = '1' + res;
        return res;
    }


}

int main() {
    IOS;

    //string s = "99";
    //cout << func(s) << endl;


    int k;
    cin >> k;

    string s = "1";
    for(int i = 0; i < k-1; i++) {
        s = func(s);
        //cout << s << endl;
    }
    cout << s << endl;


    return 0;
}


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

int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string S;
  cin>>S;
  bool ans=true;
  if(c<d){
    for(int i=a-1;i<c-1;i++){
      if(S[i]=='#'&&S[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    for(int i=b-1;i<d-1;i++){
      if(S[i]=='#'&&S[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }else{
    for(int i=a-1;i<c-1;i++){
      if(S[i]=='#'&&S[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    for(int i=b-1;i<d-1;i++){
      if(S[i]=='#'&&S[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    bool flag=false;
    for(int i=b-1;i<d;i++){
      if(S[i-1]=='.'&&S[i]=='.'&&S[i+1]=='.'){
        flag=true;
        break;
      }
    }
    if(!flag){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 640
n=int(input())

l=[]
a=[]
b=[]
d={}
s=[]

for i in range(1,n+1):
    t=list(input().split())
    l.append([t[0],int(t[1])])
    if t[0] not in a:
        a.append(t[0])
    b.append(t[0])
c=l.copy()
for e in a:
    d[e]=b.count(e)
c.sort()
i=0
while i<n:
    if d[c[i][0]]==1:
        s.append(l.index(c[i])+1)
        i+=1
    else:
        for j in range(d[c[i][0]]):
            s.append(l.index(c[i+d[c[i][0]]-1-j])+1)
        i+=d[c[i][0]]

for i in range(n):
    print(s[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (i <= K)
      ans += X;
    else
      ans += Y;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

void hawawa()
{
  string str;
  cin >> str;
  str[5] = str[13] = ' ';
  cout << str << "\n";
}

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

Measured memory_bytes: 256
a, b, k = map(int, input().split())
list = []

for i in range(a, min(b + 1, a + k)):
    list.append(i)

for i in range(max(a, b - k + 1), b + 1):
    if i not in list:
        list.append(i)

for i in range(len(list)):
    print(list[i])

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	bool f=true;
	string s0,s1;
	set<string>w;
	cin>>n;
	cin>>s0;
	w.insert(s0);
	for(int i=1;i<n;i++){
		cin>>s1;
		if (w.count(s1)) {
			f=false;
		}
		if(s0.substr(s0.length()-1,1)!=s1.substr(0,1)){
			f=false;
		}
		w.insert(s1);
		s0=s1;
	}
	if(f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int n, m, K, inp;
	cin >> n >> m;
	map<int, int> mp;

	REP(i, n){
		cin >> K;
		REP(j, K){
			cin >> inp;
			mp[inp]++;
		}
	}

	int cnt = 0;
	for(int i = 1; i <= m; i++){
		if(mp[i] == n){
			cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
n = int(input())
list_room = [0 for i in range(120)]

for i in range(n):
	b, f, r, v = map(int, input().split())
	room = ((b-1)*3+(f-1))*10 + r-1
	list_room[room] += v

#print(list_room)

for i in range(4):
	for j in range(3):
		line = ""
		for k in range(10):
			line += " "+str(list_room[i*30 + j*10 + k])			
		print(line)
	if i != 3:	
		print("#"*20)


	

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

int main()
{
  int64_t A;
  string S;
  cin >> A >> S;
  int64_t B = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) == '.')
      continue;
    int j = S.at(i) - '0';
    B = 10 * B + j;
  }
  cout << A * B / 100 << endl;
}

Measured memory_bytes: 3568
using System;

class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            
            var str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);

            bool flg = false;
            for(int i = 1; i * K <= B;i++)
            {
                int value = i * K;
                if (value >= A && value <= B)
                {
                    flg = true;
                    break;
                }
            }
            if (flg)
                Console.WriteLine("OK");
            else
                Console.WriteLine("NG");

        }
    }

Measured memory_bytes: 27544
#include<bits/stdc++.h>
using namespace std;
int main(){
	long n,a,b,c;
	a=2;
	b=1;
	cin>>n;
	if (n>1){
	for (int i=1;n>i;i++){
		c=a+b;
		a=b;
		b=c;
	}
	}
	if (n<=1){
		c=1;
		}
	cout<<c<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    vector<ll> a(4) ;
    rep( i , 0 , 4 )
        cin >> a[i] ;
    sort(all(a));
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)
        cout << "YES";
    else
        cout << "NO" ;
}  
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 256
fun main() {
  val N = readInt()
  val AN = readInts()
  val x = Array(N) { 0L }
  for (i in AN.indices) {
    if (i % 2 == 0) x[0] = x[0] + AN[i] else x[0] = x[0] - AN[i]
  }
  x[0] = x[0] / 2
  for (i in 1 until N) {
    x[i] = AN[i - 1] - x[i - 1]
  }
  println(x.map { it * 2 }.joinToString(" "))
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }

fun myBinarySearch(begin: Int, end: Int, isOk: (key: Int) -> Boolean): Int {
  var ng = begin
  var ok = end

  while (Math.abs(ok - ng) > 1) {
    val mid = (ok + ng) / 2
    if (isOk(mid)) {
      ok = mid
    } else {
      ng = mid
    }
  }

  return ok
}

fun <T> List<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}

fun <T> Array<T>.myBinarySearch(isOk: (T) -> Boolean): Int {
  return myBinarySearch(-1, size) { index -> isOk(get(index)) }
}


Measured memory_bytes: 59620
<?php

$base = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";

$num_array = explode(", ", $base);

$input = rtrim(fgets(STDIN));

echo $num_array[$input-1];

?>

Measured memory_bytes: 4604
def removal?(arr)
  arr.all? { |a| a == '.' }
end

h, w = gets.split.map(&:to_i)
ahw = h.times.map { gets.chomp.split('') }

ans = ahw.reject { |ah| removal?(ah) }
         .transpose
         .reject { |aw| removal?(aw) }
         .transpose.map(&:join)

ans.each { |ah| puts ah }


Measured memory_bytes: 2684
#include <iostream>
#include <algorithm>

using namespace std;

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

	int _max = 0;
	int _min = pre_data;
	int dd_min = -1000000001;

	bool ck = false;

	int n_data;
	while ( cin >> n_data ) {

		if ((pre_data - n_data) < 0) {
			ck = true;
			_max = max(_max, n_data -_min);
		} else {
			_min = min(_min, n_data);
			dd_min = max(dd_min, n_data-pre_data);
		}
		pre_data = n_data;
	}
	cout << ((ck) ? _max : dd_min) << endl;;
	return 0;
}

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

int main(){
  int a;
  cin >> a;
  
  int b;
  b = a % 10 ;
  
  if (b == 2 ||  b==4 || b==5 || b==7|| b==9){
    cout << "hon";
  }
  else if (b == 0 || b==1 ||  b==6 || b==8){
    cout << "pon";
  }
  else {
    cout << "bon";}
  
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    ll x,y;
    int ans=0;
    cin>>x>>y;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            if((i+j)==x&&(2*i+4*j)==y){
                ans=1;
                break;
            }
        }
    }
    yn(ans);
}

long long int series_sum(long long int n){
    long long int ans=0;
    for(long long int i=1;i<=n;i++){
        ans+=i;
    }
    return ans;
}
template <typename T>
T digitsum(T n){
    string s=to_string(n);
    T sum=0;
    T d=1;
    for(T e=0;e<s.length();e++){
        sum+=(n/d)%10;d*=10;
    }
    return sum;
}
template <typename T>
bool isPrime(T n){
    if(n<=1)return false;
    if(n==2)return true;
    if(n%2==0)return false;
    for(T q=3;q*q<=n;q+=2){
        if(n%q==0)return false;
    }
    return true;
}
template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    if(n%2==0){
        T tmp = 0;
        while (n % 2 == 0) {
            tmp++;
            n /= 2;
        }
        ret.push_back(make_pair(2, tmp));
    }
    for (T i = 3; i*i <= n; i+=2) {
        if(n%i==0){
            T tmp = 0;
            while (n % i == 0) {
                tmp++;
                n /= i;
            }
            ret.push_back(make_pair( i, tmp));
        }
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}
long long int intpow(long long int x,long long int n){
    long long int ans=1;
    for(int i=0;i<n;i++){
        ans*=x;
    }
    return ans;
}
template <typename T>T intlog(T x){
    string a=to_string(x);
    return a.length()-1;
}
long long int combination(long long int a,long long int b){
    queue<long long int> bunsi,bunbo;
    long long int ans=1;
    b=min(b,a-b);
    for(int i=0;i<b;i++){
        bunsi.push(a-i);
        if(b-i>=2)bunbo.push(b-i);
    }
    while(bunsi.size()!=0||bunbo.size()!=0){
        ans*=bunsi.front();
        bunsi.pop();
        if(ans%bunbo.front()==0){
            ans/=bunbo.front();
            bunbo.pop();
        }
    }
    return ans;
}

Measured memory_bytes: 3624
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}

console.log(main());
function main(){
  var x = o.a();
  var y = o.a();
  var n = x+y;
  if(n % 3 || x > 2*y || y > 2*x)return 0;
  n /= 3;
  fset(n);
  if(x > y){var t=y;y=x;x=t;}
  var m = y-x;
  m = (n-m)/2;
  return ncr(n,m);
}

Measured memory_bytes: 32972
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  char a,b,c;
  cin >> a;
  
  if(a=='A') b='T';
   if(a=='T') b='A';
   if(a=='G') b='C';
   if(a=='C') b='G';
  
  cout <<b <<endl;
   return 0;
}


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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  

void solve() {
    int n;
    cin >> n;
    vector<int> dp(3, 0);
    for (int day = 0; day < n; ++day)  {
        vector<int> dp2(3, 0);
        vector<int> c(3);
        for (int i = 0; i < 3; ++i) {
            cin >> c[i];
        }
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i != j) {
                    dp2[j] = max(dp[i] + c[j], dp2[j]);
                }
            }
        }
        dp = dp2;
    }
    cout << *max_element(all(dp));
}

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

//  freopen ("in.txt", "r", stdin);
//  freopen ("err.txt", "w", stderr); 
//  freopen ("out.txt", "w", stdout);

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A<=8 && B<=8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}


Measured memory_bytes: 20560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    vector<vector<mint>> dp(N+1, vector<mint>(K+1));
    dp[0][K] = 1;
    rep(i,N) {
        rep(j,K+1) {
            if (j == K) dp[i+1][K - a[i]] += dp[i][K];
            else {
                dp[i+1][max(0,j-a[i])] += dp[i][j];
                dp[i+1][j+1] -= dp[i][j]; 
            }
        }
        rep(j,K) {
            dp[i+1][j+1] += dp[i+1][j];
        }
    }

    cout << dp[N][0].a << endl;
}

Measured memory_bytes: 80256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, x, max;
	int a, b, c;
	int ans;

	while (1) {
		scanf("%d%d", &n, &x);
		if (n == 0 && x == 0) break;

		ans = 0;
		max = x; if (max > n) max = n;
		for (a = 1; a <= max; a++) {
			for (b = a + 1; b <= max; b++) {
				c = x - a - b;
				if (c > b && c <= n) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2128
#include<stdio.h>

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    
    int d = a / b;
    int r = a % b;
    double f = 1.0 * a / b;
    
    printf("%d %d %.8lf\n", d, r, f);
    
    return 0;
}


Measured memory_bytes: 2080
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        mut n: u64,
    }

    let mut ans = vec![];
    while n > 0 {
        n -= 1;
        ans.push(b'a' + (n % 26) as u8);
        n /= 26;
    }
    ans.reverse();
    let r = std::str::from_utf8(&ans).unwrap();
    println!("{}", r);
}


Measured memory_bytes: 2100
# coding: utf-8
S = input()
N = len(S)


def create(N, b, c):
    a = ""
    i = 0
    while i < (N // 2):
        a += b + c
        i += 1
    if N % 2 == 1:
        a += b
    lst = [0 for i in range(N) if a[i] == S[i]]
    return len(lst)


print(min(create(N, '1', '0'), create(N, '0', '1')))


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

Measured memory_bytes: 21716
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	int tmp;
	rep(i, n) {
		cin >> tmp;
		a[tmp] = i+1;
	}
	

	rep(i, n+1) {
		if (i == 0)continue;
		cout << a[i]<<" ";
	}


}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    class Point
    {
        internal int x;
        internal int y;
    }

    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            bool[] redpoint = new bool[2 * N + 1];
            var red = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int x = int.Parse(s[0]);
                int y = int.Parse(s[1]);               
                red[x] = y;              
            }

            bool[] bluepoint = new bool[N];
            var blue = new Dictionary<int, int>();
            for(int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int x = int.Parse(s[0]);
                int y = int.Parse(s[1]);              
                blue[x] = y;
            }

            var xsort_blue = blue.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value);
            var ysort_red = red.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, y => y.Value);

            /*
            Console.WriteLine("b");
            foreach (var s in xsort_blue)
            {
                Console.WriteLine($"({s.Key}, {s.Value})");
            }
            Console.WriteLine("r");
            foreach (var s in ysort_red)
            {
                Console.WriteLine($"({s.Key}, {s.Value})");
            }
            */

            int ans = 0;
            foreach (var s in xsort_blue)
            {
                int x = s.Key;
                int y = s.Value;
                foreach(var t in ysort_red)
                {
                    if (x > t.Key &&  y > t.Value && !redpoint[t.Key])
                    {
                        redpoint[t.Key] = true;
                        ans++;
                        //Console.WriteLine($"b ({x}, {y}) r ({t.Key}, {t.Value})");
                        break;
                    }
                }

            }

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13404
import std.stdio, std.array, std.conv, std.string;

void main() {
  string[] input = split(readln());
  int[] a = new int[3];

  for (int i = 0; i < 3; ++i) {
    a[i] = to!int(input[i]);
  }

  if (a[0] < a[1] && a[1] < a[2]) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}

Measured memory_bytes: 2484
//arc092_d.cpp
//Mon Jan 27 11:24:03 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	ll ans = 0;
	for (int i=29;i>=0;i--){
		ll bekihigh = 1<<(i+1);
		ll bekilow = 1<<i;
		for (int j=0;j<n;j++){
			a[j] = a[j]%bekihigh;
			b[j] = b[j]%bekihigh;
		}
		sort(b.begin(),b.end());
		ll keta = 0;
		for (int j=0;j<n;j++){
			int iter1t = lower_bound(b.begin(),b.end(),bekilow-a[j])-b.begin();
			int iter2t = lower_bound(b.begin(),b.end(),bekilow*2-a[j])-b.begin();
			int iter3t = lower_bound(b.begin(),b.end(),bekilow*3-a[j])-b.begin();
			int iter4t = lower_bound(b.begin(),b.end(),bekilow*4-a[j])-b.begin();
			keta += (iter2t-iter1t)+(iter4t-iter3t);
		}
		if (keta%2==1){
			ans += bekilow;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3328
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    S = input()[::-1] # 入力文字列を逆順で格納
    counts = [0] * 2019
    counts[0] = 1
    num, d = 0, 1

    for char in S:
        num = num + int(char) * d
        num = num % 2019
        d = d * 10
        d = d % 2019
        counts[num] += 1 #余りの数の番号のリストに+1していくことでカウント

    ans = 0
    for cnt in counts:
        ans += cnt * (cnt - 1) // 2
    print(ans)

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9320
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>

typedef long long llong;
using namespace std;

void lower(char* x) {
	for (int i = 0; x[i] != '\0'; i++) {
		if (65 <= x[i] && x[i] <= 90)x[i] += 32;
	}
	return;
}

int main() {
	char W[20];
	char T[1100];
	int cnt = 0;
	scanf("%s", W);
	while (1) {
		scanf("%s", T);
		if (!strcmp(T,"END_OF_TEXT"))break;
		lower(T);
		if (!strcmp(W, T))cnt++;
	}
	cout << cnt << '\n';
	return 0;
}



Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

bool comp(const pair<int, int> &a, const pair<int, int> &b){
	return a.first>b.first;
}

void solve(){ 	
	int n;
	cin>>n;
	int arr[n+1] = {0}, res[n+1]={0};
	FOR(i, 1, n+1) cin>>arr[i];
	FOR(i, 1, n+1){
		res[arr[i]] = i;
	}
	FOR(i, 1, n+1) cout<<res[i]<<" ";
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 2432
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    A, B = list(map(int, input().split()))

    # 最大公約数
    a = max(A, B)
    b = min(A, B)
    while b:
        a, b = b, a % b
    # print(a)

    # 素因数分解
    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n:
            while n % i == 0:
                n /= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    pp = prime_decomposition(a)
    # print(pp)

    # 最大公約数を素因数分解したリストから重複を除いたものがanswer
    ans = len(set(pp)) + 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<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; }



int main(int argc, char const *argv[]) {
  int n, l;
  cin >> n >> l;
  ll left = l, right = l + n - 1;
  ll eat;
  if (left >= 0) eat = left;
  else if(right<=0)
    eat = right;
  else
    eat = 0;
  cout << (right+left)*(right-left+1)/2-eat << endl;
    return 0;
}

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

int main() {
    int N,W; 
    cin >> N >> W;
    vector<long long int> K(W+1);
    vector<int> wt(N);
	vector<int> v(N);
    for(int i =0 ;i<N-1;i++){
    	cin >> wt[i] >> v[i];
    	for (int j = W; j >= 1; j--)
    		if(wt[i]<=j)
    			K[j] = max(v[i]+K[j-wt[i]],K[j]);
    }
    cin >> wt[N-1] >> v[N-1];
 	cout << max(v[N-1]+K[W-wt[N-1]],K[W]);

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,b,a) for(int i=b;i>a;i--)
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define cps CLOCKS_PER_SEC
#define complex cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
  }
  return r;
}

//think recursively also

void solve()
{  
  set<ll>s;
  ll x;
  cin>>x;
  for(ll i=0;;)
  {
    if(pow(i,5)<=(ll)(1e18))
    {
      s.insert(pow(i,5));
    }
    else
      break;
    i++;
  }
  for(auto it:s)
  {
    if(it<x)
    {
     ll lef=x-it;
     if(s.find(lef)!=s.end())
     {
      cout<<pow(it,0.2)<<" "<<-1LL*pow(lef,0.2)<<endl;
      return;
     }
    }
    else
    {
       ll lef=it-x;
       if(s.find(lef)!=s.end())
       {
        cout<<pow(it,0.2)<<' '<<pow(lef,0.2)<<endl;
        return;
       }
    }
  }
  
}
int main()
{
   fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  { //cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

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

#define ll long long

using namespace std;

int n;
bool pr[(int)1e7 + 1];
ll ans;

ll calc(int x) {
  int cnt = n / x;
  return x * 1ll * cnt * (cnt + 1) / 2;
}

main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ans += calc(i);
  }
  cout << ans << '\n';
}


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

 vector<int> num;
 long long int N;
 cin>>N;
 long long int x;
 for(int i = 0; i  < N; i++){
  cin>>x; num.push_back(x);

 }

 sort(num.begin(), num.end());
 long long int res;
 res = num[num.size()-1] - num[0];
 cout<<res;
 return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int a=1;a<=n;a++){
	for(int b=1;b<=n;b++){
	    for(int c=1;c<=n;c++){
		sum+=__gcd(a,__gcd(b,c));
	    }
	}
    }
    cout<<sum;
}


Measured memory_bytes: 3648