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

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

    return 0;
}


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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

string s;

int main()
{
	cin >> s;
	if (s == "SUN") puts("7");
	else if (s == "MON") puts("6");
	else if (s == "TUE") puts("5");
	else if (s == "WED") puts("4");
	else if (s == "THU") puts("3");
	else if (s == "FRI") puts("2");
	else puts("1");
	return 0;
}


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

int main(){
 
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int x = (A + D - 1) / D;
  int y = (C + B -1) / B;
  cout << (x>=y?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3644
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int [] a = new int[n];
		for(int i = 0; i < n; i++)
			a[i] = sc.nextInt();

		System.out.println((int)Math.ceil(((double)n - 1) / ((double)c - 1)));
	}
}


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

int main() {
ll n;
  cin>>n;
  ll num[n+1];
  ll mind=0;
  ll minz=100000000000;
  ll msum=0;
  ll les0=0;
  bool ex0=false;
  for(ll i=1;i<=n;i++){
    cin>>num[i];
    if(num[i]<0){
     les0++;} 
    
  if(minz>abs(num[i])){
    minz=abs(num[i]);
    mind=i;}
    
    msum+=abs(num[i]);
    if(num[i]==0){
      ex0=true;}
  }
  
if(les0%2==1&&!ex0){
  cout<<msum-2*minz<<endl;}
  else{
    cout<<msum<<endl;}

  
}


Measured memory_bytes: 1024
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, d;
        cin >> n >> d;

        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;

            if (x * x + y * y <= d * d)
                cnt++;
        }
        cout << cnt << '\n';
    }
    
    return 0;
}



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

