akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const int N=15;
int main()
{
//int i = 0, j;
    int c[N][N];
//int array[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
//int Max = 13, Min = 1, Sum = 91;
    char a[]={'S', 'H', 'C', 'D'};
    int n, i, j;
    for(i = 0; i < N; i++)
    {
        for(j = 0; j < N; j++)
        {
            c[i][j] = 0;
        }
    }
    scanf("%d", &n);
    
    for(i = 0; i < n; i++)
    {
        int x;
        char ch;
        scanf(" %c %d", &ch, &x);
        
        if(ch == 'S')
        {
            c[0][x]++;
        }
        if (ch == 'H')
        {
            c[1][x]++;
        }
        if (ch == 'C')
        {
            c[2][x]++;
        }
        if (ch == 'D')
        {
            c[3][x]++;
        }
    }
    

    for(j = 0; j < 4; j++)
    {
        for (i = 1 ; i <= 13; i++)
        {
            if(c[j][i] == 0)
            {
                printf("%c %d\n", a[j], i);
            }
            
        }
    }
    return 0;
}



Measured memory_bytes: 2600
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;

int main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
      int n;
      cin >> n;
      cout << (n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    bool flg = true;
    REP(i,N) {
        if(A[i]%2==0 && !(A[i]%3==0 || A[i]%5==0)) {
            flg = false;
            break;
        }
    }
    cout << (flg ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}
 
fn main() {
  let n: u32 = read();
  let ans = (n * (n + 1)) / 2;
  println!("{}", ans);
}


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

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

Measured memory_bytes: 4060
#include <stdio.h>
#include <string.h>
#include <algorithm>

#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int INF=0x3f3f3f3f;
const int N=4005;

int f[N][N],a[N],w[N],b[N];
int cw[N][N],cb[N][N];

int main(void) {
	int n; scanf("%d",&n);
	rep(i,1,n*2) {
		char ch[2]; scanf("%s%d",ch,&a[i]);
		if (ch[0]=='W') w[a[i]]=i;
		else b[a[i]]=i;
	}
	rep(i,1,n) {
		rep(j,1,i-1) cw[i][0]+=(w[j]>w[i]);
		rep(j,1,n) cw[i][j]=cw[i][j-1]+(b[j]>w[i]);
	}
	rep(i,1,n) {
		rep(j,1,i-1) cb[0][i]+=(b[j]>b[i]);
		rep(j,1,n) cb[j][i]=cb[j-1][i]+(w[j]>b[i]);
	}
	rep(i,1,n) f[i][0]=f[i-1][0]+cw[i][0];
	rep(j,1,n) f[0][j]=f[0][j-1]+cb[0][j];
	rep(i,1,n) rep(j,1,n) {
		f[i][j]=std:: min(f[i-1][j]+cw[i][j],f[i][j-1]+cb[i][j]);
	}
	printf("%d\n", f[n][n]);
	return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();
        int X = cin.nextInt();

        int[] a = new int[N + 1];
        for (int i = 0; i < M; i++)
        {
            int tmp = cin.nextInt();
            a[tmp] = 1;
        }

        int ans1 = 0;
        for (int i = X; i < N + 1; i++)
        {
            ans1 += a[i];
        }

        int ans2 = 0;
        for (int i = X; i >= 0; i--)
        {
            ans2 += a[i];
        }

        Console.WriteLine(Math.Min(ans1, ans2));
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  if ((N * A) >= B) {
    cout << B << endl;
  }
  
  else if ((N * A) < B) {
    cout << N * A << endl;
  }
}

Measured memory_bytes: 256
// Cakes and Donuts
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    bool CanBuy = false;
    for (int i = 0; i < 30; ++i) {
        for (int j = 0; j < 13; ++j) {
            int total = 4 * i + 7 * j;
            if (total == N) {
                CanBuy = true;
                break;
            }
        }
    }
    if (CanBuy) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/arc083/tasks/arc083_b

package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	var A = make([][]int, N)

	sum := 0
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)
		for j := 0; j < N; j++ {
			var a int
			fmt.Scanf("%d", &a)
			A[i][j] = a
			sum += a
		}
	}

	dupes := 0
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			if i == k || A[i][k] == 0 {
				continue
			}
			for j := i + 1; j < N; j++ {
				if k == j || A[k][j] == 0 {
					continue
				}
				x, y := A[i][j], A[i][k]+A[k][j]
				if x > y {
					fmt.Println(-1)
					return
				} else if x == y {
					dupes += A[i][j]
					A[i][j] = 0
					A[j][i] = 0
				}
			}
		}
	}

	fmt.Println((sum/2 - dupes))
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
int main()
{
	LL n, m;
	scanf("%lld%lld", &n, &m);
	if (n == 1 && m == 1)
		puts("1");
	else if (n == 1 || m == 1)
		printf("%lld", max(0ll, n * m - 2));
	else
		printf("%lld", (max(0ll, n - 2) * max(0ll, m - 2)));
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();

        int[][] a = new int[n][m];
        int[][] b = new int[m][l];

        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                a[i][j] = sc.nextInt();

        for (int i = 0; i < m; i++)
            for (int j = 0; j < l; j++)
                b[i][j] = sc.nextInt();

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                long cij = 0;
                for (int k = 0; k < m; k++)
                    cij += a[i][k] * b[k][j];
                System.out.print((j == 0) ? cij : " " + cij);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 53592
#include<stdio.h>

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right) {
  int n1, n2;
  llong cnt = 0;
  n1 = mid - left;
  n2 = right - mid;

  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];

  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    if ( L[i] <= R[j] ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

llong mergeSort(int A[], int n, int left, int right) {
  llong v1, v2, v3;
  if ( left + 1 < right ) {
    int mid = (left + right) / 2;
    v1 = mergeSort(A, n, left, mid);
    v2 = mergeSort(A, n, mid, right);
    v3 = merge(A, n, left, mid, right);
    return v1 + v2 + v3;
  } else return 0;
}

int main() {
  int A[MAX], n, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  llong ans = mergeSort(A, n, 0, n);
  printf("%llu\n", ans);
  return 0;
}

Measured memory_bytes: 4276
#include <functional>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

    vector<vector<int>> graph(3 * n, vector<int>(0));
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;

        graph[u - 1].push_back(n + v - 1);
        graph[n + u - 1].push_back(2 * n + v - 1);
        graph[2 * n + u - 1].push_back(v - 1);
    }

    int s, t;
    cin >> s >> t;

    long long inf = 1LL << 48;
    vector<long long> dist(3 * n, inf);
    dist[s - 1] = 0;

    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
    que.push(make_pair(0, s - 1));
    while (!que.empty()) {
        pair<long long, int> cur = que.top();
        que.pop();

        for (int i = 0; i < static_cast<int>(graph[cur.second].size()); i++) {
            if (dist[graph[cur.second][i]] > dist[cur.second] + 1) {
                dist[graph[cur.second][i]] = dist[cur.second] + 1;
                que.push(make_pair(dist[cur.second] + 1, graph[cur.second][i]));
            }
        }
    }

    cout << (dist[t - 1] != inf ? dist[t - 1] / 3 : -1) << endl;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, n);
    si a;
    REP(i, n){
        IN(int, k);
        a.insert(k);
    }
    YES(a.size()==n);
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;

