akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <climits>
#include <sstream>
using namespace std;

long long modpow(long long U){
    
    long long ans = 1;
    while(U>0){
        ans*=2;
        ans %= 1000000007;
        U--;
    }
    return ans;
    
}


int main() {
    
    int N;
    cin >> N;
    long long A,B;
    long long zero = 0;
    map<pair<long long, long long>,long long> mp;
    pair<long long,long long> Azero = make_pair(0,-1);
    pair<long long,long long> Bzero = make_pair(1,0);
    pair<long long,long long> pr;
    vector<pair<long long,long long>> vec;
    for(int i = 0; i < N;i++){
        cin >> A >> B;
        if(A==0&&B==0){
            zero++;
            zero %= 1000000007;
            continue;
        }else if(A == 0){
            mp[Azero]++;
            mp[Azero] %= 1000000007;
            vec.push_back(Azero);
            continue;
        }else if(B == 0){
            mp[Bzero]++;
            mp[Bzero] %= 1000000007;
            vec.push_back(Bzero);
            continue;
        }else{
            long long g = gcd(A, B);
            if(A<0)g *= -1;
            pr = make_pair(A/g,B/g);
            mp[pr]++;
            mp[pr] %= 1000000007;
            vec.push_back(pr);
        }
    }
    //sort(vec.begin(),vec.end());
    //vec.erase(unique(vec.begin(), vec.end()), vec.end());
    //cout << vec.size() <<endl;
    map<pair<long long, long long>,long long> end;
    pair<long long, long long> u;
    long long U = 0;
    long long V = 0;
    long long ans = 1;
    for(auto v:vec){
        if(v.second<0){
            u = make_pair( -v.second,v.first);
        }else{
            u = make_pair( v.second,-v.first);
        }
        
        if(end[v]==0){
            U = mp[u];
            V = mp[v];
            // cout << u.first <<" "<<u.second<<" "<<U<<endl;
            // cout << v.first <<" "<<v.second<<" "<<V<<endl;            
            // cout <<  (modpow(U)-1) + (modpow(V)-1) + 1 <<endl;
            ans *= (((modpow(U)-1)% 1000000007+(modpow(V)-1)% 1000000007)+1% 1000000007);
            ans %= 1000000007;
            end[u]++;
            end[v]++;
        }
    }
    zero %= 1000000007;
    cout << (((ans + zero)% 1000000007 - 1)% 1000000007 + 1000000007)%1000000007<<endl;
    
}


