akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int data[10],dai1,dai2,i;
	for(i=0;i<10;i++)	scanf("%d",&data[i]);
	sort(data,data+10);
	dai1=data[7]+data[8]+data[9];
	for(i=0;i<10;i++)	scanf("%d",&data[i]);
	sort(data,data+10);	
	dai2=data[7]+data[8]+data[9];
	printf("%d %d\n",dai1,dai2);
	return 0;
}


Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
int n,f[110][11],p[110][11],flag,tot=-2100000000;
bool vis[11];
inline void jd(){
	int q[110]={0},tott=0;
	for(int i=1;i<=10;++i)
		for(int j=1;j<=n;++j)
			if(f[j][i]==1&&vis[i])++q[j];
	for(int i=1;i<=n;++i){
	//	printf("%d ",q[i]);
		tott+=p[i][q[i]];
	}
	tot=max(tott,tot);
}
void dfs(int r){
	if(r==10){
		if(flag>0)jd();
		return ;
	}
	++r;
	vis[r]=true;
	++flag;
	dfs(r);
	--flag;
	vis[r]=0;
	dfs(r);
	return ;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=10;scanf("%d",&f[i][j]),++j);
	for(int i=1;i<=n;++i)
		for(int j=0;j<=10;scanf("%d",&p[i][j]),++j);
	dfs(0);
	printf("%d\n",tot);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(ll i=0;i<n;i++)
#define PRN(n) printf("%lld\n",n)
#define PRF(f) printf("%lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
typedef long long int ll;
int main(){
  ll n,m;
  scanf("%lld %lld",&n,&m);
  if(n*2>=m){
    PRN(m/2);
  }else{
    PRN(n+(m-2*n)/4);
  }
  return 0;
}

