akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
    
int main(void) {
    u_int N;    // the number of integer
    std::vector<std::vector<u_long>> dp;
    std::vector<u_int> seq;
       
    std::cin >> N;
    seq.reserve(N);
    dp.resize(N);
    for (u_int i = 0; i < N; ++i) {
        u_int tmp;
        std::cin >> tmp;
        seq.push_back(tmp);
        dp[i].resize(21, 0);
    }
       
    // solve by dp
    dp[0][seq[0]] = 1;  // initialization
    for (u_int i = 1; i < N - 1; ++i) {
        for (u_int j = 0; j < 21; ++j) {
            if (dp[i - 1][j] > 0) {
                if (j + seq[i] <= 20) {
                    dp[i][j + seq[i]] += dp[i - 1][j];
                }
                if (j >= seq[i]) {
                    dp[i][j - seq[i]] += dp[i  -1][j];
                }
            }
        }
    }
    std::cout << dp[N - 2][seq[N - 1]] << std::endl;
    
    return 0;
}


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

int main(){
	int N,M;
	cin>>N>>M;
	long ans=1;
	if(N==M){
		for(int i=0;i<N;++i){
			ans*=(long)(N-i);
			ans%=(long)(pow(10,9)+7);
			ans*=(long)(M-i);
			ans%=(long)(pow(10,9)+7);
		}
		ans*=2;
		ans%=(long)(pow(10,9)+7);
	}
	else if(abs(N-M)==1){
		for(int i=0;i<N;++i){
			ans*=(long)(N-i);
			ans%=(long)(pow(10,9)+7);
		}
		for(int i=0;i<M;++i){
			ans*=(long)(M-i);
			ans%=(long)(pow(10,9)+7);
		}
	}
	else ans=0;
	cout<<ans<<endl;
}


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


int main(){
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a,a+N,greater<int>());
    int Alice =0;
    int Bob = 0;
    for (int i = 0; i < N; i++)
    {
        if(i%2 == 0) Alice += a[i];
        else Bob += a[i];
    }
    cout << Alice - Bob << endl;
    return 0;
}

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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long long B,a,b,c=0,k,d=0,i,n,j,temp,ans=1;
	    cin>>n;
	    long long arr[n+1]={0};
	    for(i=0;i<n;i++)
	    {
	        cin>>a;
	        arr[a]++;
	    }
	    if(n%2==0)
	    {
	        for(i=1;i<n;i+=2)
	        {
	            if(arr[i]==2)
	            {
	                ans*=2;
	                ans=ans%(1000000007);
	            }
	            else 
	            {
	                ans=0;
	                break;
	            }
	        }
	    }
	    else
	    {
	        for(i=0;i<n;i+=2)
	        {
	            if(arr[i]==2)
	            {
	                ans*=2;
	                ans=ans%(1000000007);
	            }
	            else if(i!=0 && arr[i]!=2)
	            {
	                ans=0;
	                break;
	            }
	        }
	    }
	    cout<<ans;
    }
}


Measured memory_bytes: 1024
import math

N = int(input())

prev_t, x, y = 0, 0, 0
for _ in range(N):
    t, t_x, t_y = map(int, input().split())

    m_t, m_x, m_y = t - prev_t, math.fabs(t_x - x), math.fabs(t_y - y)
    if m_x > m_t or m_y > m_t or math.fabs(m_t - (m_x + m_y)) % 2 == 1:
        print("No")
        exit()

    prev_t, x, y = t, t_x, t_y

print("Yes")

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

const int COUNT = 6;


class Dice
{
public:
	int num[6];

public:
	Dice();
	void play_dice(string);
	void play(int, int, int, int);
	void print_(int x) {printf("%d\n", num[x]);}
	void to_top_and_front(int, int);
};

Dice::Dice()
{
	for (int i = 0; i < COUNT; ++i)
	{
		cin >> num[i];
		
	}
}


void Dice::play_dice(string s)
{
	if(s == "E") {play(0, 2, 5, 3); }
		
	if(s == "N") {play(0, 4, 5, 1); }
		
	if(s == "S") {play(0, 1, 5, 4); }
	
	if(s == "W") {play(0, 3, 5, 2); }
}

void Dice::play(int a, int b, int c, int d)
{
	int temp;
	temp = num[d]; num[d] = num[c]; num[c] = num[b]; num[b] = num[a]; num[a] = temp;
}


void Dice::to_top_and_front(int top, int front)
{
	string str[7] = {"N", "N", "N", "W", "N", "N", "N"};
	for (int i = 0; i < 7; ++i)
	{
		if(front == num[1]) break;
		play_dice(str[i]);
	}
	for (int k = 0; k < 4; k++)
	{
		if(top == num[0]) break;
		play_dice("W");
	}
}

