akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int cnt = 0;
	int aCnt = 0;
	for (int i = 0; i < N; ++i)
	{
		if (S[i] == 'a')
		{
			if (cnt < A + B)
			{
				cout << "Yes" << endl;
				++cnt;
				continue;
			}
		}
		else if (S[i] == 'b')
		{
			if (cnt < A + B && aCnt < B)
			{
				cout << "Yes" << endl;
				++cnt;
				++aCnt;
				continue;
			}
		}
		cout << "No" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {
  long long N, T;
  scanf("%lld %lld", &N, &T);
  vector<long long> ts(N);
  long long ans = 0;
  long long Time = 0;
  for ( int i = 0; i < N; i++ )
    scanf("%lld", &ts.at(i));
  
  for ( int i = 1; i < N; i++ ){
    if ( ts.at(i) - ts.at(i-1) > T ){
      ans += T;
    }
    else{
      ans += ts.at(i) - ts.at(i-1);
    }
  }
  ans += T;

  printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	int x;
	cin >> x;

	for(int i = 1;i <= 360;i++){
		if(i * x % 360 == 0){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3636
#include<stdio.h>
long long int gcd(long long int a,long long int b){

     if(b==0)
     return a;
     else
     return  gcd(b,a%b);
	}
	int main()
	{
		long long int a,b;
		while(scanf("%lld %lld",&a,&b)!=EOF){	
		printf("%lld %lld\n",gcd(a,b),a/gcd(a,b)*b);	
		}
    return 0;	
	}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>

int main()
{
    int n,i;
    scanf("%d", &n);
    char s[100000];
    scanf("%s", s);
    for(i=0;i<strlen(s);i++){
        int c=s[i]+n;
        if(c<=90){
            s[i]=c;
        }
        else if(c>90){
            s[i]=c-26;
        }
    }
    printf("%s", s);
    return 0;
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        Console.WriteLine(seqA.Sum() < 22 ? "win" : "bust");
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>adj[200005];
int ans[100005];
bool vis[100005];

void bfs(int src)
{
    queue<int>q;
    q.push(src);
    vis[src]=1;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(int i=0; i<adj[x].size(); i++)
        {
            int y=adj[x][i];
            if(vis[y]==0)
            {
                q.push(y);
                vis[y]=1;
                ans[y]=x;
            }
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    memset(ans,-1,sizeof ans);
    bfs(1);

    for(int i=2; i<=n; i++)
    {
        if(ans[i]==-1)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2; i<=n; i++) cout<<ans[i]<<endl;

}


Measured memory_bytes: 12960
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        TreeSet<String> s = new TreeSet<>();
        for(int i = 0; i < n; i++) s.add(scan.next());
        System.out.println(s.size());
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 78660
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
	string a;
	cin >> a;
	int s=0,heru=0;
	int n = a.size();
	REP(i,n){
		if(a[i] == 'S'){
			s++;
		}
		else if(s != 0){
			heru += 2;
			s--;
		}
	}
	cout << n-heru << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=998244353;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=3005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,s;
int dp[max_n];
int main(){
    scanf("%d%d",&n,&s);
    int ans=0;
    dp[0]=1;
    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        if(s>x)ans=Add(ans,Mul(dp[s-x],n-i+1));
        else if(s==x)ans=Add(ans,Mul(n-i+1,i));
        for(int j=s;j>=x+1;j--)dp[j]=Add(dp[j],dp[j-x]);
        dp[x]=Add(dp[x],i);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
mod=998244353
R=[]
for _ in range(k):
  l,r=map(int,input().split())
  R.append([l,r])

dp=[0 for _ in range(n+1)]
dp[1]=1
dpsum=[0 for _ in range(n+1)]
dpsum[1]=1
for i in range(2,n+1):
  for j in range(k):
    li=i-R[j][1]
    ri=i-R[j][0]
    if ri<0:
      continue
    li=max(li,1)
    dp[i]+=(dpsum[ri]-dpsum[li-1])%mod
  dpsum[i]=dpsum[i-1]+dp[i]
  dpsum[i]%=mod
print(dp[n]%mod)

Measured memory_bytes: 100700
class UnionFind:
    def __init__(self, size):
        self.parents = [-1 for _ in range(size)]

    def root(self, index):
        parent = self.parents[index]
        if ( parent < 0):
            return index
        root = self.root(parent)
        self.parents[index] = root
        return root

    def size(self, index):
        return -1 * self.parents[self.root(index)]

    def add(self, A, B):
        A = self.root(A)
        B = self.root(B)
        if (A == B):
            return
        if (self.size(A) < self.size(B)):
            A, B = B, A
        self.parents[A] += self.parents[B]
        self.parents[B] = A
N, M = [int(x) for x in input().split()]
XYZ = [[int(x) - 1 for x in input().split()] for _ in range(M)]
uf = UnionFind(N)
for x, y, z in XYZ:
    uf.add(x, y)
s = set()
for i in range(N):
    s.add(uf.root(i))
print(len(s))


Measured memory_bytes: 87256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main(){
    int K,S;
    int ans = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            if(i+j >= S-K && i+j <= S) ans++;
            
        }
        
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

ll S[100010], T[50010];
ll n, q;

ll isOk(ll index, ll key)
{
	if (S[index] >= key) return true;
	else return false;
}

ll binary_search(ll key)
{
	ll ng = -1;
	ll ok = n;

	while (abs(ng - ok) > 1)
	{
		ll mid = (ok + ng) / 2;
		if (isOk(mid, key)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(int argc, char **argv)
{
	cin >> n;
	for (ll i = 0; i < n; ++i)
		cin >> S[i];
	cin >> q;
	ll res{0};
	for (ll i = 0; i < q; ++i)
	{
		ll t; cin >> t;
		ll it = binary_search(t);
		// std::cout << "it : " << it << std::endl;
		if (S[it] == t)
			++res;
	}
	std::cout << res << std::endl;
}



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

MOD = 1000000007  # type: int


def solve(N: int, K: int):
    count = [0]*(K+1)

    answer = 0
    for k in range(K,0,-1): #kの倍数のもの
        d = K//k
        if k == 1:
            answer += pow(K,N,MOD)-sum(count) 
        else:
            count[k] = pow(d,N,MOD)
            i = 2
            while k*i <= K:
                count[k] -= count[k*i]
                i += 1
            answer += count[k]*k
        answer %= MOD
    print(answer)
    return


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
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main() {
  string s,t;
  cin>>s>>t;
  int as[100100], bs[100100];
  as[0]=bs[0]=0;
int x=s.size();
  for(int i=0;i<x;i++){
    if(s[i]=='A')as[i+1]=as[i]+1;
    else as[i+1]=as[i];
    if(s[i]=='B')bs[i+1]=bs[i]+1;
    else bs[i+1]=bs[i];
  }
  
  int at[100100],bt[100100];
  at[0]=bt[0]=0;
int y=t.size();
  for(int i=0;i<y;i++){
    if(t[i]=='A')at[i+1]=at[i]+1;
    else at[i+1]=at[i];
    if(t[i]=='B')bt[i+1]=bt[i]+1;
    else bt[i+1]=bt[i];
  }
  int q; cin>>q;
  for(int i=0;i<q;i++){
    int es,fs,et,ft;
    cin>>es>>fs>>et>>ft;
    int m,n,M,N;
    m=as[fs]-as[es-1];
    n=bs[fs]-bs[es-1];
    M=at[ft]-at[et-1];
    N=bt[ft]-bt[et-1];
    if((M-m+300000)%3==(N-n+300000)%3){
      cout<<"YES"<<endl;
    } else cout<<"NO"<<endl;
}
return 0;
}

Measured memory_bytes: 2432
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e3+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,id,x,y,nr,ans;
pair<int,pair<int,int> >v[nmax*nmax];
char a[nmax][nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')v[++id]={0,{i,j}};
		}
	}
	for(i=1;i<=id;i++)
	{
		x=v[i].sc.fr,y=v[i].sc.sc;
		nr=v[i].fr;
		ans=max(ans,nr);
		if(a[x-1][y]=='.')
		{
			v[++id]={nr+1,{x-1,y}};
			a[x-1][y]='#';
		}
		if(a[x+1][y]=='.')
		{
			v[++id]={nr+1,{x+1,y}};
			a[x+1][y]='#';
		}
		if(a[x][y-1]=='.')
		{
			v[++id]={nr+1,{x,y-1}};
			a[x][y-1]='#';
		}
		if(a[x][y+1]=='.')
		{
			v[++id]={nr+1,{x,y+1}};
			a[x][y+1]='#';
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13056
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=998244353;
#define N 321
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],dp[N*N],sum,ans;
int main(){
	n=read();
	ans=1;
	for(int i=1;i<=n;++i){
		a[i]=read();
		ans=3LL*ans%mod;
	}
	dp[0]=1;
	for(int i=1;i<=n;++i){
		sum+=a[i];
		for(int j=sum;j>=0;--j){
			(dp[j]<<=1)%=mod;
			if(j>=a[i])dp[j]=(dp[j]+dp[j-a[i]])%mod;
		}
	}
	for(int i=sum;sum-i<=i;--i){
		ans=(ans-3LL*dp[i]%mod+mod)%mod;
	}
	if(!(sum&1)){
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		for(int i=1;i<=n;++i){
			for(int j=sum;j>=a[i];--j){
				dp[j]=(dp[j]+dp[j-a[i]])%mod;
			}
		}
		ans=(ans+3LL*dp[sum>>1])%mod;
	}
	printf("%d\n",ans);
	return 0;
}



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

int main()
{
  string a="ABCDEFGHIJKLMNOPQRSTUVWXYZ",s;
  cin>>s;
  int q[s.size()];
  for(int i=0; i<s.size(); i++){
    for(int j=0; j<a.size(); j++){
      if(s[i]==a[j]){
	q[i]=j;
	break;
      }
    }
	if(q[i]<3)
		cout<<a[q[i]+23];
	else
    	cout<<a[q[i]-3];
  }
  cout<<endl;
  return 0;
}
  

Measured memory_bytes: 1188
N = int(input())
a = []
b = []
for _ in range(N):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
ans = 0
i = N-1
while i >= 0:
    # print(i)
    a[i] += ans
    r = a[i]%b[i]
    if r == 0:
        i-=1
        continue
    else:
        ans += b[i] - r
    i-=1
print(ans)

Measured memory_bytes: 15020
#include <iostream>

using namespace std;

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

int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

int main() {
    int a, b;

    while (cin >> a >> b) {
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main() {
  int n,x,y;
  cin >> n >> x >> y;
  --x;y--;
  vector<int> res(n);
  //各始点に合わせてBFS
  rep(i,n){
    vector<int> dist(n,INF);
    queue<int> q;
    //探索済みならスキップ，未探索なら距離記録，キューにプッシュ
    auto push = [&](int v, int d){
      if(dist[v] != INF) return;//探索済み
      dist[v] = d;
      q.push(v);
    };
    push(i,0);//初期化
    while(!q.empty()){
      int v = q.front();q.pop();
      int d = dist[v];
      //始点の両側に広げていく
      if(v-1 >= 0) push(v-1,d+1);
      if(v+1 < n) push(v+1,d+1);
      //
      if(v == x) push(y,d+1);
      if(v == y) push(x,d+1);
    }
    rep(i,n) res[dist[i]]++;//距離ごと集計
  } 
  rep(i,n) res[i]/=2;
  for(int i=1;i<=n-1;i++) cout << res[i] << endl;
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))

ans = [0 for i in range(n)]
for num in range(n,0,-1):
  cnt = 0
  for nu in range(num-1,n,num):
    cnt += ans[nu]
  if lis[num-1] != cnt % 2:
    ans[num-1] = 1
cnt1 = 0
for num in range(n):
  if ans[num] == 1:
    cnt1 += 1
print(cnt1)
for i in range(n):
  if ans[i] == 1:
    print(i+1,end = " ")

Measured memory_bytes: 7148
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, u, v;
int d1[100010], d2[100010];
vector<int> G[100010];

void dfs(int v, int p, int* d){
    d[v] = d[p] + 1;
    for(auto u : G[v]) if(u != p) dfs(u, v, d);
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> u >> v;
    for(int i = 1; i < N; ++i){
        int A, B;
        cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dfs(u, 0, d1);
    dfs(v, 0, d2);
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if(d1[i] <= d2[i]) chmax(ans, d2[i] - 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
INF = float("inf")


# update: node[x] を更新する
# getmin: 区間 [a, b) の最小値を返す
class SegmentTree:
    def __init__(self, arr):
        size = len(arr)
        n = 1 << size.bit_length()
        self.n = n
        self.node = [0]*(2*n - 1)
        for i in range(size):
            self.node[i+n-1] = arr[i]
        for i in reversed(range(n-2)):
            self.node[i] = max(self.node[2*i+1], self.node[2*i+2])
    
    def update(self, x, val):
        x += (self.n - 1)
        self.node[x] = val
        while x > 0:
            x = (x - 1) // 2
            self.node[x] = max(self.node[2*x+1], self.node[2*x+2])
    
    def getmax(self, a, b):
        res = 0
        l = self.n - 1 + a
        r = self.n - 1 + (b-1)
        while l <= r:
            res = max(res, self.node[l])
            res = max(res, self.node[r])
            l  = l // 2
            r = r // 2 - 1
        return res
 

# 処理内容
def main():
    N, K = map(int, input().split())
    
    seg = SegmentTree([0]*300010)
    for _ in range(N):
        A = int(input())
        a = max(A-K, 0)
        b = min(A+K, 300000)
        tmp = seg.getmax(a, b+1) + 1
        seg.update(A, tmp)
    
    print(seg.getmax(0, 300000))


if __name__ == '__main__':
    main()

Measured memory_bytes: 85508
def solve(n, a, b):
    res = n // (a + b) * a
    res += min(n % (a + b), a)
    return res


def main():
    n, a, b = map(int, input().split())
    res = solve(n, a, b)
    print(res)


def test():
    assert solve(8, 3, 4) == 4
    assert solve(8, 0, 4) == 0
    assert solve(6, 2, 4) == 2


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void) {
    int R, G, B, N, X=0;
    cin >> R >> G >> B >> N;
    for (int i=0;R*i<=N;i++) for (int j=0;G*j<=N-R*i;j++) {
        if ((N - R*i - G*j)%B == 0) X++;
    }
    cout << X << endl;

    return 0;
}

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

using namespace std;

#define rep(i, s, n) for(long i = s; i < (long)(n); ++i)

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

  vector<long> l(n);
  rep(i, 0, n) {
    cin >> l[i];
  }

  sort(l.begin(), l.end());

  long answer = 0;
  rep(i, 0, n) {
    rep(j, i + 1, n) {
      long upper_limit = l[i] + l[j] - 1;
      auto it = upper_bound(l.begin() + j + 1, l.end(), upper_limit);
      int add = it - (l.begin() + j) - 1;
      answer += max(add, 0);
    }
  }

  cout << answer << endl;
  return 0;
}


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

int main() {
	// your code goes here
	int n,c;
	cin>>n>>c;
	vector<int> data(n);
	
	for(int i=0;i<n;i++) cin>>data[i];
	sort(data.begin(), data.end(), greater<int>());
	
	int sum=0;
	for(int i=0;i<c;i++) sum+=data[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;

import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        System.out.println(0.0 + " " + 0.0);
        koch(n, new Pair(0,0), new Pair(100, 0));
        System.out.println(100.0 + " " + 0.0);
    }
    
    public static void koch(int i, Pair p1, Pair p2) {
        if (i == 0) return;
        Pair s = new Pair((p1.x * 2 + p2.x) / 3,(p1.y * 2 + p2.y) / 3);
        Pair t = new Pair((p1.x + p2.x * 2) / 3,(p1.y + p2.y * 2) / 3);
        double ux = (t.x - s.x)*Math.cos(Math.toRadians(60)) - (t.y - s.y)*Math.sin(Math.toRadians(60)) + s.x;
        double uy = (t.x - s.x)*Math.sin(Math.toRadians(60)) + (t.y - s.y)*Math.cos(Math.toRadians(60)) + s.y;
        Pair u = new Pair(ux, uy);
        
        koch(i - 1, p1, s);
        System.out.println(s.x + " " + s.y);
        koch(i - 1, s, u);
        System.out.println(u.x + " " + u.y);
        koch(i - 1, u, t);
        System.out.println(t.x + " " + t.y);
        koch(i - 1, t, p2);
    }
}

class Pair {
    double x;
    double y;
    public Pair(double x, double y) {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 33248
n, X = map(int, input().split())
A = list(map(int, input().split()))

li = []
for i in A:
    d = abs(i - X)
    li.append(d)

li.sort()
l = li[0]
divisors = []
for i in range(1, int(l ** (1 / 2)) + 1):
    if l % i == 0:
        divisors.append(i)
        if i != l // i:
            divisors.append(l // i)
divisors.sort(reverse = True)
for i in divisors:
    for j in li:
        count = 0
        if j % i != 0:
            count += 1
        if count != 0:
            break
    if count == 0:
        print(i)
        break


Measured memory_bytes: 14224
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

string s;

int main() {
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.size() - 1; ++i)
		if (s[i] != s[i + 1])
			++cnt;
	cout << cnt << "\n";
	return 0;
}




Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>

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

    std::vector<std::string> ss(n);
    std::vector<int> ts(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> ss[i] >> ts[i];
    }

    std::string x;
    std::cin >> x;

    int ans = 0;
    bool ok = false;
    for (int i = 0; i < n; ++i) {
        if (ok) ans += ts[i];
        if (ss[i] == x) ok = true;
    }

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


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

using namespace std;
typedef long long ll;

vector<int> Eratosthenes( const int N ) {
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main() {
    int x; cin >> x;
    for(const auto &p: Eratosthenes(100500)) {
        if (p >= x) {
            cout << p << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long  k,a[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long n, x;
vector<long long> a(100100, 0);

int main() {
    cin >> n >> x;
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    long long cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(i == n-1) {

        }else {
            long long sum = a.at(i) + a.at(i+1);
            if(sum > x) {
                long long rest = sum - x;
                if(a.at(i+1) >= rest) {
                    a.at(i+1) -= rest;
                }else {
                    a.at(i+1) = 0;
                }
                cnt += rest;
            }
        }
    }
    cout << cnt << endl;
}

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

int main() {
  int res;
  int cur, n;
  cin >> n >> cur;
  res = cur;
  for(int i = 0; i < n; i++) {
    int in, out; cin >> in >> out;
    cur = cur + in - out;
    if(cur < 0) {
      cout << 0 << endl;
      return 0;
    }
    res = max(res, cur);
  }
  cout << res << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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() {
  string s; cin >> s;
  rep(i, 0, 4) cout << s[i];
  cout << " ";
  rep(i, 4, 12) cout << s[i];
  cout << endl;
  return 0;
}


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

int main(){
	int A, B;
	cin >> A >> B;
	if(A <=5) cout << 0 << endl;
	else if(A <= 12) cout << B / 2 << endl;
	else cout << B << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
D - Brick Break
https://atcoder.jp/contests/abc148/tasks/abc148_d

"""
import sys


def solve(N, arr):
    x = 1
    last = -1
    ans = 0
    for a in arr:
        if a != x:
            ans += 1
        else:
            x += 1
            last = 1
    return ans if last != -1 else -1


def main(args):
    N = int(input())
    arr = [int(a) for a in input().split()]
    ans = solve(N, arr)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxself(a,b) if(b>a)a=b
#define minself(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"	
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	ll n,k;
	cin>>n>>k;
	ll ans=n%k;
	minself(ans,abs(k-ans));
	cout<<ans<<ln;
}

int main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 0
for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
        cnt = 0
        while n % i == 0:
            cnt += 1
            n //= i
        tmp = 1
        while cnt >= tmp:
            ans += 1
            cnt -= tmp
            tmp += 1
if n != 1:
    ans += 1
print(ans)

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

#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m), c(m);
    vector<vector<int>> beg(n);
    vector<vector<int>> end(n);
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i] >> c[i];
        l[i]--;
        r[i]--;
        beg[l[i]].push_back(i);
        end[r[i]].push_back(i);
    }
    vector<long> d(n, LONG_MAX);
    d[0] = 0;
    set<pair<long, int>> now;
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            if (now.empty()) {
                cout << -1;
                return 0;
            }
            d[i] = now.begin() -> first;
//            cout << i << " " << d[i] << "\n";
        }
        for (int x : beg[i]) {
//            cout << i << " " << x << " " << d[l[x]] + c[x] << "\n";
            now.insert({d[l[x]] + c[x], x});
        }
        for (int x : end[i]) {
            now.erase({d[l[x]] + c[x], x});
        }
    }
    cout << d[n - 1] << "\n";

    return 0;
}

Measured memory_bytes: 13056
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int w, h;
char a[51][51];
bool visited[51][51];
bool ok(int y, int x, char c) {
    bool res = true;
    if (a[y][x] != '.') {
        // if(c=='B') cout << "\t" << y << ", " << x << ": " << a[y][x] << ", "
        // << (a[y][x] == c) << endl;
        return a[y][x] == c;
    }
    rep(k, 4) {
        int ny = y + dy[k];
        int nx = x + dx[k];
        if (ny < 0 || nx < 0) continue;
        if (ny >= h || nx >= w) continue;
        if (visited[ny][nx]) continue;
        visited[ny][nx] = 1;
        res &= ok(ny, nx, c);
    }
    return res;
}
int main() {
    while (cin >> w >> h, w) {
        int W = 0, B = 0;
        bool f = 0;
        rep(i, h) rep(j, w) cin >> a[i][j];
        rep(i, h) rep(j, w) f |= a[i][j] != '.';
        rep(i, h) rep(j, w) {
            memset(visited, 0, sizeof(visited));
            if (a[i][j] != '.') continue;
            if (ok(i, j, 'W')) W++;
            memset(visited, 0, sizeof(visited));
            if (ok(i, j, 'B')) {
                B++;
            }
        }
        if (f)
            cout << B << " " << W << endl;
        else
            cout << "0 0" << endl;
    }
    return 0;
}

Measured memory_bytes: 3208
N=int(input())
l=[]
for _ in range(N):
    ab=list(map(int,input().split()))
    l.append(ab)
l.sort(key=lambda x:x[1])
time=0
flag=True
for i in range(N):
    time+=l[i][0]
    if time>l[i][1]:
        flag=False
        break
if flag==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 47204
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll w,h,x,y;
    cin>>w>>h>>x>>y;

    pr((((double) w) * ((double) h) )/ 2.0);
    pr(w/2.0 == x && h/2.0 == y ? 1 :0);


    // pr(sum);
}


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

using namespace std;

int main(int argc, char *argv[])
{
    
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n, m;
    int matrix[100][100], vec[100];
    int sum = 0;
    
    cin >> n >> m;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> matrix[i][j];
        }
    }
    
    for (int j = 0; j < m; j++) {
        cin >> vec[j];
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            sum += matrix[i][j]*vec[j];
        }
        cout << sum << endl;
        sum = 0;
    }
    
    return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        switch(n){
            case 25:
                System.out.println("Christmas");
                break;
            case 24:
                System.out.println("Christmas Eve");
                break;
            case 23:
                System.out.println("Christmas Eve Eve");
                break;
            case 22:
                System.out.println("Christmas Eve Eve Eve");
                break;
        }
    }
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(v.rbegin(), v.rend());
    double val = accumulate(v.begin(), v.begin() + a, 0.0) / a;
    printf("%.9lf\n", val);

    unordered_set<ll> nums;
    unordered_map<ll, ll> counter;
    unordered_map<ll, ll> numNeed;
    for (int i = 0; i < n; i++) {
        if (i >= a) {
            if (nums.count(v[i])) {
                counter[v[i]]++;
                continue;
            }
            break;
        }
        counter[v[i]]++;
        numNeed[v[i]]++;
        nums.insert(v[i]);
    }

    vector<vector<ll>> dp(52, vector<ll>(52, 0));
    dp[0][0] = 1;
    for (int i = 1; i < 52; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i][j] += dp[i - 1][j];
            if (j) dp[i][j] += dp[i - 1][j - 1];
        }
    }
    ll ans = 0;
    int num = 0;
    for (int i = 0; i < n; i++){
        if (v[i] == v[a - 1]) num++;
    }
    if (nums.size() == 1) {
        ll cnt = counter[v[0]];
        for (int i = a; i <= b; i++) {
            ans += dp[cnt][i];
        }
    } else {
        int z = 0;
        for (int i = 0; i < a; i++) {
            if (v[i] == v[a - 1]) z++;
        }
        ans = dp[num][z];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    string s;
    cin >> s;
    deque<char> dq;
    ll ans = 0;
    for (auto c : s) {
        if (!dq.empty() && dq.back() != c) {
            dq.pop_back();
            ans += 2;
        }
        else dq.push_back(c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <chrono>
#include <numeric>

using namespace std;
using namespace std::chrono;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

int main() {
    fast
    lo n,r;
    cin >> n >> r;
    if(n < 10){
        cout << r + 100 * (10 - n) << endl;
    }
    else{
        cout << r << endl;
    }
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;

  string ans = "";
  rep(i, 0, N) {
    ans += S[i];
    ans += T[i];
  }
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
#ARC050C
import sys

n=int(raw_input())
a=map(int,raw_input().split())
b=sorted(a)
if n%2==0:
 for i in xrange(0,n,2):
  if b[i+1]!=b[i]:
   print 0
   sys.exit()
 else:
  print (2**(n/2))%(10**9+7)
else:
 for i in xrange(1,n,2):
  if b[i+1]!=b[i]:
   print 0
   sys.exit()
 else:
  print (2**(n/2))%(10**9+7)   


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    while(true)
    {
        int n; cin>>n;
        if(n==0) break;

        int comb[1001]={0};
        for(int i=1;i<=n/2;i++){
            int sum=i;
            for(int j=i+1;(sum+=j)<=n;j++) comb[sum]++;
        }
        cout<<comb[n]<<endl;
    }
}

Measured memory_bytes: 3156
S = input()
F = int(S[0:2])
SE = int(S[2:4])


if F > 12 and 1 <= SE <= 12:
  print("YYMM")
elif 1 <= F <= 12 and SE > 12:
  print("MMYY")
elif 1 <= F <= 12 and 1 <= SE <= 12:
  print("AMBIGUOUS")
elif F == 0 and 1 <= SE <= 12:
  print("YYMM")
elif 1 <= F <= 12 and SE == 0:
  print("MMYY")
else:
  print("NA")





  


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

int main() {
	int h,w;
	cin >> h >> w;
	for (int i = 0;i < h*w;++i) {
		string s;
		cin >> s;
		if (s == "snuke") {
			char a = 'A';
			a += i%w;
			cout << a << i/w+1 << "\n";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
    int n, m;
    std::cin >> n >> m;
    int d, d_max;
    d_max = m/n;
    for(d = d_max; d > 0; --d){
        if((m - (n-1)*d)%d == 0 ){break;}
    }
    std::cout << d << std::endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (N, K) = *readInt()
    let h = readInt()
    let size = h.filter{ $0 >= K }.count
    print(size)
}
main()


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

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    ll total = accumulate(A.begin(), A.end(), 0LL);
    if(total >= H){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void primeFactors(ll n, unordered_map<ll, ll> &m) {
	while (n % 2 == 0) {
		if (m.find(2) != m.end())
			m[2] += 1;
		else
			m[2] = 1;

		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i = i + 2) {
		while (n % i == 0) {
			if (m.find(i) != m.end())
				m[i] += 1;
			else
				m[i] = 1;
			n = n / i;
		}
	}

	if (n > 2) {
		if (m.find(n) != m.end())
			m[n] += 1;
		else
			m[n] = 1;
	}

}

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

	unordered_map<ll, ll> m;

	primeFactors(n, m);

	ll ans = 0;
	for (auto p : m) {
		ll d = (-1 + sqrt(1 + 8 * p.second)) / 2;
		ans += d;
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 3724
xmax, ymax, N = map(int, input().split())
xmin = 0
ymin = 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if x > xmin: xmin = x
    if a == 2:
        if x < xmax: xmax = x
    if a == 3:
        if y > ymin: ymin = y
    if a == 4:
        if y < ymax: ymax = y
print(max(xmax - xmin, 0) * max(ymax - ymin, 0))


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

int main(){
  int K;
  string S;
  cin >> K >> S;
  
  if (S.size() <= K) {
    cout << S << endl;
  }
  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>

void move(double* x,double* y) {

  double d;
  double sin,cos;

  d=sqrt((*x)*(*x)+(*y)*(*y));

  cos=(*x)/d;
  sin=(*y)/d;
  //printf("%lf %lf\n",cos,sin);
  *x-=sin;
  *y+=cos;
  //printf("%lf %lf\n",*x,*y);
  return;

}

int main(void) {

  int n;
  double x,y;

  int i;


  while(1) {

    scanf("%d",&n);

    if(n==-1) break;

    x=1.0; y=0.0;

    for(i=0;i<n-1;i++) {

      move(&x,&y);

    }

    printf("%.2lf\n%.2lf\n",x,y);

  }  

  return 0;

}

Measured memory_bytes: 0