akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi, yi, q;
vector<ll>v;
set<int>s;
map<string, ll >mp;
bool PE ( int x )
{
    for ( int i = 2; i * i <= x; i++ )
        if ( x % i == 0 )
            return false;
    return true;
}
bool PR ( string s )
{
    int n = s.length();
    for ( int i = 0; i < n / 2; i++ )
        if ( s[i] != s[n - i - 1] )
            return false;
    return true;
}

int main ( void )
{
    long double a,b;
    cin>>a>>b;
    long long xx=a*b;
    cout<<fixed<<setprecision(19)<<xx;
     
     
    
   
}


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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  h[0]=h[0]-1;
  string ans="Yes";
  for(int i=0;i<n-1;i++){
    if(h[i+1]<h[i]){
      ans="No";
      break;
    }
    else if(h[i+1]==h[i]){
      h[i+1]=h[i+1];
    }
    else{
      h[i+1]=h[i+1]-1;
    }
  }
  cout << ans << endl;
    
}


Measured memory_bytes: 640
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod1 = (int)1e9 + 7;
const int mod2 = (int)1e9 + 9;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, p1 = 239, p2 = 241, h1[N], ans, H1[5005][5005], h2[N], H2[5005][5005];
char s[N];
map <pii, int> q;

inline int mult (int a, int b, int mod) {
   return 1ll * a * b % mod;
}

inline int add (int a, int b, int mod) {
   a += b;
   if (a >= mod) a -= mod;
   return a;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> s + 1;
   for (int l = 1; l <= n; l ++) {
      int pw1 = 1, pw2 = 1;
      for (int r = l; r <= n; r ++) {
         H1[l][r] = add (H1[l][r - 1], mult (s[r], pw1, mod1), mod1);
         H2[l][r] = add (H2[l][r - 1], mult (s[r], pw2, mod2), mod2);
         pw1 = mult (pw1, p1, mod1);
         pw2 = mult (pw2, p2, mod2);
      }
   }
   for (int len = 1; len <= n; len ++) {
      q.clear ();
      fill (h1 + 1, h1 + n + 1, 0);
      fill (h2 + 1, h2 + n + 1, 0);
      for (int i = 1; i + len - 1 <= n; i ++) h1[i] = H1[i][i + len - 1], h2[i] = H2[i][i + len - 1];
      for (int i = n; i >= 1; i --) {
         if (i + len + len - 1 <= n) q[{h1[i + len], h2[i + len]}] ++;
         if (q.count ({h1[i], h2[i]})) ans = len;     
      }
   }
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
             

Measured memory_bytes: 196992
#include <iostream>
#include <cstring>
#include <cstdio>
#define ll long long
#define int ll
#define lowbit(a) a&(-a)
using namespace std;

inline int read(){
	int sum=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){sum=sum*10+c-'0';c=getchar();}
	return f*sum;
}

const int N=200000;
const int M=100000;
int n,m,a[N+5];
ll t[N+5],c[N+5],tem;

inline void add(int x){for(;x<=N;x+=lowbit(x)) t[x]++;}

inline ll ask(int x){ll ret=0;for(;x;x-=lowbit(x)) ret+=t[x];return ret;}

inline int check(int x){
	ll cnt=0;
	memset(t,0,sizeof(t));
	for(int i=1;i<=n;i++) c[i]=c[i-1]+(a[i]<=x? 1:-1);
	add(1+M);
	for(int i=1;i<=n;i++){
		cnt+=ask(c[i]+M);
		add(c[i]+1+M);
	}
	return cnt>tem;
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	ll l=0,r=0;
	for(int i=1;i<=n;i++) r=max(r,(ll)a[i]);
	ll ans=r;
	tem=n*(n+1)/2/2;
	while(l<=r){
	ll mid=(l+r)>>1;
	if(check(mid)) ans=min(ans,mid),r=mid-1;
	else l=mid+1;
}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
	string type;
	int t[4]={0};
	while(cin>>type){
		type+=" ";
		int i;
		for(i=0;type[i]!=',';i++);
		i++;
		if(type[i]=='A'&&type[i+1]=='B'){
			t[2]++;
		}else if(type[i]=='A'){
			t[0]++;
		}else if(type[i]=='B'){
			t[1]++;
		}else if(type[i]=='O'){
			t[3]++;
		}
	}
	for(int i=0;i<4;i++){
		cout<<t[i]<<endl;
	}
	
	
	

}

Measured memory_bytes: 1180
#include <stdio.h>

const int bias = 10;
long long dp[bias*2+1][2],nxt[bias*2+1][2];

void mx(long long &a, long long b)
{
	if (a < b) a = b;
}

