akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a,b;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    k=0;
    l=0;
    for(i=0;i<n-1;i++)
    {
        if(v[i]>=v[i+1])
        {
            l++;
        }
        else
        {
            k=max(l,k);
            l=0;
        }
    }
     k=max(l,k);

    cout<<k<<endl;
}



Measured memory_bytes: 1400
import math

r1, c1, r2, c2 = map(int, input().split())
P = int(1e9+7)
kaizyo = [0]
kaizyo_inv = [0]
tmp = 1
for i in range(1, 2*max(r1, r2, c1, c2)+2):
    tmp = (tmp*i) % P
    kaizyo.append(tmp)
    kaizyo_inv.append(pow(tmp, P - 2, P))


def comb(n, r):
    if n < r or n==0:
        return 0
    elif n == r or r==0:
        return 1
    else:
        return kaizyo[n] * kaizyo_inv[r] * kaizyo_inv[n - r]


def solve_naive(r, c):
    if r < 0 or c < 0:
        return 0
    S = [[0] * (c+1) for _ in range(r+1)]
    for i in range(1, r + 1):
        for j in range(1, c + 1):
            S[i][j] = S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1] + comb(i + j , i)
    return S[-1][-1]


def solve(r, c):
    if r < 0 or c < 0:
        return 0
    ret = 0
    for i in range(2, r + 2):
        ret = (ret + comb(i + c, i)) % P
    return ret


# solve = solve_naive
ans = (solve(r2, c2) - solve(r1 - 1, c2) -
       solve(r2, c1 - 1) + solve(r1 - 1, c1 - 1)) % P
print(ans)


Measured memory_bytes: 213036
import sys

s = sys.stdin.readline().strip()

ans = 0
l = 0
r = len(s) - 1

while l < r:
    # print("left", l, "right", r)
    if s[l] == "x" and s[r] == "x":
        l += 1
        r -= 1
    # rにxを足したとみなし、lを進める
    elif s[l] == "x":
        l += 1
        ans += 1
    # lにxを足したとみなし、rを進める
    elif s[r] == "x":
        r -= 1
        ans += 1
    elif s[l] != s[r]:
        print(-1)
        sys.exit()
    else:
        l += 1
        r -= 1

print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);



using namespace std;



int main()
{
    int n; cin >> n;
    int a[n];
    FOR(i, n, 0)cin >> a[i];
    int lst = a[0], cnt = 0, ans = 0;
    FOR(i, n, 1)
    {
        if(a[i] > lst)
        {
            lst = a[i];
            ans = max(ans, cnt);
            cnt = 0;
        }
        else
        {
            cnt++; lst = a[i];
        }
    }
    ans = max(ans, cnt);
    cout << ans;
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,A,B;
    string S;
    cin >> N>>A>>B>>S;

    ll jyuni = A+B;
    ll kaigai_jyuni = B;
    REP(i, N)
    {
        if(S.at(i)=='c'){
            cout << "No" << endl;
        }
        else if (S.at(i) == 'a'){
            if(jyuni>0){
                cout << "Yes" << endl;
                jyuni--;
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            if(jyuni>0&&kaigai_jyuni>0){
                cout << "Yes" << endl;
                jyuni--;
                kaigai_jyuni--;
            }
            else{
                cout << "No" << endl;
            }
        }
    }
}


Measured memory_bytes: 848
//abc073_b.cpp
//Sat Sep  8 18:26:00 2018

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

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

	int ans = 0;
	for (int i=0;i<n;i++){
		int l,r;
		cin >> l >> r;
		ans += r-l+1;
	}


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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int x,y,z;
   int temp;
   cin >> x >> y >> z;
   if(x > y){
       temp = x;
       x = y;
       y=temp;
   }
   if(x > z){
       temp = x;
       x = z;
       z = temp;
   }
   if(y > z){
       temp = y;
       y = z;
       z = temp;
   }
   cout << x << " " << y << " " << z;
   cout << endl;
}


Measured memory_bytes: 3068
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll = long long;
using plong = pair<long,long>;