int main() {
  string s;
  cin >> s;
  if(s.size()%2==1){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<s.size()-1; i+=2){
    if(s.at(i)!='h'||s.at(i+1)!='i'){
      cout << "No" << endl;
      return 0; 
    }
  }
  cout << "Yes" << endl;
}



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

int main(){
    double a, b, x;  cin >> a >> b >> x;
    double half = a*a*b/2;
    if(x == half){
        cout << 45 << endl;
    }else if(x < half){
        cout << setprecision(9) << 90 - atan2(2*x/a/b, b)*360/2/M_PI << endl;
    }else{
        cout << setprecision(9) << 90 - atan2(a, 2*b-2*x/a/a)*360/2/M_PI << endl;
    }
}

Measured memory_bytes: 256
import itertools
S = input()
s = ''
for c in S:
    s += c
    s += '+'
s = s[:-1]

result = eval(s)
memo = [s]
for i in range(len(S)):
    for ss in memo:
        cache = []
        for j in range(1,len(ss)):
            if ss[j] == '+':
                kouho = ss[:j] + ss[j+1:]
                if not kouho in memo:
                    result += eval(kouho)
                    cache.append(kouho)
        memo.extend(cache)

print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

using namespace std;

// change min/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; }

// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (typename std::vector<T>::const_iterator it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> void inputVec(std::vector<T>& vec) {
	for (typename std::vector<T>::iterator it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

void Main() {
	const int N = inputVal<int>();

	double ret = 0.0;
	if (N % 2 == 0) {
		ret = 0.5;
	}
	else {
		const double dN = static_cast<double>(N);
		ret = ((dN+1)*0.5 ) / dN;
	}

	outputVal(ret);

}

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

	return 0;
}


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

