akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int x,y;
  cin>>x>>y;
  int ax = abs(x), ay = abs(y);
  int ans = 0;
  if(ax == ay) {
    ans = 1;
  } else if(ax < ay) {
    if(0 <= x && x < y) {
      ans = ay - ax;
    } else if(x < 0 && y < x) {
      ans = ay - ax + 2;
    } else {
      ans = ay - ax + 1;
    }
  } else {
    if(y <= 0 && x < y) {
      ans = ax - ay;
    } else if(0 < y && y < x) {
      ans = ax - ay + 2;
    } else {
      ans = ax - ay + 1;
    }
  }
  cout << ans << endl;

  return 0;

}


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

int main() {
	ll n;
	cin >> n;
	ll sum = 0;
	map<ll, ll> a;
	rep(i, n) {
		ll aa; cin >> aa;
		a[aa]++;
		sum += aa;
	}
	ll q; cin >> q;
	rep(i, q) {
		ll b, c;
		cin >> b >> c;
		if (a[b]==0) cout << sum << endl;
		else {
			sum -= b * a[b];
			sum += c * a[b];
			cout << sum << endl;
			a[c] = a[b] + a[c]; 
			a[b] = 0;
		}
	}
	return 0;
}

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

int main() {
  string n;
  cin>>n;
  int64_t count =0;
  int64_t i=0;
  while(i < n.size()) {
  	count += (n[i]-48);
   // cout<<count;
    i++;
  }

  if(count%9 == 0) {
  	cout<<"Yes";
  } else {
  	cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3696
a,b=input().split()
a = int(a)
b = int(b)
ans = []
for i in range(b-a+1, b):
    ans.append(str(i))
ans.append(str(b))
for i in range(b+1, a+b):
    ans.append(str(i))
print(' '.join(ans))

Measured memory_bytes: 3060
N = int(input())
H = list(map(int,input().split()))
count = 0
count_max = 0
for i in range(N-1):
  if H[i]>=H[i+1]:
    count = count+1
  elif H[i]<=H[i+1] and count_max<count:
    count_max = count
    count = 0
  else:
    count = 0
if count_max>count:
  print(count_max)
else:
  print(count)

Measured memory_bytes: 20512
#include <iostream>
using namespace std;
int main() {
	double v;
	while(cin >> v && v){
		double t;
		int h;
		t = v/9.8;
		for(int i=0; ; ++i){
			if(4.9*t*t <= 5*i-5){
				h = i;
				break;
			}
		}
		cout << h << endl;
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
constexpr ll M = 1e9 + 7;
 
int main() {
    int n;
    cin >> n;
    string rank;
    for(int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        if(c != '-') {
            rank += c;
        }
    }
    n = rank.size();

    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1));
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(rank[i] == 'U') {
                (dp[i + 1][j] += dp[i][j] * j) %= M;
                (dp[i + 1][j + 1] += dp[i][j]) %= M;
            } else {
                (dp[i + 1][j] += dp[i][j] * j) %= M;
                (dp[i + 1][j - 1] += dp[i][j] * j * j) %= M;
            }
        }
    }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 3272
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}



int main(){
    ll w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(r<=x && x<=w-r && r<=y && y<=h-r)puts("Yes");
    else puts("No");
    return 0;
}
 



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
typedef long long ll;

int N,A,B,C,D;
string S;