int main()
{
  for (int i=0;i<=bias*2;i++) dp[i][0] = dp[i][1] = -1e18; dp[bias][0] = 0;
  
  int n; scanf ("%d",&n);
  for (int k=0;k<n;k++){
	int x; scanf ("%d",&x);
  for (int i=0;i<=bias*2;i++) nxt[i][0] = nxt[i][1] = -1e18;
    for (int i=0;i<=bias*2;i++){
mx(nxt[i][0],dp[i][0]);
mx(nxt[i][0],dp[i][1]);
mx(nxt[i+2][1],dp[i][0]+x);
    }
  for (int i=1;i<=bias*2;i++){
    dp[i-1][0] = nxt[i][0];
    dp[i-1][1] = nxt[i][1];
  }
    dp[bias*2][0] = dp[bias*2][1] = -1e18;
  }
  
  int last = (n / 2) * 2 - n + bias;
  long long ans = -1e18;
  mx(ans,dp[last][0]);
  mx(ans,dp[last][1]);
  printf ("%lld\n",ans);
return 0;
}


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

void EucledeanAlgorithm(long int a, long int b) {
	int step = 0;
	while (b != 0) {
		if (a < b) swap(a, b);
		a = a % b; swap(a, b); step++;
	}
	cout << a << " " << step << endl; return;
}

int main() {
	long int a, b;
	while (1) {
		cin >> a >> b; if (a == 0 && b == 0) break;
		EucledeanAlgorithm(a, b);
	}
	return 0;
}


Measured memory_bytes: 3004
import sys

board=[[0]*10 for i in xrange(10)]

large=[[0,0,1,0,0],
       [0,1,1,1,0],
       [1,1,1,1,1],
       [0,1,1,1,0],
       [0,0,1,0,0],]
middle=[[0,0,0,0,0],
        [0,1,1,1,0],
        [0,1,1,1,0],
        [0,1,1,1,0],
        [0,0,0,0,0],]
small=[[0,0,0,0,0],
       [0,0,1,0,0],
       [0,1,1,1,0],
       [0,0,1,0,0],
       [0,0,0,0,0],]

size=[0,small,middle,large]

def isOnBoard(y,x):
    return 0<=y<10 and 0<=x<10

for line in sys.stdin.readlines():
    x,y,s=map(int,line.strip().split(","))
    for i in xrange(-2,3):
        for j in xrange(-2,3):
            if isOnBoard(y+i,x+j):
                board[y+i][x+j]+=size[s][i+2][j+2]

print sum([1 if i==0 else 0 for j in board for i in j])
print max([i for j in board for i in j])
    
    

Measured memory_bytes: 4280
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int N=2333;
int a[N];
int g[N][N];
int n;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct sumireko{int to,ne;}e[N*1000];
int he[N],ecnt;
void addline(int f,int t)
{
	e[++ecnt].to=t;
	e[ecnt].ne=he[f];
	he[f]=ecnt;
}

bool vv[N];
int bi;
int sp[N];
vector<int> to[N];
void dfs(int x)
{
	vv[x]=1;
	for(int i=he[x],t;i;i=e[i].ne)
	{
		t=e[i].to;
		if(!vv[t])
		{
			to[x].push_back(t);
			dfs(t);
		}
	}
}

priority_queue<int> q;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=n;i;i--)
		for(int j=i-1;j;j--)
			if(gcd(a[i],a[j])!=1)
				addline(i,j),addline(j,i)/*,printf("line %d %d\n",i,j)*/;
	for(int i=1;i<=n;i++) if(!vv[i])
	{
		bi++;
		sp[bi]=i;
		dfs(i);
	}
	/*printf("%d\n",bi);
	for(int i=1;i<=bi;i++) printf("%d ",sp[i]);
	puts("\n----------------------------------");
	for(int i=1;i<=n;i++)
	{
		printf("%d:",i);
		for(int j=0;j<to[i].size();j++) printf("%d ",to[i][j]);
		putchar('\n');
	}
	puts("\n----------------------------------");*/
	for(int i=1;i<=bi;i++)
		q.push(sp[i]);
	while(!q.empty())
	{
		int g=q.top();
		q.pop();
		printf("%d ",a[g]);
		for(int i=0;i<to[g].size();i++) q.push(to[g][i]);
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int min_a, max_a;
    cin >> min_a;
    max_a = min_a;
    for(int i = 1; i < N; ++i){
        int tmp;
        cin >> tmp;
        if (tmp < min_a) min_a = tmp;
        if (tmp > max_a) max_a = tmp;
    }

    cout << max_a - min_a << endl;
    return 0;
}

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

