akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            int k = in.nextInt();
            TreeSet<String> treeSet = new TreeSet<>();

            for (int i = 1; i <= k; i++) {
                for (int j = 0; j + i <= s.length(); j++) {
                    treeSet.add(s.substring(j, j + i));
                }
            }

            for (int i = 0; i < k - 1; i++) {
                treeSet.pollFirst();
            }

            out.println(treeSet.first());
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 24404
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define INF 100000000000000

int main(){
  long long q;
  cin >> q;
  long long l[q],r[q];
  for(int i=0;i<q;i++){
    cin >> l[i] >> r[i];
  }
  int prime[100001];
  for(int i=0;i<100002;i++){
    prime[i] = 1;
  }
  prime[0] = 0;
  prime[1] = 0;
  for(int i=2;i<100002;i++){
    if(prime[i] != 1) continue;
    int j = 2*i;
    while(j < 100002){
      prime[j] = 0;
      j += i;
    }
  }
  
  for(int i=100001;i>2;i--){
    if(prime[i]){
      if(prime[(i+1)/2]) continue;
      else prime[i] = 0;
    }
  }
  prime[2] = 0;

  int count[100002];
  count[0] = 0;
  for(int i=1;i<100002;i++){
    count[i] = count[i-1] + prime[i];
  }
  for(int i=0;i<q;i++){
    cout << count[r[i]]-count[l[i]]+prime[l[i]] << endl;
  }



  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
int x[maxn];

const int mod = 1e9 + 7;
int mul(ll a, ll b) {
    return a * b % mod;
}

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    forn (i, n)
        cin >> x[i];
    sort(x, x + n);

    int res = 1;
    int rem = 0;
    forn (i, n) {
        int r = x[i];
        int k = i + 1 - rem;
        if (k > (r + 1) / 2) {
            res = mul(res, k);
            ++rem;
        }
    }
    for (int i = 1; i <= n - rem; ++i)
        res = mul(res, i);
    cout << res << '\n';
}


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

long long x, y, a, b, c, ans;
int ai[100001], bi[100001], ci[100001], ansn[300001]; 

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

int main () {
    cin >> x >> y >> a >> b >> c;
    for (int i = 1; i <= a; i++) cin >> ai[i];
	for (int i = 1; i <= b; i++) cin >> bi[i];
	for (int i = 1; i <= c; i++) cin >> ci[i];

	sort (ai + 1, ai + a + 1, cmp);   //下标从 1 到 a;  
	sort (bi + 1, bi + b + 1, cmp);
	sort (ci + 1, ci + c + 1, cmp); 
	
	for (int i = 1; i <= x; i++) ansn[i] = ai[i]; 
	for (int i = 1; i <= y; i++) ansn[i + x] = bi[i];
	sort (ansn + 1, ansn + x + y + 1, cmp);   //把 ai 和 bi 综合到一起再与 c 比较!!! 
	int ansl = 1, cl = 1;
	for (int i = 1; i <= x + y; i++) {
	    if (ansn[ansl] < ci[cl]) ans += ci[cl++];
		else ans += ansn[ansl++]; 
	}  
	
	cout << ans;
	return 0; 
} 

Measured memory_bytes: 2176
from collections import deque
d=deque()
e=deque()
h,w=map(int,input().split())
field=[0 for i in range(h+2)]
field[0]=[True for i in range(w+2)]
distance=0
white=0
for i in range(h):
    s=input()
    a=[False for i in range(w+2)]
    a[0]=True
    for j in range(w):
        if s[j]=="#":
            a[j+1]=True
        else:
            white+=1

    a[w+1]=True
    field[i+1]=a
field[h+1]=[True for i in range(w+2)]
d.append((1,1))
ans=-1
while d:
    while d:
        some=d.popleft()
        index1,index2=some[0],some[1]
        if index1==h and index2==w:
            ans=distance
        if field[index1-1][index2]==False:
                field[index1-1][index2]=True
                e.append((index1-1,index2))
        if field[index1+1][index2]==False:
                field[index1+1][index2]=True
                e.append((index1+1,index2))
        if field[index1][index2+1]==False:
                field[index1][index2+1]=True
                e.append((index1,index2+1))
        if  field[index1][index2-1]==False:
                field[index1][index2-1]=True
                e.append((index1,index2-1))
    distance+=1
    d=e
    e=deque()
if ans>=0:
    print(white-ans-1)
else:
    print(-1)

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

#define coutv(v) for (int i = 0; i < (v).size(); ++i) cout << v[i] << ' '; cout << endl;
#define coutvv(v) for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cout << v[i][j] << ' '; cout << endl;}
#define debugv(v) {for (int i = 0; i < (v).size(); ++i) cerr << v[i] << ' '; cerr << endl;}
#define debugvv(v) {for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cerr << v[i][j] << ' '; cerr << endl;}}
#define stringtovector(s, v) {for (int i = 0; i < (s).size(); ++i) v.push_back(s[i]);
#define TC int TESTCASE; cin >> TESTCASE; while (TESTCASE--)
typedef long long ll;
const int mod = 1000000007;



