akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int k;
  cin >> k;
  int ans=0;
  rep(i,k+1) ans+=i;
  for(int i=1; i<=k; i++) {
      for(int j=1; j<=k; j++) {
          if(i==j) continue;
          ans+=3*gcd(i,j);
      }
  }
  if(k>2) {
    for(int i=3; i<=k; i++) {
        for(int j=2; j<i; j++) {
            int a=gcd(i,j);
            for(int l=1; l<j; l++) ans+=6*gcd(a,l);
        }
    }
  }
  pt(ans);
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
using namespace std;
typedef pair<int, int> P;
int w,h,wnum, bnum;
string field[50];
bool isin(int x, int y) { return x>=0&&x<h&&y>=0&&y<w; }
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main() {
    while (scanf("%d%d",&w,&h)) {
        if (!w&&!h) break;
        wnum=bnum=0;
        for (int i=0; i<h; i++) cin>>field[i];
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (field[i][j]=='.') {
                    int cnt=1;
                    char flag='0';
                    field[i][j]='-';
                    queue<P> que;
                    que.push(P(i,j));
                    while (!que.empty()) {
                        P p=que.front(); que.pop();
                        for (int k=0; k<4; k++) {
                            int nx=p.first+dx[k], ny=p.second+dy[k];
                            if (!isin(nx,ny)) continue;
                            if (field[nx][ny]=='.') {
                                que.push(P(nx,ny));
                                field[nx][ny]='-';
                                cnt++;
                            }
                            if (flag=='0') {
                                if (field[nx][ny]=='W') {
                                    flag='W';
                                } else if (field[nx][ny]=='B') {
                                    flag='B';
                                }
                            } else if (field[nx][ny]=='W'&&flag=='B') {
                                flag='X';
                            } else if (field[nx][ny]=='B'&&flag=='W') {
                                flag='X';
                            }
                        }
                    }
                    if (flag=='W') wnum+=cnt;
                    if (flag=='B') bnum+=cnt;
                }
            }
        }
        // for (int i=0; i<h; i++) cout<<field[i]<<endl;
        printf("%d %d\n",bnum,wnum);
    }
}

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

int n, k;
int a[100010];
int dp[100010];

int main () {
	
	cin >> n >> k;
	int mini = 1e5;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		mini = min(mini, a[i]);
	}
	
	for (int i = 0; i < mini; i ++) dp[i] = -1;
	for (int i = mini; i <= k; i ++) {
		int da = 0;
		for (int j = 0; j < n; j ++) {
			if (i-a[j] >= 0 && dp[i-a[j]] == -1) {
				da = 1;
				break;
			}
		}
	
		if (da) dp[i] = 1;
		else dp[i] = -1;
	}
	
	
	if (dp[k] == -1) cout << "Second";
	else cout << "First";
	
	return 0;
}

Measured memory_bytes: 640
s = list(input())
t = list(input())
s_set = list(set(s))
t_set = list(set(t))
l = len(s)
l_s_set = len(s_set)
l_t_set = len(t_set)

x = [[] for _ in range(l)]
for i in range(l):
    x[i].append(s[i])
    x[i].append(t[i])

for j in range(l_s_set):
    tmp = []
    for k in range(l):
        if s_set[j] == x[k][0]:
            tmp.append(x[k][1])
    if len(set(tmp)) > 1:
        print('No')
        exit()

for p in range(l_t_set):
    tmp = []
    for q in range(l):
        if t_set[p] == x[q][1]:
            tmp.append(x[q][0])
    if len(set(tmp)) > 1:
        print('No')
        exit()

print('Yes')

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

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 510000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    COMinit();
    ll v1 = 1;
    for (ll i = n; i > n - a; i--) {
        v1 *= i;
        v1 %= MOD;
    }
    ll v2 = 1;
    for (ll i = n; i > n - b; i--) {
        v2 *= i;
        v2 %= MOD;
    }
    v1 *= finv[a];
    v2 *= finv[b];
    v1 %= MOD;
    v2 %= MOD;
    ll ans = modpow(2, n, MOD) - 1 - v1 - v2;
    ans += 10 * MOD;
    ans %= MOD;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12160
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a, b = list(map(str, sys.stdin.buffer.readline().decode().split()))
    print('H' if a == 'H' and b == 'H' or a == 'D' and b == 'D' else 'D')


if __name__ == '__main__':
    main()


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