Measured memory_bytes: 128
def main():
    H, W, A, B = map(int, input().split())
    
    for i in range(H):
        if i < B:
            row = ["0"] * A + ["1"] * (W - A)
        else:
            row = ["1"] * A + ["0"] * (W - A)
        print("".join(row))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3956
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, p) = (v[0], v[1]);
    println!("{}", (a * 3 + p) / 2);
}

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 read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
#define N 300010
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define fs first
#define sc second
#define db double
#define pb push_back
#define ll long long
#define VI vector<int>
#define PII pair<int,int>
#define PQ priority_queue
#define NP next_permutation
#define ull unsigned long long
#define sz(a) (int)a.size()
#define len(a) (int)strlen(a)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define F(i,j,k) for(register int i=j;i<=k;i++)
#define CK1(x) cout<<"["<<(x)<<"]\n";
#define CK2(x,y) cout<<"["<<(x)<<","<<(y)<<"]\n";
#define CK3(x,y,z) cout<<"["<<(x)<<","<<(y)<<","<<(z)<<"]\n";
#define IOS ios::sync_with_stdio(false)
using namespace std;
istream &operator >> (istream &in,VI &v){for(auto &i:v)in>>i;return in;}
ostream &operator << (ostream &out,VI &v){for(auto i:v)out<<i<<" ";return out;}
int main()
{
    IOS;
#if 0
    int T;cin>>T;
    while(T--)
#endif
    {
        int n;
        cin>>n;
        cout<<(1000-n%1000)%1000;
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N = 200010,MOD =998244353;
LL n,Q;
LL mod[11][N],power[N];
struct Segtree
{
    LL l[N*4],r[N*4],lazy[N*4];
    LL sum[N*4];
    void build(LL x,LL ql,LL qr)
    {
        l[x] = ql;
        r[x] = qr;
        if(ql==qr)
        {
            sum[x] = 1;
            return ;
        }
        LL mid = (ql+qr)>>1;
        build(x*2,ql,mid);
        build(x*2+1,mid+1,qr);
        sum[x] = (sum[x*2]*power[r[x*2+1]-l[x*2+1]+1]%MOD+sum[x*2+1])%MOD;
    }
    void pushdown(LL x)
    {
        if(lazy[x])
        {
            LL v = lazy[x];
            lazy[x] = 0;
            sum[x*2] = mod[v][r[x*2]-l[x*2]+1];
            sum[x*2+1] = mod[v][r[x*2+1]-l[x*2+1]+1];
            lazy[x*2] = lazy[x*2+1] = v;
        }
    }
    void update(LL x,LL ql,LL qr,LL v)
    {
       // printf("%lld %lld %lld %lld\n",l[x],r[x],ql,qr);
        if(l[x]==ql&&r[x]==qr)
        {
            sum[x] = mod[v][qr-ql+1];
            lazy[x] = v;
            return ;
        }
        pushdown(x);
        LL mid = (l[x]+r[x])>>1;
      //  printf("%lld %lld %lld\n",ql,qr,mid);
        if(qr<=mid)
            update(x*2,ql,qr,v);
        else if(ql>mid)
            update(x*2+1,ql,qr,v);
        else
        {
            update(x*2,ql,mid,v);
            update(x*2+1,mid+1,qr,v);
        }
        sum[x] = (sum[x*2]*power[r[x*2+1]-l[x*2+1]+1]%MOD+sum[x*2+1])%MOD;
    }
}seg;
int main()
{
    scanf("%lld %lld",&n,&Q);
    power[1] = 10;
    for(LL i = 2;i<=n;++i)
    {
        power[i] = power[i-1]*10%MOD;
    }
    for(LL i = 1;i<=9;++i)
    {
        mod[i][1] =i;
        for(int j  =2;j<N;++j)
        {
            mod[i][j] = (mod[i][j-1]*10+i)%MOD;
        }
    }
    seg.build(1,1,n);
    while(Q--)
    {
        LL ql,qr,x;
        scanf("%lld %lld %lld",&ql,&qr,&x);
        seg.update(1,ql,qr,x);
        printf("%lld\n",seg.sum[1]);
    }
    return 0;
}


Measured memory_bytes: 35784
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
ac = Counter(inl())


for i in range(1, N + 1):
    print(ac[i])


Measured memory_bytes: 34888
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007;

int main(){
  ll N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  ll zero = 0;
  ll ret = 1;
  map<ll,ll> memo;
  rep(i,N){
    if(v[i]==0){
      memo[0]++;
      if(zero == 0) ret *= 3;
      else if(zero == 1) ret *= 2;
      else if(zero == 2) ret *= 1;
      else ret *= 0;
      ret %= MOD;
      zero++;
    }else{
      ll x = memo[v[i]-1];
      ret *= x;
      ret %= MOD;
      memo[v[i]-1]--;
      memo[v[i]]++;
    }
  }

  cout << ret%MOD << endl;
  
  return 0;
}



Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if(s == "AC") {
            ac++;
        }
        if(s == "WA") {
            wa++;
        }
        if(s == "TLE") {
            tle++;
        }
        if(s == "RE") {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
using namespace std;
using int64 = long long;
#define ForInt(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define ForItr(it, itBegin, itEnd) for (auto (it) = (itBegin); (it) != (itEnd); ++(it))


int main()
{
	int k, x;
	cin >> k >> x;
	int count = 2 * k - 1;
	int bx = x - k + 1;
	cout << bx;
	for (int i = 1; i < count; ++i)
	{
		cout << " " << (bx + i);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

int main() {
    ll N, K;
    cin >> N >> K;
    int a[N];

    rep(i, N) {
        int aa;
        cin >> aa;
        a[i] = aa;
    }

    map<int, int> m;
    rep(i, N) { m[i] = INF; }
    vector<int> v;

    m[0] = 0;
    int from = 0;
    int i = 0;
    v.pb(0);
    while (1) {
        int to = a[from] - 1;
        v.pb(to);
        if (m[to] == INF) {
            m[to] = i + 1;
        } else {
            int amari = m[to];
            int roop = i + 1 - amari;
            if (amari >= K) {
                COUT(v[K] + 1);
            } else {
                ll roop_index = (K - amari) % roop;
                COUT(v[amari + roop_index] + 1);
            }
            break;
        }
        from = to;
        i++;
    }
    return 0;
}

Measured memory_bytes: 14456
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)x.size())
using namespace std;

typedef long long lli;
typedef pair<int,int> pii;

const int inf=1e9;

vector<int> adj[1001];

int dp[2][5001],v[1001],n;
pii v2[1001][2];
bool flag=true;

bool cal(int cur,int idx) {
	int c=1,pr=0;
	for(int i=0;i<2;i++)for(int j=0;j<=5000;j++) dp[i][j] = inf;
	dp[0][0] = 0;
	for(auto &it:adj[cur]) {
		for(int i=0;i<=v[cur];i++) dp[c][i]=inf;
		for(int j=0;j<2;j++) {
			int f,s;
			if((idx^j)) f=v2[it][idx].se, s=v2[it][idx].fi;
			else f=v2[it][idx].fi, s=v2[it][idx].se;
			
			for(int i=v[cur];i>=0;i--) if(dp[pr][i] < inf && i+f <= v[cur] && s < inf) {
				dp[c][i+f] = min(dp[c][i+f], dp[pr][i]+s);
			}
		}
		swap(c,pr);
	}

	int mx=inf;
	for(int i=0;i<=v[cur];i++) if(dp[pr][i] < inf) mx = min(mx,dp[pr][i]);
	//printf("%d %d : %d %d\n",cur,idx,mx,v[cur]);
	if(mx < inf) {
		v2[cur][idx] = pii(v[cur], mx);
		return true;
	}
	else {
		v2[cur][idx] = pii(inf, inf);
		return false;
	}
}

void dfs(int cur) {
	for(auto &it:adj[cur]) dfs(it);
	
	bool f1=cal(cur,0), f2=cal(cur,1);
	if(!(f1||f2)) flag=false;
	//printf("%d : (%d %d), (%d %d)\n",cur,v2[cur][0].fi,v2[cur][0].se, v2[cur][1].fi, v2[cur][1].se);
}

int main() {
	scanf("%d",&n);
	for(int i=2,p;i<=n;i++) scanf("%d",&p), adj[p].push_back(i);
	for(int i=1;i<=n;i++) scanf("%d",v+i);

	dfs(1);
	puts(flag ? "POSSIBLE" : "IMPOSSIBLE");
		
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
  char text[5];
  scanf("%s",text);
  
  if(text[0]==text[1]&&text[2]==text[3]&&text[0]!=text[2]) printf("Yes\n");
  else if(text[0]==text[2]&&text[1]==text[3]&&text[0]!=text[1]) printf("Yes\n");
  else if(text[0]==text[3]&&text[1]==text[2]&&text[0]!=text[1]) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
const int N = 2e5+5;
const int mod = 1e9+7;
 
int add(int x,int y) {
    int ret = (x+y)%mod;
    if(ret<0) {
        ret += mod;
    }
    return ret;
}
int mul(int x,int y) {
    ll ret = (ll)x*y;
    ret %=mod;
    return ret;
}
int myPow(int x,int k) {
    int ret = 1;
    while(k>0) {
        if(k&1) {
            ret = mul(ret, x);
        }
        x = mul(x,x);
        k/=2;
    }
    return ret;
}
 
int in[N],fac[N];
 
int combi(int n,int k) {
    int ret = fac[n];
    ret = mul(ret, myPow(fac[k],mod-2));
    ret = mul(ret, myPow(fac[n-k],mod-2));
    return ret;   
}
void solve() {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    fac[0]=  1;
    for(int i=1;i<N;++i) {
        fac[i] = mul(fac[i-1],i);
    }
    int mm =  combi(n*m-2,k-2);
    int sum = 0,tmp=0,cc = 0;
    for(int i=1;i<=n;++i) {
        int x = add(mul(cc,i),-tmp); 
        ++cc;
        tmp = add(tmp,i);
        x = mul(x, mul(m,m));
        sum = add(sum,x);
    }
    cc = 0, tmp = 0;
    for(int i=1;i<=m;++i) {
        int x = add(mul(cc,i),- tmp);
        ++cc;
        tmp = add(tmp,i);
        x = mul(x,mul(n,n));
        sum = add(sum,x);
    }
    sum = mul(sum, mm);
    printf("%d\n", sum);
}
 
int main()
{
    //freopen("input.txt","r",stdin);
    solve();
}

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

int main(){
  string S;
  cin >> S;
  int red,blue;red=blue=0;
  int block = S.size();
  for(int i=0;i<block;i++){
    if(S.at(i)=='0'){
      red++;
    }else
      blue++;
  }
  cout << 2*min(red,blue);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    int dp[n+1];
    dp[0]=0;
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);

    dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++)
    {
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    if(n < 1000){
        printf("%d\n",(1000 - n));

    }
    else if(n > 1000 && n < 2000){
        printf("%d\n",(2000 - n));
    }
    else if(n > 2000 && n < 3000){
        printf("%d\n",(3000 - n));
    }
    else if(n > 3000 && n < 4000){
        printf("%d\n",(4000 - n));
    }
    else if(n > 4000 && n < 5000){
        printf("%d\n",(5000 - n));
    }
    else if(n > 5000 && n < 6000){
        printf("%d\n",(6000 - n));
    }
    else if(n > 6000 && n < 7000){
        printf("%d\n",(7000 - n));
    }
    else if(n > 7000 && n < 8000){
        printf("%d\n",(8000 - n));
    }
    else if(n > 8000 && n < 9000){
        printf("%d\n",(9000 - n));
    }
    else if(n > 9000 && n < 10000){
        printf("%d\n",(10000 - n));
    }
    else
        printf("0\n");

    return 0;
}


Measured memory_bytes: 3824
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[100010];

ll solve() {
    ll res = a[0] - 1;
    int mini = 1;
    for (int i = 1; i < n; i++) {
        if (a[i] == mini + 1) {
            mini++;
        } else if (a[i] > mini) {
            res += a[i] / (mini + 1) - (a[i] % (mini + 1) == 0);
        }
    }
    return res;
}
void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}


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

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

    int l, ab;
    if (A-B > 0){
    	l = A;
    	ab = A-B;
    }else{
    	l = B;
    	ab = B-A;
    }
	cout << (ab > 1 ? l+(l-1) : A + B)<< endl;  
}

Measured memory_bytes: 256
def main()->None:
    N, M = map(int, input().split())
    range_M = range(M)
    ab = []
    for i in range_M:
        a, b = map(int, input().split())
        ab.append(a)
        ab.append(b)
    range_N = range(N)
    for i in range_N:
        print(ab.count(i+1))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    double x1, x2, y1, y2, dis;
    cin >> x1 >>y1 >> x2 >> y2;
    dis = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    cout << fixed;
    cout << setprecision(5) << dis << endl;
}