int main() {
    string s;
    cin >> s;
    int res = 1;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        res = 3;
    }
    if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S') {
        res = 0;
    }
    if (s[0] == 'S' && s[1] == 'R' && s[2] == 'R') {
        res = 2;
    }
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'S') {
        res = 2;
    }
    cout << res;
}


Measured memory_bytes: 3528
from bisect import bisect_left,bisect_right
p=10**9+7
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
pi=1
ni=0
ans=1
i=0
while i<k-1:
  if a[ni]*a[ni+1]>a[-pi]*a[-pi-1]:
    ans=ans*a[ni]*a[ni+1]%p
    ni+=2
    i+=2
  else:
    ans=ans*a[-pi]%p
    pi+=1
    i+=1
if i==k-1:
  ans=ans*a[-pi]%p
if a[-1]<0 and k%2==1:
  ans=1
  for i in a[n-k:]:
    ans=ans*i%p
print(ans)

Measured memory_bytes: 31644
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    for(char i = '0'; i <= '9'; i++){
        for(char j = '0'; j <= '9'; j++){
            string x = "";
            x+=i, x+=j;
            for(char l = '0'; l <= '9'; l++){
                string y = x;
                y+=l;
                int z = 0;
                for(int k = 0; k < n; k++){
                    if(s[k]==y[z])z++;
                }
                if(z==3)cnt++;
            }  
        }   
    }   
    cout<<cnt;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
ll d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int dp[10000];
int main(void){
  int n;
  scanf("%d",&n);
  int a[n],x;
  FOR(n){
    scanf("%d",&x);
    a[x-1]=i+1;
  }
  FOR(n)PRN(a[i]);
  return 0;
}