bool compare(Dice a, Dice b)
{
	a.to_top_and_front(b.num[0], b.num[1]);
	
	for (int i = 0; i < COUNT; ++i)
	{
		if (a.num[i] != b.num[i])
		{
			return false;
		}
	}
	return true;
}



int main(int argc, char const *argv[])
{
	Dice *cs;
	int times;

	cin >> times;

	cs = new Dice[times];
	
	for (int i = 0; i < times; ++i)
	{
		for (int k = i+1; k < times; ++k)
		{
			if(compare(cs[i], cs[k]))
			{
				delete[] cs;
				printf("No\n");
				return 0;
			}
		}	
	}
	
	delete[] cs;
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1168
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int [N];
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		int max=a[0],min=a[0];
		for(int i=1;i<N;i++) {
			if(a[i]>max)max=a[i];
			else if(a[i]<min)min=a[i];
		}
		System.out.print(max-min);
		sc.close();
	}

}

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

set<int> dp;

class eightPuzzle {
 public:
    int table[3][3];
    int x, y;
};

int UP = 0, LEFT = 1, RIGHT = 2, DOWN = 3;
eightPuzzle move(eightPuzzle p, int dir) {
    eightPuzzle newp;
    for (int i = 0; i < 3; i++) {
        memcpy(newp.table[i], p.table[i], sizeof(p.table[i]));
    }
    newp.x = p.x;
    newp.y = p.y;

    if (dir == UP && newp.y + 1 < 3) {
        swap(newp.table[newp.y][newp.x], newp.table[newp.y + 1][newp.x]);
        newp.y++;
    } else if (dir == LEFT && newp.x + 1 < 3) {
        swap(newp.table[newp.y][newp.x], newp.table[newp.y][newp.x + 1]);
        newp.x++;
    } else if (dir == RIGHT && newp.x - 1 >= 0) {
        swap(newp.table[newp.y][newp.x], newp.table[newp.y][newp.x - 1]);
        newp.x--;
    } else if (dir == DOWN && newp.y - 1 >= 0) {
        swap(newp.table[newp.y][newp.x], newp.table[newp.y - 1][newp.x]);
        newp.y--;
    }
    return newp;
}

// 8パズルをハッシュ化する関数
int eightHash(eightPuzzle p) {
    int ret = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            ret += p.table[i][j] * pow(10, 3 * i + j);
        }
    }
    return ret;
}

