akhauriyash/Code-Regression huggingface dataset:
// Running Offline
// g++ tester.cpp
// ./a.out
//#include "/Users/manasgupta/Desktop/stdc++.h"

 #include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define float double
#define pi pair<int,int>
#define pb push_back
#define fi first
#define se second
// #define mp make_pair
#define inf 1e9
#define EPS 1e-6
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FILEIO(name1, name2) \
    freopen(name1".txt","r",stdin); \
    freopen(name2".txt","w",stdout);

const int N=3005;
const int mod = 1000000007;

int power(int a, int b, int c)
{
	int res=1;
	while (b)
	{
		if (b&1) res=(res*a)%c;
		a=(a*a)%c;
		b=b>>1;
	}
	return res;
}

int n;
float a[N];
float dp[N][N];

signed main()
{
	IOS;
	cin>>n;
	for (int i=1; i<=n; i++)
	{
		cin>>a[i];
	}
	dp[0][0]=1;
	for (int i=1; i<=n; i++)
	{
		for (int j=0; j<=i; j++)
		{
			if (j==0)
			{
				dp[i][j]=dp[i-1][j]*(1-a[i]);
			}
			else
			{
				dp[i][j]=(dp[i-1][j]*(1-a[i]) + dp[i-1][j-1]*a[i]);
			}
			// cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
		}
	}
	float ans=0;
	
	for (int i=n/2+1; i<=n; i++)
	{
		ans=ans+dp[n][i];
	}
	cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}





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

vector<int> g[200005];

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i],g[a[i]].push_back(i+1);
	if(g[1].size()==0)
		cout<<-1;
	else
	{
		int ct=1,ind=g[1][0];
		for(int i=2;i<=200000;i++)
		{
			if(g[i].size()==0)
				break;
			int in = lower_bound(g[i].begin(),g[i].end(),ind) - g[i].begin();
			if(in==g[i].size())
				break;
			ind = g[i][in];
			ct++;
		}
		cout<<n-ct;
	}
}

Measured memory_bytes: 12032
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-12;
const int mod =  1000000007;
const int LIM = 100005;


#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first
 
int fpow(int x, int n){
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b){
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n){
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************
vector<vector<int>> dp (3010,vector<int>(3010,-1));
vi sum(5000,0);
int jao(int l,int r){
      if(dp[l][r]>=0){
            return dp[l][r];
      }
      dp[l][r]= max(sum[r] - sum[l-1] - jao(l+1,r),sum[r] - sum[l-1] - jao(l,r-1));
      return dp[l][r];
}

int32_t main()
{     fio;
      cin>>n;
      forr(i,n){
            cin>>a[i];
            dp[i][i]=a[i];
            //dp[i][i][0]=a[i];
            sum[i]=a[i]+sum[i-1];
      }
      cout<<2*jao(1,n)-sum[n];
     
}


Measured memory_bytes: 74808
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
if n == 3:
    l = range(100, 1000)
if n == 2:
    l = range(10, 100)
if n == 1:
    l = range(0, 10)
flag = False
for i in l:
    num = str(i)
    if all([num[s-1] == str(c) for s, c in sc]):
        #print(num)
        #exit()
        flag = True
        ans = num
        break
if flag:
    print(num)
else:
    print(-1)
#print(-1)

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

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

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,k,ans=0;
  cin>>n;
  vector<int> v(n),a(n);
  rep(i,n) cin>>v[i];
  rep(i,n) a[i]=0;
  for(int i=0;i<n;i++){
    a[v[i]-1]=i+1;
  }
  rep(i,n) cout<<a[i]<<' ';
  cout<<endl;
  
  
  
  
  
  
  
}
///////////////////////////

Measured memory_bytes: 1536
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

bool f(string s)
{
    ll n = s.size(), i;
    for(i=0;i<n/2;i++)
        if(s[i]!=s[n-1-i])
            return 0;
    return 1;
}

// main function
int main()
{
    string s;
    ll n;
    cin>>s;
    n = s.size();
    f(s) and f(s.substr(0, n/2)) and f(s.substr(n/2+1, n/2)) ? cout<<"Yes\n":cout<<"No\n"; 
	return 0;
}


Measured memory_bytes: 256
import math