bool isPrime(int n) {
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    double sqrtNum = sqrt(n);
    for (int i = 3; i < sqrtNum; i += 2) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}


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

    while(true) {
        if (isPrime(x)) {
            break;
        }
        x++;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll a,b,c,x,tmp,cnt=0;
	cin>>a>>b>>c>>x;
	REP(i,0,a)
	{
		REP(j,0,b)
		{
			REP(k,0,c)
			{
				tmp=i*500+j*100+k*50;
				if(tmp==x)
					cnt++;
			}
		}
	}
	cout<<cnt;
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(20);
	ll r,d,x,i;
	cin>>r>>d>>x;
	for (i=0;i<10;i++){
		x=r*x-d;
		cout<<x<<"\n";
	} 
	return 0;
}

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

int a[100005];
int main()
{
	int T;
	while(cin >>T){
		memset(a,0,sizeof(a));
		int t;
		for(int i = 0; i < T; i++){
		    cin >> t;
			a[t]++;
			a[t + 1]++;
			a[t + 2]++;	
		}
	    sort(a,a+100002);
	    cout << a[100001] << endl;
	}
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, n;
	cin >> h >> w >> n;
	vi v(n);

	REP(i, n)cin >> v[i];
	int k = 0;
	REP(i, h) {
		if (i % 2 == 0) {
			REP(j, w) {
				cout << k+1;
				v[k]--;
				if (v[k] == 0)k++;
				if (j == w - 1)cout << endl;
				else cout << " ";
			}
		}
		else {
			stack<int> st;
			REP(j, w) {
				st.push(k + 1);
				v[k]--;
				if (v[k] == 0)k++;
			}
			REP(j, w) {
				cout << st.top();
				st.pop();
				if (j == w - 1)cout << endl;
				else cout << " ";
			}
		}
	}

}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
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;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<queue<ll>>q(n);
  rep(i,0,n){
    rep(j,0,n-1){
      ll x;cin>>x;
      x--;
      q[i].push(x);
    }
  }
  queue<ll>a;
  rep(i,0,n)a.push(i);
  a.push(-1);
  ll cnt=0;
  vector<ll>t(n,-1);
  while(!a.empty()){
    ll x=a.front();
    if(x==-1){
      if(a.size()!=1)a.push(-1);
      cnt++;
      a.pop();
    }
    else{
      ll y=-1;
      if(!q[x].empty())y=q[x].front();
      ll z=-2;
      if(y!=-1&&!q[y].empty())z=q[y].front();
      if(x==z&&t[x]!=cnt&&t[y]!=cnt){
        q[x].pop();
        q[y].pop();
        t[x]=cnt;t[y]=cnt;
        if(!q[x].empty())a.push(x);
        if(!q[y].empty())a.push(y);
      }
      a.pop();
    }
  }
  rep(i,0,n){
    if(q[i].size()!=0)judge=false;
  }
  if(judge)cout<<cnt<<endl;
  else cout<<-1<<endl;
  return 0;
}

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

int main() {

    int N, A;
    cin >> N >> A;

    int joyo = (N % 500);

    if ( joyo <= A) {
        cout << "Yes" << endl;
    } else if ( joyo > A) {
        cout << "No" << endl;
    }
}

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

#define MOD 1000000007


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    cout<<48-n<<'\n';
    
    
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;
int main() {
	
	//3.141592653589763537
	double r;
	cin>>r	;
	cout<<fixed<<endl;
	cout<< (double)r*r*3.141592653589793238462643383279502884197169399375105820974944592307816406286 << " " << (double)2*r*3.141592653589793238462643383279502884197169399375105820974944592307816406286 <<endl;
	
	
	
	
	
}


Measured memory_bytes: 3240
class Queue:
    def __init__(self):
        self.max = int(1e6)
        self.data = [0] * self.max
        self.head = 0
        self.tail = 0
    def isEmpty(self):
        return self.head == self.tail
    def isFull(self):
        return self.head == (self.tail + 1) % self.max
    def enqueue(self, x):
        try:
            if self.isFull():
                raise Exception('Queue is full')
            self.data[self.tail] = x
            if self.tail + 1 == self.max:
                self.tail = 0
            else:
                self.tail += 1
        except Exception as e:
            print(e)
    def dequeue(self):
        try:
            if self.isEmpty():
                raise Exception('Queue is empty')
            x = self.data[self.head]
            if self.head + 1 == self.max:
                self.head = 0
            else:
                self.head += 1
            return x
        except Exception as e:
            print(e)

class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time
        self.endTime = 0

n, q = map(int, input().split())
processes = Queue()
for i in range(n):
    name, time = input().split()
    time = int(time)
    processes.enqueue(Process(name, time))

totalTime = 0
finishedProcesses = 0