int main(){
    string S,T;
    cin>>S>>T;
    long N = S.size();
    long _S[N];
    long _T[N];
    map<char,long> mpS;
    map<char,long> mpT;
    long no=0;
    for(long i=0;i<N;i++){
        if(mpS[S[i]]==0){
            _S[i] = no;
            mpS[S[i]]=no;
            no++;
        }else{
            _S[i] = mpS[S[i]];
        }
    }
    no=0;
    for(long i=0;i<N;i++){
        if(mpT[T[i]]==0){
            _T[i] = no;
            mpT[T[i]]=no;
            no++;
        }else{
            _T[i] = mpT[T[i]];
        }
    }
    bool flag = true;
    for(long i=0;i<N;i++){
        // cout<<_S[i]<<":"<<_T[i]<<endl;
        if(_S[i]!=_T[i])flag = false;
    }
    cout<<(flag?"Yes":"No")<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  for (int i = 0; i < N; ++i)
    cin >> x[i] >> y[i] >> h[i];

  for (int i = 1; i < N; ++i)
    if (h[0] == 0 && h[i] >= 1)
      swap(x[0], x[i]), swap(y[0], y[i]), swap(h[0], h[i]);

  int Cx, Cy, H;
  for (Cx = 0; Cx <= 100; ++Cx) {
    bool flag;
    for (Cy = 0; Cy <= 100; ++Cy) {
      flag = true;
      H = h[0] + abs(x[0] - Cx) + abs(y[0] - Cy);
      for (int i = 1; i < N; ++i)
        if (h[i] != max(H - abs(Cx - x[i]) - abs(Cy - y[i]), 0))
          flag = false;

      if (flag)
        break;
    }

    if (flag)
      break;
  }

  cout << Cx << ' ' << Cy << ' ' << H << endl;
}

Measured memory_bytes: 256
N = int(input())
a = [input() for i in range(N)]

if len(a) != len(set(a)):
    print("No")
else:
    for i in range(N-1):
        aa = a[i]
        bb = a[i+1]
        if aa[-1] != bb[0]:
            print("No")
            break
    else:
        print("Yes")

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;
double a;
int n;
int main()
{
    cin>>n;
    printf("%.6lf\n",(n&1)?(((double)(n/2+1))/n):(((double)(n/2))/n));
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if(a*(x[i]-x[i-1]) > b) ans += b;
        else ans += a*(x[i]-x[i-1]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
require 'pp'

s = gets.chomp!.chars.group_by.with_index(1) {|x, i| i % 2 }

if s[0] == nil
    if s[1] == ['R'] || s[1] == ['U'] || s[1] == ['D']
        puts "Yes"
    else
        puts "No"
    end
else
    if [
        s[1].all?{|x| x == 'R' || x == 'U' || x == "D" },
        s[0].all?{|x| x == 'L' || x == 'U' || x == "D" },
    ].all?
        puts "Yes"
    else
        puts "No"
    end

end


Measured memory_bytes: 2044
class Main{

	public static void main (String[] args) {

		Main main = new Main();

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int temp = sc.nextInt();

		if (temp>=30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();;

	}

}


Measured memory_bytes: 35728
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n,p=0;
	double r=0,m=-0.1,c;
	int x[1024],y[1024];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&y[i]);
	}
	for(p=1;p<=3;p++){
		for(int i=0;i<n;i++){
			r+=fabs(pow((double)(x[i]-y[i]),p));
		}
		r=pow(r,(1.0/(double)p));
		printf("%8lf\n",r);
		r=0;
	}
	for(int i=0;i<n;i++){
		c=fabs((double)(x[i]-y[i]));
		if(c>=m){
			m=c;
		}
	}
	printf("%8lf\n",m);
	return 0;
}

Measured memory_bytes: 2952
using System;
using System.Linq;
public class Global{
    public static long a = long.Parse(Console.ReadLine());
    public static int ans = 0;
}

class program{
  static void Main(){
	divgame(2);
    divgame(3);
    divgame(5);
    for(int i=0;i<=Math.Sqrt(Global.a);i+=30){
      divgame(7+i);
      divgame(11+i);
      divgame(13+i);
      divgame(17+i);
      divgame(19+i);
      divgame(23+i);
      divgame(29+i);
      divgame(31+i);
    }
    if(Global.a != 1) Global.ans++;
    Console.Write(Global.ans);
  }
  
  static void divgame(long div){
    int meta = 0,ct = 0;
    while(Global.a%div == 0){
      Global.a/=div;
      ct++;
      if(ct > meta){
        meta++;
        Global.ans++;
        ct=0;
      }
    }
    return;
  }
}

Measured memory_bytes: 27520
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S, T, U;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	cin >> U;

	if (S == U) A--;
	else B--;

	cosp(A);
	co(B);



	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define mkp make_pair
typedef pair<ll,ll> P;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
 } 

Measured memory_bytes: 256
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))

n=int(input())
B=[]
for i in range(n):
    b=int(input())
    B.append(b)
for i in range(3):
    if A1[i] in B:
        A1.remove(A1[i])
        A1.insert(i,1)
    else:
        A1.remove(A1[i])
        A1.insert(i,0)
