akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    int tmp = min(x, y) / 2 * 2;
    ans += tmp * min(a + b, c * 2);
    x -= tmp;
    y -= tmp;

    int add;
    if (x < y) {
        add = 2*c*y;
        add = min(add, x*a+y*b);
        if (x == 1) add = min(add, 2*c+(y-1)*b);
    } 
    else if (x > y){
        add = 2*c*x;
        add = min(add, x*a+y*b);
        if (y == 1) add = min(add, 2*c+(x-1)*a);
    }
    else {
        add = min(a * x + b * y, 2*c);
    }
    ans += add;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main (){
 
  char S[105];
  int K = 0;
 
  scanf("%d", &K);
  scanf("%s", S);
 
  int len = 0;
  len = strlen( S );
 
  char SS[105];
  if( len <= K ){
    printf("%s \n", S);
  }
  else{
    strncpy( SS, S, K );
    SS[K] = '\x0';
    printf("%s", SS);
    printf("... \n");
  }
 
  return 0;
}

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

class UnionFind {
    public:
        UnionFind(){}
        explicit UnionFind(int size){
            mPar.resize(size);
            mRnk.assign(size,0);
            for(int i = 0; i < size; ++i) mPar[i] = i;
        }

        int find(int x){
            if(mPar[x]==x) return x;
            return mPar[x] = find(mPar[x]);
        }

        bool same(int x, int y){
            return find(x) == find(y);
        }

        void unite(int x, int y){
            x = find(x);
            y = find(y);
            if(x==y) return;
            if(mRnk[x] < mRnk[y]) swap(x,y);
            mPar[y] = x;
            if(mRnk[x]==mRnk[y]) ++mRnk[x];
        }
    private:
        vector<int> mPar,mRnk;
};

struct Edge{
    int from,to,cost;
    Edge(int f,int t,int c) : from(f), to(t), cost(c){}
    bool operator<(const Edge &e) const {return cost < e.cost;}
};

using Edges = vector<Edge>;

class MinimumSpanningTree {
    public:
        MinimumSpanningTree(){}
        explicit MinimumSpanningTree(int V){
            mUF = UnionFind(V);
        }

        int kruskal(Edges &es){
            int min_cost = 0;
            sort(es.begin(),es.end());
            for(auto e : es){
                if(!mUF.same(e.from,e.to)){
                    mUF.unite(e.from,e.to);
                    min_cost += e.cost;
                }
            }
            return min_cost;
        }
    private:
        class UnionFind mUF;
};

int main(){
    int V,E,s,t,w;
    cin >> V >> E;
    Edges es;
    for(int i = 0;i < E; ++i){
        cin >> s >> t >> w;
        es.emplace_back(s,t,w);
    }
    MinimumSpanningTree mst(V);
    cout << mst.kruskal(es) << '\n';
    return 0;
}


Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }

lint tos(lint n, lint X, lint D)
{
    return X * n + D * n * (n - 1) / 2;
}