int main() {
	int N; cin >> N;
	string S; cin >> S;
	for (auto && e : S) {
    	e += N;
    	if (e > 'Z') {
        	e -= 26;
        }
    }
	cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int M = 1e9+7;
#define F(i,a,b) for(int i=a;i<b;i++)
/*
ll f(int *a,int n,int k)
{
  if(n>=0 && k== 0) return 1;
  if(n==0 && k>0) return 0;
  if(dpprefix[n][k] != -1) return dpprefix[n][k];
  ll ans = 0;
  for(int i=0;i<=min(a[n],k);i++)
    ans = (ans+f(a,n-1,k-i))%M;
  dpprefix[n][k] = ans;
  return ans;
}
*/
int main() {
  int n,k;
  cin>>n>>k;
  int a[n+1];
  for(int i=1;i<=n;i++) cin>>a[i];
  vector<vector<ll>> dpprefix(n+1,vector<ll> (k+1,0));
  for(int child=0;child<=n;child++) dpprefix[child][0] = 1;
  for(int candies=1;candies<=k;candies++) dpprefix[0][candies] += dpprefix[0][candies-1];
  for(int child=1;child<=n;child++)
  {
    for(int candies=1;candies<=k;candies++)
    {
      ll left=0;
      if(candies-a[child]>0)
        left = dpprefix[child-1][candies-a[child]-1];
      dpprefix[child][candies] = (dpprefix[child-1][candies] - left+M)%M;
      dpprefix[child][candies] = (dpprefix[child][candies]+dpprefix[child][candies-1])%M;
    }
  }
  /*
  F(i,0,n+1)
  {
    F(j,0,k+1)
    {
      cout<<dpprefix[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  if(k!=0)
    cout<<(dpprefix[n][k]-dpprefix[n][k-1]+M)%M;
  else
    cout<<dpprefix[n][k];
  return 0;
}

Measured memory_bytes: 83100
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int N, K, dummy;
	dummy = scanf("%d %d", &N, &K);

	vector<int> vi;
	//map<int, int> mi;
	vector<int> mi;

	int tmp1;
	for (int i = 0; i < N; i++) {
		dummy = scanf("%d", &tmp1);
		vi.push_back(tmp1);
	}

	//mi[0] = 0;
	mi.push_back(0);

	for (int n = 1; n < N; n++) {
		int tmpMin = INT_MAX;
		for (int k = 1; k <= K; k++) {
			if (n < k) continue;
			int tmp = mi[n-k] + abs(vi[n] - vi[n-k]);
			tmpMin = min(tmpMin, tmp);
		}
		//mi[n] = tmpMin;
		mi.push_back(tmpMin);
	}
	
	printf("%d\n", mi[N-1]);
	
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007

ll findgcd(ll n,ll m){
    return __gcd(n,m);
}
ll findlcm(ll n,ll m){
    return (n*m)/findgcd(n,m);
}

ll nodig(ll n){
    int ans =0;
    while(n!=0){
        ans+=1;
        n=n/10;
    }
    return ans;
}


int main(){
    ll n,temp=0,cnt=0,ans=0;
    cin>>n;
    int a[2*n];
    for(int i=0;i<2*n;i++) cin>>a[i];
    for(int i=0;i<2*n-5;i++){
        if(i%2==0 && a[i+1]==a[i] && a[i+2]==a[i+3] && a[i+4]==a[i+5]) {
            cout<<"Yes";
            cnt = 1;
            break;
        } 
    }
    if(cnt==0) cout<<"No";
    

return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[2009]; long long dp[2009][2009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = n - 1; i >= 1; i--) {
		int lb = n - 1, r = i, rb = (i + 1) % n;
		for (int j = 0; j < n; j++) {
			if(i & 1) dp[j][r] = (a[lb] > a[r] ? dp[lb][r] : dp[j][rb]);
			else dp[j][r] = max(dp[lb][r] + a[lb], dp[j][rb] + a[r]);
			if (++lb == n) lb = 0;
			if (++r == n) r = 0;
			if (++rb == n) rb = 0;
		}
	}
	long long ret = 0;
	for (int i = 0; i < n; i++) ret = max(ret, dp[i][(i + 1 == n ? 0 : i + 1)] + a[i]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 34484
#abc134d

n=int(raw_input())
a=map(int,raw_input().split())
s=[]
x=[0]*n
for i in xrange(n,0,-1):
 y=0
 for j in xrange(i,n+1,i):
  y+=x[j-1]
 if y%2!=a[i-1]:
  x[i-1]=1
  s.append(i)
print len(s)
print ' '.join(map(str,s))


Measured memory_bytes: 17404
#include <iostream>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1e18;

int main() {
    int n;
    cin >> n;
    int f[n][10], p[n][11];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> p[i][j];
        }
    }
    long long ans = -INF;

    for (int bit = 1; bit < (1<<10); bit++) {
        long long income = 0;
        for (int i = 0; i < n; i++) {
            int c = 0;
            for (int t = 0; t < 10; t++) {
                if ((bit & (1<<t)) && f[i][t] == 1) c++;
            }
            income += p[i][c];
        }
        chmax(ans, income);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h,w,m = map(int,input().split())
bombX = [0]*h
bombY = [0]*w
bomb = set()
maxX = maxY = 0
for i in range(m):
    i,j = map(lambda x:int(x)-1, input().split())
    bomb.add((i,j))
    bombX[i] += 1
    bombY[j] += 1
    maxX = max(maxX,bombX[i])
    maxY = max(maxY,bombY[j])
maxX_index = list(i for i in range(h) if bombX[i] == maxX)
maxY_index = list(i for i in range(w) if bombY[i] == maxY)
for i in maxX_index:
    for j in maxY_index:
        if (i,j) in bomb: continue
        print(maxX+maxY)
        exit()
print(maxX+maxY-1)


Measured memory_bytes: 83676
V, E = map(int, input().split())
inf = float('inf')
graphs = [list(map(int, input().split())) for _ in range(E)]
# コストが低い順に並べる
graphs.sort(key=lambda x: x[2])
# print(graphs)

nodes = [i for i in range(V)]
cost = 0


def root(node):
    if nodes[node] == node:
        return node
    nodes[node] = root(nodes[node])
    return nodes[node]


for i, j, k in graphs:
    if not root(i) == root(j):
        cost += k
        nodes[root(i)] = root(j)
print(cost)



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

typedef long long ll;

int main() {
    ll n;
    int i;
    cin >> n;
    vector<ll>sum(n);

    sum[0] = 0;
    for (i = 1; i <= n; i++) {
        sum[i] = sum[i-1] + i;
        if (sum[i] >= n) {
            break;
        }
    }
    for (int j = i; j >= 1; j--) {
        if (n >= j) {
            cout << j << endl;
            n -= j;
        }
        if (n == 0) {
            break;
        }
    }
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 

int32_t main(){
    int n,p;
    cin>>n>>p;
    string str;
    cin>>str;
    int ans=0;
    if(p==2 || p==5){
        for(int i=0;i<n;i++){
            if((str[i]-'0')%p==0) ans+=i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    reverse(str.begin(),str.end());
    int arr[n];
    int val=1;
    for(int i=0;i<n;i++){
        arr[n-i-1]=((str[i]-'0')%p*val%p)%p;
        val=(val*10)%p;
    }
    
    unordered_map<int,int> cnt;
    int curr_sum=0;
    for(int i=0;i<n;i++){
        curr_sum=curr_sum+arr[i];
        cnt[curr_sum%p]++;
    }
    int res=0;
    for(int i=0;i<p;i++){
        res+=(cnt[i]*(cnt[i]-1))/2;
    }
    res+=cnt[0];
    cout<<res<<endl;

    
}

Measured memory_bytes: 2436
using System;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        char[] Sdash = Console.ReadLine ().ToCharArray ();
        char[] T = Console.ReadLine ().ToCharArray ();

        List<int> list = new List<int> ();
        int nowplace = 0;
        while (nowplace <= Sdash.Length - T.Length) {
            if (Sdash[nowplace] == T[0] || Sdash[nowplace] == '?') {
                list.Add (nowplace);
            }
            nowplace++;
        }

        bool ans = false;
        int ansplace = -1;
        for (int i = list.Count - 1; i >= 0; i--) {
            bool okay = true;
            for (int j = 0; j < T.Length; j++) {
                if (Sdash[list[i] + j] != '?' && Sdash[list[i] + j] != T[j]) {
                    okay = false;
                }
            }
            if (okay) {
                ans = true;
                ansplace = list[i];
                break;
            }
        }

        if (ans) {
            for (int i = 0; i < Sdash.Length; i++) {
                if (i < ansplace && Sdash[i] == '?') {
                    Sdash[i] = 'a';
                } else if (ansplace <= i && i < ansplace + T.Length) {
                    Sdash[i] = T[i - ansplace];
                } else if (Sdash[i] == '?') {
                    Sdash[i] = 'a';
                }
            }
            Console.WriteLine (Sdash);
        } else {
            Console.WriteLine ("UNRESTORABLE");
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define mxn 1000010
#define LL long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define node(a,b,c) (node){a,b,c}
using namespace std;
const int inf=1e9,mod=1e9+7;
LL l,r,sl,fh,ans;
LL rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	l=rd();r=rd();r=min(l+2019,r);ans=2019;
	for(LL i=l;i<=r;++i)
		for(LL j=i+1;j<=r;++j)
			ans=min(ans,i*j%2019);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		int cnt = 0;
		for (int i = 100; i > 0; i--) {
			if (a % i == 0 && b % i == 0) {
				cnt++;
			}
			if (cnt == k) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 22612
function Main(input) {
  let all = input.split("\n").map((x) => parseInt(x, 10));
  let a = all[0];
  let b = all[1];
  let c = all[2];
  let x = all[3];

  let ans = 0;
  for (let i = 0; i <= a; i++) {
    for (let j = 0; j <= b; j++) {
      for (let k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k === x) {
          ans++;
        }
      }
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    char  *str;
    int   i;
    int   result; 

    str = (char *)malloc(sizeof(char) * 10000);
    result = scanf("%s", str);
    i = 0;
    while (str[i] != '\0')
      i++;
    if (i != 3)
    {
      printf("No");
      return (0);
    }
    i = 0;
    while (str[i + 1] != '\0')
    {
      if (str[i] != 'A' && str[i] != 'B')
      {
        printf("No");
        return (0);
      }
      if (str[i] != str[i + 1])
      {
        printf("Yes");
        return (0);
      }
      i++;
    }
    printf("No");
    return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	long long a,ans,c;
	double b;
	int l;

	cin>>a>>b;
	c=b*100+0.5;
	ans = a*c;
	ans =ans/100;
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  dset(10);
  ind n,k;
  cin >> n >> k;
  ind P = 1/n;
  ind ans = 0;
  repa(i,1,n+1) {
    ind lg = log(k/i)/log(2);
    if(fmod(lg,1) != 0) ++lg;
    if(i >= k) ans += P;
    else ans += P*pow(0.5,(int)lg);
  }
  cout << ans;
}

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

const int N = 10;

int id[N], l[N]; double dp[350][1 << 6];

int main() {
    int n, c, frac = 0; scanf("%d%d", &n, &c); double ans = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &l[i]), id[i] = i;
    sort(l + 1, l + n + 1);
    do { // 枚举小数的相对大小
        memset(dp, 0, sizeof(dp));
        dp[l[n] * n][1 << n - 1] = 1;
        for (int i = 1; i <= n * c; i++) {
            int nw = id[(i - 1) % n + 1];
            if (nw == n) continue;
            for (int j = i; j <= n * c; j++)
                for (int s = (1 << n) - 1; s > 0; s--) if (dp[j][s] && !(s & (1 << nw - 1))) 
                    dp[min(n * c, max(j, i + l[nw] * n))][s | (1 << nw - 1)] += dp[j][s];
        }
        ans += dp[n * c][(1 << n) - 1], frac++;
    } while (next_permutation(id + 1, id + n));
    printf("%.12lf\n", ans / frac / pow(c, n - 1));
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
const int INF = 1e9;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n;
    cin>>n;
    vector<int>a(n),dp(n,INF);
    for(int i=0;i<n;i++) cin>>a[i];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        min_self( dp[i], abs(a[i]-a[i-1]) + dp[i-1] );
        min_self( dp[i], abs(a[i]-a[i-2]) + dp[i-2] );
    }
    cout<<dp[n-1],nl;
    return 0;
}

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

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

Measured memory_bytes: 256
//   /$$$$           /$$                 /$$$$  /$$$$$$            /$$
//  | $$_/          | $$                |_  $$ /$$__  $$          | $$
//  | $$    /$$$$$$$| $$$$$$$   /$$$$$$   | $$|__/  \ $$ /$$$$$$$ | $$   /$$
//  | $$   /$$_____/| $$__  $$ |____  $$  | $$  /$$$$$$/| $$__  $$| $$  /$$/
//  | $$  |  $$$$$$ | $$  \ $$  /$$$$$$$  | $$ /$$____/ | $$  \ $$| $$$$$$/
//  | $$   \____  $$| $$  | $$ /$$__  $$  | $$| $$      | $$  | $$| $$_  $$
//  | $$$$ /$$$$$$$/| $$  | $$|  $$$$$$$ /$$$$| $$$$$$$$| $$  | $$| $$ \  $$
//  |____/|_______/ |__/  |__/ \_______/|____/|________/|__/  |__/|__/  \__/
//
//
//






#include <bits/stdc++.h>
using namespace std;


#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005
#define Vii  vector<ll>
#define pb  push_back
#define pii pair<ll,ll>
#define ff  first
#define ss second
#define vpii vector<pii >
#define endl '\n'


//--------------------------------------------------//
void solve(){
	ll  n,k;
	cin>>n>>k;
	vector<ll>h(n);

for(ll i=0;i<n;i++){
	cin>>h[i];
}
ll dp[n];

for(ll i=0;i<n;i++) dp[i]=1e10;

dp[0]=0;

for(ll i=0;i<n;i++){
	for(ll j=i+1;j<=i+k;j++){
			if(j<n){
		dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
			}
		
	}
}
cout<<dp[n-1];
}

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


int main(){
  ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    int tc=1;
//	cin >> tc;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }


}


Measured memory_bytes: 4772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int w;
	
	Main() {
		readData();
		

	}	

	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			
			double m = 100000;
			int n = nextInt();
			for (int i=1;i<=n;i++) {
				m = m * 1.05;
				BigDecimal bd = new BigDecimal(m);
				BigDecimal bd3 = bd.setScale(-3, BigDecimal.ROUND_UP);
				
				m = bd3.intValue();
//				System.out.println((int)m);
			}
			DecimalFormat df = new DecimalFormat("0");
			System.out.println(df.format(m));
			
		} catch (Exception e) {
			System.out.println("dacat");
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	
	private String next() throws IOException {
		try {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		} catch (Exception e) {
			System.out.println("dacat");
		}
		return st.nextToken();
	}
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

Measured memory_bytes: 17204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
int n;
int a,b,c;
string s;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    if(n%2 == 0){
        cout << n/2-1 << endl;
    }else{
        cout << n/2 << endl;
    }

    

    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    m += n - 1;
    vector< vector<int> > G(n);
    map< pair<int, int>, bool> jest;
    vector<int> st_we(n, 0);
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        ++st_we[b];
        jest[make_pair(a, b)] = true;
    }
    int root = 0;
    for (int i = 0; i < n; ++i)
        if (st_we[i] == 0)
            root = i;
    stack<int> S;
    S.push(root);
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < G[akt].size(); ++i)
        {
            if (st_we[G[akt][i]] >= 2)
            {
                --st_we[G[akt][i]];
                jest[make_pair(akt, G[akt][i])] = false;
            }
            else
                S.push(G[akt][i]);
        }
    }
    vector<int> oj(n);
    oj[root] = -1;
    S.push(root);
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < G[akt].size(); ++i)
        {
            if (jest[make_pair(akt, G[akt][i])])
            {
                S.push(G[akt][i]);
                oj[G[akt][i]] = akt;
            }
        }
    }
    for (int i = 0; i < n; ++i)
        cout << oj[i] + 1 << endl;
    return 0;
}


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

class Program
{
  static void Main(string[] args)
  {
    var N = Int32.Parse(Console.ReadLine());
    int[] A = new int[N];
    long[] B = new long[N + 1];
    int mod = Convert.ToInt32(Math.Pow(10, 9)) + 7;
    var s = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
    for (int i = 0; i < N; i++)
    {
      A[i] = s[i];
      B[i + 1] = B[i] + A[i];
    }
    long ans = 0;
    for (int i = 0; i < N; i++)
    {
      // 累積和を使ってA[i+1] + ... A[N] を求める
      long sum = (B[N] - B[i + 1]) % mod;
      ans += A[i] * sum;
      ans %= mod;
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 45852
#include "bits/stdc++.h"

using namespace std;

void fail()
{
	cout << -1 << endl;
	exit(0);
}

void solve(void)
{
	int n;
	string s;
	cin >> s;
	n = s.size();
	if (s.back() == '1' || s.front() == '0')
	{
		fail();
	}
	vector<int> vs;
	for (int i = 2; i <= n / 2; i++)
	{
		if (s[i-1] != s[n-i-1])
		{
			fail();
		}
		if (s[i-1] == '1')
		{
			vs.push_back(i);
		}
	}
	vector<int> g[n];
	int now = 1, pr = n-1, pv = 1;
	for (int v : vs)
	{
		int r = now++;
		g[pr].push_back(r);
		for (int i = 0; i < v - 1 - pv; i++)
		{
			g[r].push_back(now++);
		}
		pr = r;
		pv = v;
	}
	g[0].push_back(pr);
	for (int i = now; i < n-1; i++)
	{
		g[0].push_back(now++);
	}
	for (int i = 0; i < n; i++)
	{
		for (int v : g[i])
		{
			cout << i + 1 << ' ' << v + 1 << '\n';
		}
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main()
{
	int n, slime = 1;
	cin >> n;
	string A;
	cin >> A;
	for (int i = 1; i < n; i++)
	{
		if (A[i] != A[i-1])
		slime++;	
	}	
	cout << slime;
	return 0;
}

Measured memory_bytes: 512
/*
*/

#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 337

using namespace std;

const int INF = 1e9;
const int N = 201231;

int n, m, cnt[N];
int odds[N];
int ans;
int evens[N];

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/input.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}

	for (int i = 1; i <= 100000; i++)
	{
		if (cnt[i] % 2)
		{
			odds[i%m]++;
		}
		evens[i%m] += cnt[i] - cnt[i] % 2;
	}

	for (int i = 0; i < m; i++)
	{
		int othr = m - i;
		othr %= m;
		if (othr < i)
			continue;

		if (i != othr)
		{
			int here = min(odds[i], odds[othr]);
			ans += here;
			odds[i] -= here;
			odds[othr] -= here;
		}
		else
			ans += odds[i] / 2,
			odds[i] %= 2;
	}

	for (int i = 0; i < m; i++)
	{
		int othr = m - i;
		othr %= m;
		int can_add = min(odds[i], evens[othr]);
		can_add -= can_add % 2;
		ans += can_add;
		odds[i] -= can_add;
		evens[othr] -= can_add;
	}

	for (int i = 0; i <m; i++)
		ans += evens[i] / 2;

	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n = 200000;
long long x,n,D=0;
pair<long long, long long> itv[max_n];
long long a[max_n],b[max_n];
void solve(){
    for(int i=0 ; i<n ; i++){
        itv[i].first = b[i];
        itv[i].second = a[i];
    }
    sort(itv, itv+n);
    long long ft = 0;
    int i;
    for(i=0 ; i<n ; i++){
        if(ft <= itv[i].first - itv[i].second){
            long long st = min(ft, itv[i].first - itv[i].second);
            ft = st + itv[i].second;
        }else{
            break;
        }
    }
    if(n == i)    cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    cin >> n;
    for(int i=0 ; i<n ; i++){
        cin >> a[i] >> b[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int main() {
  INCANT;
  cin >> N;
  vector<bool> A;
  int a, b;
  rep(i, N) {
    cin >> a;
    cin >> b;
    A.push_back(a==b);
  }
  rep(i, N-2) {
    if (A[i]&&A[i+1]&&A[i+2]) {
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3672
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			int x = in.nextInt();
			if(n == 0) break;
			int count = 0;
			boolean cont = true;
			for(int i=0; i<n; i++){
				int y = in.nextInt();
				while(cont && y != x){
					x = next(x, a, b, c);
					count++;
					if(count > 10000){
						cont = false;
					}
				}
				x = next(x, a, b, c);
				if(i<n-1) count++;
			}
			System.out.println(count > 10000 ? -1 : count);
		}
	}
	
	public static int next(int x, int a, int b, int c){
		return (x*a+b)%c;
	}
}

Measured memory_bytes: 30060
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;


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

vector<string> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int H, W;
bool seen[510][510];

void dfs(int h, int w)
{
    seen[h][w] = true;
    for (int dir = 0; dir < 4;dir++)
    {
            int nh = h + dx[dir];
            int nw = w + dy[dir];
        
        if(nh < 0|| nh >= H || nw < 0 || nw >= W){
            continue;
        }
        if(field[nh][nw] == '#'){
            continue;
        }
        if(seen[nh][nw]){
            continue;
        }
        dfs(nh, nw);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int a, b;
    cin >> a >> b;
    if(a*b % 2 == 0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        Map<String, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            String s = new String(c);
            if (!map.containsKey(s)) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(i);
                map.put(s, list);
            }
            else {
                ArrayList<Integer> list = map.get(s);
                list.add(i);
            }
        }
        long ans = 0;
        Set<String> keySet = map.keySet();
        for (String t : keySet) {
            ArrayList<Integer> list = map.get(t);
            int m = list.size();
            ans += (long)(m - 1) * m / 2;
        }
        out.println(ans);
        out.close();
    }
}


Measured memory_bytes: 78732
while True:
    n,x = list(map(int, input().split()))
    cnt = 0
    if n == 0 and x == 0:
        break

    for i in range(n):
        for j in range(n):
            if j == i:
                break
            for k in range(n):
                if j == k:
                    break

                if (i + 1) + (j + 1) + (k + 1) == x:
                    cnt += 1
    print(cnt)



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

int main() {
  int H, W; cin >> H >> W;
  char a[100][100], b[102][102];
  for(int i = 0;i < H + 2; i++){
    for(int j = 0; j < W + 2; j++){
      b[i][j] = '#';
    }
  }
  for(int i = 0;i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0;i < H; i++){
    for(int j = 0; j < W; j++){
      b[i+1][j+ 1] = a[i][j];
    }
  }
  for(int i = 0;i < H +2; i++){
    for(int j = 0; j < W +2; j++){
      cout << b[i][j] ;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main()
{
    string s, T; int countt = 0;
    cin >> s >> T;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != T[i])
        {
            countt++;
        }
    }
    cout << countt << endl;
}

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int n; scanf("%d", &n);
    vector<int> as(n);
    for (auto &a: as) scanf("%d", &a);

    vector<int> ps, qs;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) ps.push_back(as[i]);
        else qs.push_back(as[i]);
    }

    sort(as.begin(), as.end());
    // sort(ps.begin(), ps.end());
    // sort(qs.begin(), qs.end());

    multiset<int> ss;
    for (int i = 0; i < n; i += 2) ss.insert(as[i]);

    int ans = 0;
    for (auto &p: ps) {
        if (ss.count(p)) {
            ss.erase(ss.find(p));
        } else {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define qMAX 150
#define MAX 1001

void LCS(char *,char *);
  
int c[MAX][MAX],m,n;

int main()
{
  int q,j,i;
  char x[MAX],y[MAX];

  scanf("%d",&q);

  for(i = 0 ; i < q ; i++)
    {
      scanf(" %s",x);
      
      scanf(" %s",y);
      
      LCS(x,y);

      printf("%d\n",c[m][n]);
    }

  return 0;
}

void LCS(char *x,char *y)
{
  int i,j,cx,cy; //cx,cy は文字用のカウンタint
  
  m = strlen(x);
  n = strlen(y);
  
  for(i = 1 ; i <= m ; i++)
    {
      c[i][0] = 0;
    }
  for(j = 0 ; j <= n ; j++)
    {
      c[0][j] = 0;
    }

  for(i = 1,cx = 0 ; i <= m ; i++,cx++)
    {
      for(j = 1,cy = 0 ; j <= n ; j++,cy++)
	{
	  if(x[cx] == y[cy] && x[cx] != '\0' && y[cy] != '\0') c[i][j] = c[i-1][j-1] + 1;
	  else if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
	  else c[i][j] = c[i][j-1];
	}
    }

  return;
}



Measured memory_bytes: 5716
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)

	rest := make(SortBy, n)

	for i := 0; i < n; i++ {
		fmt.Sscan(getNextLine(scanner), &rest[i].s, &rest[i].p)
		rest[i].i = i + 1
	}
	sort.Sort(rest)
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, rest[i].i)
	}

	writer.Flush()
}