for i in range(3):
    if A2[i] in B:
        A2.remove(A2[i])
        A2.insert(i,1)
    else:
        A2.remove(A2[i])
        A2.insert(i,0)
for i in range(3):
    if A3[i] in B:
        A3.remove(A3[i])
        A3.insert(i,1)
    else:
        A3.remove(A3[i])
        A3.insert(i,0)
A=[A1,A2,A3]
if A1[0]==A1[1]==A1[2]==1 or A2[0]==A2[1]==A2[2]==1 or \
A3[0]==A3[1]==A3[2]==1 or A1[0]==A2[0]==A3[0]==1 or A1[1]==A2[1]==A3[1]==1 or \
A1[2]==A2[2]==A3[2]==1 or A1[0]==A2[1]==A3[2]==1 or A1[2]==A2[1]==A3[0]==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
const int MOD = 1000000007;

int N;
int vs[25][25];

int memo[1<<21];
int solve(int pat, int idx) {
  int &res = memo[pat];
  if(res < 0) {
    if(idx == N) {
      res = 1;
    } else {
      res = 0;
      REP(j, N) {
        if(pat & (1 << j)) {
          if(vs[idx][j]) {
            res = (res + solve(pat ^ (1 << j), idx+1)) % MOD;
          }
        }
      }
    }
  }
  return res;
}