int main()
{
    lint N, X, D;
    cin >> N >> X >> D;
    if (!D)
    {
        cout << (X != 0) * N + 1 << endl;
        return 0;
    }

    if (D < 0) {
        X += D * (N - 1);
        D *= -1;
    }

    int g = (X != 0 ? __gcd(abs(X), D) : D);
    X /= g, D /= g;

    vector<vector<plint>> Q(min(N + 1, D));
    REP(i, N + 1) Q[i % D].emplace_back(tos(i, X, D), tos(i, X + D * (N - 1), -D));

    lint ret = 0;
    for (auto &vec : Q) if (vec.size()) {
        sort(ALL(vec));
        lint h = vec[0].first - D;
        for (auto x : vec) {
            mmax(h, x.first - D);
            ret += max((x.second - h) / D, 0LL);
            mmax(h, x.second);
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 11136
K = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;
int main(void){
	char s[3],ans[3];
	int a;
	for(a=0;a<3;a++){
		s[a]='\0';
		ans[a]='\0';
	}
	ans[0]='A';
	while(cin >> s){
		if(ans[0]==s[0])ans[0]=s[2];
		else if(ans[0]==s[2])ans[0]=s[0];
	}
	cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
int n;
int cnt(int x){
	int res=0;
	while(x){
		res+=x%10;
		x/=10;
	}
	return res;
}
int main(){
	SF("%d",&n);
	int ans=cnt(1)+cnt(n-1);
	for(int i=2;i<n;i++){
		ans=min(ans,cnt(i)+cnt(n-i));
	}
	PF("%d",ans);
}

Measured memory_bytes: 128
object Main extends App {
  val sc = new java.util.Scanner(System.in)

  val t = sc.next
  val p = sc.next

  def loop(i:Int): Unit = {
    val res = t.indexOf(p, i)
    if (res >= 0) {
      println(res)
      loop(res + 1)
    }
  }
  loop(0)
}



Measured memory_bytes: 45048
#include <iostream>
#include <string>
#include <map>
#include <set>

using namespace std;

int main()
{
    map<string, set<int> > m;
    string inp;
    int num;

    while (cin >> inp >> num) 
        m[inp].insert(num);

    map<string, set<int> >::iterator it = m.begin();
    while (it != m.end()) {
        cout << (*it).first << endl;
        set<int>::iterator it_in;
        for (it_in = (*it).second.begin(); it_in != (*it).second.end(); it_in++) {
            if(it_in != (*it).second.begin())
                cout << " ";
            cout << *it_in;
        }
        cout << endl;
        it++;
    }

    return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;


int main(){
  int H, W;
  cin >> H >> W;
  char ch[H][W];
  char ans[H][W];
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> ch[i][j];
    }
  }
  

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(ch[i][j]=='#') ans[i][j]=ch[i][j];
      else{
        int count = 0;
        for(int k=-1;k<=1;k++){
          for(int l=-1;l<=1;l++){
            if(0<=i+k && i+k<H && 0<=j+l && j+l <W){
              if(ch[i+k][j+l]=='#') count++;
            }
          }
        }
        ans[i][j] = '0' + count;
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << ans[i][j];
    }
    cout <<endl;
  }

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

mn = 10**9+1 # 数列Aの最小値
mx = 0       # 数列Aの最大値

for v in A:
  if v < mn:
    mn = v   # 最小値を更新
  if v > mx:
    mx = v   # 最大値を更新

print(mx-mn)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define f first
#define s second

#define MAX_N 21
#define MAX_M 31

int main(){
  int n, m, tmp;
  pair<int, string> chara[MAX_N];
  int point[MAX_M];
  
  while(cin >> n, n){
    vector<int> d[MAX_N]; 
    memset(point, 0, sizeof(point));
    for(int i = 0 ; i < n ; i++){
      chara[i].f = 0;
      cin >> chara[i].s >> m;
      for(int j = 0 ; j < m ; j++){
	cin >> tmp;
	d[i].push_back(tmp);
	point[tmp]++;
      }
    }
    
    for(int i = 0 ; i < MAX_M ; i++){
      if(point[i] == 0) continue;
      if(point[i] == n){
	for(int j = 0 ; j < n ; j++) chara[j].f++;
      }
      else if(point[i] == 1){
	for(int j = 0 ; j < n ; j++){
	  for(int k = 0 ; k < d[j].size() ; k++){
	    if(d[j][k] == i) chara[j].f += n;
	  }
	}
      }
      else{
	for(int j = 0 ; j < n ; j++){
	  for(int k = 0 ; k < d[j].size() ; k++){
	    if(d[j][k] == i) chara[j].f += n - point[i]+1;
	  }
	}
      }
    }
    sort(chara, chara+n);
    cout << chara[0].f << ' ' << chara[0].s << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
int x[3], y[3];
double dist(int a, int b){
	return sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
}
int main(){
	for(int i = 0; i < 3; i++) cin >> x[i] >> y[i];
	double a = dist(0, 1);
	double b = dist(1, 2);
	double c = dist(2, 0);
	double r = (x[0] * y[1] - y[0] * x[1] + x[1] * y[2] - y[1] * x[2] + x[2] * y[0] - y[2] * x[0]) / (a + b + c);
	r = abs(r);
	// (1 - x / r) * m = 2 * x
	// m - x * m / r = 2 * x
	// m = 2 * x + x * m / r
	// m = x * (2 + m / r)
	// m / (2 + m / r) = x
	double m = max({a, b, c});
	double x = m / (2 + m / r);
	cout << fixed << setprecision(12) << abs(x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

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

  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      int flag=-1;
      for(int k=0;k<N;k++){
        if(h[k]>0){
          int tmp=h[k]+abs(x[k]-i)+abs(y[k]-j);
          if(flag==-1)flag=tmp;
          else{
            if(flag!=tmp){
              flag=-2;
              break;
            }
          }
        }
      }
      if(flag==-2)continue;
      for(int k=0;k<N;k++){
        if(h[k]==0){
          int dist=abs(x[k]-i)+abs(y[k]-j);
          if(flag>dist){
            flag=-2;
            break;
          }
        }
      }
      if(flag==-2)continue;
      cout << i << " " << j << " " << flag << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
            var T = cin.Read;
            var s = S.ToCharArray();
            var t = T.ToCharArray();
            var ans = 0;
            for(int i = 0; i < 3; i++)
            {
                if (s[i].Equals(t[i])) ans++;
            }
            WriteLine(ans);
        }



        public long C(int X, int Y)
        {

            if (Y == 0 || Y == X)
            {
                return 1;
            }
            if (X < Y)
            {
                return 0;
            }
            var Pascal = new long[X + 1, X + 1];
            for (int i = 0; i <= X; i++)
            {
                Pascal[i, 0] = 1L;
                Pascal[i, i] = 1L;
            }
            for (int i = 2; i <= X; i++)
            {
                for (int j = 1; j < i; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[X, Y];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

const int tx[4]={1,0,-1,0};
const int ty[4]={0,1,0,-1};

int w,h,d[90][90];

int check(int y,int x,int D[90][90]){
	int data[90][90];
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) data[i][j]=D[i][j];
	data[y][x]=0;int res=0;
	for(int i=0;i<4;i++){
		int Y=y+ty[i],X=x+tx[i];
		if(X<0||X>=w||Y<0||Y>=h) continue;
		if(D[Y][X]==1){
			data[Y][X]=0;
			res=max(res,check(Y,X,data));
			data[Y][X]=1;
		}
	}
	return res+1;
}

int main(){
	while(scanf("%d%d",&w,&h),w){
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) scanf("%d",&d[i][j]);
		int res=0;
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(d[i][j]==1) res = max (res , check(i,j,d));
		printf("%d\n",res);
	}
}

Measured memory_bytes: 2220
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
 freopen("input","r",stdin);
 freopen("output","w",stdout);
*/

const int sz = 1E7 + 10;

ll F[sz];
ll I[sz];

ll MOD = 998244353;

ll nchoosek(ll a, ll b) {
    ll res = F[a] * I[b];
    res %= MOD;
    return (res * I[a - b]) % MOD;
}

ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b % 2) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        b /= 2;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    F[0] = 1;
    for (int i = 1;i <= N;i++) {
        F[i] = F[i - 1] * i;
        F[i] %= MOD;
    }
    I[N] = power(F[N], MOD - 2);
    for (int i = N;i > 0;i--) {
        I[i - 1] = (I[i] * i) % MOD;
    }
    ll tol = power(3, N);
    for (int i = N / 2 + 1;i <= N;i++) {
        ll crt = nchoosek(N, i) * power(2, N - i);
        crt %= MOD;
        tol += (MOD - crt) * 2;
        tol %= MOD;
    }
    cout << tol << endl;
    return 0;
}


Measured memory_bytes: 156544
implicit none

integer n,q,i,left,right,j,l,r,k
character(:),allocatable:: s
integer,allocatable,dimension(:) ::counts
integer ::cnt=0

read(5,*)n,q
allocate(character(n)::s)
allocate(counts(n))
counts(:)=0

read(5,*)s

do k=1,n-1
if(s(k:k+1)=="AC") then
cnt=cnt+1
endif
counts(k)=cnt
enddo

do i=1,q
read(5,*)l,r
write(6,*) (counts(r-1)-counts(l-1))
enddo


deallocate(counts)
deallocate(s)
end


Measured memory_bytes: 2280
moji = str(input())
if int(moji[0:4]) < 2019:
  print("Heisei")
elif int(moji[0:4]) == 2019:
  if int(moji[5:6]) == 0 and int(moji[6:7])<=4:
    print("Heisei")
  else:
    print("TBD")
else:
  print("TBD")

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	int a = 0, b = 0;
	for(auto ch : s){
		if(ch == 'A')a++;
		else b++;
	}
	if(a && b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int a, b; cin >> a >> b;
  kek(max(0, a - 2 * b));
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    vector<ll> A(N + 1);
    ll sum = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        if (i % 2 == 1) {
            sum += A[i];
        }
        else {
            sum -= A[i];
        }
    }
    sum /= 2;
    vector<ll> ans(N + 1, 0);
    ans[1] = sum;
    cout << sum * 2 << " ";
    for (int i = 2; i <= N; ++i) {
        ans[i] = A[i - 1] - ans[i - 1];
        cout << ans[i] * 2 << " ";
    }
}

Measured memory_bytes: 4828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace problem001
{
	class Program
	{
		static void Main(string[] args)
		{
			var str = ReadLine().Split(' ');
			int K = int.Parse(str[0]);
			int X = int.Parse(str[1]);

			if(K*500 >= X)
			{
				Write("Yes");
			}
			else
			{
				Write("No");
			}
		}
	}
}


Measured memory_bytes: 13140
import sys

while True:
	data = map(int, raw_input().split())
	H = data[0]
	W = data[1]
	
	if H == 0 and W == 0:
		break
	else:
		for i in range(H):
			if i == 0 or i == H-1:
				for j in range(W):
					sys.stdout.write("#")
				print("")
			else:
				sys.stdout.write("#")
				for j in range(W-2):
					sys.stdout.write(".")
				sys.stdout.write("#")
				print("")
		print("")

Measured memory_bytes: 6440
from collections import defaultdict

N, M = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(N)]

def search(sportList):
    if not sportList:
        return float('inf')

    cnt = defaultdict(int)

    for p in range(N):
        for a in A[p]:
            if a in sportList:
                cnt[a] += 1
                break

    maxSport = -1
    ret = -float('inf')
    for s, c in cnt.items():
        if ret < c:
            maxSport = s
            ret = c

    sportList.remove(maxSport)
    return min(cnt[maxSport], search(sportList))

sportList = set(range(1, M + 1))
ans = search(sportList)

print(ans)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int S, W;
    cin >> S >> W;
    if (W >= S) cout << "unsafe";
    else cout << "safe";
    return 0;
}


Measured memory_bytes: 3648
n, m, l = map(int,input().split())
nl = []
al = []
for i in range(n + m):
   nl.append(list(map(int,input().split())))
for j in range(n):
    for k in range(l):
        num = 0
        for o in range(m):
            num += nl[j][o]*nl[n+o][k]
        al.append(num)
    print(" ".join(map(str,al)))
    al.clear()


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

// 4min
int main(void){
    char s[4];
    int a = 0, b = 0, c = 0;

    scanf("%s", s);

    if(s[0] != s[1] && s[0] != s[2] && s[1] != s[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }



    return 0;

} 


Measured memory_bytes: 256
s = input()
t = input()

s_len = len(s)
t_len = len(t)
min_count = t_len

j = 0
while j+t_len <= s_len:
    sub_s = s[j:j+t_len]
    
    count = 0
    for i in range(t_len):
        if sub_s[i] != t[i]:
            count += 1
            
    if count < min_count:
        min_count = count

    j+=1
        
print(min_count)


Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,i,j;
	cin>>n;
	long long a[n];
	vector<long long>s;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		s.push_back(a[i]);
	}
	vector<long long>::iterator it,itt;
	sort(s.begin(),s.end(),greater<int>());

	for(i=0;i<n;i++){
		j=0;
		if(a[i]==s[j])
			j++;
		cout<<s[j]<<endl;
	}
}

Measured memory_bytes: 4848
from collections import deque, Counter
from itertools import chain, combinations
import json
import numpy as np
import bisect
import sys

sys.setrecursionlimit(10 ** 8)
# mem = {}

M = 10 ** 9 + 7


def main():
    N = int(input())
    # b, c = [int(a) for a in input().split()]
    # print()

    c = 0
    for i in range(0, N + 1):
        if i % 3 == 0:
            continue
        if i % 5 == 0:
            continue
        c += i
    print(c)


if __name__ == "__main__":
    main()


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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ld n;
   cin >> n;
 cout << n*n << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
 
/*############################# DSU ##############################*/
vll parent(1e5), Size(1e5), Rank(1e5);
 
void make_set(ll v){
    parent[v]=v;
    Size[v] = 1;
    // Rank[v] = 0;
}
 
int find_set(ll v){
    return (parent[v]==v) ?  v : parent[v] = find_set(parent[v]);
}
 
void union_sets(ll a, ll b){
    a = find_set(a);
    b = find_set(b);
    if(a != b){
        if(Size[a] < Size[b])
            swap(a, b);
        // if(Rank[a] < Rank[b])
        //     swap(a, b);
        parent[b] = a;
        Size[a] += Size[b];
        // if(Rank[a] == Rank[b])
        //     Rank[a]++;
    }
}
/*############################# DSU ##############################*/
 
// ostringstream str1;
//             str1 << n;
//             string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(32);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */
 
 
void solve()
{
    ll k; cin>>k;
    string s; cin>>s;
    ll n = s.len;
    if(n>k){
        cout<<s.substr(0, k)<<"...\n";
    }
    else cout<<s<<nl;
}
 
 
int main(){
    // boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A1, A2, A3; cin >> A1 >> A2 >> A3;
    string ans = (A1 + A2 + A3 >= 22) ? "bust" : "win";
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;
int vis[150];
char s[100005]; 
int main()  
{  
	cin>>s;
	int len=strlen(s);
	for(int i=0;i<len;i++){
		vis[s[i]]=1; 
	}
	for(int i='a';i<='z';i++){
		if(vis[i]==0){
			cout<<(char)i<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;  
}  


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct CumlativeSum2D {
    int N,M;
    vector<vector<T>> arr;

    CumlativeSum2D (vector<vector<T>> &A) {
        N = A.size();
        A.emplace_back();
        M = A[0].size();
        A.pop_back();
        arr.assign(N+1, vector<T>(M+1,0));
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                arr[i+1][j+1] = A[i][j];
            }
        }
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j < M; j++) {
                arr[i][j+1] += arr[i][j];
            }
        }
        for (int j = 0; j <= M; j++) {
            for (int i = 0; i < N; i++) {
                arr[i+1][j] += arr[i][j];
            }
        }
    }

    //[h1,h2],[w1,w2]
    T get(int h1, int h2, int w1, int w2) {
        if (h1 > h2 || w1 > w2) return 0;
        return arr[h2+1][w2+1] - arr[h2+1][w1] - arr[h1][w2+1] + arr[h1][w1];
    }

    inline const vector<T> &operator[](int k) const {return arr[k+1];}
  	inline vector<T> &operator[](int k) {return arr[k+1];}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M,Q; cin >> N >> M >> Q;
    vector<string> S(N);
    rep(i,N) cin >> S[i];

    vector<vector<int>> A(N, vector<int>(M)), B(N, vector<int>(M-1)), C(N-1, vector<int>(M));
    rep(i,N) {
        rep(j,M) {
            if (S[i][j]=='1') A[i][j] = 1;
            if (j and S[i][j]=='1' and S[i][j-1]=='1') B[i][j-1] = 1; 
        }
    }
    rep(j,M) {
        rep(i,N-1) {
            if (S[i][j]=='1' and S[i+1][j]=='1') C[i][j] = 1;
        }
    }
    CumlativeSum2D<int> D(A), E(B), F(C);
    rep(i,Q) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        --x1; --y1; --x2; --y2;
        cout << D.get(x1,x2,y1,y2) - E.get(x1,x2,y1,y2-1) - F.get(x1,x2-1,y1,y2) << ln; 
    }
}


