akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    while(true){
        ll n,s;
        cin>>n>>s;
        if(n==0&&s==0) break;
        ll ans=0;
        for(ll bit=0;bit<(1<<10);bit++){
            ll sum=0,cnt=0;
            rep(i,10){
                if(bit&(1<<i)){
                    sum+=i;
                    cnt++;
                }
            }
            if(cnt!=n) continue;
            if(sum==s) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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


void solve(long long N){
    long long ans = 0;
    for (int i = 1; i < N; i++) {
        int cnt = (N - 1) / i;
        ans += cnt;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3764
import math,sys
for i in range(sys.maxsize):
    n=int(input())
    if n ==0:
        break
    else:
        l=list(map(int,input().split()))
        m=sum(l)/n
        x=0
        for j in range(n):
            x+=(l[j]-m)**2
        a=math.sqrt(x/n)
        print(a)


Measured memory_bytes: 5700
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int An[] = new int[N];
        int ans=0;
        //Anに値を取り込む
        for (int i = 0; i < N; i++) {
            An[i] = s.nextInt();
        }
        Arrays.sort(An);
        ans=An[N-1]-An[0];
        //ansを出力する
        System.out.print(ans);
    }
}

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

using namespace std;

int main()
{
    int n;

    cin >> n;

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

    for (int cy = 0; cy <= 100; cy++) {
        for (int cx = 0; cx <= 100; cx++) {
            int h_ans = -1;

            for (int i = 0; i < n; i++) {
                if (h[i] > 0) {
                    int tmp = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                    if (h_ans == -1) {
                        h_ans = tmp;
                    } else {
                        if (h_ans != tmp) {
                            h_ans = -2;
                            break;
                        }
                    }
                }
            }

            if (h_ans == -2) {
                continue;
            }

            for (int i = 0; i < n; i++) {
                if (h[i] == 0) {
                    int tmp = abs(cx - x[i]) + abs(cy - y[i]);
                    if (h_ans > tmp) {
                        h_ans = -2;
                        break;
                    }
                }
            }

            if (h_ans == -2) {
                continue;
            }

            cout << cx << " " << cy << " " << h_ans << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <string>
#include <ios>     // std::left, std::right
#include <vector> // std::setw(int), std::setfill(char)
using namespace std;

int main()
{
	
	int H;
	int W;
	cin >> H >> W;


	char hairetu[H][W] = { "0" };

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			char temp;
			cin >> temp;
			hairetu[i][j] = temp;
          
		}
	}
  
  

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

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int D1[] = new int[N];
		int D2[] = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++){
			D1[i] = stdIn.nextInt();
			D2[i] = stdIn.nextInt();
		}
		for(int i = 0; i < N - 2; i++){
			if(D1[i] == D2[i] && D1[i+1] == D2[i+1] && D1[i+2] == D2[i+2]){
				ans = 1;
			}
		}
		if(ans == 1){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35972
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
  int i,j,k;
  string s,t;
  cin >> s;
  cin >> t;
  for(i=0;i<s.size();i++){
    s = s[s.size()-1]+s.substr(0,s.size()-1);
    //cout << s << endl;
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n,h,w;
  cin >> n >> h >> w;

  cout << (n-h+1)*(n-w+1) << endl;

  return 0;
}

Measured memory_bytes: 764
from collections import Counter

def solve(R, C, K, A):
  ans = 0
  for mask in range(1 << C):
    rsums = []
    for row in A:
      rsums.append(0)
      for c in range(C):
        if row[c] == '#' and mask >> c & 1:
          rsums[-1] += 1
      
    count = {0: 1}
    for s in rsums:
      count2 = Counter()
      for k in count:
        v = count[k]
        count2[k] += v
        count2[k + s] += v
      count = count2
    ans += count[K]
  return ans


R, C, K = map(int, raw_input().split())
A = [raw_input() for _ in xrange(R)]
print solve(R, C, K, A)


Measured memory_bytes: 73068
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int da[100100],db[100100],ans=-INF;

vector<int> g[100100];
queue<int> q;

void solve(int u, int p = -1){
	int i,v;
	for(i=(g[u].l_ength()-1); i>=0; --i){
		v = g[u][i];
		if(p==v){
			continue;
		}
		if(!(da[v]>db[v] && da[u]>db[u])){
			ans = max(ans,min(db[v],db[u]));
		}
		solve(v,u);
	}
}

int main(void){
	int n,a,b,u,v,i;
	cin >> n >> a >> b; --a; --b;
	fill(da,da+n,INF);
	fill(db,db+n,INF);
	for(i=1; i<n; ++i){
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	da[a] = 0; q.push(a);
	while(!q.empty()){
		u = q.front();
		q.pop();
		for(i=(g[u].l_ength()-1); i>=0; --i){
			v = g[u][i];
			if(da[v] > da[u]+1){
				da[v] = da[u]+1;
				q.push(v);
			}
		}
	}
	db[b] = 0; q.push(b);
	while(!q.empty()){
		u = q.front();
		q.pop();
		for(i=(g[u].l_ength()-1); i>=0; --i){
			v = g[u][i];
			if(db[v] > db[u]+1){
				db[v] = db[u]+1;
				q.push(v);
			}
		}
	}
	solve(0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13184
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N  =sc.nextInt();
        int [] List = new int[N];
        for(int i=0;i<N;i++) List[i]=sc.nextInt();
        Arrays.sort(List);
        int num=0;
        for(int i=0;i<N-2;i++){
            for(int j=i+1;j<N-1;j++) {
                for(int k=j+1;k<N;k++){
                    if(List[i]+List[j]>List[k])num++;
                    else break;
                }
            }
        }
        System.out.println(num);
    }
}

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

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

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

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

llong H, W, K;
vector<vector<llong> > memo;
vector<vector<llong> > many;

llong dp(int now, int where){
	cerr << now << " " << where << endl;
	if(now == H)
		if(where == K-1)
			return 1;
		else
			return 0;

	if(memo[now][where] != -1)
		return memo[now][where];

	llong ret = dp(now+1,where)*many[where][1]%mod;
	if(where < W)
		(ret += dp(now+1,where+1)*many[where][2]) %= mod;
	if(where > 0)
		(ret += dp(now+1,where-1)*many[where][0]) %= mod;

	return memo[now][where] = ret;
}

void getNext(){
	many.resize(W, vector<llong>(3, 0));
	for(int i = 0; i < 1<<(W-1); i++){
		int cp = i;
		bitset<9> bs(i);

		bool check = false;
		for(int i = 0; i < (W-1); i++){
			if(bs.test(i)&bs.test(i+1))
				check = true;
		}
		if(check)
			continue;

		for(int i = 0; i < W; i++){
			if(i == 0){
				if(bs.test(i))
					many[i][2]++;
				else
					many[i][1]++;
			}else if(i == W-1){
				if(bs.test(i-1))
					many[i][0]++;
				else
					many[i][1]++;
			}else{
				if(bs.test(i-1))
					many[i][0]++;
				else if(bs.test(i))
					many[i][2]++;
				else
					many[i][1]++;
			}
		}
	}
}

int main(){
	cin >> H >> W >> K;
	memo.resize(H,vector<llong>(W, -1));
	getNext();

	cout << dp(0,0) << endl;

	return 0;
}

Measured memory_bytes: 256
H = [False for i in range(1000001)]

H[1] = True
for i in range(20):
    for j in range(13):
        for k in range(9):
            if (2 ** i) * (3 ** j) * (5 ** k) < 1000001:
                H[(2 ** i) * (3 ** j) * (5 ** k)] = True
            else:
                break

while True:
    L = input()
    if L == "0":
        break

    a, b = [int(i) for i in L.split()]
    ans = 0
    for i in range(a, b+1):
        if H[i]:
            ans += 1
    print(ans)






Measured memory_bytes: 13512
#定数
#1≦k≦n≦2*10^5
n , k = map(int, input().split())
#1≦P[i]≦10^3
#O(n)
P = list(map(int, input().split()))

#サイコロの目が1~numの期待値を求める関数
#O(1)
def dice_expectations(num:int)->float:
    return (num+1) / 2

#O(n)
E = list(map(dice_expectations, P)) #Expectations

#k個ずつ
tmp = sum(E[0:k])
ans = 0
#O(n-k+1)
for i in range(n-k+1):
    if tmp > ans:
        ans = tmp
    else:
        pass
    if i != n-k:
        tmp -= E[i]     #先頭のサイコロを取り除き
        tmp += E[k+i]   #次のサイコロを追加する
    else:
        pass

print(ans)  #O(n)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b;
int main() {
    cin >> a >> b;
    if (b == 100)
        ++b;
    while (a) {
        b *= 100;
        --a;
    }
    cout << b << endl;
    return 0;
}


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

const int maxn=1e5+10;
int n,K,Ans,f[maxn];
int tote,FIR[maxn],TO[maxn],NEXT[maxn];

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

int dfs(int u)
{
	int times=0;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		times=max(times,dfs(v));
	}
	if (++times==K)
		Ans+=f[u]!=1,times=0;
	return times;
}

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i;
	scanf("%d%d",&n,&K);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&f[i]);
		if (i==1) Ans+=f[i]!=1;
		else addedge(f[i],i);
	}
	f[1]=1;
	dfs(1);
	printf("%d\n",Ans);
}


Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
  int X, day;

  scanf( "%d", &X );

  if( 7 <= X ) day = X % 7;
  else day = X;

  switch( day ){
  case 1:
    printf( "fri" );
    break;

  case 2:
    printf( "sat" );
    break;

  case 3:
    printf( "sun" );
    break;

  case 4:
    printf( "mon" );
    break;

  case 5:
    printf( "tue" );
    break;
    
  case 6:
    printf( "wed" );
    break;
    
  case 0:
    printf( "thu" );
    break;

  }

  printf( "\n" );

  return 0;

}