Measured memory_bytes: 56364
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
set<int> s;
int main()
{
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    int ans=s.size();
    if(ans==2) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
#include<unordered_map>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <cstdio>
#include <cstdlib>
#include <complex>
#define ll long long
#define  point complex<double>
#define  pi acos(-1)
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define arr2dof vector  vector<vector<int>>dp(N,vector<int>(2, inf));
using namespace std;
const ll N = 2e5 + 5, mod = 1e9 + 7, inff = -1e12,inf=1e12;
const double ep = 0.0000000001;
//const double pi = 3.14159265359;

double dot(point a, point b) {
	return  (conj(a)*b).real();
}
double cross(point a, point b) {
	return  (conj(a)*b).imag();
}
double angle(point a, point b)
{
	double dt = dot(a, b);
	dt /= abs(a);
	dt /= abs(b);
	return acos(dt) * 180.0 / pi;
}

bool isrightangel(int ind) {//90 degree
	vector<point>v;
	return(angle(v[ind] - v[(ind + 1) % 3], v[ind] - v[(ind + 2) % 3]) == 90);//bshof hal eldot producty3ny fe
	//dl3en 3moden 3ashn yb2a right trinagle
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
	if (exp == 0)
		return 1;
	ll ans = fp(base, exp / 2);
	ans = (ans * ans) % mod;
	if (exp % 2 != 0)
		ans = (ans * (base % mod)) % mod;
	return ans;
}

void calcFacAndInv(ll n)
{
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
	return (fact[n] * inv[n - r]) % mod;
}





	int dp[N];
int main()
{
	ll n,arr[100005];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	dp[0] = 0;//land on 1
	dp[1] = abs(arr[0]-arr[1]);//to land on 2
	for (int i = 2; i < n; ++i) {
		dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], abs(arr[i] - arr[i - 2]) + dp[i - 2]);
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main() {
  int five, seven, arr[3];
  int i;
  five = 0;
  seven = 0;
  
  
  for (i = 0; i < 3; i++) {
    cin >> arr[i];
    if (arr[i] == 5) {
    five++;
    } else if (arr[i] == 7) {
    seven++;
    }
  }
  
  if (five == 2 && seven == 1) {
    cout << "YES" << endl;
  } else {
  cout << "NO" << endl;
  }
  
  
   
}

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


int main(){
    int a;
    cin>>a;
    if(a==25)cout<<"Christmas";
    else if(a==24)cout<<"Christmas Eve";
    else if(a==23)cout<<"Christmas Eve Eve";
    else cout<<"Christmas Eve Eve Eve";
    return 0;
}



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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  
  int n; cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;++i) {
    cin >> d[i];
  }

  sort(d.begin(), d.end());
  int k1 = d[n/2-1], k2 = d[n/2];
  // cout << k2 << ":" << k1 << ":" << endl;
  cout << k2 - k1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll mod = 1000000007;


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

  int n;
  cin >> n;

  if (n >= 24) {
    cout << 0 << endl;
    return 0;
  }

  map<int, int> m;
  m[0] = 1;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    m[tmp]++;
  }

  if (m[0] > 1) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  for (int i = 1; i <= 12; i++) {
    vector<int> a(23);
    int last = 0;
    bool flag = true;
    for (int j = 0; j <= 23; j++) {
      if (m[j] >= 3) {
        cout << 0 << endl;
        return 0;
      }

      if (m[j] == 0) continue;
      if (j - last >= i) {  // 前回から距離が十分ある
        // 二人いれば一人を移動させる。
        if (m[j] >= 2 && j >= 12) flag = false;
        if (m[j] >= 2) {
          m[j]--; m[24-j]++;
        }
        last = j;
        continue;
      }

      // 前回から距離が足りない
      if (m[j] - last < i) {
        if (m[j] >= 2) flag = false;
        // 反対側に移動させる
        if (j < 12) {
          m[j] = 0;
          m[24-j]++;
        } else {
          flag = false;
        }
      }
    }


    if (24 - last < i) flag = false;

    if (flag) ans = i;
  }

  cout << ans << endl;  

  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const ll M = 998244353;
const string END = "\n";

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

	int a, b, t;
	cin >> a >> b >> t;
	cout << (t/a)*b << END;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
cnt=0
ans=0
for i in range(n):
  d1,d2=map(int,input().split())
  if d1==d2:
    cnt=cnt+1
    ans=max(ans,cnt)
  else:
    cnt=0
if ans>=3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9140
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

ll dp[31][50];
bool is_ok[31][50];

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)break;

		REP(i,31)REP(j,50)dp[i][j]=0LL;
		memset(is_ok,false,sizeof(is_ok));

		REP(i,n){
			int f;
			cin>>f;
			REP(j,f){
				int a;cin>>a;is_ok[a][i]=true;
			}
		}

		REP(i,n)dp[0][i]=1LL<<i;
		int ans=-1;
		for(int i=1;i<=30;i++){
			REP(j,n){
				dp[i][j]=dp[i-1][j];
				if(is_ok[i][j]){
					REP(k,n){
						if(is_ok[i][k])dp[i][j]|=dp[i-1][k];
					}
				}
			}
			REP(j,n){
				if(dp[i][j]==(1LL<<n)-1)ans=i;
			}
			if(ans!=-1)break;
		}
		cout<<ans<<endl;
	}
}


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

int main (){
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    

    long long ans = 0;

    for (size_t i = 0; i < N-1; i++)
    {
        ans += A.at((1+i)/2);
    }
    


    cout << ans << endl;
    
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i,start,end) for(int i=start; i < end ; ++i)
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
//#define mod 1000000007



using namespace std;