while finishedProcesses < n:
    runningProcess = processes.dequeue()
    if runningProcess.time <= q:
        totalTime += runningProcess.time
        runningProcess.time = 0
        runningProcess.endTime = totalTime
        finishedProcesses += 1
        print(runningProcess.name, runningProcess.endTime)
    else:
        totalTime += q
        runningProcess.time -= q
        processes.enqueue(runningProcess)


Measured memory_bytes: 26236
import java.util.*;
 
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] l = new int[N];
    int ans = 0;
    for (int i = 0; i < K; i++) {
      int d = sc.nextInt();
      for (int j = 0; j < d; j++) {
          int a = sc.nextInt();
          l[a-1]++;
      }
    }
    
    for (int k = 0; k < N; k++) {
      if (l[k] == 0) {
        ans += 1;
      }
    }
    System.out.println(ans);
  }
}  

Measured memory_bytes: 46152
n = int(input())
h = list(map(int,input().split()))
x = []
count = 0
for i in range(n-1):
    if(h[i] >= h[i+1]):
        count += 1
    else:
        x.append(count)
        count = 0

x.append(count)
print(max(x))

Measured memory_bytes: 20496
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(a,b,c,x,y);
    ll ans;

    ans= min(a*x+b*y, min(min(x,y)*c*2+abs(x-y)*((x>y)?a:b),max(x,y)*c*2));
    
    out(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

void gen() {exit(0);}
int main() {
    #ifdef DEBUG
//    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    int a, b;
    scanf("%d %d", &a, &b);
    
    if (a <= 8 && b <= 8) {
        printf("Yay!\n");
    } else {
        printf(":(\n");
    }
    return 0;
}


Measured memory_bytes: 256
# 入力

A, B, C, X, Y=map(int, input().split())
numA=0
numB=0
numC=0
answer=0

if A>2*C:
    #Aを買うくらいならCを2個買うべき
    answer+=2*X*C #ABピザを、Aを充足する分購入する
    numC+=2*X
    Y-=X #その分Bも買った
    X=0

if B>2*C and Y>0:
    #Bを買うくらいならCを2個買うべき
    answer+=2*Y*C #ABピザを、Bを充足する分購入する
    numC+=2*Y
    X-=Y #その分Aも買った
    Y=0

if X>0 or Y>0: #まだどちらかを買う必要があるなら
    if A+B>2*C: #AとBを1個ずつ買うくらいならCを2個買うべき
        answer+=2*min(X, Y)*C
        numC+=2*min(X, Y)
        m=min(X, Y)
        X-=m
        Y-=m

    answer+=A*X+B*Y
    numA+=X
    numB+=Y

# print('A:'+str(numA)+' B:'+str(numB)+' C:'+str(numC))
print(answer)


Measured memory_bytes: 3064
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	static final int MAX_N = 1000000;
	boolean[] isPrime = new boolean[MAX_N];
	int[] primes;
	int[] acc;
	void makePrimes(){
		if (primes != null) return;
		for (int i = 0; i < isPrime.length; i++) isPrime[i] = true;
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i * i < isPrime.length; i++)
			if (isPrime[i])
				for(int j = i * i; j < isPrime.length; j += i)
					isPrime[j] = false;
		int p = 0;
		for (int i = 2; i < isPrime.length; i++) p += isPrime[i] ? 1 : 0;
		primes = new int[p];
		p = 0;
		for (int i = 2; i < isPrime.length; i++) if (isPrime[i]) primes[p++] = i;
		
		acc = new int[MAX_N];
		for (int i = 1; i < MAX_N; i++) {
			acc[i] = acc[i-1] + (isPrime[i] ? 1 : 0);
		}
	}
	
	int get(int a, int b) {
		if (a < 1) a = 1;
		if (b >= MAX_N) b = MAX_N - 1;
		return acc[b] - acc[a-1];
	}
	
	Scanner sc = new Scanner(System.in);
	public void run() {
		makePrimes();
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			long ans = 0;
			for (int iii = 0; iii < n; iii++) {
				int p = sc.nextInt();
				int m = sc.nextInt();
				int x = get(p - m, p + m);
				ans += x - 1;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 31608
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
ab = nan(n)
cd = nan(m)

ans = [0] * n
for i in range(n):
    a, b = ab[i]
    cur = inf
    p = -1
    for j in range(m):
        c, d = cd[j]
        dist = abs(a - c) + abs(b - d)
        if dist < cur:
            cur = dist
            p = j + 1
    ans[i] = p

print(*ans, sep="\n")

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int par[100001];
ll treesize[100001];
ll group = 100000;

int find(int x) {           //親探し
	if (par[x] == x) {
		return x;
	}
	else {
		int z = find(par[x]);
		par[x] = z;
		return z;
	}
}

bool  unit(int x, int y) {

	int xpar = find(x);
	int ypar = find(y);

	if (xpar == ypar) { return false; }   //すでに結合済み
	group--;
	par[ypar] = xpar;
	treesize[xpar] += treesize[ypar];
	return true;
}

int main()
{
	ll N, M;
	cin >> N >> M;
	pairs(AB)
	fx(M) {
		pairsp(AB);
	}
	reverses(AB);
	fx(N) {
		par[x + 1] = x + 1;
		treesize[x + 1] = 1;
	}
	vecl(ans);
	group = N;
	pb(ans,N*(N-1)/2)
	fx(M) {
		ll k = treesize[find(AB[x].first)] * treesize[find(AB[x].second)];
		if (unit(AB[x].first, AB[x].second)) {
			pb(ans, ans[x] - k);
		}
		else {
			pb(ans,ans[x])
		}
	}

	fx(M) {
		ce(ans[M-1-x])
	}
    return 0;
}



Measured memory_bytes: 4212
import java.util.Scanner;

public class Main{

	static int gcd(int a, int b){
		if(a==0){
			return b;
		}
		else return gcd(b%a,a);
	}
	static String solve(int[] arr, int k){
		int g = arr[0];int max = arr[0];
		for(int i=1;i<arr.length;i++){
			g = gcd(g,arr[i]);
			if(arr[i]>max){
				max = arr[i];
			}
		}
		if(k%g==0&&k<=max){
			return "POSSIBLE";
		}
		return "IMPOSSIBLE";
		
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i]= scan.nextInt();
			}
		System.out.println(solve(arr,k));
		}
	}