Measured memory_bytes: 1812
import Control.Applicative
import Data.List


main = do
    n <- readLn
    putStrLn $ show (solve n)

factors :: Int -> [Int]
factors n = [x | x <- [1..n], n `mod` x == 0]

factorization :: Int -> [Int]
factorization 1 = []
factorization x = v : factorization (x `div` v)
    where
        v = (factors x) !! 1

ndivider :: Int -> Int
ndivider n = foldl (\acc x -> acc * (length x + 1)) 1 (group $ factorization n)

solve :: Int -> Int
solve n = length([x | x <- [1..n], x `mod` 2 == 1, ndivider x == 8])


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define M 100006
using namespace std;
int a[M],dp[M];
int min(int a,int b)
{
	if(a>b)return b;
	return a;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		dp[i]=1000000000;
	}
	dp[1]=0;
	dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;++i)
	{
		for(int j=1;j<=k;++j)
		{
			if(i<=j)break;
			dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
	}
	cout<<dp[n];
 } 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=5010;
int k,q,d[MAXN],n;
ll x,m,sum,ans,tmp[MAXN];
int main () {
	scanf("%d%d",&k,&q);
	for (int i=1;i<=k;i++) {scanf("%d",&d[i]);}
	for (int i=1;i<=q;i++) {
		scanf("%d%lld%lld",&n,&x,&m);
		for (int j=1;j<=k;j++) {
			tmp[j]=d[j]%m;
			if (!tmp[j]) {tmp[j]=m;}
			tmp[j]+=tmp[j-1];
		}
		x=x%m+tmp[k]*((n-1)/k)+tmp[(n-1)%k];
		printf("%lld\n",n-1-x/m);
	}
	return 0;
}