struct str{
    ll r,g,b;
}st[4004];

int main(){
    ll a,c=0,ct=0,m,n,i,j,k,x=0,y,sm=0,R=0,G=0,B=0;
    scanf("%lld",&n);
    string s;
    scanf("%lld",&n);
    cin>>s;
    for(i=0;i<n;i++){
        if(s[i]=='R') R++;
        if(s[i]=='G') G++;
        if(s[i]=='B') B++;
    }
    for(i=0;i<n;i++){
        if(s[i]=='R') R--;
        if(s[i]=='G') G--;
        if(s[i]=='B') B--;
        st[i].r=R;
        st[i].g=G;
        st[i].b=B;
    }
//    for(i=0;i<n;i++) cout<<st[i].r<<' '<<st[i].g<<' '<<st[i].b<<"\n";
    for(i=1;i<n-1;i++){
        for(j=0;j<i;j++){
            if(s[i]=='R'){
                if(s[j]=='G'){
                    sm+=st[i].b;
                    if(s[i+i-j]=='B') sm--;
                }
                if(s[j]=='B'){
                    sm+=st[i].g;
                    if(s[i+i-j]=='G') sm--;
                }
            }

            if(s[i]=='G'){
                if(s[j]=='R'){
                    sm+=st[i].b;
                    if(s[i+i-j]=='B') sm--;
                }
                if(s[j]=='B'){
                    sm+=st[i].r;
                    if(s[i+i-j]=='R') sm--;
                }
            }

            if(s[i]=='B'){
                if(s[j]=='G'){
                    sm+=st[i].r;
                    if(s[i+i-j]=='R') sm--;
                }
                if(s[j]=='R'){
                    sm+=st[i].g;
                    if(s[i+i-j]=='G') sm--;
                }
            }
        }
    }
    printf("%lld\n",sm);

    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
long long f[101][100001];
int w[101],v[101];
int main()
{
	int n,W,m=0,i,j,pos=0;;
	scanf("%d %d",&n,&W);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d",&w[i],&v[i]);
		m+=v[i];
	}
	memset(f,0x7f,sizeof(f));
	f[0][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=v[i])
				f[i][j]=min(f[i-1][j],f[i-1][j-v[i]]+w[i]);
		}
	}
	for(i=0;i<=m;i++)
		if(f[n][i]<=W)
			pos=i;
	printf("%d",pos);
	return 0;
}