// ゴールに到達したかを判定する
bool goal(eightPuzzle p) {
    bool flag = true;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (p.table[i][j] != (3 * i + j + 1) % 9) flag = false;
            if (!flag) break;
        }
        if (!flag) break;
    }
    return flag;
}


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

    eightPuzzle p;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> p.table[i][j];
            if (p.table[i][j] == 0) {
                p.x = j;
                p.y = i;
            }
        }
    }
    if (goal(p)) {
        cout << 0 << endl;
        return 0;
    }
    int ehash = eightHash(p);
    dp.insert(ehash);
    queue<pair<eightPuzzle, int>> q;
    q.push(make_pair(p, 0));
    while (true) {
        int cnt;
        eightPuzzle ep;
        tie(ep, cnt) = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            eightPuzzle np = move(ep, i);
            if (goal(np)) {
                cout << cnt + 1 << endl;
                return 0;
            }
            int h = eightHash(np);
            if (dp.find(h) == dp.end()) {
                q.push(make_pair(np, cnt + 1));
                dp.insert(h);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 12256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H=INT_MAX;
  int W=INT_MAX;
  while(H+W!=0){
    cin>>H>>W;
    if(H+W==0)break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(i==0||i==H-1){
          cout<<'#';
        }else{
          if(j==0||j==W-1){
            cout<<'#';
          }else{
            cout<<'.';
          }
        }
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3072
len = gets.to_i
height_list = gets.split(' ').map(&:to_i)

result = height_list.inject(1){|lim, h|
  if h >= lim
    if h > lim
      h-1
    else
      lim
    end
  else
    break
  end
}

puts(result ? 'Yes' : 'No')

Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORI(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, d, a[12][12];
bool checksq (int x) {
    int k = (int)sqrt(x);
    if (k * k == x) return true;
    return false;
}
int main() {
    cin >> n >> d;
    FOR(i, 0, n-1) FOR(j, 0, d-1) cin >> a[i][j];
    int ans = 0;
    FOR(i, 0, n-1) FOR(j, 0, i-1) {
        int sum = 0;
        FOR(z, 0, d-1) {
            sum += (a[i][z]-a[j][z])*(a[i][z]-a[j][z]);
        }
        ans += checksq(sum);
    }
    cout << ans << endl;
    return 0;
}

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

typedef struct {
	int key, id;
} data;

typedef struct {
	data *obj;
	int size;
} max_heap;

void push(data x, max_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key > h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(max_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key > h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key > h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

typedef struct {
	int *par, *size, *height, *flag;
} UF_forest;

void UF_initialize(UF_forest *F, int n)
{
	int i;
	F->par = (int*)malloc(sizeof(int) * (n + 1));
	F->size = (int*)malloc(sizeof(int) * (n + 1));
	F->height = (int*)malloc(sizeof(int) * (n + 1));
	F->flag = (int*)malloc(sizeof(int) * (n + 1));
	for (i = 1; i <= n; i++) {
		F->par[i] = i;
		F->size[i] = 1;
		F->height[i] = 1;
		F->flag[i] = 0;
	}
}

void UF_merge(UF_forest *F, int u, int v)
{
	for (; F->par[u] != u; u = F->par[u]);
	for (; F->par[v] != v; v = F->par[v]);
	if (u == v) return;
	else if (F->height[u] > F->height[v]) {
		F->par[v] = u;
		F->size[u] += F->size[v];
		F->flag[u] |= F->flag[v];
	} else {
		F->par[u] = v;
		F->size[v] += F->size[u];
		F->flag[v] |= F->flag[u];
		if (F->height[u] == F->height[v]) F->height[v]++;
	}
}

int UF_root(UF_forest *F, int v)
{
	for (; F->par[v] != v; v = F->par[v]);
	return v;
}

int main()
{
	int i, N, H, W, A[100001], R[100001], C[100001];
	scanf("%d %d %d", &N, &H, &W);
	for (i = 1; i <= N; i++) scanf("%d %d %d", &(R[i]), &(C[i]), &(A[i]));
	
	data d;
	max_heap h;
	h.size = 0;
	h.obj = (data*)malloc(sizeof(data) * (N + 1));
	for (i = 1; i <= N; i++) {
		d.key = A[i];
		d.id = i;
		push(d, &h);
	}
	
	int r[2];
	long long ans = 0;
	UF_forest F;
	UF_initialize(&F, H + W);
	while (h.size > 0) {
		d = pop(&h);
		r[0] = UF_root(&F, R[d.id]);
		r[1] = UF_root(&F, C[d.id] + H);
		if (r[0] != r[1] && F.flag[r[0]] + F.flag[r[1]] <= 1) {
			ans += d.key;
			UF_merge(&F, r[0], r[1]);
		} else if (F.flag[r[0]] == 0) {
			ans += d.key;
			F.flag[r[0]] = 1;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n, m;
    cin >> n >> m;
    vint a(n), b(n);
    vector<pint> ab(n);
    vector<priority_queue<int>> pque(m+1);
    REP(i, n)
    {
        int a, b;
        cin >> a >> b;
        if (a <= m)
            pque[a].emplace(b);
    }
    int now = 1, kazu = 0;
    ll ans = 0;
    priority_queue<int> que;
    REP(i, m)
    {
        while (pque[i+1].size() != 0)
        {
            que.emplace(pque[i + 1].top());
            pque[i + 1].pop();
        }
        int ma=0;
        if (que.size() != 0)
        {
            ma = que.top();
            que.pop();
        }
        ans += ma;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long K;
	cin>>K;
	long long sum=0;
	for(int a=1;a<=K;a++)
	for(int b=1;b<=K;b++)
	for(int c=1;c<=K;c++)
		sum+=gcd(gcd(a,b),c);
		
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m;int a[224514],b[224514];
map<int,int>mp;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	cin>>m;
	rep(i,m)cin>>b[i];
	rep(i,n)mp[a[i]]++;
	rep(i,m){
		if(mp[b[i]])mp[b[i]]--;
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


Measured memory_bytes: 15872
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define fastestiointhewest   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

int gcdf[100005],gcdb[100005];
void solve()
{
   int n; cin>>n;
   int a[n+1];
   rep(i,1,n+1) cin>>a[i];
   int ans=-1;
   gcdf[1]=a[1],gcdb[n]=a[n];
   rep(i,2,n+1)
   {
      gcdf[i]=__gcd(gcdf[i-1],a[i]);
      gcdb[n-i+1]=__gcd(gcdb[n-i+2],a[n-i+1]);
   }
   rep(i,2,n)
   {
     ans=max(ans,__gcd(gcdf[i-1],gcdb[i+1]));
   }
   ans=max(ans,max(gcdf[n-1],gcdb[2]));
   ans=max(ans,gcdf[n]);
   cout<<ans;
} 
int main()
{   
    fastestiointhewest;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 1408
def examD():
    N = I()
    A = LI()
    ans = 0; l = 0; r = 0
    cur = 0
    while l < N:
        while r < N:
            if cur&A[r]==0:
                cur +=A[r]
                ans += (r-l+1)
            else:
                break
            r += 1
#        print(l,r,ans)
        cur ^=A[l]
        l +=1
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


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

int main() {
	int N;
	cin >> N;
	string ans = "";
	while (N!= 0) { 
		int r = N % 2;
		if (r < 0) {
			r += 2;
		}
		N = (N - r) / (-2);

		ans += (char)(r + '0');
	}
	reverse(ans.begin(),ans.end());
	if (ans == "") {
		ans = "0";
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int unsigned  long long
#define N 6666666
int su[N],cnt;
int n;
bool isprime[N];
void prime(){
    cnt=1;
    memset(isprime,1,sizeof(isprime));//初始化认为所有数都为素数
    isprime[0]=isprime[1]=0;//0和1不是素数
    for(int i=2;i<=N;i++){
        if(isprime[i])
            su[cnt++]=i;//保存素数i
        for(int  j=1;j<cnt&&su[j]*i<N;j++){
            isprime[su[j]*i]=0;//筛掉小于等于i的素数和i的积构成的合数
        }
    }
}
int mp[N]={0};
int slove(int num){
	int l=0,r=1e15;
	int res=0;
	while(l<=r){
		int mid=(l+r)/2;
		int temp=(mid*(mid+1))/2;
		if(temp<=num){
			res=mid;
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return res;
}
signed main(){
    prime();
   // cout<<su[cnt-1];
    int m;
    cin>>m;int ans=0;
    for(int i=1;i<cnt;i++){
    	if(m%su[i]==0){
    		int sum=0;
			while(m%su[i]==0){
	    		sum++;m/=su[i];
	    		if(m==1) break;
			}
			if(sum)
				ans+=slove(sum);
		}
    	if(m==1) break;
	}
	if(m>1) ans++; 
	cout<<ans;
    return 0;
}

Measured memory_bytes: 13708
import sys
readline = sys.stdin.readline

# 0-indexでやる

D = int(readline())
C = list(map(int,readline().split())) # 満足度の下がりやすさ
S = [None] * D
sortS = [None] * D
for i in range(D):
  s = list(map(int,readline().split()))
  S[i] = s.copy()
  for j in range(len(s)):
    s[j] = (s[j],j)
  sortS[i] = sorted(s, key = lambda x:x[0], reverse = True)

def make_ans(D,C,limiter = 4, threshold = 2, balance = 0.5, check_limit = False):
  ans = []
  last_submit = [0] * 26
  for i in range(D):
    info = sortS[i]
    
    if check_limit:
    
      # limiter回以上提出がないものがあれば、threshold回を超えたもののうちCの値が高いものを提出
      if i - min(last_submit) >= limiter:
        ind = -1
        for j in range(len(last_submit)):
          if i - last_submit[j] >= threshold:
            if ind == -1:
              ind = j
            else:
              if C[ind] < C[j]:
                ind = j
        ans += [ind]
        last_submit[ind] = i
        continue
      
    topval = info[0][0]
    for j in range(len(info)):
      val = info[j][0]
      if check_limit:
        if val < topval * (balance):
          continue # 最高値の半分になるのであればやめよう
      index = info[j][1]
      if i - last_submit[index] < 26:
        continue
      ans += [index]
      last_submit[index] = i
      break
    else:
      ans += [info[0][1]]
  return ans

def calc_score(arr):
  point = 0
  last_submit = [0] * 26
  for i in range(len(arr)):
    # i日目
    point += S[i][arr[i]]
    for j in range(len(last_submit)):
      point -= (i - last_submit[j]) * C[j]
  return point
      
ans = make_ans(D,C)
#print(ans)
best = calc_score(ans)
for limiter in range(28,70):
  for threshold in range(26, limiter):
    for balance in (0.6,0.65,0.7,0.75,0.8,0.85,0.9):
      new_ans = make_ans(D,C,limiter,threshold,balance,True)
      new_score = calc_score(new_ans)
      if new_score > best:
        ans = new_ans
        best = new_score
  
def show(arr):
  for a in arr:
    print(a + 1)
    
show(ans)


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

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

  vector<vector<int>> p(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> p[i][j];
    }
  }

  vector<int> square(128);
  for (int i = 0; i < 128; i++) {
    square[i] = i * i;
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      int x = 0;
      for (int k = 0; k < d; k++) {
        int t = p[i][k] - p[j][k];
        x += t * t;
      }
      if (find(begin(square), end(square), x) != end(square)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e6;
typedef long long ll;
int a[10],c[10],s[10];
int n,m;
int main()
{
    int flag=0,cnt=-2;
    scanf("%d%d",&n,&m);
    memset(a,0,sizeof(a));
    memset(c,0,sizeof(c));
    if(n==1&&m==0){
        flag=1;
        cnt=0;
    }
    for(int i=0;i<m;i++){
        scanf("%d%d",&s[i],&c[i]);
        if(s[i]==1&&n>1&&c[i]==0){
            flag=1;
            cnt=-1;
        }
        else{
            for(int j=0;j<i;j++){
                if(s[j]==s[i]&&c[i]!=c[j]){
                    flag=1;
                    cnt=-1;
                }
            }
        }
        a[s[i]-1]=c[i];
    }
    if(n>1&&a[0]==0) a[0]=1;
    if(cnt==-1||cnt==0){
        printf("%d",cnt);
    }
    if(flag==0){
        for(int i=0;i<n;i++){
            printf("%d",a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=200000+5;
int a[MAXN+5];
int n,x;
int main()
{
	scanf("%d%d",&n,&x);
	if(x==1||x==2*n-1)
	{
		printf("No\n");
	}
	else
	{
		a[n-1]=x-1;
		a[n]=x;
		a[n+1]=x+1;
		int now=1;
		for(int i=1;i<=2*n-1;i++)
		{
			if(!a[i])
			{
				while(abs(now-x)<=1)
					now++;
				a[i]=now++;
			}
		}
		printf("Yes\n");
		for(int i=1;i<=2*n-1;i++)
			printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 2304
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define ll long long
#define ull long long unsigned
using namespace std;
#define foru(i,a,n) for (int i=(a); i<=(n); i++)
#define ford(i,n,a) for (int i=(n); i>=(a); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define bit1cnt(x) (__builtin_popcountll(x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define Pi 3.14159265358979
#define ii pair<int,int>
#define LL pair<ll,ll>
#define vi vector<int>
string s;
int x, y, cntF, cntT;
vi dX, dY;
int cal(vi seg, int Dich, int type){
    unordered_map <int,int> ans;
    ans[0] = 1;
    rep(i, seg.size()){
        unordered_map <int,int> tmp;
        for(auto x : ans){
            tmp[x.first + seg[i]] = 1;
            if(i==0 && type==1) continue;
            tmp[x.first - seg[i]] = 1;
        }
        ans = tmp;
    }
    return ans[Dich];
}
int main(){
    cin >>s >>x >>y;
    ///Move with X and with Y
    int len = 0, dir = 1;
    s +='T';    ///Process last 'F' in S
    rep(i, s.size()){
        if(s[i]=='F') len++;
        else{
            if(dir) dX.push_back(len); else dY.push_back(len);
            dir = !dir;
            len = 0;
        }
    }

    if(cal(dX, x, 1) && cal(dY, y, 0))
        cout <<"Yes";
    else
        cout <<"No";
    return 0;
}


Measured memory_bytes: 768
<?php
fscanf(STDIN,"%d",$N);
// max関数を使いたいので配列で取得
$p = [];
for ($i = 0; $i < $N; $i++) {
// max関数で最大値を出力したい
fscanf(STDIN,"%d",$p[$i]);
// var_dump($p[$i]);
}
// echo gettype($p);
// echo max($p);
echo array_sum($p)-(max($p) / 2);

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

void solve(){
string s;
cin>>s;
ll sum=0;
for(int i=0;i<(int)s.size();i++)
	{
		sum+=(s[i]-'0');
	}
	if(sum%9==0) cout<<"Yes";
	else cout<<"No";
	
}
int main() {
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int place[n];
  for(int i=0;i<n;i++){
    place[a[i]-1]=i;
  }
  int count=1;
  int res=1;
  for(int i=0;i<n-1;i++){
    if(place[i]<place[i+1]) count++;
    res=max(res,count);
    if(place[i]>place[i+1]) count=1;
  }
  cout << n-res << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long


const double pi = acos(-1.0);

LL n;
int a[200005], c[200005];
LL sz[200005], r[200005];
deque<int> p[200005];
vector<int> e[200005];

void dfs(int u, int f) {
  sz[u] = 1;
  int l = p[c[u]].size();
  for (auto v : e[u]) {
    if (v == f) continue;
    dfs(v, u);
    LL x = 0;
    while((int)p[c[u]].size() > l) {
      x += sz[p[c[u]].back()];
      p[c[u]].pop_back();
    }
    if (sz[v] - x > 0) {
      r[c[u]] += (sz[v] - x) * (sz[v] - x - 1) / 2 + sz[v] - x;
    }
    //cout << u << " " << c[u] << " " << r[c[u]] << endl;
    sz[u] += sz[v];
  }
  p[c[u]].push_back(u);
}

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    c[i]--;
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--,v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(0, 0);
  for (int i = 0; i < n; i++) {
    LL x = 0;
    while(p[i].size() > 0) {
      x += sz[p[i].front()];
      p[i].pop_front();
    }
    if (n - x > 0) {
      r[i] += (n - x) * (n - x - 1) / 2 + n - x;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << n * (n - 1) / 2 + n - r[i] << endl;
  }
  return 0;
}

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

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

    vector<int> d(n);
    rep(i, 0, n) cin >> d[i];

    set<int> st;
    rep(i, 0, n) {
        st.emplace(d[i]);
    }

    cout << st.size() << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
char = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

ans = []
while N:
    i = N%26
    ans.append(char[i-1])
    N = (N-1)//26
print(''.join(ans[::-1]))

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,m;ll fact[1000005];
int qpow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res=(ll)res*x%mod;
        x=(ll)x*x%mod;
        y>>=1;
    }
    return res;
}
int inv(int x){return qpow(x,mod-2);}
int C(int x,int y){
    return fact[y]*inv(fact[x])%mod*inv(fact[y-x])%mod;
}
int main()
{
    scanf("%d%d",&n,&m);
    if((n+m)%3) {puts("0");return 0;}
    if(n*2<m||m*2<n) {puts("0");return 0;}
    int step=(n+m)/3;n-=step;m-=step;
    fact[0]=fact[1]=1;rep(i,2,n+m) fact[i]=fact[i-1]*i%mod;
    printf("%d\n",C(n,n+m));
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 101;
int n, d[N];
VI e[N];

void update(int now, int past, int v){
    d[now] = max(d[now], v);
    for (int next : e[now]){
        if (next == past) continue;
        update(next, now, v + 1);
    }
}

VL dfs(int now, int past){
    VL deg;
    ll c = 0;
    for (int next : e[now]){
        if (next == past) continue;
        c++;
        VL tmp = dfs(next, now);
        if (tmp.size() > deg.size()) deg.swap(tmp);
        REP(i,tmp.size()){
            deg[i] = max(deg[i], tmp[i]);
        }
    }
    VL ret;
    if (c) ret.push_back(c);
    for (int x : deg) ret.push_back(x);
    return ret;
}

ll calc_v(int u){
    ll ret = 1;
    VL deg = dfs(u, -1);
    for (ll x : deg) ret *= x;
    return ret;
}

ll calc_e(int u, int v){
    ll ret = 2;
    VL deg = dfs(u, v);
    VL deg2 = dfs(v, u);
    if (deg2.size() > deg.size()) deg.swap(deg2);
    REP(i,deg2.size()) deg[i] = max(deg[i], deg2[i]);
    for (ll x : deg) ret *= x;
    return ret;
}

int main() {
    int n;
    cin >> n;
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    if (n == 2){
        cout << "1 2" << endl;
        return 0;
    }

    REP(i,n){
        if (e[i].size() == 1){
            update(i, -1, 1);
        }
    }

    int mi = 1e9;
    VI v;
    REP(i,n){
        if (d[i] == mi){
            v.push_back(i);
        }else if (d[i] < mi){
            mi = d[i];
            v.clear();
            v.push_back(i);
        }
    }

    ll ans = 1e18 + 1e9;

    if (v.size() == 1){
        int x = v[0];
        ans = calc_v(x);
        for (int next : e[x]){
            ans = min(ans, calc_e(x, next));
        }
    }else{
        ans = calc_e(v[0], v[1]);
        mi--;
    }

    cout << mi << " " << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i;
	cin>>t>>i;
	cout<<t*i<<endl;


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main() {
	int cards[4][13]={0};
	int num, i, x, y;
	char ch;
	cin >> num;
	for (i = 0; i < num; i++) {
		cin >> ch >> y;
		if (ch == 'S') x = 0;
		else if (ch == 'H') x = 1;
		else if (ch == 'C') x = 2;
		else x = 3;
		cards[x][y - 1] = 1;
	}
	int j, k;
	for (j = 0; j < 4; j++) {
		for (k = 0; k < 13; k++) {
			if (cards[j][k] != 1) {
				if (j == 0) cout << "S " << k + 1 << endl;
				else if (j == 1) cout << "H " << k + 1 << endl;
				else if (j == 2) cout << "C " << k + 1 << endl;
				else cout << "D " << k + 1 << endl;
			}
		}
	}
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  string s;
  cin >> n >> s;
  unordered_set<char> us_mae;
  unordered_set<char> us_ato;

  int ans = 0;
  for (int i = 1; i < s.length(); ++i) {
    int tmpans = 0;
    us_mae.clear();
    us_ato.clear();
    for (int j = 0; j < i; ++j) {
      us_mae.insert(s[j]);
    }
    for (int j = i; j < s.length(); ++j) {
      us_ato.insert(s[j]);
    }
    for (auto x : us_ato) {
      if (us_mae.find(x) != us_mae.end()) tmpans++;
    }
    ans = max(ans, tmpans);
  }

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


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int n, z, w;
V<int> a(2010);
V<V<int>> dp(2, V<int> (2010, -1));
const int INF = 2e9;

int dfs (int turn, int now) {//now枚とった状態から
    if (dp[turn][now] != -1) return dp[turn][now];
    //printf("%d %d\n", turn, now);

    if (turn == 0) {//Xさん
        int y;
        if (now == 0) y = w;
        else y = a[now-1];
        dp[0][now] = -INF;
        chmax(dp[0][now], abs(a[n-1] - y));//全部とってゲーム終了
        for (int i = now+1; i < n; i++) chmax(dp[0][now], dfs(1, i));
        return dp[0][now];
    }
    else {//Yさん
        int x;
        if (now == 0) x = z;
        else x = a[now-1];
        dp[1][now] = INF;
        chmin(dp[1][now], abs(a[n-1] - x));//全部とってゲーム終了
        for (int i = now+1; i < n; i++) chmin(dp[1][now], dfs(0, i));
        return dp[1][now];
    }
}

int main () {
    cin >> n >> z >> w;
    rep(i, n) cin >> a[i];
    dfs(0, 0);
    cout << dp[0][0] << endl;
    /*
    rep(i, 2) {
        rep(j, n+1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N; cin >> N;

	int a = N / 100;
//	int b = (N / 10) % 10;
	int c = N % 10;

	bool res = (a == c);
	cout << (res ? "Yes" : "No") << endl;	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int lim = 1e18;
typedef long long ll;
ll x2, y2, x3, y3;
ll s;
ll un,a,b;
int k;
//1000000000000000000
ll powerMod(ll n, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1) res = res * n;
		n = n * n;
		b >>= 1;
	}
	return res;
}

int main() {
	ll s;
	cin >> s;
	if (s >= 1000000000000000000) {
		printf("0 0 1000000000 0 0 1000000000\n");
		return 0;
	}
	if (s <= 1000000000) {
		printf("0 0 1 0 0 %lld\n", s);
		return 0;
	}
	un = 1000000000;
	a = s/un;
	b = s % un;
	b = un - b;
	x3 = a+1;
	y2 = un;
	x2 = 1;
	y3 = b;
	printf("0 0 %lld %lld %lld %lld\n", x2, y2, x3, y3);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<set>
using namespace std;

int n, m;
int cnt[22], v[22][22];
int p[22];
int cur[22];
set<int> st;
int ans;

void record() {
	int mask = 0;
	for(int i=0;i<m;i++)
		if((p[i]+cur[i])%2) mask += (1<<i);
	if(mask==0) ans++;
	//printf("- %d\n", mask);
	st.insert(mask);
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++) {
		scanf("%d", &cnt[i]);
		for(int j=0;j<cnt[i];j++) {
			scanf("%d", &v[i][j]);
			v[i][j]--;
		}
	}
	for(int i=0;i<m;i++) scanf("%d", &p[i]);
	
	ans = 0;
	st.clear();
	for(int i=0;i<(1<<n);i++) {
		memset(cur, 0, sizeof cur);
		for(int j=0;j<m;j++)
			for(int k=0;k<cnt[j];k++) {
				int id = v[j][k];
				if (i&(1<<id)) cur[j] ^= 1;
			}
		//printf("%d\n", i);
		record();
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
 	string s;
  cin>>s;
  	int cb=0;
  int ca=0;
  for(int i=0 ;i < 3;i++)
    	if(s[i]=='A')ca++;
  		else cb++;
  
  if(ca>0 && cb>0)
    	cout<<"Yes\n";
  else	
    cout<<"No\n";
}

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

using namespace std;
inline int read() {
    int x = 0;
    bool f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    if (f) return x;
    return 0 - x;
}
typedef long long ll;
const int maxn = 100010;
const int inf = 0x3f3f3f3f;
const ll mod = 1000000000 + 7;


int main() {
    int h, a;
    h = read(), a = read();
    cout << (h + a - 1) / a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>
#define init(type,var) type var;cin>>var;
#define vinit(vtype,var,n) vtype var(n);loop(i,0,n)cin>>var[i];
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull MOD = 1000000007ULL;
const ull INF = (ull)(-1LL);

int main(void){
	init(ull, m);
	init(ull, d);

	ull c = 0;
	for (ull i = 1; i <= m; i++){
		for (ull j = 1; j <= d; j++){
			ull d1 = j % 10;
			ull d10 = j / 10;
			if (d1 >= 2 && d10 >= 2 && d1 * d10 == i)c++;
		}
	}

	outl(c);

	return 0;
}

Measured memory_bytes: 256
#=
C:
- Julia version: 0.5.2
- Author: abap
- Date: 2020-01-18
=#
N = parse(readline())
S = readline()
s_back = 'P'
count  =0
for i in 1:N
	s_now = S[i]
	if s_now == s_back
		count += 1
	end
	s_back = s_now
end
println(N - count)

Measured memory_bytes: 116488
import itertools
N,M,Q=list(map(int,input().split()))
src=[]
for q in range(Q):
  src.append(list(map(int,input().split())))
ML=[n+1 for n in range(M)]
X=list(itertools.combinations_with_replacement(ML,N))
L=[]
for x in X:
  a=0
  for s in src:
    if x[s[1]-1] - x[s[0]-1] == s[2]:
      a+=s[3]
  L.append(a)
print(max(L))

Measured memory_bytes: 25352
#include <stdio.h>

int MAX_prime = 1000000;
int a[2000000];

int main(void)
{
	int dummy = 0;
	int n,ans,b,d;
	for(int i = 0; i < MAX_prime; i++){
		a[i] = 1;
	}
	for(int i = 2; i < MAX_prime; i++){
		if(a[i]){
			for(int j = i * 2;j < MAX_prime; j = j + i){
					a[j] = 0;
			}
		}
	}
	a[1] = 0;
	/*
	scanf("%d",&n);
	while(n != 0){
		ans = 0;
		for(int i = n + 1; i <= 2 * n; i++){
			if(a[i]){
				ans++;
			}
		}
		printf("%d\n",ans);
		scanf("%d",&n);
	}
	*/
	scanf("%d %d %d",&b,&d,&n);
	while(n != 0){
		dummy = b;
		while(n > 0){
			if(a[dummy]){
				n--;
			}
			if(n == 0){
				ans = dummy;
			}
			dummy += d;
		}
		printf("%d\n",ans);
		scanf("%d %d %d",&b,&d,&n);
	}
	return 0;
}

Measured memory_bytes: 5120
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()

    val s = Math.floor(Math.sqrt(n.toDouble())).toLong()
    var ans = Int.MAX_VALUE
    for (a in 1..s) {
        if (n%a == 0L) {
            val b = n / a
            ans = Math.min(ans, Math.max(a.toString().length, b.toString().length))
        }
    }
    println(ans)
}


Measured memory_bytes: 33532
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, m;
    cin >> n >> m;
    ll d[n];
    mem(d, 0);
    rep(i, m)
    {
        ll x, y; cin >> x >> y; x--, y--; d[x]++; d[y]++;
    }
    print(d, n);
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

arr = MULTIPLE_INT_LIST()
arr.sort()

print(sum(arr[:2]))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
using ldouble = long double;
const ldouble EPS = 1e-10;

int main() {
    ldouble d;
    cin >> d;

    ldouble ans = d * sqrtl(2);
    for (ldouble x = 1; x < d + EPS; x += 1) {
        ldouble y = sqrt(d * d - x * x);
        if (y < 1 + EPS) ans = max(ans, x + 1);
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}



Measured memory_bytes: 3268
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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 Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<vector<char>> ans(9);
  ans[0]={'.',',','!','?',' '};
  ans[1]={'a','b','c'};
  ans[2]={'d','e','f'};
  ans[3]={'g','h','i'};
  ans[4]={'j','k','l'};
  ans[5]={'m','n','o'};
  ans[6]={'p','q','r','s'};
  ans[7]={'t','u','v'};
  ans[8]={'w','x','y','z'};
  
  rep(i,n){
    string s;
    cin>>s;
    vector<pair<char,ll>> v;
    runlength(s,v);
    for(auto c:v){
      if(c.first=='0') continue;
      cout<<ans[(c.first-'0')-1][(c.second-1)%ans[(c.first-'0')-1].size()];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3128
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	int n;
	cin >> n;
	if (n % 10 == (n / 100) % 10)
		cout << "Yes";
	else
		cout << "No";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256