Measured memory_bytes: 49344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i = 0; i < 2; i++) {
			if(s.charAt(i) != s.charAt(i + 1)) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
		sc.close();
	}
}


Measured memory_bytes: 22996
INF = 10 ** 9 + 7

n = gets.to_i
f = Array.new(n) { gets.chomp.split.map(&:to_i) }
p = Array.new(n) { gets.chomp.split.map(&:to_i) }

res = - INF
(1 << 10).times do |b|
  if b == 0
    next
  end
  cnt = Array.new(n, 0)
  10.times do |i|
    if (b >> i) & 1 != 0
      n.times do |j|
        if f[j][i] == 1
          cnt[j] += 1
        end
      end
    end
  end

  y = 0
  n.times do |j|
    y += p[j][cnt[j]]
  end
  res = [res, y].max
end
puts res

Measured memory_bytes: 14916
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)

using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
vector<int>prime;
bool sosu[101]={};
int N;
int MOD=mod;
void eratos()
{
  
 for(int i=2;i<=N;i++)
 {
     if(!sosu[i])
     {
         prime.push_back(i);
         for(int k=2*i;k<=N;k+=i)
         {
             sosu[k]=true;
         }
     }
 }
 return;
}

int pascal [30][30]={};

void set_pascal(){
    pascal[0][1]=1;
    for(int i=1;i<15;i++){
        for(int k=1;k<=10;k++){
            pascal[i][k]=pascal[i-1][k-1]+pascal[i-1][k];
        }
    }
}

int main(){

cin>>N;

eratos();//素数の書き出し

int len=prime.size();

int appear[len]={};

//出現回数をメモする
rep(i,len)
{   
    int p=prime[i];
    int t=1;
    while(p<=N){
    appear[i]+=(N/p)*t;
    p*=prime[i];
    }
}
long long nanajugo=0;
long long twentyfive=0;
long long fifteen=0;
long long five=0;
long long  three=0;
rep(i,len){
    if(appear[i]>=74)
    {
        nanajugo++;
    }
    if(appear[i]>=24)
    {
        twentyfive++;
    }
    if(appear[i]>=14)
    {
        fifteen++;
    }
    if(appear[i]>=4)
    {
        five++;
    }
    if(appear[i]>=2)
    {
        three++;
    }
}
/*
rep(i,len){
    cout<<prime[i]<<" ";
    cout<<appear[i]<<" ";
}
*/
long long  ans=0;

ans+=nanajugo;

ans+=twentyfive*(three-1);

ans+=fifteen*(five-1);


ans+=((five*(five-1))/2)*(three-2);

cout<<ans<<endl;

 return 0;
}
/*
9

0

10

1

100

543

*/


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

using namespace std;

using ll = long long;



int main(){
  int N;
  cin >> N;
  
  for(int i=2; i<10; i++){
    if((N%i==0 && N/i<10) || N==1){
      cout << "Yes" << endl;
      return 0;
    } 
  }
  
  cout << "No" << endl;
    
  return 0;
}