Measured memory_bytes: 79232
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| u64::from_str(n).unwrap());
    let (a, b) = (it.next().unwrap(), it.next().unwrap());

    for _ in 0..(b + 2) {
        print!("#");
    }
    println!("");
    for _ in 0..a {

        let mut buf = String::new();
        stdin.read_line(&mut buf).ok();

        let mut it = buf.split_whitespace().map(|n| String::from_str(n).unwrap());
        let s = it.next().unwrap();
        println!("#{}#", s);
    }


    for _ in 0..(b + 2) {
        print!("#");
    }
    println!("");

}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
    int array[100] = {0};
    int input;
    int max = 0;
    int i;
    while (scanf("%d",&input) != EOF) {
        array[input]++;
    }
    for (i = 0; i < 100; i++) {
        if (array[i] > max) {
            max = array [i];
        }
    }
    for (i = 0; i < 100; i++) {
        if (max == array[i]) {
            printf("%d\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max({a * c, a * d, b * c, b * d});
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, a[3], b[3];
int main() {
  cin >> n;
  read_n(a, 3);
  read_n(b, 3);
  i64 m = n;
  for (i64 k = 0; k < 2; ++k) {
    vector<i64> dp(m + 1);
    iota(begin(dp), end(dp), 0);
    for (i64 i = 0; i < 3; ++i) {
      for (i64 j = a[i]; j <= m; ++j) {
        dp[j] = max(dp[j], dp[j - a[i]] + b[i]);
      }
    }
    for (i64 i = 0; i < 3; ++i) swap(a[i], b[i]);
    m = *max_element(begin(dp), end(dp));
  }
  cout << m << '\n';
  return 0;
}



Measured memory_bytes: 195584
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {

        int n,m;
        cin>>n>>m;
        int a[n];
        int cnt = 0;
        for(int i=0; i<n; i++) {
            cin>>a[i];
            if(a[i] >= m) {
                cnt++;
            }
        }
        cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

/*
int calcSize() {
  int i= 1;
  while(i < MAX_N) i <<= 1;
  return (i<<1)-1;
}
*/

const int MAX_N = 400000;
const int T_SIZE = 1048575;

int dat[T_SIZE];
int pos, size;
void initTree() {
  pos = size = 0;
  fill(dat, dat+T_SIZE, 0);
}

void addNode() {
  int p = T_SIZE/2+pos++;
  ++size;
  dat[p] = 1;
  while(p != 0) {
    p = (p-1)/2;
    dat[p] = dat[p*2+1] + dat[p*2+2];
  }
}

void eraseNode(int n) {
  int p = T_SIZE/2+n;
  --size;
  dat[p] = 0;
  while(p != 0) {
    p = (p-1)/2;
    dat[p] = dat[p*2+1] + dat[p*2+2];
  }
}

int searchNode(int p, int n, int sum) {
  if(p >= T_SIZE/2) return p - T_SIZE/2;
  if(dat[p*2+1]+sum >= n+1) return searchNode(p*2+1, n, sum);
  else                      return searchNode(p*2+2, n, sum+dat[p*2+1]);
}

void eraseOldestNode() {
  eraseNode(searchNode(0,0,0));
}

int ptox[MAX_N];
map<int, int> xtop;
int lim;


void init() {
  initTree();
  xtop.clear();
}

void add(int x) {
  ptox[pos] = x;
  xtop[x] = pos;
  addNode();
  while(size > lim) {
    eraseOldestNode();
  }
}

void enkanN(int x) {
  eraseNode(searchNode(0, x, 0));
}

void print(int x) {
  cout << ptox[searchNode(0, x, 0)] << endl;
}

void enkanX(int x) {
  eraseNode(xtop[x]);
}

int main() {
  int q;
  while(cin >> q >> lim && (q || lim)) {
    init();
    int query, x;
    for(int i = 0; i < q; ++i) {
      cin >> query >> x;
      switch(query) {
      case 0: add(x); break;
      case 1: enkanN(x-1); break;
      case 2: print(x-1); break;
      case 3: enkanX(x); break;
      }
    }
    cout << "end" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <boost/algorithm/string.hpp>
using namespace std;


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


#define Vec(a) vector<a>

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) cout << fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN


void odd(int n)
    {
    bool b=1;
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0) {cout << "NO" << sp; b = 0;  break;}
    }
    if (b)
    cout << "Yes" << sp;
    b=1;
    }
ll fact(int n ){

long long fact =1;

for (int i =2 ;i<=n;++i)

{
    fact*=i;
}
return fact;
}


ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int a[4];

int main()
{
    init();

    long long n , p=100 , ans=0; cin>>n;

    while(n>p)

    {
        p+=p/100;
        ans++;
    }

    cout << ans;
}



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

using namespace std;

string immigration(int N, vector<int>& A) {
	for (int i = 0; i < N; i++)
		if (A[i] % 2 == 0 && A[i] % 3 && A[i] % 5)
			return "DENIED";
	return "APPROVED";
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << immigration(N, A);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N; cin>>N;
    vec d(N);
    rep(i,N) cin>>d.at(i);
    sort(ALL(d));
    vec s(N+1,0);
    rep(i,N) s.at(i+1)=d.at(i)+s.at(i);
    ll AKAN=1;
    for(int i=N; i>1; i--) {
        if(s.at(i)>s.at(i-1)*3) {AKAN=i; break;}
    }
    cout<<N-AKAN+1<<endl;

}

Measured memory_bytes: 1920
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, K = map(int, readline().split())
    K -= 1
    S = readline().strip()
    
    S = list(S)
    S[K] = S[K].lower()
    print(''.join(S))
    return


if __name__ == '__main__':
    main()


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

int main() {
    int n;
    cin >> n;
    vector<double> a(n);
    vector<int64_t> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        b.at(i) = 1000000000 * a.at(i) + 0.5;
    }

    vector<vector<int64_t>> count2d(19, vector<int64_t>(19));
    vector<int64_t> count2(n), count5(n);
    for (int i = 0; i < n; i++) {
        while (b.at(i) % 2 == 0) {
            count2.at(i)++;
            b.at(i) /= 2;
        }
        while (b.at(i) % 5 == 0) {
            count5.at(i)++;
            b.at(i) /= 5;
        }
        count2.at(i) = min<int>(count2.at(i), 18);
        count5.at(i) = min<int>(count5.at(i), 18);
        count2d.at(count2.at(i)).at(count5.at(i))++;
    }

    int64_t ans = 0;
    for (int i = 0; i <= 18; i++) {
        for (int j = 0; j <= 18; j++) {
            for (int k = 18 - i; k <= 18; k++) {
                for (int l = 18 - j; l <= 18; l++) {
                    ans += count2d.at(i).at(j) * count2d.at(k).at(l);
                }
            }
        }
    }
    for (int i = 9; i <= 18; i++) {
        for (int j = 9; j <= 18; j++) {
            ans -= count2d.at(i).at(j);
        }
    }
    ans /= 2;
    cout << ans << endl;
}


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

int main(void){
    unsigned long int n, a, b;
    cin >> n >> a >> b;
    unsigned long int ret = 0;
    ret += (n / (a + b)) * a;
    ret += min(a, n % (a + b));
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,i,j,k,v,x,cnt=0,m=0;
  int A[1000000];
  int G[1000000];
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    }
   
  G[0]=1;
  for(i=1;G[i-1]<=n;i++){
    m++;
    G[i]=G[i-1]*3+1;
    if(m>100)break;
  }
  for(i=0;i<m/2;i++){
    x=G[i];
    G[i]=G[m-i-1];
    G[m-i-1]=x;
  }
   
   
  for(i=0;i<m;i++){
    for(j=G[i];j<n;j++){
      v=A[j];
      k=j-G[i];
      while(k>=0&&A[k]>v){
    A[k+G[i]]=A[k];
        k=k-G[i];
    cnt++;
      }
      A[k+G[i]]=v;
    }
  }
   
  printf("\n%d\n",m);
  for(i=0;i<m;i++){
    printf("%d ",G[i]);
  }
  printf("\n%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
    }
  return 0;
}


Measured memory_bytes: 5608
import itertools
from math import sqrt
N = int(input())
POINTS = []
for n in range(N):
    x,y = list(map(int,input().split()))
    POINTS.append({"x":x,"y":y})

ans = 0
num=0
for candidate in itertools.permutations(POINTS):
    num +=1
    for i,v in enumerate(candidate):
        if i == 0:
            continue
        prev = candidate[i-1]
        ans += sqrt((v["x"] - prev["x"]) ** 2 +(v["y"]-prev["y"]) ** 2)
print(str(ans/num))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string O;
  string E;
  
  cin >> O >> E;
  
  int size1 = O.size();
  int size2 = E.size();
  
  for(int i = 0; i < size1; i++){
    cout << O.at(i);
    
    if(i == size1 - 1 && size1 > size2){
      break;
    }
    
    cout << E.at(i);
  }
  
  cout << endl;
}