Measured memory_bytes: 1152
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        matrix: [Chars;h],
    }

    let mut ans :i32 = 0;
    for maskc in 0 .. 1 << h {
        for maska in 0 .. 1 << w {
            let mut black : usize = 0;
            for i in 0 .. h {
                for j in 0 .. w {
                    if ((maskc >> i) & 1) == 0 && ((maska >> j) & 1) == 0 && matrix[i][j] == '#' {
                        black = black + 1;
                    }
                }
            }
            if black == k {
                ans += 1
            }

        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 2168
import sys
lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(int,c))
list(c)
x = c[0:2]
if x[0] == x[1]:
  print("Draw")
  sys.exit()
if x[0] == 1:
  print("Alice")
  sys.exit()
if x[1] == 1 :
  print("Bob")
  sys.exit()
else:pass
if x[0] ==2:
  print("Bob")
  sys.exit()
if x[1] ==2:
  print("Alice")
  sys.exit()
if x[0]>x[1]:
  print("Alice")
  sys.exit()
elif x[0]<x[1]:
  print("Bob")
  sys.exit()

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

signed main(){
    string S,T;
    cin>>S>>T;

    rep(i,S.size()){
        if(i+T.size()>S.size())break;
        string sub=S.substr(i,T.size());
        if(sub==T)cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)

int main(){
    int n, m, p, p_i;
    bool ac;
    string s;
    cin >> n >> m;
    vector<pair<int, bool>> submit(n+1);
    rep(i, m){
        cin >> p >> s;
        tie(p_i, ac) = submit[p];
        if (ac == 0 and s == "WA"){
            p_i ++;
            submit[p].first = p_i;
            submit[p].second = 0;
        }
        else if (ac == 0 and s == "AC"){
            submit[p].first = p_i;
            submit[p].second = 1;
        }
    }
    int total_ac = 0;
    int penalty = 0;
    rep(i, n){
        tie(p_i, ac) = submit[i];
        if (ac == 1){
            total_ac ++;
            penalty += p_i;
        }
    }
    cout << total_ac << " " << penalty << endl;
}


Measured memory_bytes: 1024
T = int(input())

for _ in range(T):
    N = int(input())
    A = list(map(int,input().split()))
    S = input()

    list0 = [0] * 64
    ans = 0

    for a, s in zip(A[::-1], S[::-1]):
        while a:
            b = a.bit_length() - 1
            if list0[b]:
                a ^= list0[b]
            else:
                if s == '1':
                    ans = 1
                else:
                    list0[b] = a

                break

        if ans: break

    print(ans)


Measured memory_bytes: 9184
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 1e5+500;
const ll MOD = 1e9+7;
using namespace std;

const int c = 753;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    int a[n];
    for(int i = 0;i<n;++i)
        a[i] = (s[i]-'0');
    ll ans = 1e18;
    for(int i = 0;i<n-2;++i)
    {
        int j = i+1;
        int k = j+1;
        ll x = 100 * a[i] + 10 * a[j] + a[k];
        ans = min(ans,abs(x-c));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j,k;
	int now;
	int N;
	scanf("%d",&N);
	int data[100];

	for(i=0;i<N;i++)
	{
		scanf("%d",&data[i]);
	}

	for(i=1;i<N;i++)
	{
		printf("%d",data[0]);
		for(j=1;j<N;j++)
		{
			printf(" %d",data[j]);
		}
		printf("\n");

		now=data[i];
		k=i-1;
		while((now<data[k])&&k>=0)
		{
			data[k+1]=data[k];
			k--;
		}
		data[k+1]=now;

	}
	printf("%d",data[0]);
	for(j=1;j<N;j++)
	{
		printf(" %d",data[j]);
	}
	printf("\n");


	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

const int maxn = 200010;

int H, W, n;
int sx, sy;

struct matrix {
	int x1, y1, x2, y2;
	matrix(int x1_=0, int y1_=0, int x2_=0, int y2_=0) : x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
};

char s1[maxn], s2[maxn];
matrix a[maxn], b[maxn];

int check(matrix m) {
	return m.x1 > m.x2 || m.y1 > m.y2;
}

int main() {
	scanf("%d%d%d", &H, &W, &n);
	scanf("%d%d", &sx, &sy);
	scanf("%s", s1+1);
	scanf("%s", s2+1);
	a[n+1] = matrix(1, 1, H, W);
	for (int i = n; i >= 1; i--) {
		{
			//cal b[i]
			b[i] = a[i+1];
			if (s2[i] == 'L') {
				b[i].y2 ++;
			} else if (s2[i] == 'R') {
				b[i].y1 --;
			} else if (s2[i] == 'U') {
				b[i].x2 ++;
			} else b[i].x1 --;
			if (b[i].x1 < 1) ++ b[i].x1;
			if (b[i].x2 > H) -- b[i].x2;
			if (b[i].y1 < 1) ++ b[i].y1;
			if (b[i].y2 > W) -- b[i].y2;
		}
		{
			//cal a[i]
			a[i] = b[i];
			if (s1[i] == 'L') a[i].y1 ++;
			else if (s1[i] == 'R') a[i].y2 --;
			else if (s1[i] == 'U') a[i].x1 ++;
			else a[i].x2 --;
			if (check(a[i])) {
				puts("NO");
				return 0;
			}
		}
	}
	if (sx >= a[1].x1 && sx <= a[1].x2 && sy >= a[1].y1 && sy <= a[1].y2) {
		puts("YES");
	} else puts("NO");
	return 0;
}

Measured memory_bytes: 6912
#include"bits/stdc++.h"
using namespace std;
int dy[4]={0,1,0,-1},dx[4]={1,0,-1,0};
int H,W,ans=0;
char maze[52][52];
int dist[52][52];
queue<pair<int,int>> que;
int main()
{
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> maze[i][j];
      dist[i][j] = -1;
      if(maze[i][j]=='.')
        ans++;
    }
  }
  dist[0][0] = 0;
  que.push(make_pair(0,0));
  while(!que.empty()){
    int cy=que.front().first,cx=que.front().second;
    que.pop();
    if(cy==H-1&&cx==W-1){
      ans -= dist[cy][cx]+1;
      cout << ans << "\n";
      return 0;
    }
    for(int i=0;i<4;i++){
      int ny=cy+dy[i],nx=cx+dx[i];
      if(ny<0||H<=ny||nx<0||W<=nx||maze[ny][nx]=='#')
        continue;
      if(dist[ny][nx]==-1){
        dist[ny][nx]=dist[cy][cx]+1;
        que.push(make_pair(ny,nx));
      }
    }
  }
  cout << "-1\n";
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    bool is_multi = false;
    if (w == x * 2.0000000 && h == y * 2.00000000) is_multi = true;
    cout << w * h / 2 << " " << is_multi << endl; 
}


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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  int a=A*B;
  int b=C*D;
  
  if(a>b){
    cout<<a<<endl;
  }
  else{cout<<b<<endl;
      }
}
    

Measured memory_bytes: 256
k = int(input())
a, b = map(int, input().split())