Measured memory_bytes: 3604
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] in = sc.next().toCharArray();
		for(int i = 0; i < in.length; i++) {
			if(in[i] != 'A' && in[i] != 'Z') {
				in[i] = 0;
			}
		}
		boolean nowA = true;
		for(int i = 0; i < in.length; i++) {
			if(in[i] == 0) continue;
			if(nowA && in[i] == 'Z') {
				in[i] = 0;
				continue;
			}
			if(!nowA && in[i] == 'A') {
				in[i] = 0;
				continue;
			}
			if(in[i] == 'A') {
				nowA = false;
			}
			if(in[i] == 'Z') {
				nowA = true;
			}
		}
		for(int i = in.length-1; i >= 0; i--) {
			if(in[i] == 0) continue;
			if(in[i] == 'A') {
				in[i] = 0;
				break;
			}
			if(in[i] == 'Z') {
				break;
			}
		}
		boolean check = false;
		for(int i = 0; i < in.length; i++) {
			if(in[i] == 'A') {
				check = true;
				break;
			}
		}
		
		if(check) 
			for(int i = 0; i < in.length; i++) {
				if(in[i] != 0)
				System.out.print(in[i]);
			}
		else
			System.out.print(-1);
		System.out.println();
		
		
	}
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;

    ll ac = 0;
    ll wa = 0;
    ll tle = 0;
    ll re = 0;
    REP(i, N){
            string s;
            cin >> s;
            if( s == "AC" ) ac++;
            else if(s == "WA") wa++;
            else if(s == "TLE") tle++;
            else re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;


}

Measured memory_bytes: 3624
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

xpy = 0

if N == 1:
    xpy = 0
else:
    for i in range(N):
        if V[i]-C[i] > 0:
            xpy += V[i]-C[i]

print(xpy)

Measured memory_bytes: 3060
#include <stdio.h>

int const M = 998244353;
int i, n, x, c[7 << 14];

int power(int a, int b) {
  int r = 1;
  for(; b; b >>= 1) {
    if(b & 1)
      r = (long long) r * a % M;
    a = (long long) a * a % M;
  }
  return r;
}  

int main() {
  scanf("%d%d", &n, &x);
  int r = 0;
  if(x == 0) {
    for(i = 0; ++i < n; c[x]++) scanf("%d", &x);
    if(c[0] == 0) {
      c[0] = r = 1;
      for(i = 0; c[++i];) {
        n -= c[i];
        r = (long long) r * power(c[i - 1], c[i]) % M;
      }
    }
  }
  printf("%d\n", n > 1 ? 0 : r);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  string s;cin>>s;
  ll q;cin>>q;
  vector<ll> d,m,c;
  for(ll i=0;i<n;i++){
    if(s[i]=='D')d.push_back(i);
    if(s[i]=='M')m.push_back(i);
    if(s[i]=='C')c.push_back(i);
  }
  ll sum[n+1];
  sum[0]=0;
  for(ll i=0;i<c.size();i++){
    ll y=lower_bound(m.begin(),m.end(),c[i])-m.begin();
    sum[i+1]=sum[i]+y;
  }
  ll dm[2000010],dc[2000010];
  for(ll i=0;i<2000001;i++){
    ll mm=lower_bound(m.begin(),m.end(),i)-m.begin();
    ll cc=lower_bound(c.begin(),c.end(),i)-c.begin();
    dm[i]=mm;dc[i]=cc;
  }
  for(ll i=0;i<q;i++){
    ll k;cin>>k;
    ll ans=0;
    for(ll j=0;j<d.size();j++){
      ll rc=dc[d[j]+k],lc=dc[d[j]],lm=dm[d[j]];
      ans+=(sum[rc]-sum[lc])-(rc-lc)*lm;
    }
    cout<<ans<<endl;
  }
}
  

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define int ll

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

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

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a = b; return true;} return false; }

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    int t1 = H1*60+M1;
    int t2 = H2*60+M2 - K;
    cout << max((int)0, t2 - t1) << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    string S,T;
    cin >> S >> T ;
    int count=0;
    for(int i=0;i<3;i++)
    {
        if(S.at(i)==T.at(i))
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

//a,bのGCD
int GCD(int a, int b){
  if(a<b){swap(a,b);}  
  if(a%b==0){return b;}
  else{return GCD(a%b,b);}
}

int main() {
  ll n,m; string s,t;
  cin>>n>>m>>s>>t;
  ll ans=0;
  ll g=GCD(n,m);
  if(s[0]!=t[0]){ans=-1;}
  else if(g==1){ans=n/g*m;}
  else{
    bool b=true;
    rep(i,g){
      if(s[n/g*i]!=t[m/g*i]){b=false;break;}
    }
    if(b){ans=n/g*m;}
    else{ans=-1;}
    
  }
  cout<<ans;
}

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

typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<vector<lli> > vvi;
typedef vector<ii> vii;

#define EB emplace_back
#define PB push_back
#define MP make_pair
#define FF first
#define SS second

const int mod = 1e9 +7;
lli a[16][16], n, dp[131072];
int abc, cnt;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>a[i][j];
	for(int m=1; m<(1LL<<n); m++)
	{
		for(int i=0; i<n; i++)
		{
			if((m>>i)&1)
			{
				for(int j=i; j<n; j++)
					if((m>>j)&1) dp[m]+=a[i][j];
			}
		}
		abc = (1LL<<(__builtin_popcount(m)-1)), cnt=0;
		for (int s=m; s&&cnt<=abc; s=(s-1)&m)
			dp[m] = max(dp[m], dp[s]+dp[m^s]), cnt++;
	}
	cout << dp[(1LL<<n)-1];
}