type Rest struct {
	i int
	s string
	p int
}
type SortBy []Rest

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].s == a[j].s {
		return a[i].p > a[j].p
	}
	return a[i].s < a[j].s
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int prime[300000];
    rep(i, 300000) prime[i] = 1;
    prime[1] = 0;
    for(int i = 2; i <= 2000; i++){
        for(int j = (i << 1); j < 300000; j+=i){
            prime[j] = 0;
        }
    }
    vector<int> ans;
    while(true){
        int res = 0;
        int N; cin >> N;
        if(N == 0) break;
        int lim = N+N;
        for(int i = N+1; i <= lim; i++) if(prime[i]) res++;
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4232
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;

int mp[4][4];
int visited[4];

int main(){

    for(int i = 0;i < 3;i++){
        int a,b;
        cin >> a >> b;
        visited[a-1]++;
        visited[b-1]++;
    }

    int odd = 0;
    for(int i = 0;i < 4;i++){
        if(visited[i] % 2 == 1){
            odd++;
        }
    }
    if(odd == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    

    return 0;
}

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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pd pair<double, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 200001
#define mod 1000000000

signed main()
{
  lli n;
  cin >> n;
  float ans = 2 * 3.1415 * n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

bool ok(vector<int> b){
  
  vector<int> t;
  int n;
  for(int i = 0 ; i< b.size()-1 ; i++){
    n = b[i+1] - b[i];
    t.push_back(n);
  }
 

  for(int i = 0 ; i < t.size()-1 ; i++){
    if(t[i] != t[i+1]) return false;
  }
  return true;
}
  

int main(){
  int n;
  int ans;
  while(cin >> n){
    if(n == 0) break;
  vector<int> a;
  
    int c;
    for(int i = 0 ; i < n +1 ; i++){
      cin >> c;
      a.push_back(c);
    }
        
    for(int i = 0 ; i < n+1 ; i++){
      vector<int> b;
      for(int j = 0 ; j < n+1 ; j++){
	if(i == j) continue;
	b.push_back(a[j]);
      }
      if(ok(b)){
	ans = a[i];
	goto end;
      }
    }
  end:
    cout << ans << endl;
  }
  return 0;
}

    

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

signed main(){
	int q;
	set<int>s;
	cin>>q;
	while(q--){
		int x,y;
		cin>>x>>y;
		if(x==1)cout<<s.count(y)<<endl;
		else if(!x){
			s.insert(y);
			cout<<s.size()<<endl;
		}
		else if(x==2)s.erase(y);
		else{
			int l=y,r;
			cin>>r;
			set<int>::iterator end,it;
			it=s.lower_bound(l);
			end=s.upper_bound(r);
			for(;it!=end;it++){
				cout<<(*it)<<endl;
			}
		}
	}
}



Measured memory_bytes: 12444
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const long long INF = 9223372000000000000/2145;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

int h(int n){
    if(n==0) return 0;
    int ret = n%10;
    return ret + h(n/10);
}

signed main(){
    int n;
    scanf("%d",&n);
    int x;
    x = h(n);
    if(n%x==0) puts("Yes\n");
    else puts("No\n");
    return 0; 
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

ll cal(ll a) {
    if (a < 0) return 0;
    ll res = 0;
    rep(i, 50) {
        ll loop = 1LL<<(i+1);
        ll cnt = (a / loop) * (loop / 2);
        cnt += max(0LL, a%loop-loop/2+1);
        res += (cnt%2)<<i;
    }
    return res;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = cal(b) ^ cal(a-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;
#define _ ios::sync_with_stdio(false)

const int MAXN = 1010;
const int INF = 0xfffffff;
typedef long long ll;

ll n,a,b;
int main(){
    cin>>n>>a>>b;
    if(a>b)
        cout<<"0"<<endl;
    else if(a==b)
        cout<<"1"<<endl;
    else if(n==1)
        cout<<"0"<<endl;
    else
        cout<<(n-2)*b+(2-n)*a+1;
}


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


void solve(long long N){
    N = N % 1000;
    if (N == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - N << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3756
#include<iostream>
using namespace std;
 
static const int N = 1000;
 
void trace(int A[], int n){
  for ( int i = 1; i <= n; i++ ){
    if ( i >1 ) cout << " ";
    cout << A[i];
  }
  cout << endl;
}
 
main(){
  int n;
  int A[N+1];
  cin >> n;
  for ( int i = 1; i <= n; i++ ) cin >> A[i];
   
  trace(A, n);
  for ( int j = 2; j <= n; j++ ){
    int key = A[j];
    int i = j - 1;
    while( i > 0 && A[i] > key ){
      A[i+1] = A[i];
      i--;
    }
    A[i+1] = key;
 
    trace(A, n);
  }
}

Measured memory_bytes: 3120
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Integer.parseInt(in.next()),A[]=new int[n];
		for(int i=0;i<n;i++) A[i]=Integer.parseInt(in.next());
		
		int q=Integer.parseInt(in.next());
		for(int i=0;i<q;i++) {
			int com=Integer.parseInt(in.next()),
					b=Integer.parseInt(in.next()),
					e=Integer.parseInt(in.next());
			
			if(com==0) {
				int min=A[b];
				for(int j=b+1;j<e;j++) {
					if(A[j]<min)min=A[j];
				}
				out.println(min);
			}
			else {
				int max=A[b];
				for(int j=b+1;j<e;j++) {
					if(A[j]>max)max=A[j];
				}
				out.println(max);
			}
		}
		out.flush();
	}

}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (auto& item : a) {
    cin >> item;
  }

  auto isprime = [](int m) {
    if (m % 2 == 0) return m == 2;
    for (int i = 3; i * i <= m; i += 2) {
      if (m % i == 0) return false;
    }
    return true;
  };
  auto result = count_if(a.begin(), a.end(), isprime);
  cout << result << endl;
  return 0;
}



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

int Output(int a, int b, int c)
{
	if(a == b and b == c)
		return 1;
	else if(a != b and b != c and a != c)
		return 3;
	else
		return 2;
}

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

	cout << Output(a, b, c) << endl;

	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(c - a)<= d) {
    cout << "Yes" << endl;
    return 0;
  }
  if (abs(b - a) <= d && abs(c - b) <= d) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<ll>;
using p = pair<ll,ll>;
using m = map<ll,ll>;
using vv = vector<v>;
int gcd(int a,int b){
    return a==0? b :gcd(a,a%b);
}


int main(){
    ll n,T;
    cin >> n >> T;
    auto t = vector<ll>(n,0);
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    
    ll sum =0;
    for (int i = 0; i < n-1; i++)
    {
       if(t[i+1]-t[i]>T){
       	sum-=t[i+1]-t[i]-T;
       }
    }
    
    cout << sum+t[n-1]+T;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N,L;
    cin>>N>>L;
    int ans=0;
    int mn=10000;
    rep(i,N){
        ans+=L+i;
        if(abs(L+i)<abs(mn)){mn=L+i;}
    }
    ans-=mn;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

vector<int> graph[100005];
vector<bool> used(100005);
vector<int> ans;
bool finished = false;

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

  string s; cin >> s;
  auto ans = 0;
  rep(i, s.size()) {
    if (s.at(i) == '2') {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;

#define endl '\n'

int h[N],dp[N];

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n,maxn;
	cin>>n;
	for(int i=0;i<n;i++) cin>>h[i];
	dp[0]=maxn=0;
	for(int i=1;i<n;i++){
		if(h[i]<=h[i-1]) dp[i]=dp[i-1]+1;
		else dp[i]=0;
		maxn=max(maxn,dp[i]);
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 1024
module A = Array
module C = Char
module I = Int64
module L = List
module Q = Queue

let pf = Printf.printf

let read_int () = Scanf.scanf "%d " (fun x -> x)
let read_float () = Scanf.scanf "%f " (fun x -> x)
let read_string () = Scanf.scanf "%s " (fun x -> x)
let read_array read n = A.init n (fun _ -> read ())

let range s t = A.init (t - s) @@ (+) s
let foreach fold_f init s t map_f =
  range s t |> A.map map_f |> A.fold_left fold_f init

module S = struct
  include String
  let of_array a = String.init (A.length a) (A.get a)
  let to_array s = A.init (String.length s) (String.get s)
end;;

let () =
  let p = read_int () in
  let q = read_int () in
  let r = read_int () in
  let res = L.fold_left min max_int [p + q; q + r; r + p] in
  Printf.printf "%d\n" res


Measured memory_bytes: 2432