int main()
{
	int n;
	cin>>n;
	int a,b;
	int count=0;
	int flag=0;
	while(n--)
    {
        cin>>a>>b;
        if(a==b){count++;}
        if(a!=b){count=0;}
        if(count ==3){flag=1;}
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
}



Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
  int id;
  int parent;
  int left;
  int right;
}Node;
void buildMaxHeap(Node *T,int n){
  int i;
  for(i=n/2;1<=i;i--){
    maxHeapify(T, i, n);
  }
}
int maxHeapify(Node *T,int i,int n){
  int l,r;
  int largest;
  Node A;
  
  l=2*i;
  r=2*i+1;
  if(l <= n && T[l].id > T[i].id){
    largest = l;
  }else largest = i;
  if(r <= n && T[r].id > T[largest].id){
    largest = r;
  }
  if(largest != i){
    A = T[i];
    T[i]=T[largest];
    T[largest]=A;
    maxHeapify(T, largest,n);
  }
}
int main(){
  int n,x;
  int i;
  Node *T;
  
  scanf("%d",&n);
  T=(Node*)malloc(sizeof(Node)*(n+1));
  for(i=1;i<=n;i++){//入力
    scanf("%d",&x);
    T[i].id=x;
    if(2*i<=n) T[2*i].parent=x;
    if(2*i+1<=n) T[2*i+1].parent=x;	
    if(i%2==0)T[i/2].left=x;
    else T[(i-1)/2].right=x;
  }
  buildMaxHeap(T,n);
  for(i=1;i<=n;i++){//出力
    printf(" %d",T[i]);
    }
  printf("\n"); 
  return 0;
}



Measured memory_bytes: 9512
#include <iostream>

int main()
{
	int a, b, c;
	char o;
	for (;;) {
		std::cin >> a >> o >> b;
		switch (o) {
		case '+':
			c = a + b;
			break;
		case '-':
			c = a - b;
			break;
		case '*':
			c = a * b;
			break;
		case '/':
			c = a / b;
			break;
		case'?':
			return 0;
		}
		std::cout << c << '\n';
	}
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{
    fast_cin;
    ll t;


        map<ll,ll>mp;
        map<ll,ll>::iterator it;
        string s,s1;
        ll lock=0,sum=0,co=0;
        ll n,m,k;
        cin>>s>>s1;
        for(int i=0;i<s.length();i++)
        {
            if(s[i]!=s1[i])
                sum++;
        }
        cout<<sum<<endl;






        s1.clear();
        vec.clear();

}



Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

int N;
int a[109];

int main() {
    cin >> N;
    REP(i, N) cin >> a[i+1];
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 2 == 1 && a[i] % 2 == 1) cnt++;
    }
    PRINT(cnt);
    return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;
	vector<int>	aa(8);
	for(i=0;i<n;i++) {
		cin >> a;
		if (a > 3199) ans++;
		else if (a > 2799) aa[7] = 1;
		else if (a > 2399) aa[6] = 1;
		else if (a > 1999) aa[5] = 1;
		else if (a > 1599) aa[4] = 1;
		else if (a > 1199) aa[3] = 1;
		else if (a >  799) aa[2] = 1;
		else if (a >  399) aa[1] = 1;
		else aa[0] = 1;
	}
	m = 0;
	for(i=0;i<8;i++) {
		m += aa[i];
	}
	ans =  m + ans;
	if (m==0) m=1;
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

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