Measured memory_bytes: 4180
import java.util.*;
class Main{
    public static void main(String[]args){
        Scanner cin=new Scanner(System.in);
        String input_a=cin.next();
        String input_b=cin.next();
        String output;
        if(input_a.equals("H")){
            if(input_b.equals("H")){
                output = "H";
            }else{
                output = "D";
            }
        }else{
            if(input_b.equals("H")){
                output = "D";
            }else{
                output = "H";
            }
        }
        System.out.println(output);
        }
    }


Measured memory_bytes: 23764
K = int(input())
import math
c = 0
for i in range(1,K+1):
    for j in range(1,i):
        for k in range(1,j):
            c += 6*math.gcd(math.gcd(i,j),k)
            
for i in range(1,K+1):
    for j in range(1,i):
        c += 6*math.gcd(i,j)
        
c += K*(K+1)//2

print(c)

Measured memory_bytes: 9188
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
As=LI()

DIG_CUM = [[0]*60 for _ in range(N+1)]

for i in range(N):
    for s in range(60):
        DIG_CUM[i+1][s] = DIG_CUM[i][s] + ((As[i] >> s) & 1)

# for arr in DIG_CUM:
#     print(arr)

res = 0
for i in range(N-1):
    for s in range(60):
        coef = DIG_CUM[N][s] - DIG_CUM[i+1][s]
        if (As[i] >> s) & 1: coef = N - i - 1 - coef
        # coef = (N - i - 1 - (DIG_CUM[N][s] - DIG_CUM[i+1][s])) if (As[i] >> s) & 1 else DIG_CUM[N][s] - DIG_CUM[i+1][s]
        res += coef * (1 << s)
    res %= DVSR
print(res)


Measured memory_bytes: 203332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 2, 0);
  rep(i, N)
  {
    cin >> A[i + 1];
  }
  int sum_price = 0;
  rep(i, N + 2)
  {
    sum_price += abs(A[i] - A[i + 1]);
  }
  vector<int> ans(N);
  rep(i, N)
  {
    ans[i] = sum_price + abs(A[i + 2] - A[i]) - abs(A[i + 2] - A[i + 1]) - abs(A[i + 1] - A[i]);
  }

  printVector(ans);
  return 0;
}

Measured memory_bytes: 2048
#include<stdio.h>

int main()
{
	int i,n,max,sum,array[5000]={0};
	
	while(scanf("%d",&n)!=EOF)
	{
		if(n==0)
		{
			break;
		}
		
		max=-1000000;
		sum=0;
    	for(i=0;i<n;i++) 
		{
        	scanf("%d",&array[i]);
        	
        	sum+=array[i];
        	
        	if(max<sum)
        	{
        		max=sum;
			}
			
			if(sum<0)
			{
				sum=0;
			}
		}
		
		printf("%d\n",max);
	}
	
	return 0;
}


Measured memory_bytes: 2036
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    n = input()
    if n == "A":
        print("T")
    elif n == "C":
        print("G")
    elif n == "G":
        print("C")
    else:
        print("A")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


Measured memory_bytes: 39408
#include<cstdio>

int min(int a,int b){ return a>b?b:a;  }

int max(int a,int b){ return a>b?a:b; }

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",c-min(a-b,c));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i,a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    int mi=INT_MAX;
    int ma=INT_MIN;
    for(i=0;i<n;i++)
    {
        if(a[i]>ma)
            ma=a[i];
        if(a[i]<mi)
            mi=a[i];
    }
    cout<<ma-mi;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>star[200005];