Measured memory_bytes: 384
N = int(input())
list = input().split()
H = [int(x) for x in list]
 
FLAG = True
current = H[N-1]
for i in reversed(range(N-1)):
  if(H[i]-1 > current):
    FLAG = False
    break
  elif(H[i]-1 == current):
    H[i] = H[i] -1
  else:
    H[i] = H[i]
  current = H[i]
  
if(FLAG == True):
  print("Yes")
else:
  print("No")

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >>  d.at(i);

    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=d.at(i)*d.at(j);
            // cout << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
typedef unsigned long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;

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

int main() {
    int n;
    cin >> n;
    vector<ll> t;
    for (int i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        t.push_back(temp);
    }
    ll lcm = t[0];
    for (int i = 1; i < n; i++) {
        ll a = lcm;
        ll b = t[i];
        ll g = gcd(a, b);
        a /= g;
        if (a * b / b == a)
            lcm = a * b;
        else
            break;
    }
    cout << lcm << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n, l := nextInt(), nextInt()

	apple := make([]int, n)
	total := 0
	for i := 0; i < n; i++ {
		apple[i] = i + l
		total += apple[i]
	}

	min := math.Inf(1)
	ans := 0

	for i := 0; i < n; i++ {
		sum := 0
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			sum += apple[j]
		}
		tmp := float64(sum) - float64(total)

		if math.Abs(tmp) < min {
			min = tmp
			ans = sum
		}

	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string a, b;
  in2(a, b);
  if(a.size() < b.size())
    out("LESS");
  else if(a.size() > b.size())
    out("GREATER");
  else{
    if(a < b)
      out("LESS");
    else if(a == b)
      out("EQUAL");
    else
      out("GREATER");
  }
  memi;
}