if a % k != 0:
    if a <= (a//k + 1)*k <= b:
        print('OK')
    else:
        print('NG')
else:
    if a <= (a//k)*k <= b:
        print('OK')
    else:
        print('NG')

Measured memory_bytes: 9180
def main():
    N = int(input())
    C = [0]*N
    S = [0]*N
    F = [0]*N
    for i in range(N-1):
        C[i],S[i],F[i] = map(int,input().split())
    for i in range(N):
        t = 0
        for j in range(i,N-1):
            if t < S[j]:
                t = S[j]
            elif t%F[j] == 0:
                tmp = 0
            else:
                t = t + F[j] - t%F[j]
            t += C[j]
        print(t)

if __name__ == '__main__':
    main()

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

using namespace std;

const int N = 2e5 + 10;
int a[N];

int main() {
	int k, n;
	cin >> k >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0] = a[n] - k, a[n + 1] = a[0] + k;
	int mmin = 0x3f3f3f3f, x;
	for (int i = 1; i <= n; i++) {
		x = min(k - (a[i + 1] - a[i]), k - (a[i] - a[i - 1]));
		mmin = min(mmin, x);
	}
	cout << mmin << endl;
	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



int main()
{
   int N;

   cin >> N;

   vector<int> s(N+1);
   vector<int> res(N+1);


   for( int i = 2; i <= N; i++ )
   {
       cin >> s[i];

       res[s[i]] += 1;

   }


   for( int i = 1; i <= N; i++ )
   {
       cout << res[i] << endl;
   }
    
}

Measured memory_bytes: 4840
#include<iostream>
using namespace std;
void swap(int& a,int& b){
  int tmp;
  tmp=a;
  a=b;
  b=tmp;
}

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

cout<<a<<" "<<b<<" "<<c<<endl;

  return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}


Measured memory_bytes: 2572
#include<bits/stdc++.h>
#define Ll long long
using namespace std;
const int N=2e5+5;
int a[N];
int n,m,x,y,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x,a[x]++;
	for(int i=1;i<100000;i++)ans=max(ans,a[i-1]+a[i]+a[i+1]);
	cout<<ans;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int i,j,a,b,c;
	for(c=1;;)
	{
		scanf("%d %d",&a,&b);
		if(a==0 && b==0)break;
		for(j=1;j<=a;j++)
		if(j%2==0)
	{
		for(i=1;i<=b;i++)
			{
				if(i%2==0)
					printf("#");
				else
					printf(".");
		}
			printf("\n");
		}
		else
		{
				for(i=1;i<=b;i++)
				{
				if(i%2==0)
					printf(".");
				else
					printf("#");
				}
					printf("\n");
		}	
			printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool isprime(vector<int> monstuday, int n) {
	if (n == 6) {
		return true;
	}
	for (int i = 0; monstuday[i] <= (int)sqrt(n); i++) {
		if (n % monstuday[i] == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	vector<int> monstuday;
	//vector<int> monstu_p;
	vector<int> ans;
	int i = 7;
	int n;
	//int ans_n;

	while (true) {
		if (i >= 300000) {
			break;
		}
		monstuday.push_back(i - 1);
		monstuday.push_back(i + 1);
		i += 7;
	}
	//cout << monstuday[3] << monstuday.size() << endl;
	//return 0;
	//monstu_p.push_back(monstuday[0]);
	/*for (int i = 0; i < (int)monstuday.size(); i++) {
		if (isprime(monstuday, monstuday[i])) {
			monstu_p.push_back(monstuday[i]);
		}
	}
	for (int i = 0; i < (int)monstu_p.size(); i++) {
		cout << monstu_p[i] << " ";
		}
		cout << endl;*/
	//return 0;
	while (true) {
		cin >> n;
		if (n == 1) {
			break;
		}
		cout << n << ":";
		if (isprime(monstuday, n)) {
			cout << " " << n << endl;
			continue;
		}
		//int m = (int)sqrt(n);
		for (int i = 0; monstuday[i] <= n; i++) {
			if (n % monstuday[i] == 0 && isprime(monstuday, monstuday[i])) {
				cout << " " << monstuday[i];
			}
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1984
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N,l=0; cin >> N;
	long long ans = 1;
	vector<long long> a(N);
	map<long long, int> b;
	for (int i = 0; i < N; i++)cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = N-1; i >=0; i--) {
		b[a[i]]++;
		if (b[a[i]] %2==0&&b[a[i]]!=0) { ans *= a[i]; l++; }
		if (l == 2)break;
	}
	if(l==2)cout << ans << endl;
	else cout << '0' << endl;
}



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

struct BipartiteGraph{
    int n,num;
    vector<int> par,rank;
    BipartiteGraph(int n):n(n),num(2*n),par(2*n),rank(2*n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    int size(int x){
        return rank[root(x)];
    }
    int count(){
        return num;
    }
    void add_edge(int u,int v){
        merge(u,v+n),merge(u+n,v);
    }
    bool build(){
        for (int i=0;i<n;++i){
            if (same(i,i+n)) return false;
        }
        return true;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    BipartiteGraph BG(N);
    vector<int> deg(N,0);
    for (int i=0;i<M;++i){
        int u,v; cin >> u >> v;
        BG.add_edge(--u,--v);
        ++deg[u]; ++deg[v];
    }
    if (!BG.build()){
        cout << N*(N-1)/2-M << '\n';
        return 0;
    }
    ll cnt=0,ans=0;
    for (int i=0;i<N;++i) cnt+=BG.same(0,i);
    for (int i=0;i<N;++i) if (BG.same(0,i)){
        ans+=N-cnt-deg[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    //input
    int N;
    cin >>N;
    vector<pair<int,int>> A[N];
    rep(i,N){
        int a;
        cin >> a;
        rep(j,a){
            int x,y;
            cin >> x >> y;
            x--;
            A[i].emplace_back(make_pair(x,y));
        }
    }
    int res=0;
    for(int bit = 0;bit < (1 << N);bit++){
        bool flag = true;
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) { 
                count++;
                for(auto a : A[i]){
                    if((bit & (1 << a.first) && a.second == 0) || (!(bit & (1 << a.first)) && a.second == 1)){
                        flag = false;
                        break;
                    }
                }
            }
            if(!flag) break;
        }
        if(flag) res = max(res,count);
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;

ll V;
struct edge {
	ll to, cost;
};
vector<edge> G[MAX_N];
ll d[MAX_N];
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> que;

void dijkstra(ll s) {
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		ll v = p.second;
		if (p.first > d[v])continue;
		rep(i, 0, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	ll E, r; cin >> V >> E >> r;
	rep(i, 0, E) {
		ll s, t, d; cin >> s >> t >> d;
		G[s].push_back(edge{ t, d });
		//G[t].push_back(edge{ s, d });
	}

	dijkstra(r);

	rep(i, 0, V) {
		if (d[i] == INF)cout << "INF" << endl;
		else cout << d[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 19472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
int n,a[N],b[N],c[N],d[N];
ll ans;
int main(){
	scanf("%d",&n);
	for(int i =1;i<=n;i++) scanf("%d",a+i);
	for(int i =1;i<=n;i++) scanf("%d",b+i);
	for(int i =1;i<=n;i++) scanf("%d",c+i);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	for(int i =1,j = 1;i<=n;i++){
		while(j<=n && a[j]<b[i]) j++;
		d[i] = j-1;
	}
	ll tot =0;
	for(int i =1,j=1;i<=n;i++){
		while(j<=n && b[j]<c[i]) {
			tot += d[j];
			j++;
		}
		ans += tot;
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

int N;
int A[100005];

int ky(int maxi1,int maxi2, int p){
  return min( abs(maxi1-p), abs(maxi2-p) ); 
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for(int i=0;i<N;i++)
    cin >> A[i];
  sort( A, A+N );

  int res1 = A[N-1];
  int maxi1 = res1/2;
  int maxi2 = (res1+1)/2;
  P res2 = P(1000000001,-1);
  for(int i=0;i<N;i++){
    int k = ky(maxi1, maxi2, A[i]);
    if( k < res2.first ) {
      res2 = P(k, A[i]);
    }
  }
  cout << res1 << " " << res2.second << endl; 
}


Measured memory_bytes: 640
N = int(input())

def keta(num) :
    ket = 0
    while num > 0 :
        ket += num%10
        num //= 10
    return ket

ans = 1000

for i in range(1,N) :
    total = keta(i) + keta(N-i)
    ans = min(ans, total)

print(ans)


Measured memory_bytes: 2940
program main
  integer :: N,M
  integer,allocatable :: s(:),c(:)
  integer :: max_, min_, tmp
  integer :: i,j
  logical :: check
  read(*,*) N,M
  if (M == 0 .and. N /= 1) then
     write(*,'(i0)') 10**(N-1)
     stop
  else if (M == 0 .and. N == 1 ) then
     write(*,'(i0)') 0
     stop
  end if
  allocate(s(M),c(M))
  do i = 1,M
     read(*,*) s(i), c(i)
  end do
  !
  if (N /= 1) then
     do i = 1,M
        if (S(i) == 1 .and. c(i) == 0) then
           write(*,'(i0)') -1
           stop
        end if
     end do
  end if
  !
  do i = 1,M
     do j = i,M
        if ( S(j) == S(i) ) then
           if (c(j) /= c(i) ) then
              write(*,'(i0)') -1
              stop
           end if
        end if
     end do
  end do
  !
  !
  !
  max_ = 10**N - 1
  if (N /= 1) then
     min_ = 10**(N-1)
  else
     min_ = 0
  end if
  tmp = max_ + 1
  do j = min_, max_
     check = .false.
     do i = 1,M
        if ( digit(s(i),j,N)  == c(i) ) then
           check = .true.
        else
           check = .false.
           exit
        end if
     end do
     if (check .and. tmp > j) then
        tmp = j
     end if
  end do
  if (tmp > max_) then
     write(*,'(i0)') -1
  else 
     write(*,'(i0)') tmp
  end if
contains
  integer function digit(s,i,n)
    integer :: s,i,n
    character(len=N) :: tmp

    write(tmp,'(i0)') i
    read(tmp(s:s),*) digit
    return
  end function digit
end program main


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

int main(void){
    int n;
    vector<int> a;
    int max = 0, cnt = 0;

    cin >> n;
    a.resize(n);

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

    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            cnt++;
        }else{
            if(max < cnt) max = cnt;
            cnt = 0;
        }
        if(max < cnt) max = cnt; 
    }
    cout << max+1 << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
  string s;
  
  cin >> s;
 
  if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

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

ll a[100001];
pll p[100001];
priority_queue<ll, vector<ll>, greater<ll>> pq;

bool comp(const pll& a, const pll& b) {
    return a.second > b.second;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int n, m; cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pq.push(a[i]);
    }
    // sort(a, a + n);
    
    for (int i = 0; i < m; i++) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p, p + m, comp);
    
    ll sum = 0;
    for (int i = 0; i < m; i++) {
        ll b = p[i].first, c = p[i].second;
        while (b) {
            if (pq.top() < c) {
                pq.pop();
                pq.push(c);
                b--;
            } else break;
        }
    }
    
    while (!pq.empty()) {
        sum += pq.top(); pq.pop();
    }
    
    cout << sum << '\n';
    
    return 0;
}


Measured memory_bytes: 3572
n, m = map(int,input().split())
C = list(map(int,input().split()))

dp = [float('inf')]*10**5

dp[0] = 0

for i in range(n+1):
    for c in C:
        dp[i] = min(dp[i-c]+1, dp[i])
        
print(dp[n])


Measured memory_bytes: 7664
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int a(0),b,c,ans(0),tmp(0);
  	string s;
  	//vector<>x();
  	cin >> s;
  	for(int i = 0;i < 2;i++){
		if(s.at(i) == '9'){
          cout << "Yes";
          return 0;
        }
    }
  	cout << "No";
  
}
   


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s; cin >> s;
	int n = s.length();
	for (int i = 0; i < n; i += 2) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int i,j,k,n,m;
	cin>>n>>m;
	for(i=0;i<=n;i++)
	for(j=0;j<=n;j++)
	for(k=0;k<=n,i+j+k<=n;k++)
	if(i*1000+j*5000+k*10000==m&&i+j+k==n){
		cout<<k<<" "<<j<<" "<<i<<endl;
		return 0;
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 384
from operator import itemgetter

n = int(input())
jobs = [list(map(int, input().split())) for i in range(n)]

jobs.sort(key=itemgetter(1))

flg = True
sum = 0
for a, b in jobs:
    sum += a
    if sum > b:
        flg = False
        break

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 53732
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << (x) << endl
#define int long long
using namespace std;
using II = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  int N = in();
  VI tri(1e4); tri[1] = 1;
  REPI (i, 2, 1e4 - 1) {
    tri[i] = tri[i - 1] + i;
  }
  int num = -1;
  REPI (i, 1, 1e4) {
    if (N == tri[i]) {
      num = i; break;
    }
  }
  if (num == -1) {
    cout << "No" << endl; return 0;
  }
  VVI ans(num + 1);
  int i = 0;
  for (int k = num; k > 0; k--) {
    REP (j, k) {
      i++;
      ans[num - k].push_back(i);
      ans[num - k + j + 1].push_back(i);
    }
  }
  cout << "Yes" << endl;
  cout << ans.size() << endl;
  for (auto an: ans) {
    cout << an.size() << ' ';
    for (auto x: an) {
      cout << x << ' ';
    }
    cout << endl;
  }
}


Measured memory_bytes: 3328
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s,t="CODEFESTIVAL2016";
    cin>>s;
    int n=s.size(),i,br=0;
    for(i=0;i<n;i++)
        if(s[i]!=t[i])br++;
    cout<<br<<endl;
}


Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut s = a.clone();
    for i in 1..n {
        s[i] += s[i - 1];
    }
    let a = s;
    let mut ans = std::i64::MAX;
    let mut sum = 0i64;
    let mut add = 0i64;
    if a[0] <= 0 {
        let d = -a[0] + 1;
        add += d;
        sum += d;
    }
    // + - + -
    for i in 1..n {
        if i % 2 == 1 {
            if a[i] + add >= 0 {
                let d = a[i] + add + 1;
                add += -d;
                sum += d;
            }
        } else {
            if a[i] + add <= 0 {
                let d = -(a[i] + add) + 1;
                add += d;
                sum += d;
            }
        }
    }
    ans = std::cmp::min(ans, sum);
    let mut sum = 0i64;
    let mut add = 0i64;
    if a[0] >= 0 {
        let d = a[0] + 1;
        add += -d;
        sum += d;
    }
    // - + -
    for i in 1..n {
        if i % 2 == 0 {
            if a[i] + add >= 0 {
                let d = a[i] + add + 1;
                add += -d;
                sum += d;
            }
        } else {
            if a[i] + add <= 0 {
                let d = -(a[i] + add) + 1;
                add += d;
                sum += d;
            }
        }
    }
    ans = std::cmp::min(ans, sum);
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
 
int X, Y, S;
 
int tax(int n, int r) { return n * (100 + r) / 100; }
 
int main(void) {
  while(cin >> X >> Y >> S, X && Y && S) {
    int m = 0;
    REP(i, 1, S) REP(j, 1, S) if(tax(i, X) + tax(j, X) == S) m = max(m, tax(i, Y) + tax(j, Y));
    cout << m << endl;
  }
 
  return 0;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }
template <typename Monoid>
struct SegmentTree {
  int sz;
  vector<Monoid> node;
  const Monoid identity;

  SegmentTree(int n) : identity(Monoid::identity()) {
    sz = 1;
    while (sz < n) sz <<= 1;
    node.resize(2 * sz, identity);
  }

  void update(int k, const Monoid &x) {
    k += sz;
    node[k] = x;
    while (k >>= 1) {
      node[k] = node[2 * k + 0] + node[2 * k + 1];
    }
  }
  Monoid query(int l, int r) {
    Monoid L = identity, R = identity;
    for (l += sz, r += sz; l < r; l >>= 1, r >>= 1) {
      if (l & 1) L += node[l++];
      if (r & 1) R += node[--r];
    }
    return L + R;
  }
};

struct Monoid {
  int v;
  bool operator==(const Monoid& that) const { return v == that.v; }
  bool operator!=(const Monoid& that) const { return !(*(this) == that); }

  static Monoid identity() { return Monoid((1 << 31) - 1); }

  Monoid(int v = (1 << 31) - 1) : v(v) {}
  Monoid& operator+=(const Monoid& that) {
    v = min(v, that.v);
    return *this;
  }
  Monoid operator+(const Monoid& that) const { return Monoid(*this) += that; }
};

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

  SegmentTree<Monoid> seg(n);
  for (int i = 0; i < (int)(q); ++i) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      cout << seg.query(x, y + 1).v << endl;
    } else {
      seg.update(x, y);
    }
  }

  return 0;
}



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

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

  int cnt0 = 0;
  int cnt1 = 0;

  for(int i = 0; i < s.size(); i++){
    if(s[i] == '0') cnt0++;
    if(s[i] == '1') cnt1++;
  }

  if(cnt0 > cnt1) cout << cnt1*2 << endl;
  else cout << cnt0*2 << endl;

  return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

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

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

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

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const long double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//







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

    int tmp = 1 + 2*d;

    int ans = (n+tmp-1)/tmp;

    cout << ans << endl;
}





































Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
} 

ll fibonacci(int x){
	if(x<=1)return 1;
	static vector<ll> memo(45, -1);
	if(memo[x]>=0)return memo[x];
	return memo[x] = fibonacci(x-1) + fibonacci(x-2);
}

int main(){
	int n;
	cin >> n;
	cout << fibonacci(n) << endl;
	return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  // cout << s;
  int flag = 1;
  int n = s.size();
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1] && flag)
      flag = 0;
    else if (s[i] != s[i - 1] && flag)
      break;
    else
      flag = 1;
    // cout << flag << " ";
  }
  if (flag)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

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

  int d[N];
  set <int> s;

  for (int i = 0; i < N; i++) {
    cin >> d[i];
    s.insert(d[i]);
  }
  
  cout << s.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int N, K;  cin >> N >> K;
    vector<int> x(N);  rep(i, N) cin >> x[i];

    ll ans = INF;
    rep(i, N-K+1) {
        ll sum = 0;
        rep(j, K-1) {
            sum += x[i+j+1] - x[i+j];
        }
        sum += min(abs(x[i+K-1]), abs(x[i]));
        ans = min(ans, sum);
    }

    print(ans);
}


Measured memory_bytes: 640
s = list(input())
n = len(s)
t = ["resare","esare","remaerd","maerd"]
s.reverse()
check = True
i = 0
while i < n:
    counter = 0 #不適合数
    for k in range(4):
        temp = True
        for j in range(len(t[k])):
            if s[i+j] != t[k][j]:
                temp = False
                break
        if temp == False:
            counter += 1
        else:
            add = len(t[k])
    if counter == 4:
        check = False
        break
    else:
        i += add
if check:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3956
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int maxi = 0;


int main(){
	int n;
	while(scanf("%d",&n)==1,n){
		vector<string> mat;
		maxi = 0;
		char el[n+5];
		for(int x=0;x<n;++x){
			scanf("%s",el);
			string ss(el);
			mat.push_back(ss);
		}
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				int x=i,y=j,tmp = 0;
				while(y>=0 && x<n && mat[x][y]=='1'){
					tmp++;--y;++x;
				}
				maxi = max(tmp,maxi);
				x=i;y=j;tmp=0;
				while(x<n && mat[x][y]=='1'){
					tmp++;++x;
				}
				maxi = max(tmp,maxi);
				x=i;y=j;tmp=0;
				while(y<n && mat[x][y]=='1'){
					++tmp;++y;
				}
				maxi = max(tmp,maxi);
				x=i;y=j;tmp=0;
				while(x<n && y<n && mat[x][y]=='1'){
					++tmp;++x;++y;
				}
				maxi = max(tmp,maxi);
			}
		}
		cout<<maxi<<endl;	
	}
	return 0;
}