Measured memory_bytes: 3284
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        while(true){
 
            String x = sc.next();
            int ans=0;
 
            if(x.equals("0")){break;}
            else{
                for(int i=0;i<x.length();i++){
                    ans += (x.charAt(i)-'0');
                }
                System.out.println(ans);
                ans = 0;
            }
        }
    }
}


Measured memory_bytes: 25992
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int a[4][3][10] = {};
	int n, b, f, r, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}

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

	return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int temp = 0;

		if(b > a){
			temp = a;
			a = b; 
			b = temp;
		}

		if(a == b){
			System.out.println(b);
		}else{
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		}
		

	}
}

Measured memory_bytes: 26352
#!/usr/bin/env python3
import sys
import math

def solve(N: int):
    a = 0
    if (N % 2 == 0):
        a = N / 2
    else:
        a = math.floor(N / 2)+1
    print(a/N)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
mod = (10**9)+7
w = [0]*n
for i in a:
    w[i] += 1
if (n%2==1):
    if (w[0]!=1):
        print(0)
        exit()
    for i in range(1,n):
        if (i%2==1):
            if (w[i]>0):
                print(0)
                exit()
        else:
            if (w[i]!=2):
                print(0)
                exit()
    print(pow(2,n//2,mod))
else:
    if (w[0]!=0):
        print(0)
        exit()
    for i in range(1,n):
        if (i%2==0):
            if (w[i]>0):
                print(0)
                exit()
        else:
            if (w[i]!=2):
                print(0)
                exit()
    print(pow(2,n//2,mod))

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

using namespace std;

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

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

	int N; cin >> N;
	string S; cin >> S;

	int x = 0;
	int res = 0;
	rep (i, S.length()){
		if (S[i] == 'I'){
			++x;
		}else{
			--x;
		} // end if
		res = max(res, x);
	} // end rep

	cout << res << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
int main()
{
    ll N;
    cin >> N;
    ll a, b;
    for (ll i = sqrt(N); i > 0; i--)
    {
        if (N % i == 0)
        {
            a = N / i;
            break;
        }
    }
    b = N / a;
    cout << a + b - 2;
    return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_2_D Shell Sort
// 2018.4.27 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cnt;

void insertion_sort(int n, int *a, int g)
{
	int i, j, key;

	for (i = g; i < n; i++) {
		key = a[i];
		j = i-g;
		while (j >= 0 && a[j] > key) {
			a[j+g] = a[j];
			j -= g;
cnt++;
		}
		a[j+g] = key;
	}
}

int m;
int g[102];

void shell_sort(int n, int *a)
{
	int i, lim;

	lim = n / 9;		// 要素数/9
	if (lim < 40) lim = 40;
	g[0] = 1;
	for (m = 1; ; m++) {
		g[m] = 3*g[m-1]+1;
		if (g[m] >= n || g[m] > lim) break;
	}

	cnt = 0;
	for (i = m-1; i >= 0; i--) insertion_sort(n, a, g[i]);
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int a[1000002];

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	shell_sort(N, a);
	printf("%d\n", m);
	printf("%d", g[m-1]);
	for (i = m-2; i >= 0; i--) printf(" %d", g[i]);
	printf("\n%d\n", cnt);
	for (i = 0; i < N; i++) printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 5552
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	int K, S;
	int remaining;
	int x, y, z;
	int patterns;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	K = atoi(ch);
	ch = strtok(NULL, " ");
	S = atoi(ch);

	patterns = 0;
	for(x = 0; x <= K; x += 1) {
		remaining = S - x;
		if(remaining < 0) {
			break;
		}
		for(y = 0; y <= K; y += 1) {
			remaining = S - x - y;
			if(remaining < 0) {
				break;
			}
			if(remaining <= K) {
				patterns += 1;
			}
		}
	}

	printf("%d\n", patterns);

	return 0;
}


Measured memory_bytes: 2080
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    over3200 = len([ai for ai in a if ai >= 3200])
    c = set([ai // 400 for ai in a if ai < 3200])
    print(max(1, len(c)), len(c) + over3200)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 2940
package main

import (
	"fmt"
	"math"
)

func main()  {
	var p, q, r int
	fmt.Scan(&p, &q, &r)

	fmt.Println(p+q+r-maxInt(p,maxInt(q,r)))
}

func maxInt(x int, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{ 
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;
NodePointer N;
NodePointer listSearch(int key);
void initialize();
void print();
void deleteNode(NodePointer a);
void deleteFirst();
void deleteLast();
void delete(int key);
void insert(int key);
int main(){ 
  int key;
  int size;
  int currentSize = 0; 
  char op[50]; 
  int np = 0, nd = 0;
  scanf("%d", &size); 
  initialize();
  for ( int i = 0; i < size; i++ ){
    scanf("%s%d", op, &key);
    if ( op[0] == 'i' ) {
      insert(key);
      np++;
      currentSize++;
    } 
    else if ( op[0] == 'd' ) 
    {
      if (strlen(op) > 6){
	if ( op[6] == 'F' )
            deleteFirst();
	else if ( op[6] == 'L' )
            deleteLast();
      }
      else { delete(key); nd++; 
      } 
      currentSize--; 
    }
  }
  print(); 
  return 0;
}
NodePointer listSearch(int key)
{
NodePointer i;
  for(i=N;i->next!=N;i=i->next)
  {
    if(i->next->key==key)
        return i->next;
  }
  return NULL;
} 
void initialize()
{
  N = malloc(sizeof(struct node));
  N->next = N; 
  N->prev = N;
}
void print()
{ 
  NodePointer cur = N->next;
  int isf = 1;
  while(1){
    if ( cur == N ) break;
    if ( isf == 0) printf(" "); 
    printf("%d", cur->key);
    cur = cur->next; isf = 0; 
  } 
  printf("\n");
}
void deleteNode(NodePointer a)
{
  a->next->prev=a->prev;
  a->prev->next=a->next;
  free(a);
}
void deleteFirst()
{ 
  NodePointer a = N->next;
  if ( a == N )
      return;
  deleteNode(a);
}
void deleteLast()
{
  NodePointer i;
  i=N->prev;
  deleteNode(i);
}
void delete(int key)
{
  NodePointer i; 
  i=listSearch(key);
  if(i!=NULL)
      deleteNode(i);
} 
void insert(int key)
{ 
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=N->next;
  N->next->prev=x;
  N->next=x;
  x->prev=N;
}



Measured memory_bytes: 32960
# -*- coding: utf-8 -*-
r, c = map(int, raw_input().split())
cl= [0] * c
for i in xrange(r):
	t = map(int, raw_input().split())
	for i, a in enumerate(t): cl[i] += a
	print ' '.join(map(str, t)), sum(t)
print ' '.join(map(str, cl)), sum(cl)

Measured memory_bytes: 6368
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
const int inf = 1000000000;
using namespace std;

int main()
{
	int n, x;
	cin >> n;
	vector<int> ary;
	int sum = 0;
	int min = 101, max = 0;

	for (int i = 0; i < n; i++) {
		cin >> x;
		ary.push_back(x);
		if (min > x) min = x;
		if (max < x) max = x;
	}
  
	unsigned int mmin = inf;
	for (int j = min; j <= max; j++) {
      sum = 0;
		for (int i = 0; i < n; i++) {
			sum += (ary[i] - j) * (ary[i] - j);
		}
		if (mmin > sum) mmin = sum;
	}

	cout << mmin << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int n,a[100005];

int32_t main() {
	cin>>n;
	int i;
	map<int,int> mp;
	for(i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]=i+1;
		
	}
	for(i=1;i<=n;i++)
		cout<<mp[i]<<" ";
	
	
	
}


Measured memory_bytes: 7040
#include <iostream>
#include <string.h>


using namespace std;

const int SMAX = 1001;
int dp[SMAX][SMAX];

int main() {
  char s1[SMAX], s2[SMAX];
  int s1len, s2len;
  cin >> s1;
  cin >> s2;

  s1len = strlen(s1);
  s2len = strlen(s2);

  for (int dpi=1; dpi<=s1len; ++dpi) {
    dp[dpi][0] = dp[dpi-1][0] + 1;
  }
  for (int dpj=1; dpj<=s2len; ++dpj) {
    dp[0][dpj] = dp[0][dpj-1] + 1;
  }
  for (int i=0; i<s1len; ++i) {
    for (int j=0; j<s2len; ++j) {
      int dpi = i+1;
      int dpj = j+1;
      int r = dp[dpi-1][dpj-1] + (s1[i]==s2[j] ? 0 : 1) ;    // replace cost
      int a = dp[dpi][dpj-1] + 1;   // add cost
      int d = dp[dpi-1][dpj] + 1;   // del cost
      int min = r;
      if (min>a)min = a;
      if (min>d)min = d;
      dp[dpi][dpj] = min;
    }
  }
  cout << dp[s1len][s2len] << endl;
/*
  for (int i=0; i<=s1len; ++i) {
    for (int j=0; j<=s2len; ++j) {
      cerr << dp[i][j] << " ";
    }
    cerr << endl;
  }
  */
  return 0;
}

Measured memory_bytes: 6988
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define true 1
#define false 0
typedef long long ll;
typedef unsigned char Uchar; 

int main(void){
  
  int i,j;
  char str[16];
  int n = 0,s=0;
  scanf("%s",str);
  
  for(i=0;i<3;i++){
    if(str[i] == 'R') {
      n++;
      //s = n;
    }else{
      n = 0;
    }
  
    if(n >= s) s = n;
    
  }
  printf("%d",s);
  
  return 0;
}

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

a=[1]
for i in range(2,33):
	for j in range(2,11):
		x=i**j
		if x<=1000:
			a.append(x)

a=list(set(a))
a.sort()
	
def binarySearch(value, xList):
    low=0
    high=len(xList)
    while low!=high:
        mid=(low+high)//2
        if xList[mid]<=value:
            low=mid+1
        else:
            high=mid
    return xList[low-1]
		
print(binarySearch(n,a))

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var input string
	fmt.Scan(&input)

	v := make([]int, len(input))
	for i, r := range input {
		v[i] = int(r - '0')
	}

	n := len(input) - 1
	op := make([]string, n)
	var ans int
	wantAns := 7

	for bit := 0; bit < (1 << uint(n)); bit++ {
		ans = v[0]
		for i := 0; i < n; i++ {
			if bit&(1<<uint(i)) == (1 << uint(i)) {
				ans += v[i+1]
				op[i] = "+"
			} else {
				ans -= v[i+1]
				op[i] = "-"
			}
		}
		if ans == wantAns {
			break
		}
	}

	var ansFormula string
	for i := range op {
		ansFormula = fmt.Sprintf("%s%d%s", ansFormula, v[i], op[i])
	}
	ansFormula = fmt.Sprintf("%s%d=%d", ansFormula, v[len(v)-1], wantAns)
	fmt.Println(ansFormula)
}


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

int main()
{
string s ;
cin >> s ;
ll n=s.size();
ll r[n]={};
ll temp=0;
rep(i,n){
  if(s[i]=='R')temp++;
  else {
    r[i]=temp;
    temp=0;
  }
}
ll l[n]={};
temp=0;
rep(i,n){
  if(s[n-1-i]=='L')temp++;
  else {
    l[n-1-i]=temp;
    temp=0;
  }
}
rep(i,n){
  if(r[i]!=0){
    ll te=r[i]/2;
    r[i-1]=r[i]-te;
    r[i]=te;
  }
}
rep(i,n){
  if(l[n-1-i]!=0){
    ll te=l[n-1-i]/2;
    l[n-1-i+1]=l[n-1-i]-te;
    l[n-1-i]=te;
  }
}
rep(i,n)
cout << r[i]+l[i] << " ";

cout << endl;
return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>

using namespace std;

int divisors (int n) {
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            if (n / i == i) cnt++;
            else cnt += 2;
        }
    }
    
    return cnt;
}

int main() {
 	int n;
  	cin >> n;
  	
  	int ans = 0;
  	for (int i = 1; i <= n; i++) {
  	    int x = n - i;
  	    ans += divisors(x);
  	}
  	
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define W V<long long>
#define R(n) for(int i=0;i<n;i++)
W S(V<W>&p,int E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}V<W>c(3,W(2));R(2){for(W x:T[i]){int Q=(2*x[0]+x[1])%3;if((Q+1)%2){c[i][0]^=1;}if(Q){c[i][1]^=1;}}}R(2){if(c[1-i]==c[2]){W ans=S(T[i],E-1);ans[0]*=2;ans[1]*=2;ans[1]+=i;return ans;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){long long M=2e17;int n;cin>>n;V<W>p(n);R(n){long long a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vi t(n);
    rp(i,n){
        cin >> t.at(i);
    }
    int m;
    cin >> m;
    vi p(m),x(m);
    rp(i,m){
        cin >> p.at(i) >> x.at(i);
    }
    rp(i,m){
        int ans=0;
        rp(j,n){
            if(j==p.at(i)-1){
                ans += x.at(i);
            }else{
                ans += t.at(j);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		int i = 1;
		while(true)
		{
			int x = stdIn.nextInt();
			
			if(x==0)
			{
				break;
			}
			
			System.out.println("Case "+i+": "+x);
			
			i++;
		}
	}

}

Measured memory_bytes: 32956
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(k<=a)cout<<k<<endl;
    else if(k<=a+b)cout<<a<<endl;
    else cout<<a-(k-a-b)<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    size_t min_value = 753;
    for (size_t i = 0; i < s.length() - 2; ++i) {
        auto diff = abs(stoi(s.substr(i, 3)) - 753);
        if (diff < min_value) min_value = diff;
    }
    cout << min_value << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int x,y;
  cin>>x>>y;
  cout<<(x)+(y)/2<<endl;
}







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

int main()
{
  int X,Y;
  cin >> X >> Y ;
  
  if(Y/2>=X&&(Y+2)/4<=X&&Y%2==0){
   	cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }


return 0;
}


Measured memory_bytes: 3620
while True:
   n=int(input())
   if n==0:
      break
   else:
      if n==1:
           print(1)
      elif n==2:
           print(1)
      else:
        A=[0]*(n+1) #地面が１なのでｎ段目までは要素がｎ+1
        A[0]=1
        A[1]=1
        A[2]=2
        for i in range(3,(n+1)): #1が3からnまで変化する
          A[i]=A[i-1]+A[i-2]+A[i-3]
        print((A[n])//3650+1)


Measured memory_bytes: 5596
def f(n):
	e=[1,0,0,1];z=[1,1,1,0]
	while n:e=[e,g(e,z)][n%2];z=g(z,z);n//=2
	return e[1]
M=998244353;g=lambda a,b:[(a[0]*b[0]+a[1]*b[2])%M,(a[0]*b[1]+a[1]*b[3])%M,(a[2]*b[0]+a[3]*b[2])%M,(a[2]*b[1]+a[3]*b[3])%M];n,m=map(int,input().split());I=[1,1];r=f(m+2*n-2);c=1
for i in range(2,n):I+=[(M-M//i)*I[M%i]%M]
for i in range(n-1):r=(r+c*(M-f(2*n-2-2*i)))%M;c=c*(m+i)*I[i+1]%M
print(r)

Measured memory_bytes: 52976
-- 1_2_D
main = do ns <- getLine
          let [w, h, x, y, r] = map (\x -> read x :: Int) $ words ns
          putStrLn $ check w h x y r

check :: Int -> Int -> Int -> Int -> Int -> String
check w h x y r = if x + r <= w && y + r <= h && x - r >= 0 && y - r >= 0
                    then "Yes"
                    else "No"

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<set>

using namespace std;

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

#include<iostream>

int n;
long int a[200000];
long int s[200000];


long int f(int x, int y){
    long int sm1 = s[y] - s[x] + a[x];
    return sm1;
}

int main(){
    long int const INF = 10000000000000000;
    cin >> n;
    rep(i, n) cin >> a[i];
    s[0] = a[0];
    rep(i, n - 1) s[i+1] = s[i] + a[i+1];
    // rep(i, n) cout << s[i] << " ";
    // cout << endl;

    long int ans = INF;
    for (int i = 1; i < n - 2; i++){
        int l = 0;
        int r = i;
        long int a, b, c, d;
        while(l < r - 1){
            int mid = (l + r) / 2;
            if (f(0, mid) < f(mid+1, i)){
                l = mid;
            }else{
                r = mid;
            }
        }
        if (r == i || abs(f(0, l) - f(l + 1, i)) < abs(f(0, r) - f(r + 1, i))){
            a = f(0, l);
            b = f(l + 1, i);
        }else{
            a = f(0, r);
            b = f(r + 1, i);       
        }
        
        l = i + 1;
        r = n - 1;
        while(l < r - 1){
            int mid = (l + r) / 2;
            if (f(i + 1, mid) < f(mid + 1, n - 1)){
                l = mid;
            }else{
                r = mid;
            }
        }
        if (r == n - 1 || abs(f(i + 1, l) - f(l + 1, n - 1)) < abs(f(i + 1, r) - f(r + 1, n - 1))){
            c = f(i + 1, l);
            d = f(l + 1, n - 1);
        }else{
            c = f(i + 1, r);
            d = f(r + 1, n - 1);       
        }
        ans = min(ans, max(max(a, b), max(c, d)) - min(min(a, b), min(c, d)));
    }
    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<ll> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  
  ll ans = LLONG_MAX;
  for (int i = 0; i <= N - K; i++) {
    ll d;
    if (x.at(i + K - 1) < 0) {
      d = -x.at(i);
    } else if (0 < x.at(i)) {
      d = x.at(i + K - 1);
    } else {
      d = x.at(i + K - 1) - x.at(i);
      d += min(-x.at(i), x.at(i + K - 1));
    }
    if (ans > d) ans = d;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    
    int a, b, c, k = 0, r, tmp, cnt=0;
    
    scanf("%d%d%d", &a, &b, &c);
    /* 自然数 a > b を確認・入替 */
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    
    /* 最大公約数を出力 */
    //printf("最大公約数 = %d\n", b);
    
    
    int i;
    
    
    for( i=1; i<=b; ++i ){
        if( b%i == 0 ){
            cnt++;
        }
    }
    /* 約数を求める */
    for( i=1; i<=b; ++i ){
        if( b%i == 0 ){
            if(k==cnt-c){
                //printf("k = %d\n", k);
                //printf("cnt = %d\n", cnt);
                printf("%d\n", i);
            }
            k++;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<string> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int s2 = 0;
	int s1 = 0;
	int c[26];
	for (int i = 0; i < 26; i++) {
		c[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			c[(int)(A[i][j] - 'a')]++;
		}
	}
	bool f = false;
	int c4 = 0;
	int c2 = 0;
	int c1 = 0;
	if ((N % 2 == 0) && (M % 2 == 0)) {
		c4 = (N*M);
	}
	else if ((N % 2 == 0) + (M % 2 == 0) == 1) {
		if (N % 2 == 1) {
			c4 = (N - 1)*M;
			c2 = M;
			c1 = 0;
		}
		else {
			c4 = (M - 1)*N;
			c2 = N;
			c1 = 0;
		}
	}
	else {
		c4 = (M - 1)*(N - 1);
		c2 = (N + M - 2);
		c1 = 1;
	}
	for (int i = 0; i < 26; i++) {
		if (c4 == 0) break;
		c4 -= (c[i] / 4) * 4;
		c[i] -= (c[i] / 4) * 4;
		if (c4 < 0) {
			c[i] += -c4;
			c4 = 0;
		}
	}
	for (int i = 0; i < 26; i++) {
		if (c2 == 0) break;
		c2 -= (c[i] / 2) * 2;
		c[i] -= (c[i] / 2) * 2;
		if (c2 < 0) {
			c[i] += -c2;
			c2 = 0;
		}
	}
	for (int i = 0; i < 26; i++) {
		if (c1 == 0) break;
		c1 -= c[i];
		c[i] -= 0;
		if (c1 < 0) {
			c[i] += -c1;
			c1 = 0;
		}
	}
	if (c4 == 0 && c2 == 0 && c1 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int a; std::cin >> a;
    std::cout << a + a*a + a*a*a << "\n";
}


Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    set<char> s;
    rep(i,3){
        char ch; cin>>ch;
        s.insert(ch);
    }
    cout<<(s.size()==2 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int n;
 cin>>n;
 vector<int> a(n);
 for(int i=0;i<n;i++) cin>>a[i];
 vector<int> l(n),r(n);
 l[0]=0;
 for(int i=1;i<n;i++){
  l[i]=__gcd(l[i-1],a[i-1]);
 }
 r[n-1]=0;
 for(int i=n-2;i>=0;i--){
  r[i]=__gcd(r[i+1],a[i+1]);
 }
 int ans=0;
 for(int i=0;i<n;i++){
  ans=max(ans,__gcd(l[i],r[i]));
 }
 cout<<ans<<endl;
 return 0;
}

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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf  1e18
#define mk(arr,n,type) type *arr=new type[n];
#define ti(arr,n) for(ll i=0;i<n;++i)cin>>a[i];
#define ot(arr,n) for(ll i=0;i<n;++i)cout<<a[i]<<" ";
#define str(a) string a;cin>>a;
#define w(x) int x;cin>>x;while(x--)
int main()
{
	int n, cnt = 0, s = 0; cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int a, b; cin >> a >> b;
		if (a == b)
		{
			++cnt;
		}
		else
		{
			if (cnt >= 3)
			{
				s = 1;
				break;
			}
			else
				cnt = 0;
		}
	}
	if(cnt>=3)
		s=1;
	if (s == 1)
		cout << "Yes";
	else
		cout << "No";
}

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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MAX_N = 2e6 + 1;

int gcd(int a, int b) {
    if (a == 0)return b;
    return gcd(b % a, a);
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    int d = gcd(x, 360);
    cout << 360 / d << endl;
}

Measured memory_bytes: 3616
n,m,k = map(int,input().split())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

x = [0]

y = [0]

for i in range(n):
    x.append(x[i]+a[i])

for i in range(m):
    y.append(y[i]+b[i])

ans = 0

cnt = m

for i in range(n+1):
    
    if k-x[i]<0:
        break
    
    while y[cnt]>k-x[i]:
        cnt -= 1
        
    ans = max(ans,cnt+i)
    
print(ans)

Measured memory_bytes: 47676
var
 s:string;
 a,b,c,d,i,j,k:longint;
begin
 readln(s);
 a:=ord(s[1])-48;
 b:=ord(s[2])-48;
 c:=ord(s[3])-48;
 d:=ord(s[4])-48;
      if a+b+c+d=7 then writeln(a,'+',b,'+',c,'+',d,'=7')
 else if a+b+c-d=7 then writeln(a,'+',b,'+',c,'-',d,'=7')
 else if a+b-c+d=7 then writeln(a,'+',b,'-',c,'+',d,'=7')
 else if a+b-c-d=7 then writeln(a,'+',b,'-',c,'-',d,'=7')
 else if a-b+c+d=7 then writeln(a,'-',b,'+',c,'+',d,'=7')
 else if a-b+c-d=7 then writeln(a,'-',b,'+',c,'-',d,'=7')
 else if a-b-c+d=7 then writeln(a,'-',b,'-',c,'+',d,'=7')
 else if a-b-c-d=7 then writeln(a,'-',b,'-',c,'-',d,'=7');
end.

Measured memory_bytes: 128
import math
N=int(input())
for i in range(N):
    a,b,c=map(int,input().split())
    if c==math.sqrt(a**2+b**2) or a==math.sqrt(c**2+b**2) or b==math.sqrt(a**2+c**2):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5660
#include <vector>
#include <bitset>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
using namespace std;

class Point{
public:
    int y, x;
    Point(){}
    Point(int y0, int x0){
        y = y0;
        x = x0;
    }
};

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

int solve(int n, vector<vector<int> >& panel0, int last)
{
    if(n == 0 && last != panel0[0][0])
        return 0;

    int h = panel0.size();
    int w = panel0[0].size();
    int color = panel0[0][0];

    int ret = 1;
    for(int i=1; i<=6; ++i){
        if(panel0[0][0] == i)
            continue;

        vector<vector<int> > panel = panel0;
        queue<Point> q;
        q.push(Point(0, 0));
        panel[0][0] = i;

        int tmp = 1;
        while(!q.empty()){
            Point p = q.front();
            q.pop();
            for(int j=0; j<4; ++j){
                int y = p.y + dy[j];
                int x = p.x + dx[j];
                if(y < 0 || y >= h || x < 0 || x >= w)
                    continue;
                if(panel[y][x] == color){
                    panel[y][x] = i;
                    q.push(Point(y, x));
                    ++ tmp;
                }
            }
        }

        if(n == 0)
            return tmp;
        ret = max(ret, solve(n-1, panel, last));
    }
    return ret;
}

int main()
{
    for(;;){
        int h, w, c;
        cin >> h >> w >> c;
        if(h == 0)
            return 0;

        vector<vector<int> > panel(h, vector<int>(w));
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> panel[i][j];
            }
        }

        cout << solve(5, panel, c) << endl;
    }
}

Measured memory_bytes: 916