Measured memory_bytes: 256
package main

import (
	// "bufio"
	"fmt"
	// "os"
	// "sort"
)

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

func max(a,b int)int{
	if(a>b){
		return a
	}
	return b
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	var k, n int
		fmt.Scan(&k, &n)
	 
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
	var dist int;
	dist = k - arr[n-1] + arr[0]
	for i := 0; i < n-1; i++ {
		// 家間での距離を測り、最大のものを保持する
		dist = max(dist, arr[i+1] - arr[i])
	}
	fmt.Println(k-dist);
}

// package main
 
// import (
// 	"fmt"
// )
 
// func main() {
// 	var k, n int
// 	fmt.Scan(&k, &n)
 
// 	a := make([]int, n)
// 	for i := range a {
// 		fmt.Scan(&a[i])
// 	}
 
// 	base := k - a[n-1] + a[0]
// 	for i := 0; i < n-1; i++ {
// 		// 家間での距離を測り、最大のものを保持する
// 		base = max(base, a[i+1] - a[i])
// 	}
// 	// 家間の距離が最大の区間を除いた距離が最短
// 	fmt.Println(k - base)
// }
 
// func max(a, b int) int {
// 	if a > b {
// 		return a
// 	}
// 	return b
// }


Measured memory_bytes: 5504
// #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)

typedef long long ll;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

int field[51][51];
int w, h;

void rec(int x, int y) {
  if (x < 0 || x > 50) return;
  if (y < 0 || y > 50) return;
  if (!field[x][y]) return;
  
  field[x][y] = 0;
  int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
  int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
  
  REP(i, 8) {
    rec(x + dx[i], y + dy[i]);
  }
}