Measured memory_bytes: 100352
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	int n = *max_element(A.begin(), A.end());
	int r = -1;
	for (auto x : A) if (x != n) {
		if (r == -1 || abs(x - n/2) < abs(r - n/2)) {
			r = x;
		}
	}
	cout << n << " " << r << endl;
}


Measured memory_bytes: 640
/* */
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
const int MAX_LEN = 1010;
#define GETLINE(x) fgets(x,MAX_LEN,stdin);
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<ll> vll;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N=200100;
ll inf=1e15;
int n,m,k,ans;
ll a[N];
ll b[N];
int main () { 
	scanf("%d %d %d",&n,&m,&k);
	a[0]=b[0]=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++){
		scanf("%lld",&b[i]);
		b[i]+=b[i-1];
	}
	for(int i=0;i<=n;i++){
		if(k>=a[i]){
			int rem=(int)(upper_bound(b,b+m+1,k-a[i])-b)-1;
			ans=max(ans,i+rem);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=3;
    if(a==b&&a!=c)ans=2;
    else if(a==b&&a==c)ans=1;
    else if(a==c)ans=2;
    else if(a!=c&&b==c)ans=2;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;

int tower[1000] = {};

int main()
{
	tower[1] = 1;
	FOR(i, 2, 999)
	{
		tower[i] = tower[i - 1] + i;
	}
	int a, b;
	cin >> a >> b;
	int d = b - a;
	FOR(i, 1, 998)
	{
		if (d == 1 + tower[i] - tower[i - 1])
		{
			cout << tower[i - 1] + i - a << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int M = ni();
        
        ArrayList<Integer> div = new ArrayList<>();
        for (int i = 1; i*i <= M; i++) {
            if(M%i==0){
                div.add(i);
                div.add(M/i);
            }
        }
        Collections.sort(div, Comparator.reverseOrder());
        for (int i = 0; i < div.size(); i++) {
            int d = div.get(i);
            if(M/d>=N){
                out.println(d);
                return;
            }
        }



















        // int N = ni();
        // int M = ni();
        // ArrayList<Integer> d = new ArrayList<>();
        // for (int i = 1; i*i <= M; i++) {
        //     if(M%i==0){
        //         d.add(i);
        //         d.add(M/i);
        //     }
        // }
        // Collections.sort(d, Comparator.reverseOrder());
        // int ans = 0;
        // for (Integer i : d) {
        //     if(M/i >= N) {
        //         ans = i;
        //         break;
        //     }
        // }
        // out.print(ans);
        
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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





int main(){
  while(1){
  int n,r;
  cin>>n>>r;
  if(n==0 && r==0){break;}
  int a[1000];
  for(int i=0;i<1000;i++){a[i]=i;}
  for(int i=0;i<r;i++){
    vector<int> b(0);
    vector<int> d(0);
    int p,c;
    cin>>p>>c;
    for(int i=p;i<p+c;i++){
      b.push_back(a[i]);
    }
    for(int i=1;i<p;i++){
      d.push_back(a[i]);
    }
    for(int i=1;i<=c;i++){
      a[i]=b[i-1];
    }
    for(int i=c+1;i<p+c;i++){
      a[i]=d[i-c-1];
    }
  }
  cout<<n-a[1]+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
#define LL long long
const LL MAX = 1e6+10;
LL n,m,k,x,y;
LL a[MAX];
map<LL,LL>TM;
int main ()
{
    cin>>n;
    LL sum=0;
    LL add=0;
    TM[0]=1;
    for(LL i=1;i<=n;i++)
    {
        cin>>x;
        sum+=x;
        add+=TM[sum];
        TM[sum]++;
        //cout<<add<<"_"<<sum<<endl;
    }
    cout<<add<<endl;
    return 0;
}


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

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  for(int i=l; i <= r; i++){
    if(i%d == 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int cnt;

void insertionSort(int* a, int n, int g){

    int i, j, v;

    for(i = g; i < n; i++){
        v = a[i];
        j = i - g;
        while((j >= 0) && (a[j] > v)){
            a[j + g] = a[j];
            j = j - g;
			cnt++;
        };
        a[j + g] = v;
    }
}

void shellsort(int* a, int n)
{
	cnt = 0;
	int i, p;
	int m;
	int G[15];

	p = 1;
	for(i = 1; i < 20; i++){
		p = p * 3;
		if(p - 1 > 2 * n) break;
	}
	if(i > 1) i = i - 1;
	m = i;

	p = 1;
	for(i = 0; i < m; i++){
		p = p * 3;
		G[m - 1 - i] = (p - 1) / 2;
	}
	cout << m << endl;
	for(i = 0; i < m - 1; i++) cout << G[i] << " ";
	cout << G[m - 1] << endl;

	for(int i = 0; i < m; i++){
		insertionSort(a, n, G[i]);
	}
}

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

	shellsort(A, n);
	cout << cnt << endl;
    for(i = 0; i < n; i++) cout << A[i] << endl;

    return 0;
}

Measured memory_bytes: 5064
#include <iostream>
#include <utility>
#include <queue>
#include <cmath>
using namespace std;

int dist(pair<int,int> p1,pair<int,int> p2){
    return abs(p1.first-p2.first)+abs(p1.second-p2.second);
}

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

    queue<pair<int,pair<int,int>>> list;
    for(int i=0;i<N;i++){
        int t,x,y;
        cin >> t >> x >> y;
        list.push(make_pair(t,make_pair(x,y)));
    }

    pair<int,pair<int,int>> from=make_pair(0,make_pair(0,0));
    while(!list.empty()){
        pair<int,pair<int,int>> to=list.front();
        int d=dist(from.second,to.second);
        int dt=to.first-from.first;
        if(d>dt || (dt-d)%2==1){
            cout << "No" << endl;
            return 0;
        }
        from=to;
        list.pop();
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
while True:
    H, W = (int(x) for x in input().split())
    if H == W == 0:
        break
    for row in range(H):
        if row == 0 or row == H - 1:
            print("#"*W)
        else:
            print("#" + "."*(W-2) + "#")
    print()


Measured memory_bytes: 5624
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
cnt = Counter()
for a in reads():
  cnt[a-1] += 1
  cnt[a] += 1
  cnt[a+1] += 1

ans = max(cnt.values())
print(ans)



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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	


int main(){
	
	int n,val;
	
  cin >> n; 
  
  int ans = 0;
  int result = 0;
  f(i,0,n){
	  cin >> val;
	  ans = 0;
	  while(1){
		  if(val%2==0){
			  val= val/2;
			  ans++;
		  }else{
			 break;
		  }
	  }
	  result +=ans;
  }
  
  cout << result << endl;

  
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
string S;
int m=0,y=0;
signed main(){
  cin >> S;
  if(S[0]=='0'){
    if(S[1]=='0');
    else m++;
  }
  if(S[0]=='1'){
    if(S[1]>='3');
    else m++;
  }
  if(S[2]=='0'){
    if(S[3]=='0');
    else y++;
  }
  if(S[2]=='1'){
    if(S[3]>='3');
    else y++;
  }
  if(m==1 && y==1) cout << "AMBIGUOUS" << endl;
  else if(m==1) cout << "MMYY" << endl;
  else if(y==1) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	ans := math.MaxInt32

	for a := 1; a < n; a++ {
		b := n - a
		ans = min(ans, digitsSum(a)+digitsSum(b))
	}
	fmt.Println(ans)
}

func digitsSum(x int) int {
	result := 0
	for x != 0 {
		result += x % 10
		x /= 10
	}
	return result
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  ans+=min(k,a);
  k-=min(k,a);
  k-=min(k,b);
  ans-=min(k,c);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
A = [int(a) for a in input().split()]
dp = [[0] * (N+1) for _ in range(N+1)]

for d in range(N):
    for l in range(N-d):
        r = l + d
        if d == 0:
            dp[l][r] = A[l] * (-1)**(N+d+1)
            
        else:
            s = (-1)**(N+d+1)
            dp[l][r] = max(A[l] + dp[l+1][r] * s, A[r] + dp[l][r-1] * s) * s

print(dp[0][N-1])

Measured memory_bytes: 112860
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace cc
{
    class Program
    {
        // LCM
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // GCD
        public static long Gcd(long a, long b)
        {
            if (a < b)
            {
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            }

            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');

            long A = long.Parse(strs[0]);
            long B = long.Parse(strs[1]);
            long C = long.Parse(strs[2]);
            long D = long.Parse(strs[3]);

            long E = Lcm(C, D);

            long ans = B / C - (A - 1) / C +
                       B / D - (A - 1) / D -
                       (B / E - (A - 1) / E);

            ans = B - A + 1 - ans;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

struct THuman
{
	double X;
	double Y;
	int Degree;
};

THuman Move(int Distance, THuman Human)
{
	Human.Y += Distance * cos(Human.Degree * M_PI / 180);
	Human.X += Distance * sin(Human.Degree * M_PI / 180);
	return Human;
}

int main()
{
	THuman Human = {0, 0, 0};
	while(true){
		int Distance;
		int Degree;
		char Dummy;
		cin >> Distance >> Dummy >> Degree;
		if(Distance == 0 && Degree == 0) break;
		Human = Move(Distance, Human);
		Human.Degree += Degree;
	}
	double GaussX, FractionalX, GaussY, FractionalY;
	FractionalX = modf(Human.X, &GaussX);
	FractionalY = modf(Human.Y, &GaussY);
	cout << fixed << setprecision(0) << GaussX << endl << GaussY << endl;
	return 0;
}

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

int main(){
    int abcd,a,b,c,d;
    cin>>abcd;
    a=abcd/1000;
    b=(abcd/100)%10;
    c=(abcd/10)%10;
    d=abcd%10;
    if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
    else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
    else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
    else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
    return 0;
}

Measured memory_bytes: 256
K = int(input())

total = 0
for i in range(1,K+1,1):
  for j in range(1,K+1,1):
    tmp1 = i
    tmp2 = j
    while tmp1 % tmp2 != 0:
      tmp = tmp1 % tmp2
      tmp1 = tmp2
      tmp2 = tmp
    for k in range(1,K+1,1):
      tmp1 = k
      tmp3 = tmp2
      while tmp1 % tmp3 != 0:
        tmp = tmp1 % tmp3
        tmp1 = tmp3
        tmp3 = tmp
      total += tmp3
print(total)
      


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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}
int main(){
    int n=qr();
    repi(i,1,n)printf("ACL");
    return 0;
}

Measured memory_bytes: 3764