akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
#define BLANK 0
#define LOSE 1
#define BACK 2
int main()
{
  int N,T,L,B;
  int i,j,k;
  while(cin>>N>>T>>L>>B,N|T|L|B){
    vector<int>board(N+1,BLANK);
    vector< vector<double> >dp(T+1,vector<double>(N+1,0));
    vector< vector<double> >rest(T+1,vector<double>(N+1,0));

    for(i=0;i<L;i++){
      int t;
      cin>>t;
      board[t]=LOSE;
    }
    for(i=0;i<B;i++){
      int t;
      cin>>t;
      board[t]=BACK;
    }

    dp[0][0]=1;
    for(i=1;i<=T;i++){
      dp[i][N]+=dp[i-1][N];

      for(j=0;j<=N-1;j++){
	dp[i][j]+=rest[i-1][j];

	for(k=1;k<=6;k++){
	  int t;
	  if(j+k>N)t=N-((j+k)%N);
	  else t=j+k;

	  if(board[t]==BACK){
	    dp[i][0]+=dp[i-1][j]/6.0;
	  }else if(board[t]==LOSE){
	    rest[i][t]+=dp[i-1][j]/6.0;
	  }else{
	    dp[i][t]+=dp[i-1][j]/6.0;
	  }
	}
      }
    }
    printf("%8.6f\n",dp[T][N]);
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(101,0);
  rep(i,N){
   int tmp;
   cin >> tmp;
   vec.at(tmp) = 1; 
  }
  int ans = 0;
  rep(i,101){
    ans += vec.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.io.*;

class Main
{
 public static void main(String[] args) throws IOException
 {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
  String[] str = br.readLine().split(" "); 
  int x=Integer.parseInt(str[0]);
  int y=Integer.parseInt(str[1]);
  
  System.out.println(x*y + " " + (2*x+2*y));
 }
}

Measured memory_bytes: 24196
n=int(input())
while n!=0:
    S=0
    #print(n)
    l=input().rstrip().split()
    l=list(map(int,l))
    #print(l)
    m=sum(l)/len(l)
    #print(m)
    for i in range(len(l)):
        S+=(l[i]-m)**2
    print((S/len(l))**(1/2))
    n=int(input())


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	string c;
	for(auto x : s)
		if(x == 'C'){
			if((int)c.size() == 0)
				c += x;
		}else if(x == 'F'){
			if((int)c.size() == 1)
				c += x;
		}

	cerr << c;
	if(c == "CF")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

int main() {
  int64_t s;
  cin>>s;
  int a_1=0;
  int a_2=0;
  int b_1,b_2;
  int64_t c_1, c_2;
  if (s%1000000000==0) {
    b_1=s/1000000000;
    c_2=1000000000;
    b_2=0;
    c_1=0;
  } else {
    int64_t q=s/1000000000;
    int64_t res=1000000000*(q+1)-s;
    b_1=q+1;
    c_2=1000000000;
    b_2=1;
    c_1=res;
  }
  cout<<a_1<<" "<<a_2<<" "<<b_1<<" "<<b_2<<" "<<c_1<<" "<<c_2;
}



Measured memory_bytes: 256
let n, k = Scanf.scanf "%d %d\n" (fun n k -> (n, k))

let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x))

let a' = Array.make n 0

let () =
  Array.iter (fun x -> a'.(x - 1) <- a'.(x - 1) + 1) a ;
  let a'' = List.filter (( <> ) 0) @@ Array.to_list a' in
  let len = List.length a'' and a''' = List.fast_sort (fun i j -> j - i) a'' in
  ( if List.length a''' <= k then 0
  else Array.sub (Array.of_list a''') k (len - k) |> Array.fold_left ( + ) 0 )
  |> Printf.printf "%d\n"

Measured memory_bytes: 26752
class dictionary{
    constructor(m){
        this.S = new Array(m);
        this.m = m;
    }
    
    h1(key){
        return key % this.m;
    }
    h2(key){
        return 1 + key % (this.m-1);
    }
    h(key,i){
        return (this.h1(key)+i*this.h2(key)) % this.m;
    }
    insert(key){
        let i = 0;
        while(true){
            let j = this.h(key,i);
            if(typeof this.S[j]==="undefined"){
                this.S[j] = key;
                return j;
            }else{
                i++;
            }
        }
    }
    search(key){
        let i = 0;
        while(true){
            let j = this.h(key,i);
            if(this.S[j]===key){
                return j;
            }else if(i>=this.m || typeof this.S[j]==="undefined"){
                return false;
            }else{
                i++;
            }
        }
    }
}

function main(input){
    let lines = input.trim().split("\n");
    let length = parseInt(lines.shift());
    let dict = new dictionary(length);

    for(let i =0;i<length;i++){
        let args = lines[i].trim().split(" ");
        args[1] = args[1].replace(/A/g,"1");
        args[1] = args[1].replace(/C/g,"2");
        args[1] = args[1].replace(/G/g,"3");
        args[1] = args[1].replace(/T/g,"4");


        if(args[0]==="insert"){
            dict.insert(parseInt(args[1]));
        }else if(args[0]==="find"){
            let res = dict.search(parseInt(args[1]));
            if(typeof res==="number") console.log("yes");
            else console.log("no");
        }
        
    }
    
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 201352
#include<iostream>
#include<algorithm>
using namespace std;
#define max 1000
#define vmax 10000
int n,A[max],allMin;
int B[max];//定义排序之后的货物
int T[vmax];//值每一个货物应该摆放的位置
int sum;//存储总成本
bool Flag[max];//标志当前货物是否被摆放到正确位置
int deal(){
int fsum=0;
for(int i=0;i<n;i++){//从0开始检索当前位置是否被摆放
    if(Flag[i]==true) continue;
    int now=i;
    int sinCirvalue=0;
    int sinMin=vmax;
    int sNum=0;
    while(1){
        Flag[now]=true;
        sNum++;
        sinMin=min(sinMin,A[now]);
        sinCirvalue+=A[now];
        now=T[A[now]];
        if(Flag[now]==true) break;
    }
    fsum+=min(sinCirvalue+(sNum-2)*sinMin,sinCirvalue+sinMin+(sNum+1)*allMin);
}
return fsum;
}
int main(){
    cin>>n;
    allMin=vmax;
    for(int i=0;i<n;i++){
    cin>>A[i];
    B[i]=A[i];
    allMin=min(allMin,A[i]);
    Flag[i]=false;
    }
    sort(B,B+n);//得到最后的排序结果
    for(int i=0;i<n;i++){
    T[B[i]]=i;//索引是货物的重量，值是这个货物应该摆放的位置
    }
    sum=deal();
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3176
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, m = il()
a = ils(n, "input()")
b = ils(m, "input()")
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = 1
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    flag = 0
        if flag:
            print("Yes")
            exit()
print("No")

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

int main() {
	int N;
	cin >> N;
	vector<int> P(N), Q(N);
	for (int &e : P) {
		cin >> e;
	}
	for (int &e : Q) {
		cin >> e;
	}
	vector<int> perm(N);
	vector<vector<int>> perms;
	iota(begin(perm), end(perm), 1);
	do {
		perms.push_back(perm);
	} while (next_permutation(begin(perm), end(perm)));
	auto itp = lower_bound(perms.begin(), perms.end(), P);
	auto itq = lower_bound(perms.begin(), perms.end(), Q);
	cout << abs(distance(itp, itq)) << endl;
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,i,j,k,now,num,ans,v[1010],a[1010],f[2][310][310],p=1e9+7;
int main(){
	scanf("%lld",&n);
	m=n*2;
	for(i=1;i<=m;i++)scanf("%lld",&a[i]);
	for(i=1;i<=m;i+=2)if(a[i]==-1||a[i+1]==-1){
		num+=(a[i]==-1)&&(a[i+1]==-1);
		if(a[i]!=-1)v[a[i]]=1;
		 else if(a[i+1]!=-1)v[a[i+1]]=1;
	}
	 else v[a[i]]=v[a[i+1]]=2;
	ans=1;
	for(i=1;i<=num;i++)ans=ans*i%p;
	f[0][0][0]=1;num=0;
	for(i=m;i;i--)if(v[i]!=2){
		now^=1;
		memset(f[now],0,sizeof(f[now]));
		for(j=0;j<=num;j++)
		 for(k=0;j+k<=num;k++)if(f[now^1][j][k]){
		 	if(v[i]){
		 		f[now][j][k+1]=(f[now][j][k+1]+f[now^1][j][k])%p;
		 		if(j)f[now][j-1][k]=(f[now][j-1][k]+f[now^1][j][k])%p;
			 }
			  else{
			  	f[now][j+1][k]=(f[now][j+1][k]+f[now^1][j][k])%p;
			  	if(k)f[now][j][k-1]=(f[now][j][k-1]+k*f[now^1][j][k])%p;
			  	if(j)f[now][j-1][k]=(f[now][j-1][k]+f[now^1][j][k])%p;
			  }
		 }
		num=min(num+1,n);
	}
	printf("%lld",ans*f[now][0][0]%p);
}
/*
把n*2的排列想象成一个括号序列，bi序列相当于求左括号有多少种不同的位置方案 
*/

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

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

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define PB push_back
#define PF push_front
#define poB pop_back ()
#define poF pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    lli num , m = 0 , sum = 0 ;
    cin >> num ;
    lli a [num] ;
    loopcin(num , a ) ;
    loop(num) {
        m = max (m , a[i]) ;
        sum += a[i] ;
    }
    (m < sum - m ? Yes : No ) ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
int ss,s;
vector<int> v[N];
void dfs(int p,int fa,int dep){
	if(dep>ss){ss=dep; s=p;}
	for(auto i:v[p])if(i!=fa)dfs(i,p,dep+1);
}
int main(){
	int n=read();
	for(int i=1;i<n;i++){
		int s=read(),t=read();
		v[s].push_back(t); v[t].push_back(s);
	}
	dfs(1,0,1); ss=0;
	dfs(s,0,1);
	if(ss%3==2)puts("Second"); else puts("First");
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  
  bool ok = true;
  rep(i, n){
    int a; cin >> a;
    if(a%2 == 0){
      if(a%3 != 0 && a%5 != 0) ok = false;
    }
  }

  cout << (ok ? "APPROVED" : "DENIED") << endl;

  return 0;
}


Measured memory_bytes: 256
//RITIK RAI:
//#pragma GCC optimize("O3")
 
/*----------------------------------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
/*----------------------------------------------------------------------------------------------------------*/
 
#define ll long long int
#define ull unsigned long long int
#define ld long double

/*----------------------------------------------------------------------------------------------------------*/
 
#define pll pair<ll,ll>
#define mp make_pair
#define fir first
#define sec second
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bin binary_search

/*----------------------------------------------------------------------------------------------------------*/

#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>b;i--)
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define print1(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl
#define print(arr,a,b)  for(ll i=a;i<b;i++) cout<<arr[i]<<endl
#define print2d(dp,r,c) for(ll i=0;i<r;i++){for(ll j=0;j<c;j++) cout<<dp[i][j]<<" "; cout<<endl;}
 
/*----------------------------------------------------------------------------------------------------------*/
 
#define ritik ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
 /*--------------------------------------------FUNCIONS--------------------------------------------------------------*/
 
ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
 
ll max3(ll a,ll b,ll c)
{
    return max(max(a,b),c);
}


ll nCr(ll n, ll r)
{
    ll x=n-r,y=0,z=1;
    while(y<r)
    {
        z=(z*(x+1))/(y+1);
        x++;y++;
    }
    return z;
}
 
/*-----------------------------------------------write your code here-----------------------------------------------------------*/


int main()
{
    ll n,k; cin>>n>>k;
    cout<<min(n%k,k-n%k)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	vl dp(n+1);
	dp[0]=0;dp[1]=1;
	if(n!=1)dp[2]=1+(s[0]!=s[1]);
	range(i,3,n+1){
		if(s[i-1]!=s[i-2])dp[i]=dp[i-1]+1;
		else dp[i]=dp[i-3]+2;
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int n;
vector<int> divisor[mx];
int a[mx],cnt[mx];

void precalc(){
    for(int i=2;i<mx;i++){
        for(int j=i;j<mx;j+=i) divisor[j].pb(i);
    }
}

int main()
{
    precalc();
    scanf("%d",&n);
    int gcd=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        gcd=__gcd(gcd,a[i]);
    }
    bool valid=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<(int)divisor[a[i]].size();j++){
            int d=divisor[a[i]][j];
            cnt[d]++;
            if(cnt[d]>1){
                valid=0;
                break;
            }
        }
        if(!valid) break;
    }
    //for(int i=2;i<=n;i++) debug()<<imie(cnt[i]);
    if(valid) printf("pairwise coprime\n");
    else if(gcd==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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

const int inf=100000000;

llong pownew(llong m, llong n) {
        if (n == 0) { return 1; }
        if (n % 2 == 0) { return pow(m*m, n/2); }
        return pow(m, n-1) * m;
    }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S; cin>>S;
    int n=S.size();
    vector<int> v(n,0);
    REP(i,n) v[i]=S[i]-'0';

    llong ans=0;
    vector<llong> cal(n,0);//誤差項
    for(int i=n-1; i>=0; --i)
    {
    llong vv=pownew(2,i)*pownew(10,n-1-i);
    cal.push_back(vv);
    }
    reverse(cal.begin(),cal.end());

    vector<llong> cx(n,0);
    for(int i=n-1; i>0; --i)
    {
        llong h=pownew(2,i-1)*pownew(10,n-1-i);
        cx[i-1]=h+cx[i];
    }

    for(int i=0; i<n; i++)
    {
        ans+=v[i]*(cal[i]+cx[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <iomanip>

using namespace std;

int main() {
  bool n = false , s = false, w = false, e = false;
  string str;
  cin >> str;
  for (auto&& ch : str) {
    if (ch == 'W')w = true;
    if (ch == 'E')e = true;
    if (ch == 'S')s = true;
    if (ch == 'N')n = true;
  }
  if ((n && !s) || (!n&&s)) {
    cout << "No" << endl;
    return 0;
  }
  if ((w && !e) || (!w&&e)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  	string s;
  	cin >> s;
  	if(s[2]==s[3]&&s[4]==s[5]){Yes}
  	No

  	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    int a[100],b[100];
    int ans=0;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
       scanf("%d %d ", &a[i],&b[i]);
    }
    for(int i=0;i<n;i++){
       if(a[i] == b[i]){
         if(++ans ==3) break;
       } else ans=0;
    }
  
    // 出力
    if(ans!=3){
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[100000],b[100000];
	bool c=true;
	cin>>a;
	int l=strlen(a);
	for(int i=0;i<l;i++)
		b[l-1-i]=a[i];
	for(int i=0;i<l;i++)
	{
		if(b[i]=='b') b[i]='d';
		else if(b[i]=='d') b[i]='b';
		else if(b[i]=='q') b[i]='p';
		else if(b[i]=='p') b[i]='q';
	}
	for(int i=0;i<l;i++)
		if(a[i]!=b[i])
		{
			c=false;
			break;
		}
	if(c==true) cout<<"Yes";
	else cout<<"No";
	return 0;		
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>

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

ll INF (1ll << 60);

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int upper = 1 << n;
    ll ans = INF;
    for(int bit = 0; bit < upper; bit++) {
        int index = 0;
        unordered_set<int> us;
        int b = bit;
        while(b != 0) {
            if(b & 1) {
                us.insert(index);
            }
            index++;
            b >>= 1;
        }
        if(us.size() != k) {
            continue;
        }
        if(us.find(0) == us.end())
            continue;
        ll tmp = 0;
        vector<ll> aa= a;
        ll tmpmax = a[0];
        for(int i = 1; i < n; i++) {
            if(us.find(i) != us.end()) {
                if(a[i] <= tmpmax) {
                    aa[i]= tmpmax + 1;
                    tmp += aa[i] - a[i];
                }
                tmpmax = aa[i];
            } else {
                if(a[i] > tmpmax) {
                    tmp = INF;
                    break;
                }
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;
llong x[1005];

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

    llong ans = 1ll << 60ll;
    for (llong p = 0; p <= 2000; p++) {
        llong mv = -1;
        for (llong i = 0; i < n; i++) {
            mv = max(mv, llabs(x[i] - p));
        }

        ans = min(mv, ans);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3092
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
        boolean flag[] = new boolean[N];
        for(int i=0;i<N;i++) flag[i] = false;
        int K = sc.nextInt();
        int count = 0;
        for(int i=0;i<K;i++){
            int d = sc.nextInt();
            for(int j=0;j<d;j++)
              	flag[sc.nextInt()-1]=true;
        }
        for(int i=0;i<N;i++) if(!flag[i]) count++;
        System.out.println(count);
    }
}

Measured memory_bytes: 46464
#!/usr/bin/python3

def main():
  n = int(input())
  a = list(map(int, input().split(' ')))

  max_a = max(a)
  min_a = min(a)

  if max_a >= 0 and min_a <= 0:
    result, process = has_pos_and_neg(a)
    print(result)
    for line in process:
      print(line)

  elif min_a > 0:
    a.remove(max_a)
    a.remove(min_a)
    a.append(min_a - max_a)

    result, process = has_pos_and_neg(a)
    print(result)
    print('{} {}'.format(min_a, max_a))
    for line in process:
      print(line)

  elif max_a < 0:
    a.remove(max_a)
    a.remove(min_a)
    a.append(max_a - min_a)

    result, process = has_pos_and_neg(a)
    print(result)
    print('{} {}'.format(max_a, min_a))
    for line in process:
      print(line)


def has_pos_and_neg(a):
  if len(a) == 1:
    return a[0], []

  max_a = max(a)
  min_a = min(a)

  a.remove(max_a)
  a.remove(min_a)

  process = []

  for elem in a:
    if elem <= 0:
      process.append('{} {}'.format(max_a, elem))
      max_a -= elem
    else:
      process.append('{} {}'.format(min_a, elem))
      min_a -= elem

  process.append('{} {}'.format(max_a, min_a))
  result = max_a - min_a

  return result, process

if __name__ == '__main__':
  main()

Measured memory_bytes: 17336
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n);
    cin>>v;
    priority_queue<ll, vector<ll>, greater<ll>> vv;
    rep(i, n){
        vv.push(-v[i]);
    }
    rep(i, m){
        auto y = vv.top();
        vv.pop();
        vv.push(y/2);
    }
    ll sum = 0;
    
    rep(i, n){
        auto y = vv.top();
        vv.pop();
        sum-=y;
    }
    pr(sum);



}

Measured memory_bytes: 2168
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const ll MAX_N = 1e5+5;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll a[300005];

int main(){
    fastio;
    ll n;
    cin>>n;
    map <ll,ll> map1;
    f(i,0,n) {cin>>a[i];map1[a[i]]++;}
    ll ans=0;
    map <ll,ll>::iterator it;
    for(it=map1.begin();it!=map1.end();it++){
        ll aux=it->sc;
        ans+= (aux-1)*aux/2;
    }
    f(i,0,n){
        ll p= ans - map1[a[i]]*(map1[a[i]]-1)/2 + (map1[a[i]]-1)*(map1[a[i]]-2)/2;
        cout<<p<<endl;

    }



}



Measured memory_bytes: 11136
import sys

class WeightedUnionFind:
    def __init__(self, N:int):
        """N: 大きさ
        size: 連結成分の大きさ
        weight: rootからの重み
        """
        self.par = [i for i in range(N)]
        #self.size = [1]*N
        self.rank = [0]*N
        self.weight = [0]*N

    def root(self, x:int)->int:
        """根を求める"""
        if self.par[x] == x: # if root
            return x
        else:
            root_x = self.root(self.par[x]) # 経路圧縮
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = root_x
            return root_x

    def get_weight(self, x: int)->int:
        """x の重みを取得"""
        self.root(x) # 経路圧縮
        return self.weight[x]

    def get_diff(self, x:int, y:int)->int:
        """x と y の差分を取得"""
        if not self.is_same(x, y): return "?" # 判定不可
        return self.get_weight(y) - self.get_weight(x)

    def is_same(self, x:int, y:int)->bool:
        """x と y が同じ集合に属するか否か"""
        return self.root(x)==self.root(y)

    def unite(self, x:int, y:int, w:int)->bool:
        """weight[y] = weight[x]+w となるようにmerge(x が y の親)
        return True if merge 可能"""
        if self.is_same(x, y): return False
        root_x = self.root(x)
        root_y = self.root(y)
        w += (self.weight[x] - self.weight[y]) # 重みを補正
        if self.rank[root_x] < self.rank[root_y]:
            self.par[root_x] = root_y
            self.weight[root_x] = -w
        else:
            self.par[root_y] = root_x
            self.weight[root_y] = w
            if self.rank[root_x] == self.rank[root_y]:
                self.rank[root_x] += 1
        return True

    def get_size(self, x:int)->int:
        """xの属するグループのサイズ"""
        return self.size[self.root(x)]

if __name__ == "__main__":
    N,Q = map(int, sys.stdin.readline().split())
    wuf = WeightedUnionFind(N)
    for _ in range(Q):
        l,r,d = map(lambda x: int(x)-1, sys.stdin.readline().split())
        d += 1
        if not wuf.unite(l,r,d):
            if wuf.get_diff(l,r)!=d:
                print("No")
                sys.exit()
    print("Yes")


Measured memory_bytes: 10012
n = int(input())
ans = 0
def bfs(x):
    global ans
    if x>n: return 0
    else:
        if set(list(str(x)))=={'7','5','3'}:
            ans+=1
        bfs(x*10+3)
        bfs(x*10+5)
        bfs(x*10+7)
bfs(0)
print(ans)

Measured memory_bytes: 45912
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	static int n;
	static List<List<Integer>> list;
	static int[] a, ans, val;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int u = Integer.parseInt(sa[0]) - 1;
			int v = Integer.parseInt(sa[1]) - 1;
			list.get(u).add(v);
			list.get(v).add(u);
		}
		br.close();

		ans = new int[n];
		val = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			val[i] = Integer.MAX_VALUE;
		}
		dfs(0, -1, 1);

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			pw.println(ans[i]);
		}
		pw.flush();
	}

	static void dfs(int x, int p, int dep) {
		int idx = Arrays.binarySearch(val, a[x]);
		if (idx < 0) idx = ~idx;
		int bk = val[idx];
		val[idx] = a[x];

		int lis = Arrays.binarySearch(val, Integer.MAX_VALUE - 1);
		if (lis < 0) {
			lis = ~lis;
			lis--;
		}
		ans[x] = lis;

		for (int next : list.get(x)) {
			if (next != p) {
				dfs(next, x, dep + 1);
			}
		}
		val[idx] = bk;
	}
}


Measured memory_bytes: 108112
//##MohK
#include <bits/stdc++.h>
using namespace std ;
using ll = long long;
int main()
{
    ll a,b,res=0,k;
    cin>>a>>b>>k;
    vector<int>x;
    for(ll i=1;i<=a;i++){
        if(a%i==0&&b%i==0){
            res++;
            x.push_back(i);
        }
        else continue;
    }
    ll c=x.size()-k+1;
    cout<<x[c-1]<<endl;

    return 0 ;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main(){
	intt N, K; std::cin >> N >> K;
	std::vector<intt> A(N);
	for (auto& r : A) {
		std::cin >> r;
		++r;
	}
	std::vector<intt> S(N + 1, 0);
	for (int i = 0; i < N; ++i)
		S[i + 1] = S[i] + A[i];
	intt ans = 0;
	for (intt i = 0; i + K <= N; ++i)
		ans = std::max(ans, S[i + K] - S[i]);
	std::cout << std::fixed << std::setprecision(12) << (double)(ans) / 2 << std::endl;

}

Measured memory_bytes: 6384
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N,M,R;
vector<LL> r;
vector<vector<LL>> dist;
 
LL ans = INF;
 
void solve(){
	for(int i=1;i<=N;i++) dist[i][i] = 0;
	//ワーシャルフロイド
	for(int k=1;k<=N;k++){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	sort(r.begin(),r.end());
	do{
		LL sum = 0;
		for(int i=0;i<=R-2;i++) sum += dist[r[i]][r[i+1]];
		ans = min(ans,sum);
	}while(next_permutation(r.begin(),r.end()));
}
 
int main(){
    cin >> N >> M >> R;
    r = vector<LL>(R);
    for(int i=0;i<R;i++) cin >> r[i];
    dist = vector<vector<LL>>(N+1,vector<LL>(N+1,INF));
    for(int i=0;i<M;i++){
    	LL a,b,c;cin >> a >> b >> c;
    	dist[a][b] = c;
    	dist[b][a] = c;
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

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

    map<char, int> mp;
    rep(i, s.size()) mp[s[i]]++;
    bool ok = true;
    if (mp.size() != 2) ok = false;
    for (auto tmp : mp) {
        if (tmp.second != 2) ok = false;
    }

    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
N = int(input())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort(key=lambda x: x[1])

ans = "Yes"
worktime = 0
for i in range(N):
    worktime += AB[i][0]
    if worktime > AB[i][1]:
        ans = "No"

print(ans)


Measured memory_bytes: 38056
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
char a[15], b[15], c[15];

int main(){
	scanf("%s", a + 1);
	scanf("%s", b + 1);
	scanf("%s", c + 1);
	printf("%c%c%c\n", a[1] - 32, b[1] - 32, c[1] - 32);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  for(int i = 0;i < N;i++)cin >> s[i];


  int all_sum = 0;
  for(int i = 0;i < N;i++)all_sum += s[i];

  if(all_sum % 10)cout << all_sum << endl;
  else{
    int ans = 0;
    for(int i = 0;i < N;i++){
      if((all_sum - s[i]) % 10)ans = max(ans,all_sum - s[i]);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  int ans = 0;
  while (true)
  {
    bool fin = false;
    for (int i = 0; i < N; i++)
    {
      if (A.at(i) % 2 == 1) 
      {
        fin = true;
        break;
      }
    }
    if (fin) break;
    
    for (int i = 0; i < N; i++)
    {
      A.at(i) /= 2;
    }
    ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s.substr(0, 4) == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,ans;
char arr[4][111];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=3;i++) scanf("%s",arr[i]+1);
    for(int i=1;i<=n;i++){
        if(arr[1][i] == arr[2][i] && arr[2][i] == arr[3][i] && arr[1][i] == arr[3][i]) continue;
        if(arr[1][i] == arr[2][i] || arr[2][i] == arr[3][i] || arr[1][i] == arr[3][i]) ans+=1;
        else ans+=2;
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N, M;
    cin >> N >> M;

    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,a = 0;
  
  cin >> N >> A;

  for(int i = 0; i < A + 1; i++){

      if((N - i) % 500 == 0){

          a++;

      }}

if(a>0){

cout << "Yes" << endl;

}else{

  cout << "No" << endl;
}





    


  }

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,m;
pair<pii,pii> edges[12525];

int data[12525];
void init(){
  REP(i,n)data[i] = -1;
}
int root(int x){
  return data[x]<0?x:data[x]=root(data[x]);
}
int unite(int a,int b){
  a=root(a);
  b=root(b);
  if(a!=b){
    if(data[a]>data[b])swap(a,b);
    data[a] += data[b];
    data[b] = a;
    return 1;
  }else{
    return 0;
  }
}

int main(){
  scanf("%d%d",&n,&m);
  ll csum=0, dsum=0;
  REP(i,m){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    csum += c;
    dsum += d;
    edges[i] = make_pair(pii(a,b),pii(c,d));
  }
  if(m==n-1){
    puts("0");
    return 0;
  }
  double low = 0, high = 1e12;
  REP(_,100){
    double t = (low+high)/2;
    vector<pair<double,pii>> es(m);
    REP(i,m){
      double cost = t * edges[i].second.first - edges[i].second.second;
      es[i] = make_pair(cost, edges[i].first);
    }
    sort(ALL(es));
    init();
    int x = n-1;
    double sum = 0.0;
    REP(i,m){
      double cost = es[i].first;
      int a = es[i].second.first;
      int b = es[i].second.second;
      if(unite(a,b)){
        sum += cost;
        x--;
        if(x==0)break;
      }
    }
    double clc = dsum - t*csum + sum;
    if(clc <= 0.0){
      high = t;
    }else{
      low = t;
    }
  }
  printf("%.9f\n",low);
  return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define int long long
#define N 10010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

vector<int> g[N],G[N];
int n;
set<int> A,B,C;

void input(){
  int a,b,c;
 
  cin>>n>>a>>b>>c;
  for(int i=0,t;i<a;i++) cin>>t,A.insert(t-1);
  for(int i=0,t;i<b;i++) cin>>t,B.insert(t-1);
  for(int i=0,t;i<c;i++) cin>>t,C.insert(t-1);

  int par[N];
  for(int i=0;i<N;i++) par[i] = i;
  for(int v:A) par[v] = *A.begin();
  for(int v:B) par[v] = *B.begin();
  for(int v:C) par[v] = *C.begin();
  
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v; u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
    u = par[u], v = par[v];
    if(u == v) continue;
    g[u].push_back(v);
    g[v].push_back(u);
  }
}

typedef pair<int,int> P;
typedef pair<P,int> PP;
vector<P> dijkstra(int start){
  vector<P> D(N,P(INF,INF));
  priority_queue<PP,vector<PP>,greater<PP>> Q;

  Q.push(PP(P(0,start),start));
  D[start] = P(0,start);
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    P cost = t.first;
    int pos = t.second;
    if(D[pos] < cost)continue;

    for(int npos:g[pos]){
      P ncost = P(cost.first+1,min(cost.second,npos));
      if(D[npos] <= ncost) continue;
      Q.push(PP(ncost,npos));
      D[npos] = ncost;
    }
  }
  return D;
}

P calc(P a,P b,P c){
  int cost = a.first + b.first + c.first;
  int node = min(a.second,min(b.second,c.second));
  return P(cost,node);
}

signed main(){
  input();
  int a = *A.begin();
  int b = *B.begin();
  int c = *C.begin();
  vector<P> AD = dijkstra(a);
  vector<P> BD = dijkstra(b);
  vector<P> CD = dijkstra(c);
  
  P ans = P(INF,INF);
  for(int i=0;i<n;i++) Min(ans,calc(AD[i],BD[i],CD[i]));
  cout<<ans.first<<" "<<ans.second+1<<endl;
  return 0;
}

Measured memory_bytes: 24708
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<ll,ll>;
//const int 1001001001;
const int NMAX=8;
const ll MOD=1000000007;
const int dbase=80*160;

int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> l(n+1);
	vector<ll> r(n+1);
	ll cnt=0;
	for(ll i=0;i<=n;i++){
		cnt+=i;
		cnt%=MOD;
		l[i]=cnt;
	}
	cnt=0;
	for(ll i=n;i>=0;i--){
		cnt+=i;
		cnt%=MOD;
		r[i]=cnt;
	}
  ll ans=0;
  for(ll i=k;i<=n+1;i++){
		ans+=r[n-i+1]-l[i-1]+1;
		if (ans<0)ans+=MOD;
	//	cout<<ans<<endl;
		ans%=MOD;
	}
	cout<<ans;







}


Measured memory_bytes: 6256
n = int(input())
S = list(map(int, input().split(' ')))
count = 0

def merge(A, left, mid, right):
  global count
  n1 = mid - left
  n2 = right - mid
  L = A[left:left+n1]
  R = A[mid:mid+n2]
  L.append(10**9+1)
  R.append(10**9+1)
  i, j = 0, 0
  for k in range(left, right):
    count += 1
    if L[i] <= R[j]:
      A[k] = L[i]
      i += 1
    else:
      A[k] = R[j]
      j += 1

def mergeSort(A, left, right):
  if left + 1 < right:
    mid = (left + right) // 2
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

mergeSort(S, 0, n)

print(*S)
print(count)


Measured memory_bytes: 61656