class Point:
    EPS = 1 << 10

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Point(self.x+other.x, self.y+other.y)

    def __sub__(self, other):
        return Point(self.x-other.x, self.y-other.y)

    def __mul__(self, other):
        return Point(self.x*other.x, self.y*other.y)

    def __floordiv__(self, other):
        return Point(self.x/other.x, self.y/other.y)

    def __abs__(self):
        return math.sqrt(self.norm())

    def norm(self):
        return self.x**2 + self.y**2

    def __eq__(self, other):
        EPS = self.__class__.EPS
        return abs(self.x-other.x) < EPS and abs(self.x-other.x) < EPS


class Vector(Point):
    def __init__(self, x, y):
        super().__init__(x, y)

    def dot(self, other):
        return self.x*other.x + self.y*other.y

    def cross(self, other):
        return self.x*other.y - self.y*other.x

    def isOrthogonal(self, a, b):
        return a.dot(b) == 0.0

    def isParallel(self, a, b):
        return a.cross(b) == 0.0

    def __add__(self, other):
        return Vector(self.x+other.x, self.y+other.y)

    def __sub__(self, other):
        return Vector(self.x-other.x, self.y-other.y)

    def __mul__(self, other):
        return Vector(self.x*other.x, self.y*other.y)

    def __floordiv__(self, other):
        return Vector(self.x/other.x, self.y/other.y)


class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

    def isOrthogonal(s1, s2):
        return (s1.p2-s1.p1).dot(s2.p2-s2.p1) == 0.0

    def isParallel(s1, s2):
        return (s1.p2-s1.p1).cross(s2.p2-s2.p1) == 0.0


class Line(Segment):
    pass


class Circle:
    def __init__(self, c, r):
        self.c = c
        self.r = r


class Polygon:
    def __init__(self, *points):
        self.points = points


n = int(input())
for i in range(n):
    q = list(map(int, input().split()))
    s = []
    for j in range(2):
        p0 = Vector(*q[j*4:j*4+2])
        p1 = Vector(*q[j*4+2:j*4+4])
        s.append(Segment(p0, p1))
    if Segment.isOrthogonal(*s):
        print(1)
    elif Segment.isParallel(*s):
        print(2)
    else:
        print(0)



Measured memory_bytes: 5712
n = int(input())
ans = n
for i in range(n + 1):
  cc = 0
  t = i
  
  while t > 0:
    cc += t % 9
    t //= 9
  t = n - i
  while t > 0:
    cc += t % 6
    t //= 6
  ans = min(ans, cc)
print(ans)