int main() {
    cin >> S;
    int N = (int)S.size();

    ll ans = 0, a = 0;
    REP(i,N-1){
        if(S[i]=='A'){
            ++a;
        } else if(S[i]=='B' && S[i+1]=='C'){
            ans += a;
            ++i;
        } else {
            a = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    unsigned long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    unsigned long long int sum=a+b+c;
    unsigned long long int term=max(a,max(b,c));
    sum-=term;
    while(k)
    {
        term*=2;
        k--;
    }
    cout<<sum+term;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for(int i=0; i<H; i++){
    cin >> S[i];
  }
  int ans = 0;
  for(int h=0; h<H; h++){
    for(int w=0; w<W; w++){
      vector<string> G;
      G = S;
      int res = 0;
      G[h][w] = '#';
      for(int i=H-1; i>=0; i--){
        for(int j=0; j<W; j++){
          if(G[i][j]=='#'){
            int temp = i;
            while(temp>=0 && G[temp][j]=='#'){
              temp--;
            }
            if(temp != -1){
              swap(G[temp][j],G[i][j]);
            }
          }
        }
      }
      int cnt = 1;
      while(1){
        int sum = 0;
        bool changed = false;
        for(int i=0; i<H; i++){
          for(int j=0; j<W; j++){
            if(G[i][j] == '#') continue;
            if(G[i].substr(j,K) == string(K,G[i][j])){
              changed = true;
              int pos = j+1;
              while(pos<W && G[i][pos]==G[i][j]){
                sum += G[i][j] - '0';
                G[i][pos] = '#';
                pos++;
              }
              sum += G[i][j] - '0';
              G[i][j] = '#';
            }
          }
        }
        for(int i=H-1; i>=0; i--){
          for(int j=0; j<W; j++){
            int temp = i;
            while(temp>=0 && G[temp][j]=='#'){
              temp--;
            }
            if(temp != -1){
              swap(G[temp][j],G[i][j]);
            }
          }
        }
        if(!changed){
          break;
        }
        res += sum * cnt;
        cnt *= 2;
      }
      // cout << endl;
      // for(int i=0; i<H; i++){
      //   for(int j=0; j<W; j++){
      //     cout << G[i][j];
      //   }
      //   cout << endl;
      // }
      chmax(ans,res);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
M = 10**9+7
xs = []
for _ in range(N):
    xs.append(list(map(int, input().split())))
X = np.array(xs, dtype="object")
S = np.ones(N, dtype="object")
#Xs = [X]
for _ in range(60):
#    Xs.append(np.dot(Xs[-1],Xs[-1])%M)
    if K%2:
        S = np.dot(X, S)%M
    K = K//2
    X = np.dot(X, X)%M
S = np.array(S, dtype="int64")
r = 0
for s in S:
    r = (r + s)%M
print(r)

Measured memory_bytes: 14544
import java.util.*;
import java.io.*;
import java.math.*;
	        public final class Main {
	    	static void solve(int[] arr, int n) {
	    	}
	        public static void main(String args[]) throws IOException {
	        	FastReader sc = new FastReader();
	        		String str = sc.next();
	        		
	        		long sum = 0;
	        		for(int i = 0;i < str.length();i++) {
	        			sum += Character.getNumericValue(str.charAt(i));
	        		}
	        		if(sum%9 == 0 ) {
	        			pn("Yes");
	        		}
	        		else pn("No");
	       }
	       static void p(Object p){System.out.print(p);}
	       static void pn(){System.out.println();}
	       static void pn(Object o){System.out.println(o);}
	       
	       static class FastReader {
	       static BufferedReader br;
	       StringTokenizer st;
	       public FastReader() {
	       br = new BufferedReader(new InputStreamReader(System.in));
	       }
	            
	       String next(){
	       while (st == null || !st.hasMoreElements()) {
	            try{
	                st = new StringTokenizer(br.readLine());
	            }
	            catch (IOException  e) {
	                e.printStackTrace();
	            }}
	            return st.nextToken();
	            }
	            
	            int nextInt(){ 
	                return Integer.parseInt(next());
	            }
	            
	            long nextLong(){ 
	                return Long.parseLong(next());
	            }
	            
	            static int max(int[] a){
	            int max = Integer.MIN_VALUE;
	            for(int i : a) max = Math.max(max, i);
	            return max;
	            }
	            
	            public int[] readIntArray(int n) {
	            int[] arr = new int[n];
	            for(int i=0; i<n; ++i) arr[i]=nextInt();
	            return arr;
	            }
	            
	            public long[] readLongArray(int n){
	            long[] arr = new long[n];
	            for(int i=0; i<n; ++i) arr[i]=nextLong();
	            return arr;
	            }
	            
	            public int[][] readIntArray(int m, int n){
	            int[][] arr = new int[m][n];
	            for(int i = 0;i<m;i++) 
	            for(int j = 0;j<n;j++) arr[i][j] = nextInt();
	            return arr;
	            }
	            
	            public String[] readStringArray(int n) {
	            String[] arr = new String[n];
	            for(int i=0; i<n; ++i) arr[i]= nextLine();
	            return arr;
	            }
	            
	            double nextDouble() {return Double.parseDouble(next());}
	            
	            String nextLine() {
	            String str = "";
	            try{str = br.readLine();}
	            catch (IOException e) {e.printStackTrace();}
	            return str;}}
	        }


Measured memory_bytes: 36592
x, k, d = map(int, input().split())
out = 0
m = abs(x) // d
if m > k:
    out = x - k * d if x >= 0 else abs(x + k * d)
else:
    if (k - m) % 2 == 0:
        out = x - m * d if x >= 0 else abs(x + m * d)
    else:
        out = (m + 1) * d - x if x >= 0 else (m + 1) * d + x
print(out)


Measured memory_bytes: 9208
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
char map[111][111];
int w[33][33],b[33][33];
int main()
{
	int A=io::F(),B=io::F();
	printf("100 100\n");
	if(A>B)
	{
		--B;
		for(register int i=1;i<=25;++i)
			for(register int j=1;j<=25;++j)
			{
				if(A)--A,w[i][j]=1;
				if(B)--B,b[i][j]=1;
			}
		for(register int i=1;i<=25;++i)
			for(register int j=1;j<=25;++j)
			{
				for(register int k=0;k<4;++k)
					map[i*4][j*4-k]=map[i*4-k][j*4]='#';
				map[i*4-2][j*4-2]=w[i][j]==0||b[i][j]?'#':'.';
				map[i*4-3][j*4-3]=w[i][j]?'.':'#';
				map[i*4-3][j*4-2]=w[i][j]?'.':'#';
				map[i*4-3][j*4-1]=w[i][j]?'.':'#';
				map[i*4-2][j*4-3]=w[i][j]?'.':'#';
				map[i*4-2][j*4-1]=w[i][j]?'.':'#';
				map[i*4-1][j*4-3]=w[i][j]?'.':'#';
				map[i*4-1][j*4-2]=w[i][j]?'.':'#';
				map[i*4-1][j*4-1]=w[i][j]?'.':'#';
			}
	}
	else
	{
		--A;
		for(register int i=1;i<=25;++i)
			for(register int j=1;j<=25;++j)
			{
				if(A)--A,w[i][j]=1;
				if(B)--B,b[i][j]=1;
			}
		for(register int i=1;i<=25;++i)
			for(register int j=1;j<=25;++j)
			{
				for(register int k=0;k<4;++k)
					map[i*4][j*4-k]=map[i*4-k][j*4]='.';
				map[i*4-2][j*4-2]=b[i][j]==0||w[i][j]?'.':'#';
				map[i*4-3][j*4-3]=b[i][j]?'#':'.';
				map[i*4-3][j*4-2]=b[i][j]?'#':'.';
				map[i*4-3][j*4-1]=b[i][j]?'#':'.';
				map[i*4-2][j*4-3]=b[i][j]?'#':'.';
				map[i*4-2][j*4-1]=b[i][j]?'#':'.';
				map[i*4-1][j*4-3]=b[i][j]?'#':'.';
				map[i*4-1][j*4-2]=b[i][j]?'#':'.';
				map[i*4-1][j*4-1]=b[i][j]?'#':'.';
			}
	}
	for(register int i=1;i<=100;++i)
		puts(map[i]+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pw(x) (1LL << (x))
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl

using namespace std;
typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;

bool solve(ll a, ll b, ll c, ll d) {
    if (a < b) return 0;
    if (d < b) return 0;
    if (c >= b) return 1;
    ll g = __gcd(d, b);

    ll x = a % b;
    x += g * (b / g - 1 - x / g);
    return x <= c;
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int T;
    int first = 1;
    while (cin >> T) {
        if (first) first = 0;
        else cout << endl;

        while (T--) {
            ll a, b, c, d;
            cin >> a >> b >> c >> d;

            const string Z[2] = {"No", "Yes"};
            cout << Z[solve(a, b, c, d)] << endl;
        }
    }


#ifdef HOME
    cerr << "time = " << (clock() * 1. / CLOCKS_PER_SEC) << "\n";
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
int x ,y;
for(int i=0; ;i++)
{
cin>>x>>y;
if(x==0&&y==0)
break;
else if(x>y)
cout<<y<<' '<<x<<endl;
else
cout<<x<<' '<<y<<endl;
}
    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else if(a == b){
        printf("a == b\n");
    }


return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<cstring>
#include<algorithm>

struct Edge
{
	int to,next;
}edge[400005];
int head[200005],cnt;

void Addedge(int a,int b)
{
	++cnt;
	edge[cnt]=(Edge){a,head[b]};
	head[b]=cnt;
}

int dist[200005];

void dfs(int x,int fa)
{
	for(int i=head[x];i;i=edge[i].next)
	{
		int to=edge[i].to;
		if(to!=fa)
		{
			dist[to]=dist[x]+1;
			dfs(to,x);
		}
	}
}

int main()
{
	int n,a,b;
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		scanf("%d%d",&a,&b);
		Addedge(a,b);
		Addedge(b,a);
	}
	dfs(1,0);
	int c=1;
	for(int i=1;i<=n;++i)
	{
		if(dist[i]>dist[c]) c=i;
	}
	memset(dist,0,sizeof(dist));
	dfs(c,0);
	int len=0;
	for(int i=1;i<=n;++i)
	{
		len=std::max(len,dist[i]);
	}
	if(len%3==1)
	{
		printf("Second");
	}
	else
	{
		printf("First");
	}
	return 0;
}

Measured memory_bytes: 14208
from collections import defaultdict


def comb(n, k, mod=10 ** 9 + 7):
    denominator = 1
    numerator = 1
    for i in range(1, k + 1):
        denominator = denominator * i % mod
    for i in range(n - k + 1, n + 1):
        numerator = numerator * i % mod
    return numerator * pow(denominator, mod - 2, mod) % mod


def main():
    n, m = map(int, input().split())
    factorization = defaultdict(int)
    while not m % 2:
        factorization[2] += 1
        m //= 2
    f = 3
    while f * f <= m:
        if not m % f:
            factorization[f] += 1
            m //= f
        else:
            f += 2
    if m != 1:
        factorization[m] += 1
    ans = 1
    mod = 10 ** 9 + 7
    for _, c in factorization.items():
        ans *= comb(c + n - 1, c, mod)
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9388
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int A=sc.nextInt(), B=sc.nextInt();
    if(A%2==0 || B%2==0)System.out.println("No");
    else System.out.println("Yes");
  }
}


Measured memory_bytes: 35888
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    graph={i+1:dict() for i in range(N)}
    #print(graph)
    for i in range(N-1):
        u,v,w=pin()
        graph[u][v]=w%2
        graph[v][u]=w%2
    #print(graph)

    ans={i+1:0 for i in range(N)}
    seen={i+1:0 for i in range(N)}
    #ans[1]=0 (always)
    stack=[(1,0)]#pos,color
    while (stack!=[]):
        p,c=stack.pop()
        if seen[p]==1:continue

        seen[p]=1
        ans[p]=c
        for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
    print(*ans.values(),sep="\n")
resolve()


Measured memory_bytes: 99684
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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


  ll N, W;
  cin >> N >> W;

  ll vals[N + 1], wts[N + 1];

  for (int i = 1; i <= N; i++) {
    cin >> wts[i] >> vals[i];
  }

  ll dp[N + 1][W + 1];

  for (int i = 0; i <= W; i++) {
    dp[0][i] = 0;
  }

  for (int i = 0; i <= N; i++) {
    dp[i][0] = 0;
  }

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= W; j++) {
      if (wts[i] > j)
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = max(dp[i - 1][j], vals[i] + dp[i - 1][j - wts[i]]);
    }
  }

  cout << dp[N][W];
}

Measured memory_bytes: 79104
n,c = gets.chomp.split(" ").map(&:to_i)
prog = n.times.map{gets.chomp.split(" ").map(&:to_i)}.sort_by{|i,j,k|i}
rec = [[prog[0][1],prog[0][2]]]
s = 1
f = false
(n-1).times do |i|
  s.times do |j|
    if (rec[s-1-j][0] == prog[i+1][0] && rec[s-1-j][1] == prog[i+1][2]) || rec[s-1-j][0] < prog[i+1][0]
      rec[s-1-j][0] = prog[i+1][1]
      rec[s-1-j][1] = prog[i+1][2]
      f = true
      break
    end
  end
  if f == false
    rec.unshift([prog[i+1][1],prog[i+1][2]])
    s += 1
  end
  f = false
  (s-1).times do |j|
    if rec[j][0] > rec[j+1][0]
      rec[j],rec[j+1] = rec[j+1],rec[j]
    end
  end
end
p s

Measured memory_bytes: 12664
//つたさんの写経
#include<bits/stdc++.h>
using namespace std;

int main(){
    
    int n, m; cin >> n >> m;
    
    //約数列挙
    vector<int> div;
    for(int k = 1; k * k <= m; k++){
        if(m % k == 0){
            div.push_back(k);
            if(m / k != k) div.push_back(m / k);
        }
    }

    int ans = 1;
    for(auto x : div){
        int rest = m / x;
        if(rest >= n) ans = max(ans, x);
    }

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

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

int main() {
    long long int N;
    cin >> N;
    string S = "";
    long long int num2 = 10;
    for(long long int i = 0; 0 < N; i++) {
        N--;
        long long int num = N % 26;
        N = N / 26 ;
        S.push_back('a' + num);
    }
    reverse(S.begin(), S.end());
    cout << S << endl;
}

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

#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define ll long long
using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
/*void dfs(int u,int par,int maxx)
{


    for(int v:adj[u])
    {
        if(v==par)
            continue;
        dfs(v,u,maxx);
    }
}


int ncr(int n , int r ){
	r = min(r,n-r);
	int res = 1 ;
	for(int i = 1 ; i <= r ; i++ ){
		( res *= n-i+1 )%= mod;
		res /= i ;
	}
	return res ;
}
*/
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll arr[N];
 int sumXOR(int n)
{
     ll sum = 0;
    for (int i = 0; i < 64; i++)
    {

        ll k = (1ll<<i);
        int ct = 0;
        for(int i=0;i<n;++i)
        {
            if(arr[i]&k)
                ct++;
        }
        sum+=  k%mod*ct%mod*(n-ct)%mod;
        sum%=mod;
    }
    return sum%mod;
}
int32_t main()
{
    io
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;

        rep(i,0,n)
        cin>>arr[i];
        ll ans = sumXOR(n);
        cout<<ans%mod<<el;

    }



    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
	
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);
        

        int N = sc.nextInt();
        int M = sc.nextInt();
        long[] a = new long[N];
        for(int i=0;i<N;i++) {
            a[i] = sc.nextLong();        	
        }
        Arrays.sort(a);
        long[] b = new long[M];
        long[] c = new long[M];
        for(int i=0;i<M;i++) {
            b[i] = sc.nextLong();         	
            c[i] = sc.nextLong();
        }
        quick_sort(c,b);
        long[] k = new long[3*N];
        int cnt=0;
        int bcnt=0,acnt=0;
        while(cnt<N) {
        	if(M-bcnt-1<0) {
        		bcnt=M-1;
        		c[M-bcnt-1]=0;
        	}
        	if(a[N-acnt-1]<0) {
        		acnt--;
        		a[N-acnt-1]=0;
        	}
        	if(a[N-acnt-1]>c[M-bcnt-1]) {
        		k[cnt]=a[N-acnt-1];
        		cnt++;
        		acnt++;
        	}else {
        		for(int i=0;i<b[M-bcnt-1];i++) {
        			k[cnt]=c[M-bcnt-1];
        			cnt++;
        		}
        		bcnt++;
        	}
        }
        long ans=0;
        for(int i=0;i<N;i++) {
        	ans=ans+k[i];
        }
        System.out.println(ans);
    }
    
  //クイックソート2（配列2つ）
    static void quick_sort(long[] d, long[] d2) {
  	  quick_sort(d,d2, 0, d.length-1);
    }

    // dのleftからrightまでの間のデータ列をクイックソートする
    static void quick_sort(long[] d, long[] d2, int left, int right) {
        if (left>=right) {
            return;
        }
        long p = d[(left+right)/2];
        int l = left, r = right;
        long tmp;
        while(l<=r) {
            while(d[l] < p) { l++; }
            while(d[r] > p) { r--; }
            if (l<=r) {
                tmp = d[l]; d[l] = d[r]; d[r] = tmp;
                tmp = d2[l]; d2[l] = d2[r]; d2[r] = tmp;
                l++; r--;
            }
        }
        quick_sort(d, d2, left, r);  // ピボットより左側をクイックソート
        quick_sort(d, d2, l, right); // ピボットより右側をクイックソート
    }
}