int main(void) {
  scanf("%d", &N);
  REP(i, N) REP(j, N) {
    scanf("%d", &vs[i][j]);
  }
  memset(memo, -1, sizeof memo);
  int res = solve((1 << N)-1, 0);
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int d[11];

signed main(){
  int n,k;
  cin>>n>>k;
  set<int> s;
  for(int i=0; i<k; i++){
    cin>>d[i];
    s.insert(d[i]);
  }
  
  
  bool ok=false;
  
  int ret=n;
  while(!ok){
    string str=to_string(ret);
    ok=true;
    for(int i=0; i<str.size(); i++){
      if(s.find(str[i]-'0')!=s.end()){
        ok=false;
        break;
      }
    }
    if(!ok) ret++;
    else{
      cout<<ret<<en;
      RE;
    }
  }
  
}

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

using namespace std;

int main()
{
	string str, command, sub, head, end;
	string orders;
	int numOfComs, a, b;

	cin>>str;
	cin>>numOfComs;
	cin.ignore();
	
	for(int i=0;i<numOfComs;i++){
		getline(cin, orders);
		istringstream ss(orders);
		for(int j=0;j<3;j++){
			switch(j){
			case 0:
				getline(ss, command, ' ');
				break;
			case 1:
				getline(ss, head, ' ');
				break;
			case 2:
				getline(ss, end, ' ');
				break;
			default:
				break;
			}
		}
		istringstream first(head);
		first>>a;
		istringstream last(end);
		last>>b;
		
		if(command=="replace"){
			getline(ss, sub, ' ');
			str.replace(a,b-a+1,sub);
		}else if(command=="print"){
			cout<<str.substr(a,b-a+1)<<endl;
		}else{
			string reversed="";
			for(int j=b;j>=a;j--){
				reversed+=str.at(j);
			}
			str.replace(a,b-a+1,reversed);
		}
	}
	
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main()
{

	string S;

	cin >> S;

	for (int ci = 0; ci < S.size(); ci++) {
		if (S[ci] == '1') {
			S[ci] = '9';
		}else if (S[ci] == '9'){
			S[ci] = '1';
		}
	}

	cout << S;

	return 0;
}



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

#define endl '\n'

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

    int n; cin >> n;
    set<string> y;
    for (int i=0; i<n; i++){
        string s; cin >> s;
        y.insert(s);
    }
    cout << y.size() << endl;
}

Measured memory_bytes: 19180
#include<stdio.h>
#include<math.h>
int main()
{
	int a;
	int i,j[101];
	j[0]=1;
	while (scanf("%d",&a)!=EOF)
	{
		int b=0;
		for (i=1;i<=a;i++)
		{
            j[i]=pow(2,i);
			if (j[i]>a)
			{
				b=j[i-1];
				break;
			}
		}
		printf("%d\n",b);
	
	}
	return 0;

}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
int CB(int *x,int K){
  if(abs(*x)<abs(K-*x)){
    return 2*abs(*x);
  }else{
    return 2*abs(K-*x);
  }
}

int main(){
  int N,K;
  scanf("%d%d",&N,&K);
  int i;
  int x[101];
  for(i=0;i<N;i++){
    scanf("%d",&x[i]);
  }
  int count=0;
  for(i=0;i<N;i++){
    count+=CB(&x[i],K);
    //printf("%d\n",count);
  }
  printf("%d",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=5000000000000000000;
ll MOD=1000000007;


int main() {
    string s;
    cin >> s;
    if (s.at(0)==s.at(s.size()-1) && s.size()%2==0) cout << "First" << endl;
    else if (s.at(0)!=s.at(s.size()-1) && s.size()%2==1)  cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct data{
  int key;
  struct data *right,*left,*parent;
};

struct data *root,*NIL;

void insert(int k){
  struct data *y = NIL;
  struct data *x = root;
  struct data *z;

  z = (struct data *)malloc(sizeof(struct data));
z -> key = k;
z -> left = NIL;
z -> right = NIL;

while(x != NIL){
  y = x;
  if(z -> key < x -> key){
    x = x -> left;
  }
  else{
    x = x -> right;
  }
}

z -> parent = y;
if(y == NIL){
  root = z;
}
else{
  if(z -> key < y -> key){
    y -> left = z;
  }
  else{
    y -> right = z;
  }
}
}

void inorder(struct data *cin){
  if(cin == NIL){
    return;
  }
  inorder(cin -> left);
  printf(" %d",cin -> key);
  inorder(cin -> right);
}
void preorder(struct data *cin){
  if(cin == NIL){
    return;
  }
  printf(" %d",cin -> key);
  preorder(cin -> left);
  preorder(cin -> right);
}

int main(){
  int n,i,x;
  char mozi[1000];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%s",mozi);
    if(strcmp(mozi,"insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(mozi,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int h, w;
    cin >> h >> w;
    vector<int> cnt(26);
    rep(i,h){
        string s;
        cin >> s;
        rep(j, s.size()) cnt[s[j]-'a']++;
    }

    int g1 = (h % 2) * (w % 2);
    int g2 = (h % 2) * (w / 2) + (w % 2) * (h / 2);
    int g4 = (h * w - 2 * g2 - g1) / 4;

    int i = 0;
    while(i < 26){
        if (cnt[i] % 4 == 1 || cnt[i] % 4 == 3){
            if (g1 == 0) break;
            cnt[i]--;
            g1--;
        }
        i++;
    }

    i = 0;
    while(i < 26){
        while(cnt[i] >= 4){
            if (g4 == 0) break;
            cnt[i] -= 4;
            g4--;
        }
        i++;
    }

    i = 0;
    while(i < 26){
        while(cnt[i] >= 2){
            if (g2 == 0) break;
            cnt[i] -= 2;
            g2--;
        }
        i++;
    }

    rep(i, 26){
        if (cnt[i] != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3636
# include <iostream>
# include <string>
const int MAX = 2e5 + 2;
using namespace std;



int main() {
    string S;
    cin >> S;
    int L = S.length();

    long long Bcnt = 0;
    long long ans = 0;
    for (int i = 0; i < L; i++) {
        if (S[i] == 'B') {
            Bcnt += 1;
        } else {
            ans += Bcnt;
        }
    }

    cout << ans << endl;
}

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

void solve () {
    string s;
    cin >> s;
    stack<char> t;
    long long ans = 0;
    char x = '0';
    for (int i = 0; i < (int) s.size(); i++) {
        if(t.empty()) {
            if (s[i] == '0') {
                x = '1';
            } else {
                x = '0';
            }
        }
        if (s[i] == x) {
            if (!t.empty()) {
                t.pop();
                ans++;
            }
        } else {
            t.push(s[i]);
        }
    }
    cout << ans * 2ll;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


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

int main(){
  string s;
  bool ans=false;
  cin >> s;
  for(char c : s)if(c=='7')ans=true;
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
a, b, c, x = 4.times.map { gets.to_i }
count = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      if 500 * i + 100 * j + 50 * k == x
        count += 1
      end
    end
  end
end

p count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
int main()
{
	int n;
	cin>>n;
	int a[n+10];
	int mx=INT_MIN,mi=INT_MAX;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mx=max(mx,a[i]);
		mi=min(mi,a[i]);
	}
	//cout<<mx<<endl;
	int re=INT_MAX;
	for(int i=mi;i<=mx;i++)
	{
		int qw=0;
		for(int j=0;j<n;j++)
		{
			int q=abs(i-a[j]);
			int w=q*q;
			qw+=w;
		}
		re=min(re,qw);
	}
	cout<<re<<endl;
}

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

const int mx = 100005;
vector<int>adj[mx],block[mx];
int vis[mx],ans[mx];
set<int>st;
void dfs(int u)
{
    vis[u] = 1;
    st.insert(u);
    for(auto v:adj[u])
    {
        if(vis[v]==0)
        {
            dfs(v);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n,m,k; cin >> n >> m >> k;
    for(int i=1; i<=m; i++)
    {
        int u,v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for(int i=1; i<=k; i++)
    {
        int u,v; cin >> u >> v;
        block[u].push_back(v);
        block[v].push_back(u);
    }

    for(int i=1; i<=n; i++)
    {
        if(vis[i]==0)
        {
            st.clear();
            dfs(i);
            int sz = st.size();
            for(auto x:st)
            {
                ans[x] = sz - 1 - adj[x].size();
                for(auto u : block[x])
                {
                    if(st.find(u)!=st.end())
                        ans[x]--;
                }
            }
        }
    }
    cout << ans[1];
    for(int i=2; i<=n; i++)cout << " " << ans[i];cout<<"\n";
    return 0;
}


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

int n;

int c(int i, int j);
int main()
{
	cin >> n;
	int ans = 100;
	int k;
	for (int i = 1; i < n / 2 + 1; i++) {
		k=c(i, n - i);
		if (k < ans)ans = k;
	}
	cout << ans<<endl;
	return 0;
}
int c(int i, int j) {
int f=0;
	while (1) {
		if (i == 0)break;
		f += i % 10;
		i = i / 10;
	}
	while (1) {
		if (j == 0)break;
		f += j % 10;
		j = j / 10;
	}
	return f;
}


Measured memory_bytes: 256
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<set>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#define mp make_pair
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}
void outc(ll x)
{
    if (x<0){
        putchar('-');
        out(-x);
    }else out(x);
    putchar(32);
}
void outn(ll x)
{
    if (x<0){
        putchar('-');
        out(-x);
    }else out(x);
    putchar(10);
}
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
//const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};

int gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll quickpow(ll x, int k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}
//ll C(int n, int m){return (fac[n] * quickpow((fac[m] * fac[n - m]) % mod, mod - 2)) % mod;}
//Unaccepted
const int maxn = 1e5 + 10;
int dp[100005];
vector<int> vi;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        int x;
        cin >> x;
        vi.emplace_back(x);
    }
    reverse(vi.begin(), vi.end());
    memset(dp, 0x3f, sizeof(dp));
    for (int x : vi){
        *upper_bound(dp, dp + n, x) = x;
    }
    cout << lower_bound(dp, dp + n, 0x3f3f3f3f) - dp << endl;
	return 0;
}








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

using namespace std;

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

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

    return gcd(b, a%b);
}

const ll L = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    string s;
    cin >> s;

    if(s[0]==s[1])
    {
        if(s[0]!=s[2] && s[2]==s[3])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    else if(s[0] == s[2])
    {
        if(s[0]!=s[1] && s[1]==s[3])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    else if(s[0] == s[3])
    {
        if(s[0]!=s[1] && s[1]==s[2])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

int require(char input) {
    vector<int> match = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    return match[(input - 48) - 1];
}

string comparison(string a, string b) {
    if (a.length() < b.length()) {
        return b;
    } else if (a.length() == b.length()) {
        if (a > b) {
            return a;
        } else {
            return b;
        }
    } else {
        return a;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<string> dp(N + 100, "");
    vector<char> A(M);
    sort(A.begin(), A.end());
    for (int i = 0; i < M; ++i) {
        cin >> A[i];
        dp[require(A[i])] = max(dp[require(A[i])][0], A[i]);
    }
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j < M; ++j) {
            if (i >= require(A[j]) && !dp[i - require(A[j])].empty()) {
                dp[i] = comparison(dp[i], dp[i - require(A[j])] + A[j]);
            }
        }
    }
    /* for (int i = 0; i < N + 1; ++i) {
        cout << i << " " << dp[i] << endl;
    } */
    cout << dp[N] << endl;
}

Measured memory_bytes: 41600
#include <bits/stdc++.h>
#include <stdio.h>
#define rep(i,n) for(int i=(0); (i)<(n); (i)++)
using namespace std;
int d;
double isInt(int a[10],int b[10]){
    int n=0;
    float sq;
    rep(i,d){
        n+=(a[i]-b[i])*(a[i]-b[i]);
    }
    sq=sqrt(n);
    //printf(" %d\n",n==((int)sq)*((int)sq));
    return n==((int)sq)*((int)sq);
}
int main(){
    int n,cnt=0;
    cin>>n>>d;
    int x[10][10];
    rep(i,n){
        rep(j,d)
            cin>>x[i][j];
    }
    rep(i,n-1){
        for(int j=i+1; j<n; j++){
            //printf("%d %d",i,j);
            if(isInt(x[i],x[j])){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  int x, ans=0;
  cin >> x;
  ans += x / 500 * 1000;
  x %= 500;
  ans += x / 5 * 5;
  cout << ans;
}

Measured memory_bytes: 3544
#include <iostream>
using i64 = long long;

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

    if (n % 2 == 0 || n % 5 == 0) {
        std::cout << -1 << std::endl;
        return 0;
    }

    int a = 7 % n;
    for (int i = 1; ; i++) {
        if (a == 0) {
            std::cout << i << std::endl;
            return 0;
        }
        a = (a * 10 + 7) % n;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  double N;
  string S;
  
  cin >> N;
  cin >> S;
  
  double T=0;
  
  for(int i=0; i<N/2; i++){
    
    if(S[i]==S[N/2+i]){
      T++;
    }
    
    else{
      T+=0; 
    }
    
  }
  
  if(T==N/2){
    cout << "Yes" << endl;
  }
    
  else{
    cout << "No" <<endl;
  }
    
  
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int h[100010];

bool do_judge(long long n, int A, int B, int N){
        int ans;
        long long sum;
        sum =0;
        for(int i=0; i<N; i++){
                int a;
                if((h[i]-n*B) % (A-B) == 0){
                        ans = (h[i] - n*B) / (A-B);
                }else{
                        ans = (h[i] - n*B) / (A-B) + 1;
                }
                if((h[i]-n*B)<0){
                        ans = 0;
                }
                //cout<<"ans="<<ans<<endl;
                sum += ans;
        }
        //cout<<"sum="<<sum<<endl;
        if(sum>n)
                return false;
        else
                return true;
}


int main(){
        int N, A, B;
        cin>>N>>A>>B;
        for(int i=0;i<N;i++){
                cin>>h[i];
        }
        long long left=1;
        long long right=1000000010;
        long long mid;
        int min=1000000010;
        while(left<=right){
                mid = (left + right) / 2;
                //cout<<"left="<<left<<"rigth="<<right<<endl;
                if(do_judge(mid,A,B,N)){
                        if(min>mid){
                                min = mid;
                        }
                        right = mid - 1;
                }else{
                        left = mid+1;
                }
        }
        cout<<min<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;

class Main
{
    public static void main (String[] args)
    {
      int a[] = new int[10];

      Scanner cin = new Scanner(System.in);
      for (int i = 0;i < 10; i++) {
        a[i] = cin.nextInt();
      }
      Arrays.sort(a);

      for (int i = 9; i > 6; i--){
        System.out.println(a[i]);
      }
    }
}

Measured memory_bytes: 26136
def read_input():
    n, m = map(int, input().split())

    edges = []
    nodes = list(range(1, n + 1))

    for i in range(m):
        a, b = map(int, input().split())
        edges.append((a, b))


    edges_dic = {}
    for i in range(n):
        edges_dic[i + 1] = []

    for edge in edges:
        edges_dic[edge[0]].append(edge[1])
        edges_dic[edge[1]].append(edge[0])

    return n, m, nodes, edges_dic


# throughを通過済みとして、curr_nodeから残りのnodesにたどり着けるかチェックする
def check_path(curr_node, rest_nodes, edges_dic, through):
    # 終点
    if not rest_nodes:
        return 1

    # rest_nodesのうち、curr_nodeからいけるnodeがあるか確認する
    next_nodes = edges_dic[curr_node]
    targets = []
    for n in next_nodes:
        if n in rest_nodes:
            targets.append(n)

    # restがあるにもかかわらず、次にいけるnodeがない
    if not targets:
        return 0

    # いけるnodeがあれば、その先をチェックする
    count = 0
    for t in targets:
        new_rest = [r for r in rest_nodes if r != t]
        new_through = through + [curr_node]
        count += check_path(t, new_rest, edges_dic, new_through)

    return count


def submit():
    n, m, nodes, edges_dic = read_input()

    rest_nodes = [r for r in nodes if r != 1]
    paths = check_path(1, rest_nodes, edges_dic, [])
    print(paths)


if __name__ == '__main__':
    submit()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;
 
/* --------------------------------------------------- */
 
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n), ans(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 1; i < n; i += 2) {
        sum -= 2 * a[i];
    }
    ans[0] = sum;
    rep(i, n - 1) {
        ans[i + 1] = 2 * a[i] - ans[i];
    }
    
    rep(i, n) {
        if(i != n - 1) cout << ans[i] << " " ;
        else cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 1..r                                       # 変数 i を1からrまで増やして繰り返し処理する。
    
a= gets.split.map(&:to_i)
    for j in 1..c                                   # 変数 i を1からcまで増やして繰り返し処理する。
    h[i-1][j-1] = a[j-1]
    h[i-1][c] += a[j-1]
    h[r][j-1] += a[j-1]
    h[r][c] += a[j-1]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end



Measured memory_bytes: 7028
#!/usr/bin/env python3

import sys
import numpy as np


def main():
    n, k = map(int, sys.stdin.buffer.readline().split())

    warps = list(map(int, sys.stdin.buffer.readline().split()))
    warps = [0] + warps
    warps = np.array(warps, dtype=int)

    dp = np.zeros((k.bit_length() + 1, n + 1), dtype=int)

    dp[0, :] = warps

    for h in range(1, len(dp)):
        dp[h] = dp[h - 1][dp[h - 1]]

    node = 1
    # for i in reversed(range(k.bit_length())):
    for i in range(k.bit_length(), -1, -1):
        if k >> i & 1:
            node = dp[i][node]

    print(node)


main()



Measured memory_bytes: 126980
n = int(input())
A = map(int, input().split())
A = sorted(A)
maxa = max(A)

from bisect import bisect_left
m = (maxa+1)//2
l2 = bisect_left(A, m)

if abs(A[l2] - m) >= abs(A[l2-1] - m):
    print(maxa, A[l2-1])
else:
    print(maxa, A[l2])



Measured memory_bytes: 14428
#include <iostream>
#include <string>

using namespace std;

string func(char a[10][10], int s, int t)
{
	if(s+1 < 8 && t+1 < 8){
		if(a[s][t+1]=='1' && a[s+1][t+1]=='1' && a[s+1][t]=='1'){
			return "A";
		}
	}
	if(s+3 < 8){
		if(a[s+1][t]=='1' && a[s+2][t]=='1' && a[s+3][t]=='1'){
			return "B";
		}
	}
	if(t+3 < 8){
		if(a[s][t+1]=='1' && a[s][t+2]=='1' && a[s][t+3]=='1'){
			return "C";
		}
	}
	if(s+2 < 8 && t-1 >= 0){
		if(a[s+1][t]=='1' && a[s+1][t-1]=='1' && a[s+2][t-1]=='1'){
			return "D";
		}
	}
	if(s+1 < 8 && t+2 < 8){
		if(a[s][t+1]=='1' && a[s+1][t+1]=='1' && a[s+1][t+2]=='1'){
			return "E";
		}
	}
	if(s+2 < 8 && t+1 < 8){
		if(a[s+1][t]=='1' && a[s+1][t+1]=='1' && a[s+2][t+1]=='1'){
			return "F";
		}
	}
	
	return "G";
}

int main()
{
	char a[10][10];
	
	while(cin >> a[0]){
		for(int i = 1; i < 8; i++){
			cin >> a[i];
		}
		bool f = false;
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(a[i][j] == '1'){
					cout << func(a, i, j) << endl;
					f = true;
					break;
				}
			}
			if(f){
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
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 main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  for(ll i = 0; i < s.size(); i++){
    if(s[i] == ',') s[i] = ' ';
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const ll mod=1000000007;
ll dp[210][210][210];
char c[210];

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> c[i];
	dp[0][0][0]=1LL;
	rep(i,n)rep(x,n+1)rep(y,n+1){
		if(dp[i][x][y]==0) continue;
		switch(c[i]){
			case 'U':
				dp[i+1][x][y]+=dp[i][x][y]*x;
				dp[i+1][x][y]%=mod;
				dp[i+1][x+1][y+1]+=dp[i][x][y];
				dp[i+1][x+1][y+1]%=mod;
				break;
			case '-':
				dp[i+1][x][y]+=dp[i][x][y];
				dp[i+1][x][y]%=mod;
				break;
			case 'D':
				dp[i+1][x][y]+=dp[i][x][y]*y;
				dp[i+1][x][y]%=mod;
				if(x-1>=0&&y-1>=0){
					dp[i+1][x-1][y-1]+=dp[i][x][y]*x*y;
					dp[i+1][x-1][y-1]%=mod;
				}
				break;
		}
	}
	cout << dp[n][0][0] << endl;
	return 0;
}

Measured memory_bytes: 68776
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

int main()
{
	speed;
	
	ll a;
	cin>>a;
	ll ans=0,cnt;
	for(ll i=1;i<=a;i+=2)
	{
		cnt=0;
		for(ll j=1;j<=i;j+=2){
			if(i%j==0)
			{
				cnt++;
			}
		}
		if(cnt==8)
		{
			ans++;
		}
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    let mut k = 0;
    for a in A {
        let mut a = a;
        while a % 2 == 0 {
            k += 1;
            a /= 2;
        }
    }

    println!("{}", k);
    return;
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n, c; cin >> n >> c; n++;
	VI p(c); rep(i, c)cin >> p[i];
	Cout((accumulate(all(p), 0) + n - 1) / n);
}


Measured memory_bytes: 3108
#include <stdio.h>

int main() {
  int N;
  char S[10002];
  scanf("%d %s", &N, S);

  for(int i = 0; S[i] != '\0'; i++) {
    S[i] = 'A' + (S[i] - 'A' + N) % 26;
  }

  printf("%s\n", S);

  return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e3+7;
char maz[N][N];
ll vis[N][N],dis[N][N];

int main()
{
    FAST
    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
       ll n,m,tar;
       cin>>n>>m>>tar;
       map<ll,ll>mp,mp1,mp2;
       vector<pair<ll,ll> >v;
       for(i=0; i<tar; i++)
       {
           ll r,c;
           cin>>r>>c;
           v.pb({r,c});
           mp[r]++;
           mp1[c]++;
           mp2[c]++;
       }
       sort(v.begin(),v.end());
       multiset<ll>s;
       for(auto it: mp1)
        s.insert(it.second);

        set<ll>s1;
        ll ans=0;
       for(i=0; i<tar; i++)
       {
           ll fir=v[i].first;
           ll cnt=mp[fir];
           s1.clear();
            /*if(cnt==4)
           {
               for(auto it: s)
                cout<<it<<"\n";
               cout<<"\n";
           }*/
           for(j=i; j<i+cnt; j++)
           {
               ll val=mp1[v[j].second];
               mp1[v[j].second]--;

               s.erase(s.find(val));
               s.insert(val-1);
               s1.insert(v[j].second);
           }
           //cout<<s.size()<<"\n";
           ll cnt2=*s.rbegin();


           //cout<<"\n";
           ans=max(ans,cnt+cnt2);
           //cout<<cnt<<" "<<cnt2<<"\n";
           for(auto it : s1)
           {
               ll val=mp1[it];
               s.erase(s.find(val));
               mp1[it]=mp2[it];
               s.insert(mp1[it]);
           }
           i=i+cnt-1;
           //cout<<ans<<"\n";
       }

       cout<<ans;



    }
    return 0;
}





Measured memory_bytes: 78248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
int N;
vector<int> compress(int *x1, int *x2) {
    vector<int> res;
    rep(i, N) {
        res.push_back(x1[i]);
        res.push_back(x2[i]);
    }
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    rep(i, N) {
        x1[i] = find(all(res), x1[i]) - res.begin();
        x2[i] = find(all(res), x2[i]) - res.begin();
    }
    return res;
}
signed main(void) {
    cin >> N;
    int X1[N], X2[N], Y1[N], Y2[N];
    rep(i, N) cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
    vector<int> X = compress(X1, X2);
    vector<int> Y = compress(Y1, Y2);
    vector<vector<int>> R(4010, vector<int>(4010, 0));
    rep(i, N) {
        int x0 = X1[i], x1 = X2[i], y0 = Y1[i], y1 = Y2[i];
        R[x0][y0]++;
        R[x1][y0]--;
        R[x0][y1]--;
        R[x1][y1]++;
    }
    rep(i, 4009) {
        rep(j, 4009) R[i + 1][j] += R[i][j];
    }
    rep(j, 4009) {
        rep(i, 4009) R[i][j + 1] += R[i][j];
    }
    int ans = 0;
    rep(i, 4009) rep(j, 4009) {
        if(R[i][j] > 0) {
            ans += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 128816
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import deque

n, k = map(int, input().split())
a = list(map(int, input().split()))
count = [0] * (n + 1)
for v in a:
    count[v] += 1
count = deque(sorted(v for v in count if v != 0))
kind = len(count)
ans = 0
while kind > k:
    v = count.popleft()
    kind -= 1
    ans += v
print(ans)

Measured memory_bytes: 101112
#include<stdio.h>
#include<math.h>
int main(){
 int a,b,c,d,e,f,det;
 double x,y;
 while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)!=EOF){
  det=a*e-b*d;
  x=(double)(e*c-b*f)/det;
  y=(double)(-d*c+a*f)/det;
  printf("%.3f %.3f\n",x==0?fabs(x):x,y==0?fabs(y):y);
 }
 return 0;
}

Measured memory_bytes: 636