int main() {
  while (true) {
    int n = Scanner::nextInt();
    if (n == 0) break;
    
    int count = 0;
    for (int i = n + 1; i <= 2 * n; i++) {
      bool flag = true;
      for (int j = 2; j * j <= i; j++) {
        if (i % j == 0) {
          flag = false;
          break;
        }
      }
      if (flag) {
        count++;
      }
    }
    PRINT(count);
  }
  
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, x;
  cin >> n >> x;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll ans = 0;
  if (a[0] > x) {
    ans += a[0] - x;
    a[0] = x;
  }

  REP(i, n) {
    ll sum = a[i - 1] + a[i];
    if (sum > x) {
      ans += sum - x;
      a[i] -= sum - x;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
#define repr2(i, s, n) for(int i = n-1; i >= s; i--)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1), b(n+1, 0);
  rep2(i, 1, n+1) cin >> a[i];
  int m = 0;
  repr2(i, 1, n+1){
    int x = 2;
    int flag = 0;
    while(i * x <= n){
      if (b[i*x] == 1) flag = (flag + 1) % 2;
      x++;
    }
    if (a[i] != flag){
      m++;
      b[i] = 1;
    }
  }
  
  cout << m << endl;
  int cnt = 0;
  rep2(i, 1, n+1){
    if (b[i] == 1){
      cnt++;
      if (cnt == m) cout << i << endl;
      else cout << i << ' ';
    }
  }
  
  return 0;
}

Measured memory_bytes: 4716
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i, n)cin >> v[i];
    ll res = 0;
    rep(i, n + 1){
        for(int j = n - 1; j >= -1; j--){
            if(i - j > 1)continue;
            ll sum = 0;
            vector<ll> list(1, INF);
            rep(k, i){
                sum += v[k];
                if(v[k] < 0)list.push_back(v[k]);
            }

            for(int l = n - 1; l > j; l--){
                sum += v[l];
                if(v[l] < 0)list.push_back(v[l]);
            }

            sort(ALL(list));
            ll rem = k - i - (n - 1 - j);
            if(rem < 0)continue;

            rep(r, rem){
                if(list[r] == INF)break;
                sum -= list[r];
            }
            res = max(res, sum);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let mut aa = i::i();
    let mut bb = i::i();

    if (aa>bb){
        let mut str=String::from("");
        let mut len=aa as usize;
        for xx in 0..len{
            str+= &bb.to_string();
        }
        println!("{}",str);
    }else{
        let mut str=String::from("");
        let mut len=bb as usize;
        for xx in 0..len{
            str+= &aa.to_string();
        }
        println!("{}",str);
    }

}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define INF 1001001001

struct Edge {
  int to;
  int cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
};

int main() {
  int vs, es;
  cin >> vs >> es;
  vector< vector<Edge> > E(vs);
  rep(i,es) {
    int s, t, w;
    cin >> s >> t >> w;
    E[s].emplace_back(t,w);
    E[t].emplace_back(s,w);
  }

  vector<bool> used(vs);
  vector<int> mincost(vs,INF);

  mincost[0] = 0;

  int ans = 0;
  while (true) {
    int v = -1;
    rep(u,vs) if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;

    if (v == -1) break;
    ans += mincost[v];
    used[v] = true;

    for (auto e : E[v]) mincost[e.to] = min(mincost[e.to], e.cost);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi T(N);
    rep(i,N) cin>>T[i];
    int sum=0;
    rep(i,N) sum+=T[i];
    int reset=sum;
    int M;
    cin>>M;
    rep(i,M) {
        int p,x;
        cin>>p>>x;
        p--;
        sum-=T[p];
        sum+=x;
        cout<<sum<<endl;
        sum=reset;
    }
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
n = gets.to_i
a = gets.split.map(&:to_i)

c = []
a.each_with_index do |ai, i|
  ai.times { c << i + 1 }
end

map = h.times.map { Array.new(w, 0) }
y = 0
x = 0
h.times do |y|
  if y.even?
    x = 0 
    d = 1
  else
    x = w - 1
    d = -1
  end
  w.times do
    map[y][x] = c.shift
    x += d
  end
end

map.each do |x|
  puts x.join(' ')
end


Measured memory_bytes: 2556
#include <iostream>
#include<stdio.h>
using namespace std;
void outPut(int a[], char s){
	for(int i = 1; i <= 13; i++){
		if(a[i] == 0){
            printf("%c %d\n",s ,i);
        } 
	}
}
int main(){
    int n, num;
    char s;
    int S[14]= {0};
    int H[14]= {0};
    int C[14]= {0};
    int D[14]= {0};
    cin >> n;
    for(int i=0;i<n; i++){
        cin >> s >> num;
        switch(s){
            case 'S':
			S[num] = 1;
			break;
		    case 'H':
			H[num] = 1;
			break;
		    case 'C':
			C[num] = 1;
			break;
		    case 'D':
			D[num] = 1;
			break;
        }
    }
  	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define fir first
#define sec second
using namespace std;
int main()
{
    ll n, p;
    cin >> n >> p;
    if (n == 1)
    {
        cout << p << endl;
        return 0;
    }
    ll ans, i = 1;

    while (powl(i, n) <= p)
    {
        if (p % (ll)(powl(i, n)) == 0)
            ans = i;
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
N, K = map(int, input().split())
x = [int(i) for i in input().split()]
mintime = 1e9
for i in range(N-K+1):
    time1 = abs(x[i])+x[i+K-1]-x[i]
    time2 = abs(x[i+K-1])+x[i+K-1]-x[i]
    time = min([time1,time2])
    if time < mintime:
        mintime = time
print(mintime)


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

int main()
{
	int a,b,c,sum=0;
	cin>>a;
	if(a==3 || a==5 || a==7)
		cout<<"YES"<<endl;
	else
	{
			cout<<"NO"<<endl;
	}
	
	
	
	return 0;
}
	

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

int main(){
    int n; cin >> n;
    vector<int> lis(n);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
    }
    ll ans = 10000000;
    for(int i = -100; i <= 100; i++){
        ll mid = 0;
        for(int l = 0; l < n; l++){
            mid += (lis[l] - i) * (lis[l] - i);
        }
        ans = min(ans, mid);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int h, w;
	int i, j;
	
	for(;;){
		scanf("%d %d", &h, &w);
		if(h==0 && w==0){
			break;
		}
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 572
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	vector<string> dig = { ".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
	vector<int> cn = { 5,3,3,3,3,3,4,3,4 };
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(j, n) {
		string s;
		cin >> s;

		int i = 0;
		while (i < s.size()) {
			char c = s[i];
			++i;
			if (c != '0') {
				int cnt = 0;
				while (s[i] == c) {
					cnt++;
					++i;
				}
				cout << dig[int(c - '0') - 1][cnt%cn[int(c - '0') - 1]];
			}
		}
		cout << endl;
	}
	
	return 0;
}

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

using namespace std;

int a[100][100];

int main(){
    int N, M;
    cin >> N >> M;
    REP(i, N) REP(j, N) cin >> a[i][j];
    REP(i, M){
        int ope;
        cin >> ope;
        if(ope == 0){
            int y, x, l, arg;
            cin >> y >> x >> l >> arg;
            x--; y--;
            assert(x + l <= N && y + l <= N);
            arg /= 90;
            while(arg--){
                int tmp[100][100];
                REP(i, N) REP(j, N) tmp[i][j] = a[i][j];
                REP(dy, l) REP(dx, l) {
                    a[y + dy][x + dx] = tmp[y + l - 1 - dx][x + dy];
                }
            }
        }else if(ope == 1){
            int y, x, l;
            cin >> y >> x >> l;
            x--; y--;
            assert(x + l <= N && y + l <= N);
            REP(dy, l) REP(dx, l) a[y + dy][x + dx] ^= 1;
        }else if(ope == 2){
            int y;
            cin >> y;
            y--;
            int tmp[100];
            REP(x, N) tmp[x] = a[y][x];
            REP(x, N) a[y][x] = tmp[(x + 1) % N];
        }else if(ope == 3){
            int y;
            cin >> y;
            y--;
            int tmp[100];
            REP(x, N) tmp[x] = a[y][x];
            REP(x, N) a[y][x] = tmp[(x + N - 1) % N];
        }else if(ope == 4){
            int y, x;
            cin >> y >> x;
            x--; y--;
            bool b[100][100] = {};
            b[y][x] = true;
            int dx[4] = {1, 0, -1, 0};
            int dy[4] = {0, 1, 0, -1};
            bool update = true;
            while(update){
                update = false;
                REP(i, N) REP(j, N) if(b[i][j])
                REP(r, 4) if(0 <= i + dy[r] && i + dy[r] < N && 0 <= j + dx[r] && j + dx[r] < N && a[i][j] == a[i + dy[r]][j + dx[r]]){
                    if(!b[i + dy[r]][j + dx[r]]){
                        update = true;
                        b[i + dy[r]][j + dx[r]] = true;
                    }
                }
            }
            REP(i, N) REP(j, N) if(b[i][j]) a[i][j] ^= 1;
        }
    }
        REP(y, N) {
            REP(x, N){
                cout << a[y][x];
                if(x == N - 1) cout << endl;
                else cout << " ";
            }
        }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,j) for(int i=0;i<j;i++)

int main(){
	int S[13] = {};
	int H[13] = {};
	int C[13] = {};
	int D[13] = {};

	int n;
	char gara;

	cin >> n;

	rep(i,n){

		int kawari;
		cin >> gara;
		
		if(gara == 'S'){
			cin >> kawari;
			S[kawari-1] = 1;
		}
		if(gara == 'H'){
			cin >> kawari;
			H[kawari-1] = 1;
		}
		
		if(gara == 'C'){
			cin >> kawari;
			C[kawari-1] = 1;
		}
		
		if(gara == 'D'){
			cin >> kawari;
			D[kawari-1] = 1;
		}
		
	}

	rep(i,13){
		if(S[i] == 0){
			cout << "S " << i+1 << "\n";  
		}
	}

	rep(i,13){
		if(H[i] == 0){
			cout << "H " << i+1 << "\n";  
		}
	}

	rep(i,13){
		if(C[i] == 0){
			cout << "C " << i+1 << "\n";  
		}
	}
	rep(i,13){
		if(D[i] == 0){
			cout << "D " << i+1 << "\n";  
		}
	}

	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N;
int a[10101], b[10101];

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

	cin >> N;
	ll suma = 0;
	ll sumb = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		suma += a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		sumb += b[i];
	}

	ll rem = sumb - suma;
	if (rem < 0) {
		puts("No");
		return 0;
	}

	ll acnt = 0;
	ll bcnt = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] > b[i]) {
			bcnt += a[i]-b[i];
		}
		else if (a[i] < b[i]) {
			if ((b[i] - a[i]) % 2 == 0) {
				acnt += (b[i]-a[i])/2LL;
			}
			else {
				bcnt++;
				acnt += (b[i] + 1 - a[i]) / 2LL;
			}
		}
	}
	if (acnt > rem || bcnt > rem) {
		puts("No");
		return 0;
	}

	if (2LL*(rem - acnt) == rem - bcnt) {
		puts("Yes");
	}
	else puts("No");


	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int cmp(const void* p, const void* q) {
	return *(int*)q - *(int*)p;
}

int main(void) {
	char s[100000] = { 0 };
	int cnt[3] = { 0 };
	int len, flag = 0;

	scanf("%s", s);
	len = strlen(s);
	for (int i = 0; i < len; i++) cnt[s[i] - 97]++;
	qsort(cnt, 3, sizeof(int), cmp);
	if (len % 3 == 0) {
		if (cnt[0] == cnt[1] && cnt[1] == cnt[2])flag = 1;
	}
	else if (len % 3 == 1) {
		if (cnt[0] == cnt[1] + 1 && cnt[1] == cnt[2])flag = 1;
	}
	else {
		if (cnt[0] == cnt[1] && cnt[1] == cnt[2] + 1) flag = 1;
	}
	if (flag)printf("YES");
	else printf("NO");
	return 0;
}


Measured memory_bytes: 256
s = str(input())
a = s.count("N")
b = s.count("W")
c = s.count("S")
d = s.count("E")
if (a  == 0 and c != 0) or (c  == 0 and a != 0) or (b  == 0 and d != 0) or (d  == 0 and b != 0):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	string S;
	cin >> S;
	auto result = 0;
	for (auto i = 0; i < S.length() / 2; ++i)
	{
		if (S[i] != S[S.length() - i - 1])
		{
			++result;
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

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

void run(void){
  char *s=(char *)malloc(sizeof(char)*(100000+1));
  char *t=(char *)malloc(sizeof(char)*(100000+1));
  scanf("%s",s);
  scanf("%s",t);
  int slen=0;
  while(s[slen]!='\0') slen++;
  int tlen=0;
  while(t[tlen]!='\0') tlen++;
  int *scnt=(int *)malloc(sizeof(int)*(slen+1));
  int *tcnt=(int *)malloc(sizeof(int)*(tlen+1));
  scnt[0]=0;
  int i;
  for(i=0;i<slen;i++){
    scnt[i+1]=(scnt[i]+(s[i]=='A'?1:-1)+3)%3;
  }
  tcnt[0]=0;
  for(i=0;i<tlen;i++){
    tcnt[i+1]=(tcnt[i]+(t[i]=='A'?1:-1)+3)%3;
  }
  int q;
  scanf("%d",&q);
  while(q--){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int ans=(scnt[b]-scnt[a-1]+3)%3==(tcnt[d]-tcnt[c-1]+3)%3;
    printf("%s\n",ans?"YES":"NO");
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

vector<ll> enum_divisors(ll N){
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i){
        if (N % i == 0){
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int digit(ll a){
    int res = 0;
    while(a > 0){
        a /= 10;
        res++;
    }
    return res;
}

int f(ll a, ll b){
    return max(digit(a),digit(b));
}


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

    vector<ll> divisors = enum_divisors(N);

    int ans = 100000000;
    for(auto divisor : divisors){
        ll a = divisor;
        ll b = N/divisor;
        ans = min(ans, f(a,b));
    }

    cout << ans << endl;

}

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

int main() {
  int n;
  ll p;

  cin >> n;
  vector<int> a(n+1);
  vector<int> ans(n+1);
  rep(i,n+1) ans[i]=0;

  for(int i=2;i<=n;++i) {
    cin >> a[i];
    ans[a[i]]++;
  }
  for(int i=1;i<n+1;++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long double ld;
struct pnt{
	ld x, y;
	pnt(){}
	pnt(ld x, ld y) : x(x), y(y) {}
	pnt operator+(pnt b){
		return pnt(x + b.x, y + b.y);
	}
	pnt operator-(pnt b){
		return pnt(x - b.x, y - b.y);
	}
	ld operator%(pnt b){
		return x * b.y - b.x * y;
	}
};
ld area(pnt a, pnt b, pnt c){
	b = b - a;
	c = c - a;
	return abs(b % c);
}
ld dist(pnt a, pnt b){
	a = b - a;
	return hypot(a.x, a.y);
}
int main(){
	int n, k = 1;
	ld res = 0;
	cin>>n;
	vector<pnt> poly(n);
	forn(i, n) cin>>poly[i].x>>poly[i].y;
	//poly.push_back(poly[0]);
	while(area(poly[n - 1], poly[0], poly[(k + 1) % n]) > area(poly[n - 1], poly[0], poly[k])) k++;
	forn(i, n){
		res = max(res, dist(poly[i], poly[k]));
		while(area(poly[i], poly[(i + 1) % n], poly[(k + 1) % n]) > area(poly[i], poly[(i + 1) % n], poly[k])){
			k++;
			k %= n;
			res = max(res, dist(poly[i], poly[k]));
		}
	}
	cout<<fixed<<setprecision(6)<<res<<"\n";
	return 0;
}


Measured memory_bytes: 5532
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int x,y;
    cin >> x >> y;
    vector<int> g = {-1,0,1,0,2,0,2,0,0,2,0,2,0};
    if(g[x]==g[y]){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


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

string rotate(string s) {
	return s.substr(1) + s[0];
}

int main() {
	string s,t;
	cin >> s >> t;
	int n = s.size();
	bool flag = true;
	for (int i = 0; i < n; i++) {
		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
		s = rotate(s);

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


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

int main() {
	string str_1;
	string str_2;
	cin >> str_1 >> str_2;
	bool yes = false; // default to yes
	int len_1 = str_1.size();
	int len_2 = str_2.size();
	for (int i = 0;i != len_1;++i) {
		if (str_1[i] == str_2[0]) {
			int k = i;
			for (int j = 0;j < len_2;++j) {
				if (k == len_1) {
					k = 0;
				}
				if (str_1[k] == str_2[j]) {
					++k;
				} else {
					break;
				}
				if (j == len_2 - 1) {
					yes = true;
				}
			}
		}
	}
	cout << (yes ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3180
import java.util.Scanner;
public class Main {
	int kanadasine[]=new int[100];
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		String S=stdIn.next();
		if(N%2==1)
			System.out.println("No");
		else
			if(S.substring(0,N/2).equals(S.substring(N/2,N)))
				System.out.println("Yes");
			else
				System.out.println("No");
	}
}


Measured memory_bytes: 21844