Measured memory_bytes: 97228
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 100005;

int n;
vector <ii> neigh[Maxn];
int col[Maxn];

void Fill(int v, int p, int c)
{
    col[v] = c;
    for (int i = 0; i < neigh[v].size(); i++) {
        ii u = neigh[v][i];
        if (u.first == p) continue;
        if (u.second % 2) Fill(u.first, v, 1 - c);
        else Fill(u.first, v, c);
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        neigh[a].push_back(ii(b, c));
        neigh[b].push_back(ii(a, c));
    }
    Fill(1, 0, 0);
    for (int i = 1; i <= n; i++)
        printf("%d\n", col[i]);
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    ll n;
    cin >> n;
    map<ll, ll> factors = prime_factor(n);

    cout << n << ":";
    for(auto x: factors) {
        REP(i, x.second) {
            cout << " " << x.first;
        }
    }
    cout << endl;

    return 0;
}


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

main() {
    int D,N; cin >> D >> N;
    if(D==0 && N!=100) cout << N << endl;
    else if(D==0 && N==100) cout << 101 << endl;
    else if(D==1 && N!=100) cout << 100*N << endl;
    else if(D==1 && N==100) cout << 10100 << endl;
    else if(N!=100) cout << 10000*N << endl;
    else cout << 1010000 << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
def warshall_floyd(N, edges,
                   nopath=None,
                   start_distance=0,
                   plus_func=lambda D,d: D+d):
    '''
    edges: list of set
        edges = [{(y0, distance0), (y1, distance1), ...}, ...]
    '''
    ret = [[nopath]*N for _ in range(N)]
    for i in range(N):
        ret[i][i] = start_distance
    for i in range(N):
        for j, d in edges[i]:
            if 0 <= j < N:
                ret[i][j] = plus_func(start_distance, d)
    for k in range(N):
        for i in range(N):
            if i == k: continue
            for j in range(N):
                if j == k or ret[i][k] == nopath or ret[k][j] == nopath:
                    continue
                d = plus_func(ret[i][k], ret[k][j])
                if ret[i][j] == nopath or d < ret[i][j]:
                    ret[i][j] = d
    return ret

N, M, L = inpl()
road = [[] for _ in range(N)]
for i in range(M):
    A, B, C = inpl()
    if C <= L:
        road[A-1].append((B-1,C))
        road[B-1].append((A-1,C))

Q = int(input())
ST = []
goals = [set() for _ in range(N)]
for _ in range(Q):
    s, t = inpl()
    s -= 1
    t -= 1
    ST.append((s, t))

distance = warshall_floyd(N, road)
path = [set() for _ in range(N)]
for i in range(N):
    for j in range(N):
        d = distance[i][j]
        if d is not None and d <= L:
            path[i].add((j,1))
ans = warshall_floyd(N, path)
for s, t in ST:
    if ans[s][t] is None:
        print(-1)
    else:
        print(ans[s][t]-1)


Measured memory_bytes: 88156
import copy
n = int(input())
a = input().split()
a_sr = []
a_sr_l = []
for i in range(n-1):
    if a[i][1] not in a_sr_l:
        for j in range(i+1, n):
            if a[i][1] == a[j][1]:
                if a[i][1] not in a_sr_l:
                    a_sr_l.append(a[i][1])
                if len(a_sr) == 0:
                    a_sr.append(a[i][0])
                a_sr.append(a[j][0])
a_b = copy.deepcopy(a)
a_s = copy.deepcopy(a)
# print(a)
# print(a1)
# print(a2)

# Bubble Sort
neighbor = True
while neighbor:
    neighbor = False
    for i in range(n-1, 0, -1):
        if a_b[i][1] < a_b[i-1][1]:
            a_tmp = a_b[i]
            a_b[i] = a_b[i-1]
            a_b[i-1] = a_tmp
            neighbor = True
for i in range(n-1):
    print(a_b[i], end=" ")
print(a_b[n-1])
a_b_s = []
a_b_s_l = []
for _ in a_sr_l:
    for i in range(n):
        if a_b[i][1] == _ and _ not in a_b_s_l:
            for j in range(i+1, n):
                if a_b[i][1] == a_b[j][1]:
                    if a_b[i][1] not in a_b_s_l:
                        a_b_s_l.append(a_b[i][1])
                    if len(a_b_s) == 0:
                        a_b_s.append(a_b[i][0])
                    a_b_s.append(a_b[j][0])

if a_b_s != a_sr:
    print("Not stable")
else:
    print("Stable")
# Selection Sort
# print(a_s)
for i in range(n-1):
    tmp_index = i
    for j in range(i+1, n):
        # 最小の値探索
        # print("# temp", tmp_index, "j", j)
        if a_s[j][1] < a_s[tmp_index][1]:
            tmp_index = j
    if tmp_index != i:
        # 最小と左端入れ替え
        a_tmp = a_s[i]
        a_s[i] = a_s[tmp_index]
        a_s[tmp_index] = a_tmp
for i in range(n-1):
    print(a_s[i], end=" ")
print(a_s[n-1])
a_s_s = []
a_s_s_l = []
for _ in a_sr_l:
    for i in range(n):
        if a_s[i][1] == _ and _ not in a_s_s_l:
            for j in range(i+1, n):
                if a_s[i][1] == a_s[j][1]:
                    if a_s[i][1] not in a_s_s_l:
                        a_s_s_l.append(a_s[i][1])
                    if len(a_s_s) == 0:
                        a_s_s.append(a_s[i][0])
                    a_s_s.append(a_s[j][0])
# print("a_s_s", a_s_s)
# print("a_sr", a_sr)
if a_s_s != a_sr:
    print("Not stable")
else:
    print("Stable")



Measured memory_bytes: 6360
S = input()
N = len(S)
for i in range((N+1)//2):
    if S[i] != S[-i-1]:
        print("No")
        exit()
for i in range((N-1)//2 -1):
    if S[i] != S[(-(N+1)//2) -i-1]:
        print("No")
        exit()
for i in range(N - (N+3)//2):
    if S[(N+3)//2 +i-1] != S[-i-1]:
        print("No")
        print(i)
        exit()
print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q;
  cin >> n >> q;
  queue<int> Q[n];
  for(int i=0;i<q;i++){
    int num;
    cin >> num;
    if(num==0){
      int t,x;
      cin >> t >> x;
      Q[t].push(x);
    }
    if(num==1){
      int t;
      cin >> t;
      if(Q[t].size()) cout << Q[t].front() << endl;
    }
    if(num==2){
      int t;
      cin >> t;
      if(Q[t].size()) Q[t].pop();
    }
  }
  return 0;
}



Measured memory_bytes: 4400
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;


int main(void){
    int a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f){
        int dt = a*e - b*d;
        int xu = c*e - f*b;
        int yu = a*f - c*d;
        double x, y;
        if(xu == 0) 
            x = 0;
        else
            x = (double)xu/dt;
        if(yu == 0)
            y = 0;
        else
            y = (double)yu/dt;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 1192
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()

using LL = long long;
int vis[100005];
vector <int> ans;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
	return getchar();
//    if (ib == ie) {
//        ib = ibuf;
//        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
//    }
//    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

using P = pair<int,int> ;
vector<vector<P> > g(100005 + 1);
int b[100005];
#define fi first
#define se second

void dfs(int x)
{
	vis[x]=1;
	for(auto u:g[x])
	{
		if(vis[u.first]) continue;
		dfs(u.first);
		if(b[u.first])
		{
			ans.push_back(u.second);
			b[u.first]^=1;
			b[x]^=1;
		}
	}
}

int main() {
    ios_base::sync_with_stdio(false);
    int n,m;
	cin>>n>>m;
    vector<P> bomb;
    vector <int> lsh;
    for (int i = 0; i < n; ++i) {
    	int a,b;
    	cin>>a>>b;
        bomb.emplace_back(a, b);
		lsh.push_back(a);
    }
	sort(all(lsh));
    sort(begin(bomb),end(bomb));
    for(int i=0;i<n;i++)
    {
    	b[i]=bomb[i].second;
	}
	for(int i=n;i>=0;i--)
	{
		b[i]^=(i?b[i-1]:0);
	}
    for (int i = 1; i <= m; ++i) {
    	int l,r;
		cin>>l>>r;
		l=lower_bound(all(lsh),l)-lsh.begin();
		r=upper_bound(all(lsh),r)-lsh.begin();
		g[l].push_back(make_pair(r,i));
		g[r].push_back(make_pair(l,i));
    }
    
	for(int i=0;i<=n;i++)
	{
		if(vis[i]) continue;
		dfs(i);
		if(b[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	sort(all(ans));
	cout<<ans.size()<<endl;
	for(auto x:ans)
	{
		cout<<x<<' ';
	}
	cout<<endl;
    return 0;
}


Measured memory_bytes: 14964
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int N;
 	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; i++) cin >> a[i];
	sort(a.begin(), a.end()); // 数列aを昇順ソート
	cout << a[N-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){


    string s;
    cin >> s;
 
    int c = 0;
    string ss = "",o = "";
    
    rep(i,0,sz(s)){
	ss += s[i];
	if(o != ss){
	    c++;
	    o = ss;
	    ss = "";
	}   
    }

    P(c);
    return  0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int n;

int trav(int cur, pi p) {
	if(p.F <= cur && cur <= p.S) return cur;
	if(cur < p.F) return p.F;
	return p.S;
}
ll go(multiset<pi> ls, multiset<pi> rs) {
	int cur = 0;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		pi p;
		if(i & 1) p = *ls.rbegin();
		else {
			p = *rs.begin();
			swap(p.F, p.S);
		}
		ans += abs(trav(cur, p)-cur);
		cur = trav(cur, p);
		ls.erase(ls.lower_bound(p));
		swap(p.F, p.S);
		rs.erase(rs.lower_bound(p));
	}
	ans += abs(cur - 0);
	return ans;
}

ll go1(multiset<pi> ls, multiset<pi> rs) {
	int cur = 0;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		pi p;
		if((i & 1) == 0) p = *ls.rbegin();
		else {
			p = *rs.begin();
			swap(p.F, p.S);
		}
		ans += abs(trav(cur, p)-cur);
		cur = trav(cur, p);
		ls.erase(ls.lower_bound(p));
		swap(p.F, p.S);
		rs.erase(rs.lower_bound(p));
	}
	ans += abs(cur - 0);
	return ans;
}

signed main()
{
	IO_OP;
	
	cin >> n;
	multiset<pi> ls, rs;
	for(int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		ls.insert({l, r});
		rs.insert({r, l});
	}
	cout << max(go(ls, rs), go1(ls, rs)) << endl;

}





Measured memory_bytes: 19072
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795

 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
#define MAXN 402
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

void solve()
{
    ll n;cin>>n;string s;cin>>s;
    if(s.length()<=n)cout<<s<<endl;
    else
    {
        cout<<s.substr(0,n);
        cout<<"..."<<endl;
    }
}

signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//   }
   
    solve();
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
    int H, W;

    scanf("%d %d", &H, &W);
    while ((H != 0) || (W != 0)) {
        int i, j;
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                if ((i + j) % 2 == 0) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            putchar('\n');
        }
        putchar('\n');
        scanf("%d %d", &H, &W);
    }

    return 0;
}

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

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

   int ans = 0;
   for (int i = 0; i <= stoi(s); i++) {
      string t = to_string(i);
      int sum = 0;
      for (char c : t) {
         sum += c - '0';
      }
      if (sum >= a && sum <= b) {
         ans += stoi(t);
      }
   }

   cout << ans << endl;

   return 0;
}

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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl


int main() {

	fast_cin;

	int n,m,target,ans,sum;
	int mat[8][8],tmp[8][8];
	string s;
	
	cin >> n >> m >> target;

	for(int i = 0; i < n; i++) {
		cin >> s;
		for(int j = 0; j < m; j++) {
			mat[i][j] = ( s[j] == '.' ? 0 : 1 );
		}
	}

	

	int comb = (1 << (n+m));
	ans = 0;
	
	for(int i = 0; i < comb; i++) {
		
		for(int j = 0; j < n; j++) {
			for(int k = 0; k < m; k++) {
				tmp[j][k] = mat[j][k];
			}
		}

		for(int j = 0; j < n; j++) {
			if( (i & (1 << j)) ) {
				for(int k = 0; k < m; k++) {
					tmp[j][k] = 0;
				}
			}
		}

		for(int j = n; j < n+m; j++) {
			if( (i & (1 << j)) ) {
				for(int k = 0; k < n; k++) {
					tmp[k][j-n] = 0;
				}
			}
		}

		sum = 0;

		for(int j = 0; j < n; j++) {
			for(int k = 0; k < m; k++) {
				sum += tmp[j][k];
			}
		}

		if(sum == target) {
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {
	char d[20];
	scanf("%s",&d);
	for(int i=0;i<5;i++){
		printf("%c",(char)d[i]);
	}
	printf(" ");
	for(int i=0;i<7;i++){
		printf("%c",(char)d[i+6]);
	}
	printf(" ");
	for(int i=0;i<5;i++){
		printf("%c",(char)d[i+14]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    long long a,b;
    scanf("%lld%lld",&a,&b);
    long long sum=abs(a*b-a*2-b*2+4);
        printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a[205],sum,n;
bool flag=true;
int main() {
    cin>>n;
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    while(1){
        for(int i=0;i<n;i++)
        {
            if(a[i]%2==0)
            {
                a[i]=a[i]/2;
                sum=sum+1;
            }
            else
            {
              flag=false;
                break;
            }
        }
        if(flag==false)
        {
            break;
        }
    }
    cout<< sum/n;
}
    
    
    
       

Measured memory_bytes: 256
let cnt = ref 0

let merge a l m r =
  let ai = Array.make (m - l + 1) max_int in
  for i = 0 to m - l - 1 do
    ai.(i) <- a.(l + i)
  done;
  let aj = Array.make (r - m + 1) max_int in
  for i = 0 to r - m - 1 do
    aj.(i) <- a.(m + i)
  done;
  let i = ref 0 in
  let j = ref 0 in
  for k = l to r - 1 do
    incr cnt;
    if ai.(!i) <= aj.(!j) then begin
      a.(k) <- ai.(!i);
      incr i;
    end else begin
      a.(k) <- aj.(!j);
      incr j;
    end
  done

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  print_int a.(0);
  for i = 1 to n - 1 do
    Printf.printf " %d" a.(i)
  done;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 22048
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
using namespace std;

int main(void){
    string s;
    cin >> s;
    int a = 0, t = 0;
    for(char &c : s){
        if(c == 'R') t++;
        else t = 0;
        if(t > a) a = t;
    }
    cout << a << '\n';
    return 0;
}

Measured memory_bytes: 3572
n=int(input())
ans=n

for i in range(n+1):
    cnt=0
    t=i
    while t>0:
        cnt+=t%6
        t//=6
    t=n-i
    while t>0:
        cnt+=t%9
        t//=9
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int A = 0, B = 0,K=0;
	cin >> A >> B;
	K = (A + B) / 2;
	if (2 * K == A + B)
	{
		cout << K;
	}
	else
	{
		cout << "IMPOSSIBLE";
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> dif(N);
    for(int i = 0; i < N; i++)cin >> dif[i];
    sort(dif.begin(), dif.end());
    cout << dif[N / 2] - dif[N / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int N, count, max_count = 0;
	cin >> N;
	vector<int> masu(N);
	rep(i, N) cin >> masu[i];
	rep(i, N)
	{
		count = 0;
		while(masu[i+count]==1)
		{
			count++;
		}
		max_count = max(max_count, count);
		i += count;
	}
	cout << max_count+1 << endl;
}



Measured memory_bytes: 3100
def main():

    x, n = map(int, input().split())
    ans = 0
    if n == 0:
        ans = x
        print(f'{ans}')
        exit()
    else:
        p = [int(i) for i in input().split()]

    for i in range(0, 102):
        if abs(x - i) not in p:
            ans = abs(x - i)
            break
        if x + i not in p:
            ans = x + i
            break
    
    print(f'{ans}')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9028