Measured memory_bytes: 256
i = 0
lis = []
while True:
    s = input()
    i += 1
    s = int(s)
    lis.append(s)
    if s == 0:
        break

for j in range(i - 1):
    fmt = "Case {a}: {b}"
    s = fmt.format(a = j + 1,b = lis[j])
    print(s)

Measured memory_bytes: 7972
#!/usr/bin/env/ python

from itertools import chain

N,M=map(int,raw_input().split())
road=[0]*M
for i in range(M):
    road[i]=map(int,raw_input().strip().split())

road=list(chain.from_iterable(road))

for i in range(N):
    print road.count(i+1)

Measured memory_bytes: 2692
#include<stdio.h>

int main(void){

  int N;
  long int a[10000];
  long int ans = 0;
  scanf("%d", &N);
  for(int i = 0 ; i < N ; i++){
    scanf("%ld" , &a[i]);
  }

  for(int i = 0 ; i < N ; i++){
    while(a[i] % 2 == 0){
      a[i] /= 2;
      ans++;
    }
  }

  printf("%ld", ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

const int M=2e5+5;

int main()
{
	int n,a;
	int pre=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(a==pre+1)
			pre++;
	}
	printf("%d\n",pre?n-pre:-1);
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int x[n],y[n];
    rep(i,n) cin >> x[i] >> y[i];
    int x1[n],y1[n];
    rep(i,n){
        x1[i] = x[i]+y[i];
        y1[i] = x[i]-y[i]; 
    } 
    sort(x1,x1+n);
    sort(y1,y1+n);
    cout << max(x1[n-1]-x1[0],y1[n-1]-y1[0]) << endl;
}

Measured memory_bytes: 6748
#include <iostream>
#include <queue>
using namespace std;
int D[110]={};
int R[110][110]={};
int n,a,b,k;
void bfs(int src){
	queue<int> Q;
	Q.push(src);
	D[src] = 0;
	while (! Q.empty()) {
		int cur = Q.front();
		Q.pop();
		for(int dst=1;dst<n+1;dst++){
			if(R[cur][dst]==1 && D[dst]==0){
				D[dst] =D[cur]+1;
				Q.push(dst);
			}
		}
	}
}
int main() {
	cin >> n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>k;
		for(int j=0;j<k;j++){
		cin>>b;
		R[a][b]=1;
		}
	}
	bfs(1);
	cout <<"1 0"<<endl;
	for(int m=2;m<n+1;m++){
		if(D[m]==0){
		cout <<m<<" "<<-1<<endl;
		}else{
		cout <<m<<" "<<D[m]<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1252
//D
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    int N;
    cin >> N;
    int tmp = 1;
    for(int i=0; i<N; i++){
        y:
        if(IsPrime(tmp*10+1)){
            cout << tmp*10+1;
            if(i!=N-1) cout << " ";
            tmp++;
        }
        else{
            tmp++;
            goto y;
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int a[30];

int main() {
	int n;
	while(n=in()){
		int i,sum=0,A;
		for(i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i];
		}
		int res=100100100;
		for(i=0;i<1<<n;i++){
			A=0;
			int j;
			for(j=0;j<n;j++){
				if(i>>j&1){
					A+=a[j];
				}
			}
//cout<<i<<" "<<A<<endl;
			chmin(res,abs(sum-2*A));
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	for i := 0; i < len(s); i++ {
		a := s[i] + byte(n)
		if a > 'Z' {
			a -= 26
		}
		fmt.Printf("%c", a)
	}
	fmt.Println()
}


Measured memory_bytes: 768
#include <stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  int xa, xb, ya, yb;
  xa = x + r;
  xb = x - r;
  ya = y + r;
  yb = y - r;
  if((xa<=W)&&(xb>=0)&&(ya<=H)&&(yb>=0)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

int main(){
    int a;
    scanf("%d",&a);
    printf("%d",a*(1+a*(1+a)));
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


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

using namespace std;
vector<vector<pair<int,int>>> adj(1000005);
int colors[1000005];
int vis[1000005];
void dfs(int cur){
    vis[cur]=1;
    for(int i=0;i<adj[cur].size();i++){
        int w=adj[cur][i].second;
        int to=adj[cur][i].first;
        if(w%2==0){
            colors[to]=colors[cur];
        }
        else{
            colors[to]=(!colors[cur]);
        }
        if(!vis[to]){
            dfs(to);
        }
    }
}

int main() {
    //freopen("sample-8.in", "r", stdin);
    //freopen("output8.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v,w;
        cin>>u>>v>>w;
        adj[u].push_back({v,w});
        adj[v].push_back({u,w});
    }
    dfs(1);
    for(int i=1;i<=n;i++){
        cout<<colors[i]<<endl;
    }
    return 0;
}


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

public class AtCoder
{
  public static void Main()
  {
    var input = Console.ReadLine().Trim().Split().Select(e => int.Parse(e)).ToArray();
    var n = input[0];
    var yen = input[1];

    for (var x = 0; x <= n; x++)
    {
      for (var y = 0; y <= n; y++)
      {
        var z = n - x - y;
        if (z >= 0 && (10000 * x + 5000 * y + 1000 * z) == yen)
        {
          Console.WriteLine($"{x} {y} {z}");
          return;
        }
      }
    }

    Console.WriteLine("-1 -1 -1");
  }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  int N;
  cin >> N;
  int A[N];
  FOR(i,0,N) cin >> A[i];
  int64_t sum = 0;
  int mae = A[0];
  FOR(i,1,N) {
    if (mae > A[i]) {
      sum += mae - A[i];
      //cout << sum << endl;
    }
    else mae = A[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int n; cin >> n;
	vector<int> price(n);
	vector<int> cost(n);
	for (int i = 0; i < n; i++) {
		cin >> price[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> cost[i];
	}
	vector<int> maxs(n);
	int maxx = 0;

	for (int i = 0; i < n; i++) {
		if (price[i] > cost[i]) {
			maxx += price[i] - cost[i];
		}
	}

	cout << maxx << endl;

	return 0;
}

Measured memory_bytes: 256
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	a,b = LI()
	s = input().split('-')

	if len(s[0]) == a and len(s[1]) == b:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
	main()

Measured memory_bytes: 3316
import numpy as np
a = input()
N = int(a)

xy = [map(int, input().split()) for _ in range(N)]
x, y = np.array([list(i) for i in zip(*xy)])

z = x + y
w = x - y

ans = max((max(z)-min(z)),(max(w)-min(w)))
print(ans)

Measured memory_bytes: 134612
N,M = map(int,input().split())
check = [0]*N
ac = 0
penalty = 0
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if check[pi-1] == -1:
    continue
  if si == 'WA':
    check[pi-1] += 1
  else:
    ac += 1
    penalty += check[pi-1]
    check[pi-1] = -1
print(ac,penalty)



Measured memory_bytes: 3828
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100
 
struct S{
  int g, t;
  S(int g, int t) : g(g), t(t) {}
};
 
int arr[MAX];
vector<S> seat;
 
int minute(int i){
  return 17*(i%2) + 3*(i%3) + 19;
}
 
void make(){
  int g = 0;
  for(int i = 0 ; i < 17 ; i++){
    seat.push_back(S(-1,-1));
  }
  vector<S> _wait;
  for(int i = 0 ; i < 570 ; i++){
    int size = _wait.size();
 
    if(size){
      for(int j = 0 ; j < size ; j++){
        _wait[j].t++;
      }
    }
    
    for(int j = 0 ; j < 17 ; j++){
      if(seat[j].g != -1){
        seat[j].t--;
        if(seat[j].t == 0){
          seat[j].g = seat[j].t = -1;
        }
      }
    }
  
    if(size){
      for(int j = 0 ; j < size ; j++){
        int n = _wait[j].g;
        int cnt, c;
        bool flg = false;
        if(n % 5 == 1) cnt = c = 5;
        else cnt = c = 2;
        for(int k = 0 ; k < 17 ; k++){
          if(seat[k].g == -1) cnt--;
          else cnt = c;
          if(cnt == 0){
            for(int l = k-c+1 ; l <= k ; l++){
              seat[l].g = n;
              seat[l].t = minute(n);
            }
            arr[n] = _wait[j].t;
            flg = true;
            j--;
            _wait.erase(_wait.begin());
            break;
          }
        }
        if(!flg || !_wait.size()) break;
      }
      size = _wait.size();
    }
    if(g == 100) continue;
    if(i % 5 == 0){
      int cnt, c;
      bool flg = false;
      if(size){
        _wait.push_back(S(g,0));
        g++;
        continue;
      }
      if(g % 5 == 1) cnt = c = 5;
      else cnt = c = 2;
       
      for(int j = 0 ; j < 17 ; j++){
        if(seat[j].g == -1) cnt--;
        else cnt = c;
        if(cnt == 0){
          flg = true;
          for(int k = j-c+1 ;  k <= j ; k++){
            seat[k].g = seat[k].g = g;
            seat[k].t = seat[k].t = minute(g);
          }
          arr[g] = 0;
          break;
        }
      }
      if(!flg){
        _wait.push_back(S(g,0));
      }
      g++;
    }
  }
}
 
int main(){
  int N;
 
  make();
  while(cin >> N){
    cout << arr[N] << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
string debug_string (const string& s) {
	return '"' + s + '"';
}
string debug_string (bool b) {
	return (b ? "true" : "false");
}
string debug_string (const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string (const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f (...) {
		return 0;
	}
	template<typename T>
	static char f (decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string (const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string (const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string (const pair<T, U>& p) {
	string s = "[";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += "]";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out (Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	cout << "Christmas";
	for (int i = 0;i < 25 - n;++i) {
		cout << " Eve";
	}
	cout << '\n';
	return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M;
    Scd2(N,M);

    vi num(33,-1);

    int ans = 0;
    int s,c;
    Rep(i,M){
        Scd2(s,c);
        s--;
        if( s == 0 && c == 0 ) ans = -1;
        if( num[s] != -1 && num[s] != c ) ans = -1;
        num[s] = c;
    }

    if( ans != -1 ){
        ans += num[0]>=0?num[0]:1;
        Repe(i,N,1){
            ans *= 10;
            ans += num[i]>=0?num[i]:0;
        }
    }

    if( N == 1 && ( num[0] == 0 || num[0] == -1 ) ) ans = 0;

    printf ("%d\n", ans );

    return 0;
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;

  int d = 0;
  bool xflg = true;
  vector<int> xd, yd;
  rep(i, s.size()) {
    if (s[i] == 'F') d++;
    if (s[i] == 'T' || (i == s.size() - 1)) {
      if (xflg)
        xd.eb(d);
      else
        yd.eb(d);
      d = 0;
      xflg = !xflg;
    }
  }

  vector<vector<bool>> xdp(2, vector<bool>(17000, false));
  xdp[0][8000] = true;
  rep(i, xd.size()) {
    int cur = i % 2;
    int next = (i + 1) % 2;
    xdp[next] = vector<bool>(17000, false);
    rep(j, 17000) if (xdp[cur][j]) {
      xdp[next][j + xd[i]] = true;
      if (i) xdp[next][j - xd[i]] = true;
    }
  }

  vector<vector<bool>> ydp(2, vector<bool>(17000, false));
  ydp[0][8000] = true;
  rep(i, yd.size()) {
    int cur = i % 2;
    int next = (i + 1) % 2;
    ydp[next] = vector<bool>(17000, false);
    rep(j, 17000) if (ydp[cur][j]) {
      ydp[next][j + yd[i]] = ydp[next][j - yd[i]] = true;
    }
  }

  if (xdp[xd.size() % 2][x + 8000] && ydp[yd.size() % 2][y + 8000]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  char s[100];
  scanf("%s",s);
  s[strlen(s)-8]=0;
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){      
        lint n,c;
        cin>>n>>c;
        lint d[c][c];
        lint x[n][n];
        rep(i,c){
            rep(j,c){
                cin>>d[i][j];
            }
        }
         rep(i,n){
            rep(j,n){
                cin>>x[i][j];
            }
        }
        vector<vector<lint>> sum(3,vector<lint>(c,0));
        rep(k,c){
        rep(i,n){
            rep(j,n){
                sum[(i+j+2)%3][k]+=d[x[i][j]-1][k];
            }
        }
        }
        lint ans=INF;
        rep(i,c){
            rep(j,c){
                rep(k,c){
                    if(i==j||j==k||i==k)continue;
                    ans=min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
                }
            }
        }
     cout<<ans<<endl;
      }
  
     


Measured memory_bytes: 2176
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){

    int n;
    string s;
    cin >> n >> s;

    string t = s.substr(n/2);
    string tt = s.substr(0,n/2);

    if(t == tt)Yes;
    else No;
 
    return  0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a,b,c,i,n;
scanf("%d %d %d",&a,&b,&c);
n=0;
for(i=a;i<=b;i++){
if(c%i==0){
n++;
}
}
printf("%d\n",n);
return 0;
}

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

int main() {
    int N;
    cin>>N;
    bool f=false;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==N){
                f=true;
                break;
            }
            if(f) break;
        }
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int N;
vector<string> graph(300);
vector<int> color(300, -1);

bool dfs(int v, int cur = 0){
  color[v] = cur;
  REP(i, N) if(graph[v][i] == '1'){
    if(color[i] != -1){
      if(color[i] == cur) return false;
      continue;
    }
    if(!dfs(i, 1-cur)) return false;
  }
  return true;
}

signed main() {
  cin >> N;

  REP(i, N) cin >> graph[i];

  if(!dfs(0)){
    cout << -1 << endl;
    return 0;
  }

  vector<vector<int>> dist(N, vector<int>(N, INF));
  REP(i, N) REP(j, N) if(graph[i][j] == '1') dist[i][j] = 1;
  REP(i, N) dist[i][i] = 0;

  REP(k, N) REP(i, N) REP(j, N){
    chmin(dist[i][j], dist[i][k]+dist[k][j]);
  }

  int ans = 0;
  REP(i, N) REP(j, N) if(dist[i][j] != INF){
    chmax(ans, dist[i][j]);
  }

  cout << ans+1 << endl;

  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, d; cin >> n >> d;
    ll range = d * 2 + 1;
    cout << (n+range-1) / range << endl;
    
}

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

int main()
{
  int n;
  cin >> n;
  int x = 1;
  int ans = 1;
  for(int i = 2; i <= n; i++){
    x = i;
    while(x * i <= n){
      x *= i;
      ans = max(ans, x);
    }
  }
  cout << ans << endl;
      
    
  return 0;
}

Measured memory_bytes: 3528