akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)

LL n, m, x_[1000], y_[1000], z_[1000];

int main() {
	cin >> n >> m;
	inc(i, n) { cin >> x_[i] >> y_[i] >> z_[i]; }
	
	LL x[1000], y[1000], z[1000], ans = 0;
	inc(k, 8) {
		inc(i, n) { x[i] = x_[i]; }
		inc(i, n) { y[i] = y_[i]; }
		inc(i, n) { z[i] = z_[i]; }
		
		if(bit(k, 0)) { inc(i, n) { x[i] *= -1; } }
		if(bit(k, 1)) { inc(i, n) { y[i] *= -1; } }
		if(bit(k, 2)) { inc(i, n) { z[i] *= -1; } }
		
		LL v[1000];
		inc(i, n) { v[i] = x[i] + y[i] + z[i]; }
		sort(v, v + n, greater<LL>());
		
		LL s = 0;
		inc(i, m) { s += v[i]; }
		setmax(ans, s);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int judge(char s[2]);
int main(void)
{
	int num1, num2;
	char s1[2], s2[2];

	cin>>s1;
	cin>>s2;

	num1=judge(s1); num2=judge(s2);

	if(num1<num2){
		cout<<"<"<<endl;
	}else if(num1==num2){
		cout<<"="<<endl;
	}else{
		cout<<">"<<endl;
	}
}
int judge(char s[2])
{
	if(s[0]=='A'){
		return 10;
	}else if(s[0]=='B'){
		return 11;
	}else if(s[0]=='C'){
		return 12;
	}else if(s[0]=='D'){
		return 13;
	}else if(s[0]=='E'){
		return 14;
	}else{
		return 15;
	} 
}

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

using namespace std;

const int mod = 1000000007;

bool connected(int k, int w) {
  for (int i = 0; i + 2 < w; i++) {
    if (((k >> i) & 1) && ((k >> (i + 1)) & 1))
      return true;
  }
  return false;
}

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

  vector<vector<int>> dp(H + 1, vector<int>(W, 0));
  dp[0][0] = 1;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < 1 << (W - 1); k++) {
	if (connected(k, W))
	  continue;

	if (j >= 1 && ((k >> (j - 1)) & 1)) {
	  dp[i + 1][j - 1] += dp[i][j];
	  dp[i + 1][j - 1] %= mod;
	} else if (j <= W - 2 && ((k >> j) & 1)) {
	  dp[i + 1][j + 1] += dp[i][j];
	  dp[i + 1][j + 1] %= mod;
	} else {
	  dp[i + 1][j] += dp[i][j];
	  dp[i + 1][j] %= mod;
	}
      }
    }
  }

  cout << dp[H][K - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      //入力
      int N =sc.nextInt();//リンゴの数
      int L =sc.nextInt();
      
      int app[] =new int[N];//リンゴの味
      int pie[] =new int[N];//アップルパイの味
      
      int sum =0;//作る予定だったアップルパイの味
      
      //作る予定だったアップルパイの味を求める
      for(int i=0; i<N; i++){
      	app[i] = L+i;
        sum += app[i];
      }
      
      //作る予定だったアップルパイの味から
      //食べてしまったリンゴの味を引いたアップルパイの味を求める
      for(int i= 0; i<N; i++){
      	pie[i] = sum-app[i];
      }
      
      //作る予定だったアップルパイの味と
      //食べてしまったリンゴの味を引いたアップルパイの味の差の初期値
      int diff =0;
      
      //求める答え
      int ans =0;
      
      //差の絶対値が最小のものを求める
      for(int i=0; i<N; i++){
      	int min = Math.abs(sum-pie[i]);
        
         if(i == 0 ||diff > min){
         	diff = min;//条件が合えば最小を更新する
           	ans = pie[i];
         }
      }
      		System.out.println(ans);
    }
}   

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	cout << (N - 1) / 2 + 1 << endl;
	
	return 0;
}

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