Measured memory_bytes: 256
unittest
{
	assert( [ "CODEFESTIVAL" ].parse.expand.solve == "CODE" );
	assert( [ "CODEFESTIVALFESTIVAL" ].parse.expand.solve == "CODEFESTIVAL" );
	assert( [ "YAKINIKUFESTIVAL" ].parse.expand.solve == "YAKINIKU" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return s[ 0 .. $ - 8 ];
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    ll a=0,b=0,c=0,d=0,n=0;
    //VI a(N);
    string s,s1,s2;
    cin >> a>>b; 
    
    c=a+b;
    d=a*b;
    n=a-b;

    cout << max(max(c,d),n) << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N;
int p[202020];

void solve() {
    int tmp = INF;
    int ans = 0;
    FOR(N) {
        if (p[i] < tmp) {
            ans++;
            tmp = p[i];
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(N)
        cin >> p[i];
    solve();
    return 0;
}


Measured memory_bytes: 1792
X, N = gets.split.map &:to_i
p_array = gets.split.map &:to_i
#puts p_array
array = [*-300..300]
not_include_p =  array - p_array # sa syuugou
tag = 100
min = 1000
 
not_include_p.each { |n|
  sa = (n-X).abs
  if min > sa
    min = sa
    tag = n
  end
} if N != 0

puts N == 0 ? X : tag 


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    ll a, b, c;
    cin >> a >> b >> c;
    if (b >= c){
        cout << b + c << '\n';
    }
    else{
        cout << 2 * b + min(c - b, a + 1) << '\n';
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Principal;

namespace Contest
{
    class Program
    {
        public void Solve()
        {
            var sc = new Scanner();
            int n = sc.NextInt();
            for (int i = 0; i < n; i++)
            {
                int a = sc.NextInt();
                if (a % 2 == 1)
                {
                    Console.WriteLine("first");
                    return;
                }
            }
            Console.WriteLine("second");
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 15300
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,j,flag=3;
    string s;
    cin>>s;
    int len=s.size();
    for(i=0,j=len-1;i<j;i++,j--){
        if(s[i]!=s[j])
        flag--;
    }
    for(i=0,j=(len-1)/2-1;i<j;i++,j--){
        if(s[i]!=s[j])
        flag--;
    }
    for(i=(len+1)/2,j=len-1;i<j;i++,j--){
        if(s[i]!=s[j])
        flag--;
    }
    if(flag==3)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3620
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

import itertools

L=list(itertools.permutations(range(1,N+1)) )

Pnum=-1
Qnum=-1

for i,item in enumerate(L):
  if item==P:
    Pnum=i
  if item==Q:
    Qnum=i
  if Pnum>-1:
    if Qnum >-1:
      break

      
print(abs(Pnum-Qnum))

Measured memory_bytes: 8052
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

int main()
{
    int n; scanf("%d", &n);
    printf("%d", (1000 - (n % 1000)) % 1000);
    return 0;
}


Measured memory_bytes: 1732
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint a[100100],b[100100];
vector<pint> v;
int main()
{
	int n;cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		v.pb(mp(a[i]+b[i],i));
	}
	sort(All(v));reverse(All(v));
	lint out=0;
	rep(i,n){
		int j=v[i].se;
		if(i%2==0) out+=a[j];else out-=b[j];
	}
	cout<<out<<endl;
}


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

#define N 100010

int main()
{
	int n,m,h[N+1],ma[N+1];
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	    ma[i]=0;
	}
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		ma[a]=max(ma[a],h[b]);
	    ma[b]=max(ma[b],h[a]);
	}
	
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=h[i]>ma[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4388
num = raw_input()
num_list = []
for i in range(int(num)):
        a = raw_input()
        num_list.append(int(a))

maxv = -10000000000000
minv = num_list[0]

for i in range(1, len(num_list)):
        maxv = max(maxv, num_list[i] - minv)
        minv = min(minv, num_list[i])

print maxv

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

string s[10],st;
map<string,bool>M;
int k;

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	cin>>st>>k;
}

bool DicCmp(string Cmp1,string Cmp2){
	for(int i=0;i<min(Cmp1.size(),Cmp2.size());++i){
		if(Cmp1[i]>Cmp2[i])return false;
		if(Cmp1[i]<Cmp2[i])return true;
	}
	return(Cmp1.size()<Cmp2.size());
}

int main(){
	init();
	int Cnt=0;
	for(int i=0;i<st.size();++i){
		string str="";
		for(int j=i,len=1;j<st.size()&&len<=k;++j,++len){
			str=str+st[j];
			if(!M[str]){
				M[str]=1;
				s[++Cnt]=str;
			}
			if(Cnt>k){
				for(int ii=Cnt-1;ii>=1;--ii)
				if(DicCmp(s[ii+1],s[ii])){
					swap(s[ii+1],s[ii]);
				}
				--Cnt;
			}
			else if(Cnt>1){
				for(int ii=Cnt-1;ii>=1;--ii)
				if(DicCmp(s[ii+1],s[ii])){
					swap(s[ii+1],s[ii]);
				}
			}
		}
	}
	cout<<s[k]<<endl;
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int x; cin >> x;
   cout << (10-(x/200)) << endl;
}

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

int main() {
    int a, b, l, m, n;
    cin >> a;
    l = int(a/100);
    m = int((a - l * 100) / 10);
    n = int(a - l * 100 - m * 10);
    b = n*100+m*10+l;
    if (a == b){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

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

int i,n,a,o,k,e;
main()
{
  cin>>n>>k;
 	for(i=1; i<=n; i++)
 	{
	 	cin>>o;
		 if(o>=k)
		 e++;
	}
  cout<<e;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int a = getInt();
		int b = getInt();
		System.out.println( a * n < b ? a*n : b ) ;
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,head[100005],tot,ans,son[100005],vis[100005],q;
struct edge
{
	int v,nxt;
}edg[200005];
void addedg(int u,int v)
{
	edg[tot].v = v;
	edg[tot].nxt = head[u];
	head[u] = tot++;
	++son[u];
}
void dfs(int k,int fa)
{
	int temp = 0,x = 0;
	for(int i = head[k];i != -1;i = edg[i].nxt)
	{
		if(edg[i].v != fa)
		{
			dfs(edg[i].v,k);
			if(!vis[edg[i].v])
				++temp;
			else if(vis[edg[i].v] == 1)
			{
				vis[k] = 2;
				q = 1;
				++x;
			}
			else
			{
				++x;
				vis[k] = 2;
				q = 1;
			}
		}
	}
	if(temp >= 2)
	{
		ans += temp-1;
		vis[k] = 1;
		q = 0;
	}
	if(x >= 2)
		q = 0;
	
}
int main()
{
	while(~scanf("%d",&n))
	{
		int u,v;
		memset(head,-1,sizeof(int)*(n+1));
		memset(son,0,sizeof(int)*(n+1));
		tot = 0;
		for(int i = 1;i < n;++i)
		{
			scanf("%d%d",&u,&v);
			addedg(u,v);
			addedg(v,u);
			vis[i] = 0;
		}
		vis[0] = 0;
		ans = 0;
		q = 0;
		int root=-1;
		for(int i = 0;i < n;++i)
			if(son[i] != 1)
			{
				root = i;
				break;
			}
		if(root!=-1)
		{
			dfs(root,root);
			printf("%d\n",ans+q);
		}
		else
			printf("1\n");
	}
	return 0;
}

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

namespace SquareSearch
{
    class Program
    {
        static char GetCharOrDefault(string s, int index, char defaultChar)
        {
            if (s.Length <= index)
            {
                return defaultChar;
            }

            return s[index];
        }



        static bool SearchSquare(string line, int[] lengthOfRow, int targetSquareLength)
        {
            var isFound = false;

            var count = 0;
            for (var i = 0; i < lengthOfRow.Length; ++i) { 
                if (GetCharOrDefault(line, i, ' ')  != '*') {
                    ++lengthOfRow[i];
                }
                else {
                    lengthOfRow[i] = 0;
                }

                if (targetSquareLength <= lengthOfRow[i])
                {
                    ++count;
                    if (targetSquareLength <= count)
                    {
                        isFound = true;
                    }
                }
                else
                {
                    count = 0;
                }
            }

            return isFound;
        }


        static int GetLargetSquareLength(int rank, IEnumerable<string> lines)
        {
            var lengthOfRow = new int[rank];
            var targetSquareLength = 1;
            foreach (var s in lines)
            {
                if (SearchSquare(s, lengthOfRow, targetSquareLength))
                {
                    ++targetSquareLength;
                }
            }
            return targetSquareLength - 1;
        }


        static IEnumerable<string> ReadLines(int count)
        {
            for (var i = 0; i < count; ++i)
            {
                yield return Console.ReadLine();
            }
        }


        static void Main(string[] args)
        {
            var answer = new List<int>();

            while (true) 
            {
                var input = Console.ReadLine();
                var rank = 0;
                {
                    if (int.TryParse(input, out rank) == false)
                    {
                        break;
                    }

                    if (rank == 0)
                    {
                        break;
                    }
                }

                var length = GetLargetSquareLength(rank, ReadLines(rank));
                answer.Add(length);
            }

            foreach (var n in answer) {
                Console.WriteLine(n);
            }
        }
    }
}

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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

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


int main() {
  
  int N;
  bool blank = 0;
  cin >> N;
  rep(_, N) {
    if(blank) cout << endl;
    blank = 1;
    int arr[9][9] = {{}};
    char output[9][20] = {{}};
    VII star;
    for(int i=0; i<9; i++) {
      int used[10] = {};
      for(int j=0; j<9; j++) {
	cin >> arr[i][j];
	used[arr[i][j]] ++;
	output[i][2*j]   = ' ';
	output[i][2*j+1] = (char)('0' + arr[i][j]);
      }
      for(int j=0; j<9; j++){
	if(used[arr[i][j]] > 1) {
	  output[i][2*j] = '*';
	}
      }
    }
    
    for(int j=0; j<9; j++) {
      int used[10] = {};
      for(int i=0; i<9; i++) {
	used[arr[i][j]] ++;
      }
      for(int i=0; i<9; i++) {
	if(used[arr[i][j]] > 1) {
	  output[i][2*j] = '*';
	}
      }
    }
    
    for(int i=0; i<3; i++) {
      for(int j=0; j<3; j++) {
	int used[10] = {};
	
	for(int k=0; k<3; k++) {
	  for(int l=0; l<3; l++) {
	    used[arr[i*3+k][j*3+l]] ++;
	  }
	}
	
	for(int k=0; k<3; k++) {
	  for(int l=0; l<3; l++) {
	    if(used[arr[i*3+k][j*3+l]] > 1) {
	      output[(i*3+k)][2*(j*3+l)] = '*';
	    }
	  }
	}
	
      }
    }
    
    for(int i=0; i<9; i++) {
      cout << output[i] << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

inline int getint_mae() {
	char C = getchar_unlocked();
	int A = C - '0';
	while (isdigit(C = getchar())) A = A * 10 + C - '0';
	return A;
}

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], *di = dn, dt;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint_mae(), M = getint_mae(), Q = getint_mae();
	char S[2000][2001];
	rep(i, N) fread_unlocked(S[i], 1, M + 1, stdin);
	int B[2001][2001] = {}, C[2001][2001] = {}, D[2001][2001] = {};
	rep(i, N) {
		rep(j, M) {
			B[i + 1][j + 1] = B[i + 1][j] + S[i][j] - '0';
			if (i != 0) C[i + 1][j + 1] = C[i + 1][j] + ((S[i - 1][j] - '0') & (S[i][j] - '0'));
			if (j != 0) D[i + 1][j + 1] = D[i + 1][j] + ((S[i][j - 1] - '0') & (S[i][j] - '0'));
		}
	}
	rep(j, M) rep(i, N) {
		B[i + 1][j + 1] += B[i][j + 1];
		C[i + 1][j + 1] += C[i][j + 1];
		D[i + 1][j + 1] += D[i][j + 1];
	}
	
	rep(q, Q) {
		int a = getint(), b = getint(), c = getint(), d = getint();

		int kotae = B[c][d] - B[c][b - 1] - B[a - 1][d] + B[a - 1][b - 1] - C[c][d] + C[c][b - 1] + C[a][d] - C[a][b - 1] - D[c][d] + D[c][b] + D[a - 1][d] - D[a - 1][b];
		putint(kotae);

	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 54400
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;


int main(){
    int n, w;
    cin >> n >> w;
    vector<int> W(n), V(n);
    for(int i=0;i<n;i++){
        cin >> W[i] >> V[i];
    }
    vector<vector<ll>> dp(n+1, vector<ll> (w+1));

    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            if(j >= W[i]){
                dp[i+1][j] = max(dp[i][j-W[i]]+V[i], dp[i][j]);
            }
            else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int main()
{
	int n,k; cin>>n>>k;
	string s; cin>>s;
	s[k-1] = s[k-1]+'a'-'A';
	cout << s << endl;
	return 0;
}

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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

vector<bool> b(1000010,false);

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    map<int,int> mp;
    sort(a.begin(),a.end(),less<int>());

    rep(i,n){
        if(!b[a[i]]){
            if(mp[a[i]]==0){
                mp[a[i]] = 1;
            }else{
                b[a[i]] = true;
                continue;
            }
            for(int j = 2*a[i]; j < 1000010; j += a[i]){
                b[j] = true;
            }
        }
    }

    int ans = 0;
    rep(i,n){
        if(b[a[i]]==false) ans++;
    }

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

Measured memory_bytes: 14256
#include <stdio.h>
#include <string.h>

int main(void)
{
    char in[10010];
    int n,i,j,len;
    int al;

    scanf("%d", &n);
    scanf("%s", in);
    len = strlen(in);
    for(i=0; i<len; i++){
        al = in[i] - 'A';
        al = (al+n) % 26;
        in[i] = 'A'+ al;
    }
    printf("%s\n", in);
}

Measured memory_bytes: 128
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int r,c,n,t,x,y,ans;
map<int,int> f[N];
set<int> g[N];
struct data{int x,y;
}a[N];
int main()
{
    r=read(),c=read();n=read();ans=r+1;
    for (int i=1;i<=n;i++) a[i].x=read(),a[i].y=read(),f[a[i].x][a[i].y]=1,g[a[i].y].insert(a[i].x);
    for (int i=1;i<=c;i++) g[i].insert(r+1);
    int x=1,y=1;
    for (;x<r;)
    {
        ans=min(ans,*g[y].lower_bound(x));
        x++;if (!f[x][y+1]&&y<c) y++;
    }
    ans=min(ans,*g[y].lower_bound(x));
    cout<<ans-1;
    return 0;
}

Measured memory_bytes: 56064
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()
    alist = intina()

    ans = 0

    for a in alist:
        while a & 1 == 0:
            a >>= 1
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4756
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;
void print_vec(vector<int>& a,int n=-1){
	n = (n==-1 ? a.size():n);
	for(int i=0;i<n;i++)
		cout << a[i] << (i<n-1 ? " ":"\n");
}

void print_vec(vector<long long>& a,int n=-1){
	n=(n==-1 ? a.size():n);
	for(int i=0;i<n;i++)
		cout << a[i] << (i<n-1 ? " ":"\n");
}

inline int win_lose(int a, int b){
	return ((b==0 && a==1) || (b==1 && a==2) || (b==2 && a==0));
}

long long get_max(int n, vector<int>& t, long long r, long long p, long long s){
	// print_vec(t);
	vector<vector<long long>> dp(n,vector<long long>(3,0ll));
	vector<long long> sc{r,p,s};
	dp[0][0]=sc[0]*win_lose(0,t[0]);
	dp[0][1]=sc[1]*win_lose(1,t[0]);
	dp[0][2]=sc[2]*win_lose(2,t[0]);
	long long tmp=0;
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			tmp=0;
			for(int k=0;k<3;k++)
				if(j!=k)
					tmp=max(tmp,dp[i-1][k]);
			dp[i][j]=(sc[j]*win_lose(j,t[i]))+tmp;
		}
	}
	// for(int i=0;i<n;i++){
	// 	print_vec(dp[i]);
	// }
	return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

void solve(){	
	int n,k;
	long long r,s,p;
	string t;
	cin>>n>>k;
	cin>>r>>s>>p;
	cin>>t;
	long long ans=0;
	for(int i=0;i<k;i++){
		vector<int> curr_s;
		for(int j=0;j*k+i<n;j++){
			if(t[j*k+i]=='r')
				curr_s.pb(0);
			if(t[j*k+i]=='p')
				curr_s.pb(1);
			if(t[j*k+i]=='s')
				curr_s.pb(2);
		}
		ans+=get_max(curr_s.size(),curr_s,r,p,s);
	}
	cout<<ans<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 6216
/*
数値の制約が小さいから, 集会を開く座標pを全探索すれば良い
*/

#include <bits/stdc++.h>
using namespace std;


int main(){
    int n;
    cin >> n;
    
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    sort(x.begin(),x.end());
    
    int ans = 1e8 + 7;
    int minIndex = x[0];
    int maxIndex = x[n-1];
    
    for (int p = minIndex; p <= maxIndex; p++){
        
        int cost = 0;
        
        for (int i = 0; i < n; i++){
            cost += (x[i]-p)* (x[i]-p);
        }
        
        ans = min(ans, cost);
    }
    
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
//#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int a[200050];
string b;
signed main(){
    int n;
    cin >> n;
    rep(i,n) cin >> a[i];
    if(n % 2 == 0){ 
        for(int i = n-1;i >= 1;i -= 2){ 
            if(i == n-1) cout << a[i];
            else cout << ' ' << a[i];
        }
        for(int i = 0;i <= n-2;i += 2){ 
            cout << ' ' <<a[i];
        }
    }   
    else{
        for(int i = n-1;i >= 0;i -= 2){ 
            if(i == n-1) cout << a[i];
            else cout << ' ' << a[i];
        }
        for(int i = 1;i <= n-2;i += 2){ 
            cout << ' ' <<a[i];
        }
    }   
    cout << '\n';
    return 0;   
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
string str = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8";
string getstr(char s, char g) {
	int i, j;
	for (i = 0; str[i] != s; i++);
	for (j = i; str[j] != g; j++)if (str[j] == s)i = j;
	return str.substr(i, j - i + 1);
}
signed main() {
	int n; cin >> n;
	while (n--) {
		char a, b; cin >> a >> b;
		cout << getstr(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define M 200005
using namespace std;
int n,A[M];
int B[M];
int ans[M],len;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=n;i;i--){
		int t=0;
		for(int j=i<<1;j<=n;j+=i)t^=B[j];
		B[i]=t^A[i];
		if(B[i])ans[++len]=i;
	}
	sort(ans+1,ans+len+1);
	printf("%d\n",len);
	for(int i=1;i<=len;i++)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 2944