char S[200005];
char T[200005];
int n;

int main(){
  
  	scanf("%s",&S);
  	scanf("%s",&T);
  	n = strlen(S);
  	int ans = 0;
  	for ( int i = 0; i < n; i++ ){
    	ans += (S[i] != T[i]);
    }
 	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
struct qwe{long long x,v;}a[100010];
long long n,c,nx,nv,ans,fl[100010],fr[100010],ml[100010],mr[100010];
long long read()
{
	char ch=getchar();long long Num=0,F=1;
	while(!isdigit(ch)){if(ch=='-') F=-1;ch=getchar();}
	while(isdigit(ch)){Num=(Num<<1)+(Num<<3)+ch-'0';ch=getchar();}
	return Num*F;
}
bool my(qwe g,qwe h)
{return g.x<h.x;}
int main()
{
	n=read();c=read();
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].v=read();
	sort(a+1,a+1+n,my);a[n+1].x=c;
	for(int i=1;i<=n;i++) fl[i]=fl[i-1]+a[i].v+a[i-1].x-a[i].x,ml[i]=max(ml[i-1],fl[i]);
	for(int i=n;i>=1;i--) fr[i]=fr[i+1]+a[i].v+a[i].x-a[i+1].x,mr[i]=max(mr[i+1],fr[i]);
	ans=max(ml[n],mr[1]);
	for(int i=1;i<=n;i++)
	{
		if(fl[i]>a[i].x) ans=max(ans,fl[i]-a[i].x+mr[i+1]);
		if(fr[i]>c-a[i].x) ans=max(ans,fr[i]-c+a[i].x+ml[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n, p; cin>>n>>p;
    long long o = 0, e = 0;
    for(int i = 0; i < n; ++i){
        int a; cin>>a;
        if(a%2)++o;
        else ++e;
    }
    long long x = pow(2, e+o-1);
    if(p%2 && o==0)cout<<0<<endl;
    else if(!p%2 && o==0)cout<<x*2<<endl;
    else cout<<x<<endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    string s;
    std::cin >> n >>s;
    int a=0;
    for (int i = 0; i < n; i++) {
        int t=0;
        for (int j = 0; j < n-i; j++) {
            t=(t+1)*(s[j]==s[j+i]);
            a=max(a,min(t,i));
        }
    }
    std::cout << a << std::endl;
}


Measured memory_bytes: 384
import sys
from collections import deque
a = deque(map(str, input().rstrip()))
b = deque(map(str, input().rstrip()))
c = deque(map(str, input().rstrip()))

curr = "a"

while True:
    if curr == "a":
        if len(a) == 0:
            print("A")
            sys.exit()
        curr = a.popleft()
    elif curr == "b":
        if len(b) == 0:
            print("B")
            sys.exit()
        curr = b.popleft()
    else:
        if len(c) == 0:
            print("C")
            sys.exit()
        curr = c.popleft()

Measured memory_bytes: 3316
n = int(input())
ab = []
for i in range(n):
    a, b = list(map(int, input().split(' ')))
    ab.append((a, b))
ab = sorted(sorted(ab), key=lambda x: x[1])
ct = 0
valid = True
for a, b in ab:
    ct += a
    if ct > b:
        valid = False
        break
    
print('Yes' if valid else 'No')


Measured memory_bytes: 79320
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int n = 0;
    int room_cap[4][3][10] = {0};
    int b,f,r,v;
    cin >> n ;

    if(n > 1000 || n <= 0) return 0;

    for(int i = 0; i< n; i++)
    {
       cin >> b >> f >> r >> v;
       room_cap[b-1][f-1][r-1] += v;
       if(room_cap[b-1][f-1][r-1] < 0)
       {
           room_cap[b-1][f-1][r-1] = 0;
       }
    }

    for (int i = 0; i < 4 ; i++)
    {
        for(int j = 0 ; j < 3; j++)
        {
            for(int k= 0; k< 10;k++)
            {
                cout << " " << room_cap[i][j][k];
            }
            cout << endl;
        }
        if(i <3)
        {
            cout << "####################" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int d, g; cin >> d >> g;
  V<> p(d), c(d); for (int i = 0; i < d; i++) cin >> p[i] >> c[i];
  int res = 1e9;
  for (int s = 0; s < 1 << d; s++) {
    int t = g, tmp = 0;
    V<> q = p;
    for (int i = 0; i < d; i++) {
      if (s & 1 << i) {
        t -= c[i] + q[i] * 100 * (i + 1);
        tmp += q[i];
        q[i] = 0;
      }
    }
    V<> a;
    for (int i = 0; i < d; i++) {
      for (int j = 0; j < q[i]; j++) a.push_back(100 * (i + 1));
    }
    sort(a.rbegin(), a.rend());
    for (auto&& i : a) {
      if (t <= 0) break;
      t -= i, tmp++;
    }
    res = min(res, tmp);
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
def binary_search(a, f, target, left, right):
    ans = a[-1] * f[-1]
    while left + 1 < right:
        mid = (left+right)//2
        cost = 0
        for aa,ff in zip(a,f):
            if ff > mid:
                cost += aa
            elif aa - mid // ff > 0:
                cost += aa - mid // ff
        if cost > target:
            left = mid
        else:
            right = mid
    return right

n,k = map(int,input().split())
a = sorted(map(int, input().split()), reverse=True)
f = sorted(map(int, input().split()))
target = binary_search(a,f,k,-1,max(a) * max(f))
mx = 0
cost = 0
for aa, ff in zip(a,f):
    if ff > target:
        cost += aa
        aa = 0
    elif aa - target // ff > 0:
        cost += aa - target // ff
        aa = (target // ff)
    if mx < aa * ff:
        mx = aa * ff
print(mx)


Measured memory_bytes: 119500
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll f(ll x, ll m) {
	return x % m;
}
ll mod = 998244353;
int main() {
	ll N;
	cin >> N;
	vector<ll> A(N, 0);
	bool ch = false;
	rep(i, N) {
		ll D;
		cin >> D;
		if (i == 0) {
			if(D!=0)ch = true;
			else A[D]++;
		}
		else {
			if (D == 0 || D >= N) {
				ch = true;
			}
			else {
				A[D]++;
			}
		}
	}
	ll an = 1;
	if (ch)cout << 0 << endl;
	else {
		for (ll i = 1; i < N; i++) {
			ll j = A[i];
			ll k = A[i - 1];
			if (j != 0 && k == 0) {
				cout << 0 << endl;
				return 0;
			}
			else {
				
				rep(p, j) {
					an *= k;
					an %= mod;
				}
				
			}
		}
		cout << an << endl;
	}
	
}

Measured memory_bytes: 4044
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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 MOD 1000000007
#define INF 1073741823
#define LLINF 4611686018427387903
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VII;
#pragma endregion

int f(int n) {
    switch (n) {
        case 1:
            return 2;
        case 2:
        case 3:
        case 5:
            return 5;
        case 4:
            return 4;
        case 6:
        case 9:
            return 6;
        case 7:
            return 3;
        case 8:
            return 7;
        default:
            return 0;
    }
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    VI A(M); REP(i, M) cin >> A[i];
    VI dp(N + 1, -INF);
    dp[0] = 0;
    REP(i, N + 1) REP(j, M) if (i >= f(A[j])) dp[i] = max(dp[i], dp[i - f(A[j])] + 1);
    sort(RALL(A));
    REP(i, M) {
        while (N >= f(A[i]) && dp[N - f(A[i])] == dp[N] - 1) {
            if (dp[N] == 1 && N != f(A[i])) break;
            cout << A[i];
            N -= f(A[i]);
        }
    }
    getchar(); getchar();
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	x := nextInt() // a
	y := nextInt() // b
	//l := make([]int, n)

	costDefault := a*x + b*y
	costmin := costDefault
	// ABピザを2枚ずつAピザ,Bピザで置き換えていく
	for ab := 0; ab <= 100000; ab++ {
		xhusoku := 0
		yhusoku := 0

		if x-ab > 0 {
			xhusoku = x - ab
		}

		if y-ab > 0 {
			yhusoku = y - ab
		}

		newcost := 2*c*ab + a*xhusoku + b*yhusoku
		//fmt.Println(ab, "--", costmin, newcost)
		costmin = min(costmin, newcost)
	}

	fmt.Println(costmin)

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

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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



int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	stack<char> ch;
	ch.push(s[0]);
	for(int i=1;i<s.length();i++){
		if(ch.top()!=s[i]){
			ch.push(s[i]);
		}
	}
	cout<<ch.size()<<endl;
	return 0;
}

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

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

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

	int ans = 0;

	for (int i = 0; i < N; i++) {

		bool is_candidate = true;

		for (int j = 0; j < i; j++) {
			if (H[j] > H[i]) {
				is_candidate = false;
				break;
			}
		}

		if (is_candidate) {
			ans++;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 3596
#include <stdio.h>

int main(int argc, char const *argv[])
{
  int num;
  double p;
  scanf("%d", &num);
  if(num%2==0) p=0.5;
  else{
    p=(num+1)/2;
    p=p/num;
  }
  printf("%f\n", p);
  return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD = 1000000007;

int main() {
    int N,X,Y;cin >> N >> X >> Y;
    int D[N] = {};
    for (int i = 1;i <= N - 1;i++){
        for (int j = i + 1;j <= N;j++){
            int stan = j - i;
            int scut = abs(X - i) + abs(Y - j) + 1;
            int dist = min(stan,scut);
            D[dist - 1] += 1;
        }
    }
    for (int i = 0;i < N - 1;i++){
        cout << D[i] << endl;
    }
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
v = list(map(int,input().split()))

v = sorted(v,reverse=True)
max_ave = sum(v[0:a])/a
index_max_ave = -1
for i in range(a,b+1)[::-1]:
  max_ave = max(sum(v[0:i])/(i),max_ave)
  if max_ave == sum(v[0:i])/(i):
    index_max_ave = i

print(max_ave)

def combination(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result


num = v[index_max_ave-1]
for i in range(index_max_ave):
  if num != v[i]:
    print(combination(v[0:index_max_ave].count(num)+v[index_max_ave:n].count(num),v[0:index_max_ave].count(num)))
    exit()

cnt = v.count(num)
ans = 0
for i in range(a,min(b+1,cnt+1)):
  ans += combination(cnt,i)
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template<typename T>
#define _HT template<typename H,typename... T>
_T _DEF(T,in,int c){T n{};int m{1};while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
_T _SCAN(T &n){int c{gcu()};return c==EOF?false:(n=in<T>(c),true);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
_OUT(string s){for(char c:s)pcu(c);}
#endif
_OUT(const char *s){while(*s)pcu(*s++);}
_T _OUT(T n){static char b[20];char *p{b};T m=n<0?pcu('-'),-1:1;if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{int e,b{0},s{1};range(int _b,int _e,int _s):e(_e),b(_b),s(_s){}range(int _b,int _e):e(_e),b(_b){}range(int _e):e(_e){}
	struct it{int v,s;it(int _v,int _s):v(_v),s(_s){}operator int()const{return v;}operator int&(){return v;}int operator*()const{return v;}it& operator++(){v+=s;return *this;}};
	it begin(){return{b, s};}it end(){return{e,s};}};

int main() {
	array<int, 4> s;
	int a {};
	for (int &i: s)
		a += i = in();
	outl(a - *min_element(begin(s), end(s)) + max(in(), in()));
}


Measured memory_bytes: 2548
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,c[499],s[499],f[499];
	cin>>n;
	for(int i=0;i<n-1;i++)
		cin>>c[i]>>s[i]>>f[i];
	for(int i=0;i<n;i++){
		int time=0;
		for(int pos=i;pos<n-1;pos++){
			if(time<s[pos])
				time=s[pos];
			else
				time=(time+f[pos]-1)/f[pos]*f[pos];
			time+=c[pos];
		}
		cout<<time<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int h,w;
  string grid[10];
  bool flag=true;

  cin>>h>>w;
  FOR(i,0,h)cin>>grid[i];
  FOR(i,0,h-1){
    FOR(j,0,w-1){
      if(grid[i][j]=='#'){
        if(grid[i][j+1]=='#' && grid[i+1][j]=='#')flag=false;
        if(grid[i][j+1]=='.' && grid[i+1][j]=='.')flag=false;
      }
    }
  }
  FOR(i,1,h){
    FOR(j,1,w){
      if(grid[i][j]=='#'){
        if(grid[i][j-1]=='#' && grid[i-1][j]=='#')flag=false;
        if(grid[i][j-1]=='.' && grid[i-1][j]=='.')flag=false;
      }
    }
  }
  if(flag)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
2^3000
DP確定なんだが
どうすんだ
(r,c) = DP[c][r]

2 5 5
1 1 3
2 4 20
1 2 1
1 3 4
1 4 2

0  0  0
0  3  0
0  1  0
0  4  0
0  2  20

同じ行で３個までだった。。。
rとc逆う
グローバル関数でかかないとスタックオーバーフローだ。
２００万こえてる。
*/
ll DP[3001][3001][4];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll R,C,K; cin>>R>>C>>K;
  vector<vector<ll>> M(R+1, vector<ll>(C+1, 0));
  rep(i,K){
    ll r,c,v; cin>>r>>c>>v;
    M[r][c]=v;
  }
  for(ll r=1; r<=R; r++){
    for(ll c=1; c<=C; c++){
      rep(a, 4)//上からもってくる場合
        DP[r][c][0] = max(DP[r][c][0], DP[r-1][c][a]);
      if (M[r][c]>0)
        DP[r][c][1] = DP[r][c][0] + M[r][c];
      rep(a, 4)//左から
        DP[r][c][a] = max(DP[r][c][a], DP[r][c-1][a]);
      if (M[r][c]>0)
        rep(a, 3){
          if(DP[r][c-1][a]>0)
            DP[r][c][a+1] = max(DP[r][c][a+1], DP[r][c-1][a] + M[r][c]);
      }
    }
  }
  ll ans = 0;
  rep(i,4)
    ans = max(ans, DP[R][C][i]);
  cout<<ans<<endl;
}
/*  rep(i, R+1){
    rep(j, C+1)
      cout<<DP[i][j][2];
    cout<<endl;
  }
}
*/

Measured memory_bytes: 355112
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

unsigned int dp[3002][3002];
int main() {
	memset(dp, 0, sizeof(dp));
	int N, T; cin >> N >> T;
	int S; cin >> S;
	vector<pair<int, int>>ps;
	for (int i = 0; i < N; ++i) {
		int A, B; cin >> A >> B;
		ps.emplace_back(A, B);
	}
	for (int i = 0; i < N; ++i) {
		for (int t = 0; t <= T; ++t) {
			const int nextt = t + ps[i].second;
			if (nextt <= T) {
				if (!(t <S&&nextt > S)) {
					dp[i + 1][nextt] = max(dp[i + 1][nextt], dp[i][t] + ps[i].first);
				}
			}
			dp[i + 1][t] = max(dp[i + 1][t], dp[i][t]);
			dp[i][t + 1] = max(dp[i][t + 1], dp[i][t]);
		}
	}
	cout << dp[N][T] << endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


using namespace std;

#define int         long long
#define ld          double
#define vi          vector <int>
#define vp          vector <pair<int,int>>
#define vvi         vector <vector <int>>
#define pb          push_back
#define mp          make_pair
#define pi          pair<int,int>
#define all(a)      a.begin(),a.end()
#define sz(a)       a.size()
#define sl(a)       a.length()
#define rev(a)      sort(all(a),greater<int>())
#define ff          first
#define ss          second
#define minel(a)	*min_element(all(a))
#define maxel(a)	*max_element(all(a))
#define Mod         1000000007
#define deb(x)      cout << x << endl;
#define o(x)        for(auto a:x)cout << a <<" ";cout << endl;
#define o2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cout << x[i][j] << " ";cout << endl; } 
#define i(x,n)      for(int i=0;i<n;i++)cin >> x[i];
#define i2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cin >> x[i][j]; }
int inf = 1e18;
const int Max = 3005;
int dp[Max][Max];

vi a;
void solve(int l,int r)
{
    if(l == r)
    {
        dp[l][r] = a[l];
        return ;

    }

    if(dp[l][r] == -1)
    {
        solve(l+1,r);
        solve(l,r-1);
    }

   
    dp[l][r] = max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
    return ;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;cin >> n;
    a.resize(n);i(a,n);


    for(int i=0;i<Max;i++)
    {
        for(int j=0;j<Max;j++)dp[i][j] = -1;
    }

   
    solve(0,n-1);


    deb(dp[0][n-1]);
}



Measured memory_bytes: 74364
#include<iostream>
using namespace std;
int p[10010];
void init(int n)
{
    for(int i=0;i<=n;i++)
        p[i]=i;
};
int root(int a)
{
    if(p[a]==a)
        return a;
    return (p[a]=root(p[a]));
};
bool is_same_set(int a,int b)
{
    return root(a)==root(b);
};
void unite(int a,int b)
{
    p[root(a)]=root(b);
};
int main()
{
    int n,q;
    cin>>n>>q;
    init(n);
    for(int i=0;i<q;i++)
    {
        int cmd,a,b;
        cin>>cmd>>a>>b;
        if(cmd==0)
        {
            unite(a,b);
        }
        else
        {
            cout<<is_same_set(a,b)<<endl;
        }
    }
}

Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	for (int u = 0; u < 100; u++)
	{
		int a[5],b[5];
		int p = 0;

		for (int i = 0; i < 5; i++)
		{
			cin >> a[i] >> b[i];
			if (a[i] == 0 && b[i] == 0)
			{
				p++;
				break;
			}
		}
		if (p != 0)
		{
			break;
		}

		int gg = 0,ggg = 0;
		for (int i = 0; i < 5; i++)
		{
			if (a[i] + b[i] > gg)
			{
				gg = 0;
				gg = a[i] + b[i];
				ggg = 0;
				ggg = i;
			}
		}


		if (ggg == 0)
		{
			cout << 'A';
		}
		else if (ggg == 1)
		{
			cout << 'B';
		}
		else if (ggg == 2)
		{
			cout << 'C';
		}
		else if (ggg == 3)
		{
			cout << 'D';
		}
		else if (ggg == 4)
		{
			cout << 'E';
		}
		cout << " " << gg << endl;
	}
}



Measured memory_bytes: 3068
N,M,C=map(int,input().split())
b = input().rstrip().split(' ')
count = 0
for i in range(N):
  t = input().rstrip().split(' ')
  total = 0
  for j in range(M):
    total += int(t[j]) * int(b[j])
  total += C
  if total > 0:
    count += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define task "atcoder"
#define fi first
#define se second
#define ALL(v) (v).begin(), (v).end()
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;

const int N=200005;
string s;
int n,f[N],cnt[3000];

int pw(int n, int k)
{
    if(k==1) return n;
    if(k==0) return 1;
    int t=pw(n,k/2);
    if(k&1) return (t*t%2019)*n%2019;
    else return t*t%2019;
}
void solve()
{
    cin>>s;
    s=' '+s;
    n=s.size()-1;
    ///1234
    for(int i=1;i<=n;++i)
    {
        int c=s[i]-'0';
        f[i]=(f[i-1]+c*pw(10,n-i)%2019)%2019;
    }
    ll ans=0;
    cnt[0]=1;
    for(int i=1;i<=n;++i)
    {
        ans+=cnt[f[i]];
        ++cnt[f[i]];
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solve();
}





Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=a;i>n;i--)
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define MOD 1000000007

int main() 
{ 
	FAST;
	lli n;
	cin>>n;
	if(n==2||n==3||n==5){
		cout<<n<<endl;
		return 0;
	}
	bool flag=true;
	while(flag){
		bool temp = true;
		if(!(n&1)){
			n++;
			continue;
		}
		for(int i=3;i<=sqrt(n);i+=2){
			if(n%i==0){
				//cout<<n<<endl;
				temp = false;
				break;
			}
		}
		if(temp){
			cout<<n<<endl;
			return 0;
		}
		n++;
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n,d;
        cin >> n >> d;
        int i,j,k;
        int x=2*d+1;
        int ans=(n+x-1)/x;
        cout << ans << '\n';
        

}

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

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

  int total = 0;
  int minAbs = 10000000;

  for(int i = 0; i < n; i++){
    if(abs(minAbs) > abs(l + i)){
      minAbs = l + i;
    }

    total += (l + i);

  }

  cout << total - minAbs << endl;

  return 0;

}


Measured memory_bytes: 256
import sys

list=[]
num=6

for i in range(num):
    list.append(int(input()))
    if list[i]<0 or list[i]>123:
        print("Unexpected this input.")
        sys.exit()

for i in range(num-1):
    for j in range(num-1):
        if list[i]-list[j-1]>list[5]:
            print(":(")
            sys.exit()

print("Yay!")


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
int main(){
  char o[55],e[55];
  scanf("%s%s",o,e);
  for(int i=0;i<strlen(o)+strlen(e);i++){
    if(i%2==0) printf("%c",o[i/2]);
    else printf("%c",e[i/2]);
  }
}

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

string lcs(const string& a, const string& b) {
  const int n = a.size(), m = b.size();
  vector< vector<int> > X(n+1, vector<int>(m+1));
  vector< vector<int> > Y(n+1, vector<int>(m+1));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i] == b[j]) {
        X[i+1][j+1] = X[i][j] + 1;
        Y[i+1][j+1] = 0;
      } else if (X[i+1][j] < X[i][j+1]) {
        X[i+1][j+1] = X[i][j+1];
        Y[i+1][j+1] = +1;
      } else {
        X[i+1][j+1] = X[i+1][j];
        Y[i+1][j+1] = -1;
      }
    }
  }

  string c; 
  for (int i = n, j = m; i > 0 && j > 0; ) {
    if      (Y[i][j] > 0) --i;
    else if (Y[i][j] < 0) --j;
    else { c+=a[i-1]; --i; --j; }
  }
  reverse(c.begin(), c.end());
  return c;
}

int main()
{
	string s;
	while(cin >> s, s!="#END")
	{
		string ans;
		for(int i=0; i<s.size(); i++)
		{
			string a=s.substr(0,i);
			string b=s.substr(i);

			string c=lcs(a,b);

			if(ans.size() < c.size()) ans=c;
			else if(ans.size() == c.size() && ans < c) ans=c;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1088
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    ll q;
    cin >> s >> q;
    deque<char> dq;
    rep(i, sz(s)) dq.push_back(s[i]);
    int flag = 0;
    rep(i, q){
        int t;
        cin >> t;
        if(t == 1) flag = 1 - flag;
        else {
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(flag) dq.push_back(c);
                else dq.push_front(c);
            } else {
                if(flag) dq.push_front(c);
                else dq.push_back(c);
            }
        }
    }
if(!flag) {
    rep(i, sz(dq)) cout << dq[i];
} else {
    reverse(all(dq));
    rep(i, sz(dq)) cout << dq[i];
}


}




//queue<pint>().swap(q); キュー内を全て削除
//priority_queue<ll, vector<ll>, greater<ll> > que;
//auto dp=make_v<int>(4,h,w);
//vector<vector<ll>> g;
//g.assign(n, vector<ll>()); g.resize(n);でも大丈夫っぽい
//fill_v(dp,0);

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int mod = 1e9+7;

vector<P> prime_factorize(int N){
	vector<P> ans;
	for(int a = 2; a*a <= N; a++){
		if(N%a == 0){
			int ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}

signed main(){
	int a, b; cin >> a >> b;
	int g = __gcd(a, b);
	vector<P> map = prime_factorize(g);
	cout << map.size() + 1 << endl; 
}

Measured memory_bytes: 256
n = int(input())
x = []
y = []
z = []
for i in range(n):
  a,b = map(int, input().split())
  x.append(a+b)
  y.append(a-b)
  z.append(b-a)
print(max(max(x) - min(x),max(y) - min(y),max(z) - min(z)))

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

int main() {
  int n;
  cin >> n;
   
  for (int i=0; i<n; i++){
    string S;
    cin >> S;
  
    if (S=="Y"){
      cout << "Four" << endl;
      break;
    }else if (i==n-1)
      cout << "Three" << endl;
  }
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll b[200],a[200][200];

int main(){FIN;
  ll n,m,c,ans=0; cin >> n >> m >> c;
  fore(i,0,m) cin >> b[i];
  fore(i,0,n) fore(j,0,m) cin >> a[i][j];
  fore(i,0,n){
    ll acum=c;
    fore(j,0,m) acum+=a[i][j]*b[j];
    ans+=acum>0;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
n, m = gets.strip.split.map(&:to_i)
conds = m.times.map { gets.strip.split }

ans = -1

(0..(10 ** n).pred).each do |i|
  str = i.to_s.chars

  flag = conds.all? do |s, c|
    pos = s.to_i - 1
    str[pos] == c
  end

  if flag && str.length == n
    ans = i
    break
  end
end

puts(ans)


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

const int MOD = 10007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int dp[1001][8];
    string s;
    cin >> N >> s;
    int num[1000];
    for(int i = 0; i <= N; i++){
        fill(dp[i], dp[i] + 8, 0);
    }
    for(int i = 0; i < N; i++){
        if(s[i] == 'J'){
            num[i] = 2;
        }
        if(s[i] == 'O'){
            num[i] = 1;
        }
        if(s[i] == 'I'){
            num[i] = 0;
        }
    }
    for(int i = 0; i < 8; i++){
        if((i >> 2) == 1){ dp[0][i] = 1; }
    }
    for(int i = 0; i < N-1; i++){
        for(int j = 0; j < 8; j++){
            for(int k = 0; k < 8; k++){
                if((j & k) == 0) continue;
                if((j >> num[i]) % 2 == 0) continue;
                dp[i+1][k] = (dp[i+1][k] + dp[i][j]) % MOD;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 8; i++){
        if((i >> num[N-1]) % 2 != 0){
            ans += dp[N-1][i];
        }
    }
    printf("%d\n", ans % MOD);
    return 0;
}

Measured memory_bytes: 1260