vector<int>endd[200005];
int vis1[200005];
int vis2[200005];
int ans[505][505];
int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for (int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		star[a].push_back(i);
		endd[b].push_back(i);
	}
	for (int i=0;i<m;i++){
		vis1[i]=1;
	}
	for (int i=1;i<=n;i++){
		for (int j=i;j<=n;j++){
			int tmp=0;
			for (int k=0;k<endd[j].size();k++){
				vis2[endd[j][k]]=1;
				if (vis1[endd[j][k]]==1){
					tmp++;
				}
			}
			ans[i][j]=tmp;
			if (j>i){
				ans[i][j]+=ans[i][j-1];
			}
		}
		for (int j=0;j<star[i].size();j++){
			vis1[star[i][j]]=0;
		}
	}
	for (int i=0;i<q;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		printf ("%d\n",ans[a][b]);
	}
}

Measured memory_bytes: 15360
from fractions import gcd
#from math import factorial
from math import sqrt

N,X=map(int,input().split())
x=list(map(int,input().split()))
G=abs(x[0]-X)
for i in range(N):
    x[i]=abs(x[i]-X)
    G=gcd(G,x[i])
print(G)


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

int main()
{
    int n;
    int sum = 0;
    vector<int> times;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        times.push_back(t);
        sum += t;
    }
    
    int m;
    cin >> m;
    for(int i = 0; i < m; ++i)
    {
        int p, x;
        cin >> p >> x;
        cout << sum + (x - times.at(p-1)) << endl;
    }

}

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

using namespace std;

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

class S{
public:
  string s;
  int n;
  S(string s,int n):s(s),n(n){}
};

int main(){
  while(1){
    string a;
    cin>>a;
    if(a=="0")break;

    queue<S> que;
    map<string,int> memo;
    char cc[111][111];
    rep(i,111)rep(j,111)cc[i][j]=-1;
    que.push(S(a,0));
    int ans=0;
    int kn=0;
    while(1){
      if(que.empty()==1){
	break;
      }
      S u = que.front();
      que.pop();
      ans=u.n;
      //cout<<u.s<<" "<<u.n<<endl;
      if(memo[u.s]!=0){
	continue;
      }
      memo[u.s]=1;
      int comp=1;
      int ch=u.s[0];
      reps(i,u.s.size()-1){
	if(ch!=u.s[i]){
	  comp=0;
	  break;
	}
      }
      if(comp==1){
	kn=1;
	break;
      }
      cc['r']['g']=cc['g']['r']='b';
      cc['r']['b']=cc['b']['r']='g';
      cc['b']['g']=cc['g']['b']='r';
      rep(i,u.s.size()-1){
	string cop=u.s;
	if(u.s[i]!=u.s[i+1]){
	  cop[i]=cop[i+1]=cc[cop[i]][cop[i+1]];
	  que.push(S(cop,u.n+1));
	}
      }
    }
    if(kn==1){
      printf("%d\n",ans);
    }else{
      printf("NA\n");
    }
  }
}

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

int main()
{
  int64_t n;
  cin >> n;
  stack<int64_t> S;
  while (n > 0)
  {
    n--;
    S.push(n % 26);
    n /= 26;
  }
  while (S.size())
  {
    cout << (char)(S.top() + 'a');
    S.pop();
  }
  cout << endl;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        char[] SS = S.toCharArray();
        char[] TT = T.toCharArray();
        int count = T.length();

        for (int i = 0; i < T.length(); i++) {
            for (int j = i; j < S.length(); j++) {
                int n = i;
                if (TT[i] == SS[j]) {
                    for (int k = 0; k < T.length() - i; k++) {
                        if(j + k >= S.length()){
                            n = count;
                            break;
                        }
                        if (TT[i + k] != SS[j + k]) n++;
                    }
                    if (n < count) count = n;
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 36644
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N;
	cin >> N;
	vector<pair<string, int>> V(N);
	string S;
	int t;
	for(int i = 0; i < N; i++){
		cin >> S >> t;
		V[i] = mpair(S, t);
	}
	string X;
	cin >> X;
	int ans = 0;
	bool flag = false;
	for(int i = 0; i < N; i++){
		if(flag)ans += V[i].second;
		if(V[i].first == X)flag = true;
	}
	cout << ans << endl;

	return 0;
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

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

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 2E5 + 10;

int n;
int a[N], nex[N];

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	nex[n - 1] = n;
	for (int i = n - 2; i >= 0; --i)
		nex[i] = a[i + 1] ? i + 1 : nex[i + 1];
	ll ans = 0;
	for (int i = 0; i < n; ++i){
		int s = 0, j = i;
		for (; j < n && (s & a[j]) == 0; j = nex[j])
			s |= a[j];
		ans += j - i;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792