int main() {
    int A,B,N,s;
    cin >> A >> B;
    int ans = 0, flag = 1;
    N = A;
    string n;

    for (int i = A; i < B+1; i++)
    {
        n = to_string(i);
        s = n.length();
        if(n[0] == n[4] && n[1] == n[3])
        {
            ++ans;
        }
        
        //++N;
    };

    cout << ans << endl;
    
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
S = input()

d = defaultdict(list)
for i, c in enumerate(S):
    d[c].append(i)


def gtmin(arr, num):
    for e in arr:
        if e >= num:
            return e
    return -1


cnt = 0
for i in range(1000):
    num = str(i).zfill(3)
    after = 0
    ok = True
    for digit in num:
        min_val = gtmin(d[digit], after)
        if min_val >= 0:
            after = min_val + 1
        else:
            ok = False
            break
    if ok:
        cnt += 1
print(cnt)

Measured memory_bytes: 42732
#include<stdio.h>

int main()
{
	int high,wide,i,j;

	while(1){
		scanf("%d %d",&high,&wide);
		if(high==0 && wide==0) break;

		if(high < 3 || 300<wide){
			printf("error\n");
		}else{
			for(i=0;i<high;i++){
				if(i==0||i==high-1){
					for(j=0;j<wide;j++)printf("#");
				}else{
					printf("#");
					for(j=2;j<wide;j++) printf(".");
					printf("#");
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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


























int main(){
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll s = 0;
    while(h1 != h2){
        s += 60;
        h1++;
    }
    s += m2 - m1;
    cout << s - k << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N, K;
  cin >> N >> K;
  int R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  
  vector<string> str(K, "");
  for(int i = 0; i < T.size(); i++){
    str.at(i%K) += T.at(i);
  }
  ll ans = 0;
  for(int i = 0; i < K; i++){
    //str.at(i)について
    for(int j = 0; j < str.at(i).size(); j++){
      if(j != 0 && str.at(i).at(j) == str.at(i).at(j-1)){
        int counter = 0;
        for(int k = j; k < str.at(i).size(); k++){
          if(str.at(i).at(j-1) == str.at(i).at(k)) counter++;
          else break;
        }
        if(str.at(i).at(j) == 'r') ans += counter/2 * P;
        if(str.at(i).at(j) == 's') ans += counter/2 * R;
        if(str.at(i).at(j) == 'p') ans += counter/2 * S;
        j += counter;
        j--;
      }
      else{
        if(str.at(i).at(j) == 'r') ans += P;
        if(str.at(i).at(j) == 's') ans += R;
        if(str.at(i).at(j) == 'p') ans += S;
      } 
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
ll a[405][405];
ll n,b[405],c[405];
ll solve(ll start,ll end)
{
//	cout<<start<<" "<<end<<endl;
	if(start==end)return 0;
	if(a[start][end]>-1)return a[start][end];
	a[start][end]=LONG_LONG_MAX;
	for(int i=start;i<end;i++)
	{
		a[start][end]=min(a[start][end],solve(start,i)+solve(i+1,end)+c[end]-c[start-1]);
	}
	return a[start][end];
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	cin>>n;
  	For(i,n)cin>>b[i+1];
  	c[0]=0;
  	For(i,n)c[i+1]=c[i]+b[i+1];
  	For(i,n+1)For(j,n+1)a[i][j]=-1;
  	cout<<solve(1,n)<<endl;
	return 0;
}

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

string solve(string s,int k){
    string res = "";
    int n = s.size();

    for(int i = 0;i < n-1;i ++){
        if(s[i]=='a' || k<'z'-s[i]+1) res += s[i];
        else{
            res += 'a';
            k -= 'z'-s[i]+1;
        }
    }
    int r = k%26;

    if(r<'z'-s[n-1]+1) res += (char)(s[n-1]+r);
    else r -= 'z'-s[n-1]+1,res += (char)('a'+r);

    return res; 
}

int main(){
    string s;
    int k;
    cin >> s >> k;

    cout << solve(s,k) << endl;
    return 0;
}

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

const int INF = 100000000;
int n, h;
int segMax[100000*4], segAdd[100000*4];

void add(int a, int b, int x, int k, int l, int r){
	if(r <= a || b <= l) return;
	
	if(a <= l && r <= b){
		segAdd[k] += x;
		while(k){
			k = (k-1)/2;
			segMax[k] = max(segMax[k*2+1]+segAdd[k*2+1], segMax[k*2+2]+segAdd[k*2+2]);
		}
		return;
	}
	
	add(a,b,x,k*2+1,l,(l+r)/2);
	add(a,b,x,k*2+2,(l+r)/2,r);
}

int getMax(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return 0;
	if(a <= l && r <= b) return (segMax[k]+segAdd[k]);
	int left = getMax(a,b,k*2+1,l,(l+r)/2);
	int right = getMax(a,b,k*2+2,(l+r)/2,r);
	
	return (max(left,right)+segAdd[k]);
}

int main(){
	scanf("%d%d",&n,&h);
	int hp = h;
	ll ans = 0;
	priority_queue<P> que;
	for(int i = 0; i < n-1; i++){
		int a, b;
		scanf("%d%d",&a,&b);
		add(i,i+1,hp,0,0,n);
		que.push(P(min(b,h-hp),i));
		hp -= a;
		while(hp <= 0){
			P p = que.top();
			que.pop();
			int sm = getMax(p.second, i+1, 0, 0, n);
			
			if(sm+p.first > h){
				p.first = h-sm;
				que.push(p);
				continue;
			}
			
			int num = min((-1*hp)/p.first + 1, (h-sm)/p.first);
            ans += num;
            hp += num*p.first;
             
            add(p.second, i + 1, num * p.first, 0, 0, n);
            que.push(p);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3408
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 200100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
const int inf=1e9;
struct Line{int v,next;}e[MAX<<1];
int h[MAX],cnt=1,dg[MAX];
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;++dg[u];}
int n,c[MAX],fa[MAX],sz[MAX];ll ans;
int S[MAX],top;
char s[MAX];
int d1[MAX];//子树中距离最远的一个点
int d2[MAX];//同上，可以从父亲转移
int d3[MAX];//子树中有经过至少一个黑点的最远点
int d4[MAX];//同上，可以从父亲转移
int d5[MAX];
int d6[MAX];//每一个点的下界
void dfs1(int u,int ff)
{
	fa[u]=ff;sz[u]=c[u];
	if((u!=1&&dg[u]==1)||(u==1&&!dg[u]))//leaves
	{
		d1[u]=0;d3[u]=c[u]?0:inf;
		return;
	}
	int mx=0,mx2=inf;
	for(int i=h[u];i;i=e[i].next)
	{
		int v=e[i].v;if(v==ff)continue;
		dfs1(v,u);sz[u]+=sz[v];
		mx=max(mx,d1[v]);
		if(d3[v]<inf)mx2=min(mx2,d1[v]);
	}
	d1[u]=mx+1;d3[u]=mx2+1;
	if(c[u])d3[u]=min(d3[u],d1[u]);
}
void dfs2(int u,int ff)
{
	d2[u]=max(d2[u],(ff!=0)+d2[ff]);
	if(ff)d5[u]=max(d5[u],d2[u]-1);
	top=0;for(int i=h[u];i;i=e[i].next)if(e[i].v!=ff)S[++top]=e[i].v;
	for(int i=1,mx=-1;i<=top;++i)//前缀其他儿子转移一下
	{
		int v=S[i];
		d2[v]=max(d2[v],mx+2);
		mx=max(mx,d1[v]);
	}
	for(int i=top,mx=-1;i>=1;--i)//后缀其他儿子转移一下
	{
		int v=S[i];
		d2[v]=max(d2[v],mx+2);
		mx=max(mx,d1[v]);
	}
	for(int i=h[u];i;i=e[i].next)
		if(e[i].v!=ff)dfs2(e[i].v,u);
}
int main()
{
	n=read();
	for(int i=1;i<n;++i)
	{
		int u=read(),v=read();
		Add(u,v);Add(v,u);
	}
	scanf("%s",s+1);int tot=0;
	for(int i=1;i<=n;++i)tot+=(c[i]=s[i]-48);
	if(!tot){puts("0");return 0;}
	memset(d3,63,sizeof(d3));memset(d4,63,sizeof(d4));
	dfs1(1,0);dfs2(1,0);
	for(int i=1;i<=n;++i)
	{
		if(c[i])d6[i]=0;
		else d6[i]=min(d3[i],(sz[i]==sz[1])?inf:d2[i]);
		int u=max(d1[i],d2[i])-1;
		for(int j=h[i];j;j=e[j].next)
		{
			int v=e[j].v;
			if(v==fa[i])u=min(u,d1[i]+1);
			else u=min(u,d5[v]+1);
		}
		if(u>=d6[i])ans+=u-d6[i]+1;
	}
	cout<<ans+1<<endl;
	return 0;
}


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

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N)
  {
    cin >> h[i];
  }
  sort(ALL(h));
  int m = 1000000000;
  rep(i,N-K+1)
  {
    m = min(m,h[i+K-1]-h[i]);
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 640
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

#互いに素なa,bについて、a*x+b*y=1の一つの解[x,y]を出力
def extgcd(a,b):
  r = [1,0,a]
  w = [0,1,b]
  while w[2]!=1:
    q = r[2]//w[2]
    r2 = w
    w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
    r = r2
    w = w2
  return [w[0],w[1]]

# aの逆元(mod M)を求める（aとMは互いに素であることが前提）
def mod_inv(a,M=mod):
  x = extgcd(a,M)[0]
  return (M+x%M)%M

#0!からn!までをmodしつつ計算
def mod_fact(n,Mod=mod):
  d = [1]*(n+1)
  for i in range(1,n+1):
    d[i] = d[i-1]*i%Mod
  return d

N,A,B,C,D = II()

value = [0]
for i in range(C,D+1):
  value.append(i)

fact = mod_fact(N)

inv = [0]*(N+1)
inv[N] = mod_inv(fact[N])
for i in range(1,N+1)[::-1]:
  inv[i-1] = inv[i]*i%mod

dp=[[0]*(N+1) for _ in range(B+1)]
for i in range(B):
  dp[i+1][0] = 1
for i in range(A,B+1):
  for j in range(A,N+1):
    if i==A:
      if j%A!=0:
        continue
      else:
        num = j//A
        if C<=num<=D:
          dp[i][j] = (fact[N]*inv[N-j]*inv[num]*pow(inv[A],num,mod))%mod
    else:
      for k in value:
        if k>j//i:
          break
        else:
          dp[i][j] = (dp[i][j] + dp[i-1][j-i*k]*fact[N-j+i*k]*inv[N-j]*pow(inv[i],k,mod)*inv[k])%mod
print(dp[B][N])

Measured memory_bytes: 126556
def main(N, M, a):
    dp = [-1] * (N+1)
    dp[0] = 1
    dp[1] = 1
    for i in a :
        dp[i] = 0
    for i in range(2, len(dp)):
        dp[i] = dp[i-1] + dp[i-2] if dp[i] != 0 else 0
    return dp[-1] % (10**9+7)

N, M = map(int, input().split())
a = list(int(input()) for _ in range(M))
print(main(N,M,a))

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

int main () {
    string s; cin >> s;
    bool flag = s[s.size() - 1] == 's';
    cout << s;
    if (flag) cout << 'e';
    cout << 's' << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
bool primer(int n) {
  if (n == 2) return true;
  if (n < 2 || n % 2 == 0) return false;
  for (int c = 3; c * c <= n; c += 2)
    if (n % c == 0) return false;
  return true;
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int cnt = 0;
  while (n--) {
    int t;
    cin >> t;
    cnt += primer(t);
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

template <class T> T gcd(T x, T y) {
    // 最小公倍数を求める
    if (y == 0)
        return x;
    gcd(y, x % y);
}

template <class T> T lcm(T x, T y) {
    // 最大公約数を求める
    T GCD = gcd(x, y);
    T ans = x / GCD * y;
    return ans;
}

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

    int N;
    scan(N);
    vector<int> v(N);
    scan(v);

    vector<int> l(N), r(N);
    l[0]     = v[0];
    r[N - 1] = v[N - 1];
    FOR(i, 1, N) { l[i] = gcd(l[i - 1], v[i]); }
    RFOR(i, N - 1, 0) { r[i] = gcd(r[i + 1], v[i]); }

    int ans = max(l[N - 2], r[1]);
    FOR(i, 1, N - 1) { chmax(ans, gcd(l[i - 1], r[i + 1])); }
    print(ans);

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 20
using namespace std;
typedef long long ll;
//switch全探索
int main() {
	int i, j;
	int N, M, k[nmax_def], s[nmax_def][nmax_def], p[nmax_def], looptime, ans = 0;
	bool swon[nmax_def], lgon;
	cin >> N >> M;
	for (i = 1; i <= M; i++)
	{
		cin >> k[i];
		for (j = 1; j <= k[i]; j++)
			cin >> s[i][j];
	}
	for (i = 1; i <= M; i++)
		cin >> p[i];

	looptime = pow(2, N);
	for (int T = 0; T < looptime; T++)
	{
		lgon = true;
		for (i = 1; i <= N; i++)
		{
			swon[i] = (T >> (i-1)) % 2;
		}
		for (i = 1; i <= M; i++)
		{
			int on_num = 0;
			for (int j = 1; j <= k[i]; j++)
			{
				if (swon[s[i][j]])
					on_num++;
			}
			if (on_num % 2 != p[i])
				lgon = false;
		}
		if (lgon)
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,M,A[1000],i,j,k;

double R;

int main()
{
cin>> R;

R*=2.*3.141592;

cout <<R;





}

Measured memory_bytes: 3788
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "bitset"

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;
const long double EPS = 1e-7;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<set<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].insert(R);
		edge[R].insert(L);
	}
	queue<int>Q;
	int three = 0;
	for (int i = 0; i < N; i++) {
		if (edge[i].size() == 1)Q.push(i);
		else if (edge[i].size() >= 3)three++;
	}
	while (three) {
		if (Q.empty()) {
			cout << "First\n";
			return 0;
		}
		vector<vector<int>>parent(N);
		set<int>nxq;
		while (!Q.empty()) {
			int cn = Q.front();
			int node = 0;
			int n = cn;
			int nx = n;
			int depth = 0;
			Q.pop();
			while (edge[nx].size() < 2) {
				node++;
				n = nx;
				nx = *edge[n].begin();
				edge[n].erase(nx);
				edge[nx].erase(n);
			}
			if (edge[nx].size() == 2)three--;
			if (node % 2) {
				edge[n].insert(nx);
				edge[nx].insert(n);
				if (edge[nx].size() == 3)three++;
				parent[nx].push_back(n);
			}
			if (edge[nx].size() == 2)nxq.insert(nx);
			if (!three) {
				node = 0;
				for (auto i : edge)if (i.size() == 2)node++;
				if (node % 2)cout << "First\n";
				else cout << "Second\n";
				return 0;
			}
		}
		//for (auto i : nxq) {
		//	if (edge[i].size() == 2) {
		//		for (auto j : parent[i])Q.push(j);
		//	}
		//	if (edge[i].size() == 1)Q.push(i);
		//}
		for (int i = 0; i < N; i++) {
			if (edge[i].size() == 1)Q.push(i);
		}
		if (clock() > CLOCKS_PER_SEC * 1900 / 1000) {
			cout << "First\n";
			return 0;
		}
	}
	int node = 0;
	for (auto i : edge)if (i.size() == 2)node++;
	if (node % 2)cout << "First\n";
	else cout << "Second\n";
	return 0;
}


Measured memory_bytes: 18904
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll;
#define N 200006
struct edge{int to,nxxt;}e[N];
int n,X,D,head[N],cnt=1,fa[N];
int v[N],id[N];
ll dp[N],w[N];
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void dfs(int te)
{v[te]=1;
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;dfs(j);
		v[te]+=v[j];w[te]+=w[j];
	}
}
bool cmp(int x,int y){return 1ll*v[x]*w[y]>1ll*v[y]*w[x];}
int main()
{
	scanf("%d%d%d",&n,&X,&D);
	scanf("%lld",&w[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%lld%d",&w[i],&fa[i]);
		ins(fa[i],i);
	}dfs(1);
	for(int i=1;i<=n;i++)id[i]=i;sort(id+1,id+1+n,cmp);int tn=min(n,D),tm=n*n*n;
    for(int i=1;i<=tm;i++)dp[i]=1e18;
    for(int i=1;i<=n;i++)
    {
        int x=id[i],tt=tn;
        for(int j=0;(1<<j)<=tt;j++)
        {
            int tv=v[x]<<j;
            ll tw=w[x]<<j;
            for(int ii=tm;ii>=tv;ii--)dp[ii]=min(dp[ii],dp[ii-tv]+tw);
            tt-=1<<j;
        }
        if(tt)
        {
            int tv=v[x]*tt;
            ll tw=w[x]*tt;
            for(int ii=tm;ii>=tv;ii--)dp[ii]=min(dp[ii],dp[ii-tv]+tw);
        }
    }
    ll ans=0;
    for(int i=0;i<=tm;i++)if(dp[i]<=X)
    {
        ll sum=i,tv=dp[i];
        for(int j=1;j<=n;j++)
        {
            int x=id[j];
            if(x==1)
            {
                sum+=(X-tv)/w[x]*v[x];
                break;
            }
            int ct=min(1ll*D-tn,(X-tv)/w[x]);
            sum+=1ll*ct*v[x],tv+=1ll*ct*w[x];
        }
        ans=max(ans,sum);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4824
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

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

  vi c(n);
  vvi g(n);
  vector<pii> E;
  rep(i, n-1){
    int a,b;cin>>a>>b;
    a--;b--;
    c[a]++;
    c[b]++;
    g[a].pb(b);
    g[b].pb(a);
    E.pb(mp(a, b));
  }
  dump(g);
  dump(E);

  int k = 0;
  rep(i, n){
    chmax(k, c[i]);
  }
  cout << k << endl;

  queue<pair<int, int>> q;
  q.push(mp(0, -1));
  vi used(n);
  used[0] = 1;
  map<pii, int> ans;
  while (!q.empty()){
    auto tmp = q.front();q.pop();
    int v;
    int r;
    tie(v, r) = tmp;
    dump(v, r);

    int col = 0;
    each(x, g[v]){
      if (!used[x]){
        col++;
        dump(x, r, col);
        if (col==r) col++;
        dump(x, r, col);

        used[x] = 1;
        dump("hello", x, col);
        q.push(mp(x, col));

        if (v<x) ans[mp(v, x)] = col;
        else     ans[mp(x, v)] = col;
      }
    }
  }
  dump(ans);
  rep(i, n-1){
    cout << ans[E[i]] << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 100;
//#define int long long
const int INF = 1e9;

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	int l = 0;
	int r = 1e9;

	while (r - l > 1){
		int m = (l + r) >> 1;

		int kk = k;
		for (int i =0 ; i < n; i++){
			int cnt = (a[i] - 1) / m;
			kk -= cnt;
		}

		if (kk < 0) l = m;
		else r = m;
	}

	cout << r << '\n';
    return 0;
}


Measured memory_bytes: 3960
M = int(input())
B = [0] + list(map(int, input().split()))

ans = [0] * (M+1)
ret = []

for i in reversed(range(1, M+1)):
    if i > M / 2:
        ans[i] = B[i]
    else:
        if B[i] == sum(ans[i*2::i]) % 2:
            ans[i] = 0
        else:
            ans[i] = 1
    if ans[i] == 1:
        ret.append(i)

print(len(ret))
if len(ret) > 0:
    print(*ret[::-1])

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

using namespace std;

typedef long long ll;

int main () {
	ll n, m, d;
	ll x, y, i;
	ll ret = 0;
	
	cin >> n >> d;
	
	for(i = 0; i< n; i++) {
		cin >>x >>y;
		if (sqrt(x * x + y * y) <= d) {
			ret++;
		}
	}
	
	cout << ret <<endl;
	
	return 0;
}

Measured memory_bytes: 3648
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    s=deque(list(input()))
    t=deque(list(input()))

    for i in range(len(s)):
        s.rotate()
        if s==t:
            print('Yes')
            break
        if i ==len(s)-1:
            print('No')
            break


resolve()

Measured memory_bytes: 3316
fact = [1 for _ in range(200000)]
inv = [1 for _ in range(200000)]
fact_inv = [1 for _ in range(200000)]

mod = 998244353
for i in range(2, 200000):
    fact[i] = (fact[i-1]*i) % mod
    inv[i] = mod - (inv[mod % i] * (mod // i)) % mod
    fact_inv[i] = (fact_inv[i-1] * inv[i]) % mod

N, M, K = map(int, input().split())
ans = 0
a = pow(M-1, N-1-K, mod)
for i in range(K, -1, -1):
    ans += (fact[N-1] * fact_inv[i] * fact_inv[N-1-i]) * M * a
    ans = ans % mod
    a *= M-1
    a = a % mod
print(ans)

Measured memory_bytes: 32608
#include<iostream>
using namespace std;
 
int main()
{int n, counter=0;
 cin>>n;
 int a[n];
 
 for(int i=0; i<n; i++)
 {cin>>a[i];}
 
 for(int i=1; i<(n-1); i++)
 { if(a[i]>a[i-1]&&a[i]<a[i+1])
   counter++;
  
  else if(a[i]<a[i-1]&&a[i]>a[i+1])
    counter++;
  
  else
    continue;}
 
 cout<<counter;
}

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

const int MOD = (int)1e9+7;

int modpow(int b, int x){
	if (x == 0) return 1;
	else if (x & 1){
		return (ll)b * modpow(b, x-1) % MOD;
	}
	else{
		int d = modpow(b, x/2);
		return (ll)d * d % MOD;
	}
}

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

	vector<int> f(k + 1);	
	for (int i = 1; i <= k; ++i){
		f[i] = modpow(k/i, n);
	}

	for (int i = k; i >= 1; --i){
		for (int j = i * 2; j <= k; j+=i){
			f[i] = (f[i] - f[j] + MOD) % MOD;
		}
	}
	int ans = 0;
	for (int i = 1; i <= k; ++i){
		ans = (ans + ((ll)f[i] * i) % MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>


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; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll N, A, B; scanf("%lld %lld %lld", &N, &A, &B);
	N %= 12;
	for (ll i = 1; i <= N; i++) {
		if (i & 1) {
			A = A - B;
		}
		else {
			B = A + B;
		}
	}
	cout << A << " " << B << endl;
	return 0;

}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, A[300][300], ans;
constexpr ll inf{ numeric_limits<ll>::max() / 3 };
int main() {
    fill(A[0], A[300], inf);
    cin >> N;
    for(int i{}; i < N; ++i)
        for(int j{}; j < N; ++j)
            cin >> A[i][j];
    for(int k{}; k < N; ++k)
        for(int i{}; i < N; ++i)
            for(int j{}; j < N; ++j)
                if(A[i][j] > A[i][k] + A[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
    for(int i{}; i < N - 1; ++i)
        for(int j{ i + 1 }; j < N; ++j) {
            ans += A[i][j];
            for(int k{}; k < N; ++k)
                if(i != k && j != k && A[i][j] == A[i][k] + A[k][j]) {
                    ans -= A[i][j];
                    break;
                }
        }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  string t;
  cin>>s>>t;
  int d=s.length();
  int e=t.length();
  int f=1;
  for(int i=0;i<d;i++){
     if(t[i]==s[i]){
      ;
     }else{
      cout<<"No";

      return 0;
     }
  }
  if(f && d==e-1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  

}

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

#define lld long long

int main() {
    lld N;
    lld sum = 0;
    cin >> N;

    for(lld i = 1; i <= N; i++) {
        if(i % 3 == 0 && i % 5 == 0) {
        } else if(i % 3 == 0) {
        } else if(i % 5 == 0) {
        } else {
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}

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

//#define FILEIO

using namespace std;

const int SZ = 52;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
     return (a > b);
}

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    long long int n, i, j, k, r, g, b, len;
    long long int sum;
    char s[5000];

    cin >> n >> s;
    len = strlen(s);
    r = g = b = 0;
    for(i = 0; i < len; i++)
    {
        if(s[i] == 'R')
        {
            r++;
        }
        else if(s[i] == 'G')
        {
            g++;
        }
        else if(s[i] == 'B')
        {
            b++;
        }
    }
    sum = r * g * b;
    for(i = 0; i < n; i++)
    {
        for(j = i + 1; j < n; j++)
        {
            if(j < (2 * j) - i && (2 * j) - i < n)
            {
                k = (2 * j) - i;
                if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])
                {
                    sum--;
                }
            }
        }
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    string S, T;
    cin>>S>>T;
    ll SzS, SzT;
    SzS=S.size();
    SzT=T.size();
    vector<char> SS(SzS);
    vector<char> TT(SzT);
    rep(i, SzS){
        SS[i]=S.at(i);
    }
    rep(i,SzT){
        TT[i]=T.at(i);
    }
    sort(ALL(SS));
    sort(ALL(TT));
    reverse(ALL(TT));
    rep(i, SzS){
        if(SS[i]<TT[i]){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(SS[i]>TT[i]){
            cout<<"No"<<endl;
            return 0;
        }
        if(i==SzT-1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}
     

Measured memory_bytes: 256
# coding:utf-8

import sys
INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    h, w = LI()

    if h % 3 == 0 or w % 3 == 0:
        return 0

    res = INF
    j = w // 2
    for i in range(1, h // 2 + 1):
        S = [i * w, (h - i) * j, (h - i) * (w - j)]
        res = min(res, max(S) - min(S))
        k = (h - i) // 2
        S = [i * w, k * w, ((h - i) - k) * w]
        res = min(res, max(S) - min(S))

    i = h // 2
    for j in range(1, w // 2 + 1):
        S = [j * h, (w - j) * i, (w - j) * (h - i)]
        res = min(res, max(S) - min(S))
        k = (w - j) // 2
        S = [j * h, k * h, ((w - j) - k) * h]
        res = min(res, max(S) - min(S))

    return res


print(main())


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
int N,D,X;
int A[200];
int i;
cin >> N >> D >> X;
for(i=1;i<=N;i++){
cin >> A[i];
}
for(i=1;i<=N;i++){
X += (D-1)/A[i] + 1;
}
cout << X << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int m = sc.nextInt(), n = sc.nextInt();
            if ((m | n) == 0) {
                break;
            }
            Integer[] r = new Integer[n];
            Arrays.fill(r, 0);
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++)
                    r[j] += sc.nextInt();
            }
            Integer[] t = r.clone();
            int[] a = new int[n];
            Arrays.sort(r, Comparator.reverseOrder());
            for (int i = 0; i < n;i++) {
                for (int j = 0; j < n; j++) {
                    if (r[i] == t[j] && t[j] >= 0) {
                        a[i] = j + 1;
                        t[j]=-1;
                        break;
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                System.out.print(a[i] + (i < n - 1 ? " " : "\n"));
            }
        }
    }
}


Measured memory_bytes: 86120
def resolve():
    N = int(input())
    S = []
    for _ in range(N):
        s = input()
        S.append(s)
    M = int(input())
    T = []
    for __ in range(M):
        t = input()
        T.append(t)
    SS = set(S)
    ans = []
    for i in SS:
        ans.append(S.count(i)-T.count(i))
    print(max(max(ans), 0))
resolve()

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

int main(){
	int N; cin>>N;
	int H[N], dp[N];
	rp(i, 0, N) cin>>H[i];
	dp[0] = 0;
	rp(i, 1, N){
		dp[i] = dp[i-1] + abs(H[i-1] - H[i]);
		if(i-2>=0) chmin(dp[i], dp[i-2] + abs(H[i-2] - H[i]));
	}
	cout<< dp[N-1] <<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int a, b, c, k, i;
  scanf("%d%d%d%d", &a,&b,&c,&k);

  if(a>b&&a>c){
    for(i=0;i<k;i++){
      a=a*2;
    }
  }else if(b>a&&b>c){
    for(i=0;i<k;i++){
      b=b*2;
    }
  }else{
    for(i=0;i<k;i++){
      c=c*2;
    }
  }

  printf("%d\n", a+b+c);

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				long a = 0;
				for (int k = 0; k < d; k++) {
					a += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
				}
				int b = (int) Math.sqrt(a);
				int c = (int) Math.ceil(Math.sqrt(a));
				if (b == c) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


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

const int mod = 1e9+7;

long long fact[100005];

long long finv[100005];

long long  inv[100005];

long long  a[100005];

map<int,int> m;

long long ncr(long long n , long long r)
{
    if((n-r)>=0 && r>=0)
    {
        return (1ll*fact[n]*(1ll*finv[n-r]%mod*finv[r]%mod)%mod)%mod;
    }
    return 0;
}

int main()
{
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for(int i = 2 ; i<=100005 ; i++)
    {
        inv[i] = ((mod - (mod/i))*inv[mod%i])%mod;
        fact[i] = (1ll*fact[i-1]*i)%mod;
        finv[i] = (1ll*finv[i-1]*inv[i])%mod;
    }



    long long  n;

    cin >> n;

    long long idx,x;

    for(int i = 1 ; i<=n+1 ; i++)
    {
        cin >> a[i];

        if(m[a[i]]==0)
        {
            m[a[i]] = i;
        }
        else
        {
            x =  m[a[i]];
            idx = i;
        }
    }

    long long ans;

    for(int i = 1 ; i<=n+1 ; i++){
    ans = ncr(n+1 , i);
    ans-=ncr(n-idx+x , i-1);
    ans = (ans+mod)%mod;

    cout << ans << "\n";
    }
}



Measured memory_bytes: 8960
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const double eps = 1e-10;
const int MAX_N = 50;
const double g = 9.8;

int N, V, X, Y;
int L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

double position(double vy, double t) {
	return vy*t-g*t*t/2.0;
}

int cmp(double lb, double ub, double a) {
	return a < lb + eps?-1:a>ub-eps?1:0;
}

// 射出路径经过(qx,qy)时，能否击中猪
bool check(double qx, double qy) {
	double a = g*g/4.0, b=g*qy-V*V, c=qx*qx+qy*qy;
	double D = b*b-4*a*c;
	if (D < 0 && D > -eps) D = 0;
	if (D < 0) return false;
	for (int d = -1; d <= 1; d += 2) { // 验证解的循环
		double t2 = (-b + d*sqrt(D))/(2*a);
		if (t2 <= 0) continue;
		double t = sqrt(t2);
		double vx = qx/t, vy=(qy+g*t*t/2.0)/t;
		// 是否通过猪的正上方？
		double yt = position(vy, X/vx);
		if (yt < Y-eps) continue;

		bool ok = true;
		for (int i = 0; i < N; ++i) {
			if (L[i] >= X) continue;
			if (R[i] == X &&  Y <= T[i] && B[i] <= yt) ok = false;
			int yL = cmp(B[i], T[i], position(vy, L[i]/vx)); // 左侧相对位置
			int yR = cmp(B[i], T[i], position(vy, R[i]/vx)); // 右侧相对位置
			int xH = cmp(L[i], R[i], vx*(vy/g)); // 最高点相对位置
			int yH = cmp(B[i], T[i], position(vy, vy/g));
			if (xH == 0 && yH >= 0 && yL < 0) ok = false;
			if (yL * yR <= 0) ok = false;
		}
		if (ok) return true;
	}
	return false;
}

int main() {
	scanf("%d%d%d%d", &N, &V, &X, &Y);
	for (int i = 0; i < N; ++i) {
		scanf("%d%d%d%d", L+i, B+i, R+i, T+i);
	}
	for (int i = 0; i < N; ++i) {
		R[i] = min(R[i], X);
	}
	bool ok = check(X, Y);
	for (int i = 0; i < N; ++i) {
		ok |= check(L[i], T[i]);
		ok |= check(R[i], T[i]);
	}
	puts(ok?"Yes":"No");
	return 0;
}


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

using namespace std;


int K, d[20], cnt;

void nxt() {
	int k;
	for (k = 1; k <= cnt; k++) {
		d[k]++;
		if (d[k] <= 9 && (k == cnt || abs(d[k] - d[k + 1]) <= 1)) break;
	}
	if (k > cnt) {
		d[++cnt] = 1;
		for (int j = 1; j < cnt; j++) d[j] = 0;
	}
	else {
		for (int j = k - 1; j; j--) {
			d[j] = max(d[j + 1] - 1, 0);
		}
	}
}

int main() {
	cin >> K;
	d[1] = cnt = 1;
	for (int i = 2; i <= K; i++) {
		nxt();
		
	}for (int j = cnt; j; j--) cout << d[j];
		cout << endl;
}

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

int main(){
    vector<int> a(2);
    vector<int> b(2);
    int i;
    cin >> a.at(0) >> a.at(1);

    for(i=0;i<2;i++){
        if(a.at(i)==1||a.at(i)==3||a.at(i)==5||a.at(i)==7||a.at(i)==8||a.at(i)==10||a.at(i)==12){
            b.at(i) = 0;
        }
        else if(a.at(i)==4||a.at(i)==6||a.at(i)==9||a.at(i)==11){
            b.at(i) = 1;
        }
        else if(a.at(i) ==2){
            b.at(i) = 2;
        }
    }

    if(b.at(0) == b.at(1)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    a, b,x = map(int, input().split())
    set1=set([i for i in range(a,min(a+x,b))])
    set2=set([i for i in range(max(a,b-x+1),b+1)])
    sumSet = set1 | set2
    list = list(sumSet)
    list.sort()

    for i in list:
        print(i)


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

int main() {
    int n;
    while(cin >> n, n) {
        vector<string> v(n);
        for(int i=0; i<n; ++i) {
            cin >> v[i];
        }
        vector<vector<int>> dp(n, vector<int>(n));
        int res = 0;
        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                if(v[i][j] == '*') {
                    dp[i][j] = 0;
                } else if(i == 0 || j == 0) {
                    dp[i][j] = 1;
                } else {
                    dp[i][j] = min(dp[i-1][j], min(dp[i-1][j-1], dp[i][j-1])) + 1;
                }
                res = max(res, dp[i][j]);
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 7824
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(void) {
    int k, s;
    cin >> k >> s;

    int count = 0;
    REP(x, k+1) {
        REP(y, k+1) {
            int z = s - x - y;
            if (z >= 0 && z <= k) count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}
ll ans=-1000000000;



int main()
{
 int n;
 cin>>n;
 vector<int> l(n);
 rep(i,n) cin>>l[i];
 sort(l.begin(),l.end());
 ll ans=0;
 rep(b,n)rep(a,b){
     int ab=l[a]+l[b];
     int r= lower_bound(l.begin(),l.end(),ab)-l.begin();
     int l=b+1;
     ans+=max(0,r-l);
 }
 cout<<ans<<endl;
}



Measured memory_bytes: 3632