Measured memory_bytes: 3060
import sys
from io import StringIO
import unittest
MOD = 1000000007
def resolve():
    S, = map(int, input().split())
    n = [0]*(S+1)
    n[0]=1
    for i in range(S+1):
        for j in range(3,i+1):
            left = i-j
            n[i]=(n[i]+n[left])%MOD


    print(n[S])
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(output, out)

    def test_入力例_1(self):
        input = """7"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1729"""
        output = """294867501"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 77720
def main():
    """
    5 <= N <= 55
    ai is prime
    ai != aj
    sum(ai...ai5) is not prime
    """
    N = int(input())
    f(N)


def f(N):
    max_num = 55555
    e = eratosthenes(max_num * 5)
    ps = []
    for i in range(2, max_num+1):
        if e[i]:
            ps.append(i)
    # print(len(ps)): 5637
    # TLE(N, e, ps)

    # (5n+1)*5 = 合成数
    ps2 = [p for p in ps if p % 5 == 1]
    print(*ps2[:N])


def TLE(N, e, ps):
    from itertools import combinations
    for c1 in combinations(ps, N):
        c2 = list(c1)
        ok = True
        c4 = None
        for c3 in combinations(c2, 5):
            c4 = list(c3)
            # print(c4)
            if not e[sum(c4)]:
                ok = False
                break
        if ok:
            print(*c4)
            return


def eratosthenes(N):
    is_prime = [True for _ in range(N + 1)]
    is_prime[0] = False
    is_prime[1] = False
    max_prime = int(N ** 0.5)
    for n in range(2, max_prime + 1):
        if is_prime[n]:
            for i in range(n * n, N + 1, n):
                is_prime[i] = False
    return is_prime


if __name__ == '__main__':
    main()


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

using namespace std;

int a, b;
int c, d;

int main(void)
{
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	while(a > 0 && c > 0)
	{
		c -= b;
		
		if(c <= 0)
		{
			printf("Yes");
			return 0;
		}
		
		a -= d;
		
		if(a <= 0)
		{
			printf("No");
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3828
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: Chars
    };
    println!(
        "{}",
        ["No", "Yes"][((n[1] == n[2]) && ((n[0] == n[1]) || (n[2] == n[3]))) as usize]
    );
}


Measured memory_bytes: 2112
<?php
	fscanf(STDIN, "%d %d %d", $x, $a, $b);
	$array = [
		'A' => abs($a - $x),
		'B' => abs($b - $x)
	];
	$key = array_keys($array, min($array));
	if($key[0] === 'A'){
		echo 'A';
	}else{
		echo 'B';
	}
?>

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

int main()
{
    char s[3];
    int i;
    for(i=0; i<3; i++)
    {
        cin >> s[i];
    }

    for(i=0; i<3; i++)
    {
        if(s[i]=='7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int a,b;
    string ans;
    cin>>a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)ans="Alice";
    if(b>a)ans="Bob";
    if(a==b)ans="Draw";
    cout<<ans<<endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h.at(i);
  
  vector<int> cost(n, -1);
  cost.at(0) = 0;
  cost.at(1) = abs(h.at(1)-h.at(0));
  for(int i = 2; i < n; i++){
    cost.at(i) = min(cost.at(i-2)+abs(h.at(i)-h.at(i-2)),
                    cost.at(i-1)+abs(h.at(i)-h.at(i-1)));
  }
  cout << cost.at(n-1) << endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
 
using namespace std;
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
 
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
 
int N;
vector<int>a;
 
int dfs(int n, int b, int c){
  if(n == 10) return 1;
 
  if(b < a[n] && dfs(n+1, a[n], c)) return 1;
  if(c < a[n] && dfs(n+1, b, a[n])) return 1;
  return 0;
}
 
int main(){
  scanf("%d", &N);
  rep(i, N){
    a.clear();
    int b;
    rep(i, 10){
      scanf("%d", &b);
      a.PB(b);
    }
 
    printf("%s\n", dfs(0, 0, 0)?"YES":"NO");
  }
  return 0;
}


Measured memory_bytes: 3140
while (l = gets.to_i) != 0
  sum = 0
  flag = true
  1.upto(12) do |i|
    m,n = gets.split(" ").map(&:to_i)
    sum += m - n
    if sum >= l && flag
      puts i
      flag = false
    end
  end
  puts "NA" if flag
end

Measured memory_bytes: 8712
G, B = map(int,input().split())

if G>0 and B>0:
    print('Positive')

elif G<=0 and B>=0:
    print('Zero')

elif G < 0 and B < 0:
    if (B - G) % 2 == 0:
        print("Negative")
    else:
        print("Positive")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Double> ret = new ArrayList<Double>();
			do {
				int n = Integer.parseInt(br.readLine());
				if (n == 0) {
					break;
				}
				String[] s = br.readLine().split(" ");
				int i, num, sum = 0;
				double ave;
				for (i = 0; i < n; i++) {
					num = Integer.parseInt(s[i]);
					sum = sum + num;
				}
				double hoge = 0.0;
				ave = (double) sum / n;
				for (i = 0; i < n; i++) {
					num = Integer.parseInt(s[i]);
					hoge = hoge + Math.pow((num - ave), 2);
				}
				ret.add(Math.sqrt(hoge / n));
			} while (true);
			for (double d : ret) {
				System.out.println(String.format("%.8f", d));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 19632
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int H[1000010];
//深さ優先探索
vector<bool> seen;
bool dfs(const Graph &G, int v){
    seen[v] = true; // v を訪問済みにする
	bool ok = true;

    // vから行ける各頂点 next_v について
    for(auto nv : G[v]){
        // if (seen[nv]) continue; // next_v が探索済みだったらスルー
        if(H[nv] >= H[v]) ok = false;
    } 
	return ok;
}


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

	int N,M; cin >> N >> M;
	rep(i,N) cin >> H[i];
	Graph G(N);
    for(int i=0;i<M;i++){
        int A, B;
        cin >> A >> B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    seen.assign(N, false); // 全頂点を「未訪問」にして初期化
	int ans = 0;
    rep(i,N){
		if(dfs(G,i)) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 9736
N, M = map(int, input().split())
a = [[] for i in range(N+1)]
for i in range(M):
  u, v = map(int, input().split())
  a[u].append(v)
#print(a)

S, T = map(int, input().split())
def main():
  c = [S]
  m = [[False, False, False] for i in range(N+1)]
  for count in range(1, 3*N+1):
    c2 = []
    for u in c:
      m[u][count %3] = True
      for v in a[u]:
        if (v == T and count %3 ==0):
          return count//3
        if not(m[v][(count+1) %3]):
          m[v][(count+1) %3]=True
          c2.append(v)
    c = c2
  return -1
print(main())


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

    }
    else if(a>b){
        for(i=0;i<a;i++){
            printf("%d",b);
        }
    }
    else{
        for(i=0;i<a;i++){
            printf("%d",b);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int x;
    cin >> x;
    if(x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)


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

G = {k: [] for k in range(N)}
for _ in range(M):
    x, y = map(int, input().split())

    # 有向グラフ
    G[x-1].append(y-1)  # 0-indexed

dp = [-1 for _ in range(100100)]


def rec(v):
    if dp[v] != -1:
        return dp[v]

    dp[v] = 0
    for nv in G[v]:
        dp[v] = max(dp[v], rec(nv)+1)

    return dp[v]


ans = 0
for v in range(N):
    ans = max(ans, rec(v))
print(ans)


Measured memory_bytes: 165648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
typedef pair<int,int> P;
int dp[114514];
signed main(){
	int n,k;
	int a[111111];
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=1000000000;
		for(int j=i-1;j>=max(0ll,i-k);j--)dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1792
def nasu(x):
  L = [0]
  t = x
  cnt = 1
  while t != 0:
    if t & 1:
      L.append(cnt)
    t >>= 1
    cnt += 1
  Ans = len(L) - 1

  L.append(H)
  pr = 0
  for i in range(1, W + 1):
    f = True
    for j in range(1, len(L)):
      k = D[L[j]][i] + D[L[j - 1]][pr] - D[L[j]][pr] - D[L[j - 1]][i]
      if k > K:
        pr = i - 1
        Ans += 1
        #print(pr, end = ",")
        break     
    else:
      continue
    for j in range(1, len(L)):
      k = D[L[j]][i] + D[L[j - 1]][pr] - D[L[j]][pr] - D[L[j - 1]][i]
      if k > K:
        return 10 ** 10
  #print(L, Ans)
  return Ans

H, W, K = list(map(int, input().split()))
S = [list(map(int, list(input()))) for _ in range(H)]

N = 2 **(H - 1)

D = [[0] * (W + 1) for _ in range(H + 1)]
for i in range(1, H + 1):
  D[i][1] = S[i - 1][0]

for i in range(1, H + 1):
  for j in range(2, W + 1):
    D[i][j] = D[i][j - 1] + S[i - 1][j - 1]

for i in range(2, H + 1):
  for j in range(W, 1, -1):
    D[i][j] += D[i - 1][j]
  D[i][1] += D[i - 1][1]

Ans = 10 ** 10
for i in range(N):
  Ans = min(Ans, nasu(i))

print(Ans)

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
int dx2[2] = {-1, 1}, dy2[2] = {1, -1};

typedef vector<vector<int>> Graph;
Graph G;
int H, W, D;

int main()
{
    ios::sync_with_stdio(false);
    cin >> H >> W >> D;

    vector<vector<int>> done(H, vector<int>(W));
    G.resize(H*W);

    char color[2][2] = {{'R', 'G'}, {'B', 'Y'}};

    rep(y, H) {
        rep(x, W) {
            int xx = x - y + H;
            int yy = x + y;

            cout << color[(xx / D) % 2][(yy / D) % 2];
        }
        cout << endl;
    }
}

Measured memory_bytes: 7424
#pragma GCC target ("sse4.2")

#include<bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long
#define endl '\n'
#define N 100010

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

    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k)
    {
        cout<<s;
    }
    else
    {
        for (int i = 0; i < k; ++i) {
            cout<<s[i];
        }
        cout<<"...";
    }
}

Measured memory_bytes: 3640
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
q = int(input())

ans = sum(A)
dic = Counter(A)
for i in range(q):
    b, c = map(int, input().split())
    cnt = dic[b]
    dic[b] = 0
    dic[c] += cnt
    ans -= cnt*b
    ans += cnt*c
    print(ans)


Measured memory_bytes: 93644
#include<stdio.h>
#include <cmath>
#include<string.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int x, y, z;
    cin >> x >> y >>z;
    if(x+y+z>=22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

const int dx[]={0,-1,1,0},dy[]={-1,0,0,1};

int main(){

  ll n;cin>>n;
  ll a,b;cin>>a>>b;
  // ll p[n];rep(i,0,n)cin>>p[i];

  ll num[3];CLR(num,0);
  rep(i,0,n){
    ll p;cin>>p;

    if(p>=b+1)num[2]++;
    else if(a+1<=p&&p<=b)num[1]++;
    else num[0]++;

  }

  out(min({num[0],num[1],num[2]}));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    int x,y;
    cin>>x>>y;
    int prize[3]={(int)3e5,(int)2e5,(int)1e5};
    int ans=0;
    rep(i,3){
        if(x==i+1){
            ans+=prize[i];
        }
        if(y==i+1){
            ans+=prize[i];
        }
        if(x==y&&y==1&&i==0){
            ans+=(int)4e5;
        }
    }
    cout<<ans<<endl;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

Int n, cnt = 0, c[5] = {0};
string s[100000];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		if(s[i][0] == 'M') c[0]++;
		if(s[i][0] == 'A') c[1]++;
		if(s[i][0] == 'R') c[2]++;
		if(s[i][0] == 'C') c[3]++;
		if(s[i][0] == 'H') c[4]++;
	}
	
	for(int i = 0; i < 3; i++){
		for(int j = i+1; j < 4; j++){
			for(int k = j+1; k < 5; k++){
				cnt += c[i]*c[j]*c[k];
			}
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

int main () {
    int t;
    cin >> t;
    
    int h, m, s;
    
    h = t/3600;
    t = t%3600;
    
    m = t/60;
    s = t%60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


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

ll gcd(ll a, ll b){
    ll r,temp;
    if (a < b){
        temp = a;
        a = b;
        b = temp;
    }
    while ( (r = a % b) != 0){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int N;
    cin >> N;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    ll ans = vec[0];
    rep(i,N - 1){
        ans = (vec[i + 1] / gcd(vec[i + 1], ans)) * ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>

template<class T> inline bool chmin(T& a, T b) 
{
  if ( a > b ) {
    a = b;
    return true;
  } else {
    return false;
  }
}

template<class T> inline bool chmax(T& a, T b) 
{
  if ( a < b ) {
    a = b;
    return true;
  } else {
    return false;
  }
}

const int max_index {100010};
const long long INF {1LL << 60};
long long dp[max_index];
long long h[max_index];

long long rec(int i)
{
  if (dp[i] < INF) return dp[i];

  if (i == 0) return 0;

  long long res = INF;
  chmin(res, rec(i-1) + std::abs(h[i] - h[i -1]));
  if (i > 1) chmin(res, rec(i-2) + std::abs(h[i] - h[i-2]));

  return dp[i] = res;
}

int main()
{
  // input
  int N {0};
  std::cin >> N;
  for (int i = 0; i < N; i++) std::cin >> h[i];
  for (int i = 0; i < N; i++) dp[i] = INF;

  std::cout << rec(N-1) << std::endl;
  return 0;
}

Measured memory_bytes: 6528
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        s_vec: [String; n],
    }
    let mut count: Vec<usize> = vec![0; 4];
    s_vec.iter().for_each(|s| match &s[..] {
        "AC" => *count.get_mut(0).expect("") += 1,
        "WA" => *count.get_mut(1).expect("") += 1,
        "TLE" => *count.get_mut(2).expect("") += 1,
        "RE" => *count.get_mut(3).expect("") += 1,
        _ => (),
    });
    println!(
        "AC x {}\nWA x {}\nTLE x {}\nRE x {}",
        count[0], count[1], count[2], count[3]
    );
}


Measured memory_bytes: 7788
// Medha's code  :


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 0x3f3f3f3f3f

int main() {

    fastio;

    ll n;
    vector<ll> swimming(100005);
    vector<ll> mountain(100005);
    vector<ll> homework(100005);
    vector<ll> dpswimming(100005);
    vector<ll> dpmountain(100005);
    vector<ll> dphomework(100005);

    cin >> n;

    for( ll i = 1 ; i <= n ; i++)
    {
        cin >> swimming[i] >> mountain[i] >> homework[i];
    }

    dpswimming[1] = swimming[1];
    dpmountain[1] = mountain[1];
    dphomework[1] = homework[1];

    for( ll i = 2 ; i <= n ; i++)
    {
        dpswimming[i] = swimming[i] + max(dpmountain[i-1] , dphomework[i-1]);
        dpmountain[i] = mountain[i] + max(dphomework[i-1] , dpswimming[i-1]);
        dphomework[i] = homework[i] + max(dpswimming[i-1] , dpmountain[i-1]);
    }

    cout<< max(dpswimming[n], max(dpmountain[n], dphomework[n]));


    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int check[110];
int main()
{
	int a;
	scanf("%d",&a);
	a%=10;
	check[2] = check[4] = check[5] = check[7] = check[9] = 1;
	check[0] = check[1] = check[6] = check[8] = 2;
	check[3] = 3;
	if(check[a]==1) printf("hon");
	else if(check[a]==2) printf("pon");
	else printf("bon");
}

Measured memory_bytes: 1728
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include<set>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}

/*
//134 E
int main(void) {
	ll n;
	cin >> n;
	vector<ll> a = vector<ll>(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	set<ll> color;
	rep(i, 0, n) {
		auto itr = upper_bound(color.begin(), color.end(), a[i]);
		if (itr == color.begin()) {
			color.insert(a[i]);
		}
		else if (itr == color.end()){
			color.erase(--itr);
			color.insert(a[i]);
		}
	}
	cout << color.size() << endl;
}
*/


//134 D
int main(void) {
	ll n;
	cin >> n;
	vector<ll> a = vector<ll>(n);
	rep(i, 0, n) cin >> a[i];
	vector<ll> ans = vector<ll>(n, 0);
	vector<ll> ball = vector<ll>(n, 0);
	for (ll i = n - 1; i >= 0; i--) {
		if ((i+1)*2 > n) {
			ans[i] = a[i];
			//ball[i] = a[i];
		}
		else {
			ll bit = 0;	
			for (ll j = (i + 1) * 2 - 1; j < n; j += i + 1) {
				bit += ans[j];
			}
			ll amari = bit % 2;
			ans[i] = amari != a[i] ? 1 : 0;
			//ball[i] = bit + ans[i];
		}
	}
	ll count = 0;
	rep(i, 0, n) if (ans[i] == 1)count++;
	cout << count << endl;
	ll outputCount = 0;
	for (ll i = 0; outputCount < count; i++) {
		if (ans[i] == 1) {
			outputCount++;
			if (outputCount == count) {
				cout << i + 1 << endl;
			}
			else {
				cout << i + 1 << " ";
			}
			
		}
	}
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    vector<string> words = { "dream", "dreamer", "erase", "eraser" };
    string s = get<string>();

    for (int i = s.size(); i > 0; ) {
        for (auto w : words) {
            //cerr << i << ", " << w.size() << endl;
            if (i - (int)w.size() >= 0 &&
                
                s.substr(i-w.size(), w.size()) == w)
            {
                //cerr << w << " matched\n";
                i -= w.size();
                goto Continue;
            } else {
                //cerr << w << " didn't match\n";
            }
        }
        cout << "NO\n";
        exit(0);
    Continue:;
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>

using namespace std;

int main(){
  int prime[187];
  static int memo[1121][187][15];
  memset(memo, 0, sizeof(memo));
  int size = 1;
  prime[0] = 2;
  for(int i=3;i<1120;i+=2){
    bool flag = true;
    for(int j=0;prime[j]*prime[j]<=i;j++)
      if(i%prime[j]==0) flag = false;
    if(flag) prime[size++] = i;
  }
  for(int i=0;i<size;i++) memo[prime[i]][i][1] = 1;
  for(int i=1;i<14;i++){
    for(int j=0;j<1121;j++){
      for(int k=0;k<187;k++){
	if(memo[j][k][i]==0) continue;
	for(int l=k+1;l<187;l++){
	  if(j+prime[l]>1120) break;
	  memo[j+prime[l]][l][i+1] += memo[j][k][i];
	}
      }
    }
  }
  int n, k;
  while(cin >> n >> k, n){
    int ans = 0;
    for(int i=0;i<187;i++) ans += memo[n][i][k];
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 12000
/**
 * 
 */


/**
 * @author Jnaneswar Reddy
 *
 */
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int n;
		Scanner scan =new Scanner(System.in);
		n=scan.nextInt();
		while(n>=1000)
		{
			n=n%1000;
		}
		if(n>0)
		System.out.println(1000-n);
		else
			System.out.println(n);
	}

}


Measured memory_bytes: 35560
import numpy as np

N = int(input())
A = []
B = []

for _ in range(N):
    putin = int(input())
    A.append(putin)
    B.append(putin)

MAX = int(np.max(A))
A.remove(MAX)
MAX2 = int(np.max(A))

for i in range(N):
    if B[i] == MAX:
        print(MAX2)
    
    else:
        print(MAX)


Measured memory_bytes: 24480
n = int(input())

max_index = 0
max_price = 0
price_list = []

for i in range(0, n):
    p = int(input())
    price_list.append(p)
    if max_price < p:
        max_price = p
        max_index = i

p_sum = 0
for i, p in enumerate(price_list):
    if i == max_index:
        p_sum += p / 2
    else:
        p_sum += p

print(int(p_sum))


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int dp[100001];
int p[11][11];

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p[i][j];
        }
    }
    for (int i = 0; i <= x; i++) {
        dp[i] = i;
    }
    for (int i = 0; i < d - 1; i++) {
        for (int j = 0; j < n; j++) {
            int w = p[i][j];
            int v = max(p[i][j], p[i + 1][j]);
            for (int k = 0; k + w <= x; k++) {
                dp[k + w] = max(dp[k + w], dp[k] + v);
            }
        }
        int tmp = dp[x];
        for (int i = 0; i <= tmp; i++) {
            dp[i] = i;
        }
        x = tmp;
    }
    dump(x);
    return 0;
}



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

int main() {
	// your code goes here
	float n, m, sum=0;
	cin>>n>>m;
	vector<float>a(n);
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	if(a[m-1]>=ceil(sum/(4*m)))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
   string s;
   cin>>s;
   ll n=s.length();
   for(int i=0;i<n;i+=2)
     cout<<s[i]; 
}
return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a, b) + min(c, d) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b, c, d, e;
	scanf("%d %d", &a, &b);
	c=a*3;
	d=b+c;
	e=d/2;
	if(d-1==0){
		printf ("0");
	}
	else{
	printf("%d", e);
}
	return 0;
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin>>n;
    if ((n[0]==n[1]&&n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3])) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>m;
		cout<<(n+m-1)/m<<endl;        
    }
    return 0;
        
}

Measured memory_bytes: 256
N,M,C = (int(i) for i in input().split())

B = list(int(i) for i in input().split())
A = []
for i in range(N):
  A.append(list(int(i) for i in input().split()))

ans = 0
for i in range(N):
  check = 0
  for j in range(M):
    check += A[i][j]*B[j]
  if check + C >0:
    ans +=1

print(ans)


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

int num[120000] = {};
int ans[10010] = {};

void prime(){
	num[0] = 1;
	num[1] = 1;
	
	for( int i=2 ; i*i<120000 ; i++ ){
		if( num[i] == 0 ){
			for( int j=2 ; i*j<120000 ; j++ ){
				num[i*j] = 1;
			}
		}
	}
	
	int cnt = 1;
	for(int i=2 ; i<120000 ; i++){
		if( !num[i] ){
			ans[cnt] = i + ans[cnt-1];
			cnt++;
		}
		if(cnt > 10000) break;
	}
}

int main(){
	
	prime();
	
	int n;
	while( cin >> n , n ){
		cout << ans[n] << endl;
	}
	
	return 0 ;
}

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

int	main() {
	int A, B, C;
	cin >>A >>B >>C;
	if ((C>=A)&&(C<=B))
		cout <<"Yes" <<endl;
	else
		cout <<"No" <<endl;
	return 0;
}



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

int main()
{
    int n;
    long long a, b;
    long long count = 0;
    vector<long long> A,B;
    cin >> n;
    for(int i=0;i<n+1;i++){
        cin >> a;
        A.push_back(a);       
    }
    for(int i=0;i<n;i++){
        cin >> b;
        B.push_back(b);       
    }
    for(int i=0;i<n;i++){
        if(A[i]+A[i+1]<=B[i]){
            count += A[i]+A[i+1];
            A[i+1] = 0;
        }else if(A[i]+A[i+1]>B[i]) {
            if(B[i]>A[i]){
                count += B[i];
                A[i+1] = A[i]+A[i+1]-B[i];
            }else { 
                count += B[i];
            }
        } 
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll factorial ( ll a, ll b ) {
    ll ret = 1;
    while(1) {
        if ( b == 0 ) {
            break;
        }
        ret = ret * a % mod;
        --a;
        --b;
    }
    return ret;
}

ll expo ( ll a, ll b ) {
    ll res = 1;
    while(b > 0) {
        if ( b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll inv ( ll a ) {
    return expo(a, mod-2);
}

ll choose ( ll a, ll b ) {
//    cout << factorial(a, b) << " " << factorial(b, b) << endl;
    return factorial(a, b) * inv(factorial(b, b)) % mod;
}

int main(){
    int x, y;
    cin >> x >> y;
    if ( ( x + y ) % 3 != 0 || y > 2 * x || y * 2 < x ) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = choose(( x + y ) / 3, x - ( x + y ) / 3);
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int a,b,c;cin>>a>>b>>c;
   if(c>=a && c<=b)cout << "Yes";
   else cout << "No";
   return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
ll dp[114514]={0};
ll sum[114514]={0};

ll N;
ll A,B;

int main(){
	cin>>N;
	ll ans=0;
	for(ll x=1;x*x+2*x<=N;x++){
		if(N%x==0){
			ans+=N/x-(ll)1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<sstream>

using namespace std;

int main(){
		int n,num,cont,v;
		string a,nex;
				stringstream ss;
	while(1){
		
		scanf("%d",&n);
		
		if(n==0){break;}
		cin>>a;
		
		for(int i=0;i<n;i++){
			cont=0;
			while(1){
				if(cont>=a.size()){break;}
				
				num=a[cont];
				
				v=0;
				while(1){
					if(a[cont]!=num){break;}
					v++;
					cont++;
				}
				ss.str("");
				ss<<v;
				
				nex+=ss.str();
				nex+=num;
			}
			a=nex;
			nex="";
		}
			cout<<a<<endl;
	}
}

Measured memory_bytes: 1080
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    long long k=(a+b)/2;
    long long c=(a+b)%2;
    if(c==0)cout<<k<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	ll ans = 0;
	ll cum = 0;
	for(int i=0; i<N; i++){
		if(A[i]==0){
			ans += cum/2;
			cum = 0;
		} else {
			cum += A[i];
		}
	}
	ans += cum/2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
def xor_sum(a):
    if a == 0 or a == 1:
        return a
    elif a == 2:
        return 3
    elif a == 3:
        return 0
    else:
        b = bin(a)[2:]
        if a % 2 == 0:
            return 2**(len(b)-1) + xor_sum(a % 2**(len(b)-1))
        else:
            return xor_sum(a % 2**(len(b)-1))

def main():
    A,B = map(int,input().split())

    a,b = xor_sum(max(0,A-1)),xor_sum(B)
    print(a ^ b)

if __name__ == "__main__":
    main()


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

signed main() {
  int A,B,N;
  cin >> A >> B >> N;
  if(B>N){
    cout << (A*N)/B-(A*(N/B)) << endl;
    return 0;
  }
  else{
    int x = N-(N%B)-1;
    cout << (A*x)/B-(A*(x/B)) << endl;
    return 0;
  }
}


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

int sum(string s){
    int t=0;
    for (int i=0; i<s.size(); i++){
        t+=s[i]-'0';
    }
    return t;
}

int main(){
    string s1;
    while(cin >> s1){
        int ans=0;
        if (s1[0]=='0') break;
        ans = sum(s1);
        cout << ans << endl;
    }
    return 0;
}


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

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d) cout << "Left" << endl;
  else if(a+b == c+d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


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

int main(){

  int n;
  cin >> n;

  int counter = 0;
  while(true){
    int num = pow(2,counter);

    if(num == n) {
      cout << num; 
      break;
    }
    else if (num > n) {
      cout << num/2; 
      break;
    }
    else {
      ++counter;
    }
  
 }

}

Measured memory_bytes: 256