Measured memory_bytes: 1308
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int h,a;
    cin >> h >> a;

    int count = 1;
    if (h - a <= 0)
    {
        cout << 1 << endl;
        return 0;
    }
    
    while (h - a > 0)
    {
        count++;
        h -= a;
    }
    

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>

using namespace std;

bool catChecker(string str){

	stack<char> cnt;
	
	for(int i=0;i<str.size();i++){
		char c=str.at(i);
		
		switch(c){
			case 'm':
				cnt.push(c);
				break;
			case 'e':
				if(!cnt.empty() && cnt.top()=='m'){
					cnt.pop();
					cnt.push(c);
				}else	return false;
				break;
			case 'w':
				if(!cnt.empty() && cnt.top()=='e'){
					cnt.pop();
				}else	return false;
				break;
			default:
				return false;
		}
		
		if(cnt.empty()){
			if(i==str.size()-1) return true;
			else return false;
		}
	}

	return false;
}


int main(void){

	string str;

	while(cin>>str)
		if(catChecker(str)) cout << "Cat" << endl;
		else cout << "Rabbit" << endl;

	return 0;
}

Measured memory_bytes: 1188
package main

import (
	"fmt"
)

func main() {
	var n int64
	fmt.Scan(&n)

	nums := make([]int64, 5)
	for i := range nums {
		fmt.Scan(&nums[i])
	}
	min := nums[0]
	for _, num := range nums {
		if num < min {
			min = num
		}
	}

	ans := n / min
	if n % min != 0 {
		ans++
	}
	fmt.Println(ans + 4)
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
struct P { int x, y; };
int n;
int cnt[100][100];
P map[100][100];
int dfs(int y, int x, int c) {
    if (cnt[x][y]!=-1&&cnt[x][y]!=c) return cnt[x][y];
    if (cnt[x][y]==c) return cnt[x][y];
    cnt[x][y]=c;
    return cnt[x][y]=dfs(map[x][y].x,map[x][y].y,cnt[x][y]);
}
int main() {
    while (scanf("%d",&n)) {
        if (!n) break;
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) scanf("%d%d",&map[i][j].x,&map[i][j].y);
        }
        memset(cnt,-1,sizeof(cnt));
        int x=0;
        set<int> res;
        for (int i=0; i<n; i++) {
            for (int j=0; j<n; j++) {
                if (cnt[i][j]==-1) {
                    cnt[i][j]=++x;
                    cnt[i][j]=dfs(map[i][j].x,map[i][j].y,cnt[i][j]);
                    res.insert(cnt[i][j]);
                }
            }
        }
        printf("%d\n",res.size());
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
#include<cstdio>
#define MAIN 200010
using namespace std;
const long long p=1000000007;
long long fact[MAIN]= {1},inv[MAIN]= {1};
long long Lucas(long long a,long long m)
{
    long long ans=fact[a];
    ans=(ans*inv[a-m]%p)*inv[m]%p;
    return ans;
}
long long power(long long a,long long b)
{
    long long ans=1;
    while(b)
    {
        if (b&1) ans=(ans*a)%p;
        b=b>>1;
        a=(a*a)%p;
    }
    return ans;
}
int main()
{
    long long h,w,a,b;
    scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
    for (int i=1; i<=200000; i++)
    {
        fact[i]=(fact[i-1]*i)%p;
        inv[i]=power(fact[i],p-2);
    }
    long long ans=0;
    for (long long i=1; i<=w-b; i++)
        ans=(ans+Lucas(a+i-2,i-1)*Lucas(h-a+w-i-1,w-i))%p;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
N,M = list(map(lambda x:int(x),input().split()))
A_list = list(map(lambda x:int(x),input().split()))
A_total = 0
can_be_choosen = 0

for n in A_list:
    A_total += n

for n in range(len(A_list)):
    if not (float(A_list[n]) < (A_total*(1.0/(4.0 * M)))):
        can_be_choosen += 1

if can_be_choosen >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060