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

using namespace std;

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

ll r = 1000000007;
ll n;
ll a[100000];
ll c[100001];

ll pow2(ll x, ll num){
    if(num==0) return 1;

    ll res = pow2(x*x%r, num/2);
    if(num%2==1) res = res*x%r;

    return res;
}

int main(){
    cin >> n;

    REP(i, n+1) c[i] = 0;
    REP(i, n){
        ll a;
        cin >> a;
        c[a] += 1;
    }

    bool flag = true;
    if(n % 2 == 1){
        if(c[0] != 1) flag = false;
        for(int i=2; i<=n; i++){
            if(i%2==0 && c[i]!=2){
                flag = false;
                break;
            }
        }
    } else {
        REP(i, n+1){
            if(i%2==1 && c[i]!=2){
                flag = false;
                break;
            }
        }
    }

    if(flag){
        cout << pow2(2, n/2) << endl;
    } else {
        cout << 0 << endl;
    }
}

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

n = 0
while 2**n <= L:
    n += 1

side_lst = []
    
rest = L - 2**(n-1)
next_num = 2**(n-1)

m = n
while rest > 0:
    if rest >= 2**(m-2):
        side_lst.append([m-1, n, next_num])
        next_num += 2**(m-2)
        rest -= 2**(m-2)
    m -= 1
    
print(n, len(side_lst)+(n-1)*2)
for i in side_lst:
    print(i[0], i[1], i[2])
    
for i in range(1, n):
    print(i, i+1, 0)
    print(i, i+1, 2**(i-1))

Measured memory_bytes: 3064
n = int(input())
num_list = [2,3,4,5,6,7,8,9]
div_flag = False
for num in num_list:
    if n / num < 10 and int(n/num)==n/num:
        div_flag = True
if div_flag or (n==1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
using System;

public class Program{
    public static void Main(){
        var input =Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        int left = 1;
        int right = 1 + 2;
        for(int i = 1; i <= 999; ++i){
            int sub = right - left;

            if(b - a == sub){
                Console.WriteLine(left - a);
            }

            left = right;
            right += (i + 2);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    rep(i,n)--a[i];
    if(n==2){
        cout<<-1<<endl;
        return 0;
    }
    map<int,int> mp;
    rep(i,n)mp[a[i]]++;
    set<int> st;
    rep(i,n)st.insert(i);
    int pre = -1;
    vector<int> b(n);
    rep(i,n-3){
        if(mp.size()==2){
            auto itr = mp.begin();
            if(itr->second==1)++itr;
            int nxt = itr->first;
            if(itr->second == n-i-1 && st.count(nxt)){
                b[i]=nxt;
                --mp[a[nxt]];
                if(mp[a[nxt]]==0)mp.erase(a[nxt]);
                pre = a[nxt];
                st.erase(nxt);
                continue;
            }
        }
        auto itr = st.begin();
        while(*itr==pre)++itr;
        int nxt = *itr;
        st.erase(itr);
        b[i]=nxt;
        pre = a[nxt];
        if(--mp[a[nxt]]==0)mp.erase(a[nxt]);
    }
    vector<int> x(3);
    auto itr = st.begin();
    rep(i,3){
        x[i]=*itr;
        ++itr;
    }
    do {
        bool ok = true;
        if(pre==x[0])ok=false;
        rep(i,2)if(a[x[i]]==x[i+1])ok=false;
        if(ok){
            rep(i,3)b[n-3+i]=x[i];
            break;
        }
    }while(next_permutation(x.begin(), x.end()));
    rep(i,n)cout<<b[i]+1<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=310,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const db eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int n,c,sum=1;
int l[N];
db dp[N][(1<<6)|10];

#ifdef FILE
const int RS=1<<20;
char buf[RS],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,RS,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read(),c=read(),sum=1;
	for(int i=1;i<=n;i++) l[i]=read();
	for(int i=1;i<n;i++) sum*=i;
	sort(l+1,l+n+1);
	db ans=0;
	for(int i=1;i<=sum;i++)
	{
		mem(dp,0);
		dp[l[n]*n][0]=1;
		for(int i=1;i<=c*n;i++)
		{
			if(i%n==0) continue;
			int p=i%n;
			for(int j=i;j<=c*n;j++)
			{
				for(int S=0;S<(1<<n-1);S++)
				{
					if(S&(1<<p-1)) continue;
					dp[min(c*n,max(j,i+l[p]*n))][S+(1<<p-1)]+=dp[j][S];
				}
			}
		}
		ans+=dp[c*n][(1<<n-1)-1];
		next_permutation(l+1,l+n);
	}
	printf("%.15lf\n",ans/sum/pow(c,n-1));
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    string ans;
    rep(i,n) cin >> s[i];
    for(int i = 'a'; i<= 'z'; i++){
        int min_cnt = 10000000;
        rep(j,n){
            int cnt=0;
            rep(k,s[j].size()){
                if(s[j][k] == i) cnt++;
            }
            min_cnt = min(min_cnt,cnt);
        }
        rep(k,min_cnt){
            ans.push_back(i);
        }
    }
    cout << ans << endl;
}

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

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

    int n;
    cin >> n;
    int a = 0; // ooooA
    int b = 0; // Boooo
    int c = 0; // BoooA

    int ans = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int ss = s.size() - 1;
        if(s[0] == 'B' and s[ss] == 'A') c++;
        else if(s[0] == 'B') b++;
        else if(s[ss] == 'A') a++;
        for(int j = 0; j < s.size(); j++){
            if(s[j] == 'A' and s[j + 1] == 'B'){
                ans++;
            }
        }
    }

    if(c == 0) ans += min(a, b);
    else if(a == 0 and b == 0 and c > 0) ans += c - 1;
    else ans += c + min(a, b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(N)]
ans = 10**18

for S in range(2**N):
    ans_cand = 0
    now = [0]*M
    
    for i in range(N):
        if (S>>i)&1:
            ans_cand += l[i][0]
            
            for j in range(1, M+1):
                now[j-1] += l[i][j]
    
    if min(now)>=X:
        ans = min(ans, ans_cand)

if ans==10**18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68684
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=1e9+7;
#define N 6000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

ll int poww(ll int a,ll int b){
    ll int ans=1,temp=a;
    while(b){
        
        if(b%2) ans=(temp*ans)%MOD;
        b>>=1;
      temp=(temp*temp)%MOD;

    }
    return ans;
}
ll int n;

ll int dp[N][N]={};
ll int calc(ll int a,ll int b){
    if(a<b) return 0;
    if(dp[a][b]) return dp[a][b];
    if(a==0){
        if(b==0) return 1;
        else return 0;
    }
    if(b==0){
        return dp[a][b]=(calc(a-1,1)+calc(a-1,0))%MOD;
    }
    return dp[a][b]=(calc(a-1,b+1)+calc(a-1,b-1)*2)%MOD;
}
main(){
    string s;
    cin>>n>>s;
    ll int t=s.size();
    ll int inv=poww(poww(2,t),MOD-2);
    cout<<calc(n,t)*inv%MOD;

    
    

    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<string> split(const string &s, char sep) {
  vector<string> res;
  int pos = 0, find_pos;
  while ((size_t)(find_pos = (int)s.find(sep, pos)) != string::npos) {
    res.emplace_back(s.substr(pos, find_pos - pos));
    pos = find_pos + 1;
  }
  if (pos < (int)s.size()) res.emplace_back(s.substr(pos, s.size() - pos));
  return res;
}

int n;
string s;
vector<int> a[100], az;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> s) {
    auto ss = split(s, ',');
    for (auto i : ss) {
      a[n].emplace_back(stoi(i));
    }
    az.emplace_back((int)a[n].size());
    n++;
  }

  for (int i = 1; i < n; i++) {
    for (int j = 0; j < az[i]; j++) {
      if (i <= n / 2) {
        int add = 0;
        if (j != 0) add = max(add, a[i - 1][j - 1]);
        if (j + 1 != az[i]) add = max(add, a[i - 1][j]);
        a[i][j] += add;
      } else {
        a[i][j] += max(a[i - 1][j], a[i - 1][j + 1]);
      }
    }
  }
  cout << a[n - 1][0] << endl;

  return 0;
}


Measured memory_bytes: 3248
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect

h,w,d=map(int,input().split())
dic={i:0 for i in range(1,h*w+1)}
for i in range(h):
    l=list(map(int,input().split()))
    for j in range(w):
        dic[l[j]]=(i+1,j+1)
q=int(input())
lr = [list(map(int,input().split())) for _ in range(q)]
res=[[] for _ in range(d)]
for i in range(1,h*w-d+1):
    x,y=dic[i]
    s,t=dic[i+d]
    power=abs(x-s)+abs(y-t)
    res[i%d].append(power)
for i in range(d):
    length=len(res[i])
    x=0
    for j in range(length):
        x+=res[i][j]
        res[i][j]=x
for i in range(q):
    l,r=lr[i]
    if l==r:
        print(0)
        continue
    else:
        mod=l%d
        quol=l//d
        quor=r//d-1
        if mod==0:
          quol-=1
          quor-=1
        if quol==0:
          print(res[mod][quor])
        else:
          quol-=1
          print(res[mod][quor]-res[mod][quol])
        

Measured memory_bytes: 83300
/*input

*/

#include <bits/stdc++.h>
#include <unistd.h>

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2) ans*=a, ans%=(mod);
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,_;
	ll n,ans = 0;
	cin>>n;
	string s; 
	cin>>s;
	string a;
	a = s;
	sort(a.begin(),a.end());
	rep(i,0,n) {
		ans += ((a[i] == 'W') && (s[i] == 'R')); 
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 3888
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.Set;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();


		Set<Integer> adj[] = new HashSet[n+1];
		for(int i = 1; i<adj.length; i++) {
			adj[i] = new HashSet<Integer>();
		}


		for(int i = 0; i < m; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			adj[a].add(b);
			adj[b].add(a);
		}

		int[] dist = new int[n+1];
		dist[0] = 0;
		int[] ans = new int[n+1];

		boolean[] end = new boolean[n+1];
		end[1] = true;
		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(1);

		while(!q.isEmpty()) {

			int v1 = q.poll();

			int tdist = dist[v1] + 1;

			Iterator<Integer> adjit = adj[v1].iterator();
			while(adjit.hasNext()) {
				int v2 = adjit.next();
				if(!end[v2]) {
					q.add(v2);
					end[v2] = true;

					dist[v2] = tdist;
					ans[v2] = v1;
				}
			}
		}

		PrintWriter out = new PrintWriter(System.out);

		StringBuilder sb = new StringBuilder("Yes\n");
		for(int i = 2; i <= n; i++) {
			sb.append(ans[i]+"\n");
		}

		out.println(sb);
		out.close();
	}

}


Measured memory_bytes: 96652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1000000007;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll d,t,s;
  cin>>d>>t>>s;
  if(d<=t*s){cout<<"Yes";}
  else{cout<<"No";}
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,N,C;
int S[100001],T[100001],ch[100001];
int EACHch[200002];
int ALLch[200002];
int cmax;

int main() {
	cin >> N >> C;
	
	REPI(0,N) cin >> S[i] >> T[i] >> ch[i];
	
	REPI(1,C+1) {
		MEMCLR(EACHch);
		REPJ(0,N) if (i==ch[j]) EACHch[2*S[j]-1]++, EACHch[2*T[j]]--;
		REPJ(1,200002) EACHch[j] += EACHch[j-1];
		REPJ(0,200002) if (EACHch[j]) ALLch[j]++;
	}
	REPI(0,200002) if (cmax < ALLch[i]) cmax = ALLch[i];
	
	cout << cmax;
	
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    int h,w;cin>>h>>w;
    vector<vector<int> > m(h,vector<int>(w));
    int n;cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int w_count=0;
    int h_count=0;
    rep(i,n){
        int color=i+1;
        rep(j,a[i]){
            if(w_count==w){h_count++;w_count=0;}
            m[h_count][w_count]=color;
            w_count++;
        }
    }
    for(int i=1;i<h;i+=2){
        reverse(ALL(m[i]));
    }
    rep(i,h){
        rep(j,w){
            cout<<m[i][j]<<" ";
        }
        cout<<endl;
    }

}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define ll long long
int main(){
    int n;
    cin >> n;
    int a;
    set<int> s;
    rep(i,n){
        cin >> a;
        if(s.count(a)){
            cout << "NO" <<endl;
            return 0;
        }else{
            s.insert(a);
        }
    }
    cout << "YES" <<endl;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
void out(ll x,ll y,ll z){
    printf("%lld %lld %lld\n",x,y,z);
    exit(0);//输出完后直接结束程序
}
void f(){//方法2
    ll c,m;
    for(ll i=1;i<=3500;i++)
        for(ll j=1;j<=3500;j++){
            c=n*i*j;
            m=4*i*j-n*i-n*j;
            if(m>0&&c%m==0)out(i,j,c/m);//判断是否为正整数
        }
}
int main(){
    cin>>n;
    if(n%2==0)out(n,n,n/2);//2的倍数
    if(n%3==0)out(n,n/3*2,n/3*2);//3的倍数
    if((n-3)%4==0)out((n+1)/4,(n+1)*(n+1)/4,(n+1)*(n+1)*n/4);//n-3是4的倍数
    if((n-1)%4==0)f();//n-1是4的倍数
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val x = scanner.nextLong()
    //val array = IntArray(74)
    /*for(i in 0..73){
        array[i] = Math.pow(i.toDouble(), 5.0).toInt()
    }
    for(i in 0..73){
        println(array[i])
    }*/
    //var result = Pair(0,0)
    //A>=0 B>=0
    for(i in 0..1000){
        for(j in 0..i){
            if(Math.pow(i.toDouble(), 5.0).toLong() - Math.pow(j.toDouble(), 5.0).toLong() === x){
                println("$i $j")
                return
            }
        }
    }
    //A>=0 B<0
    for(i in 0..1000){
        for(j in 0..1000){
            if(Math.pow(i.toDouble(), 5.0).toLong() + Math.pow(j.toDouble(), 5.0).toLong() === x){
                println("$i -$j")
                return
            }
            if(Math.pow(i.toDouble(), 5.0).toLong() + Math.pow(j.toDouble(), 5.0).toLong() > x) break
        }
    }
    //A<0 B<0
    for(i in 0..1000){
        for(j in 0..1000){
            if(-Math.pow(i.toDouble(), 5.0).toLong() + Math.pow(j.toDouble(), 5.0).toLong() === x){
                println("-$i -$j")
                return
            }
            if(-Math.pow(i.toDouble(), 5.0).toLong() + Math.pow(j.toDouble(), 5.0).toLong() > x) break
        }
    }

}

Measured memory_bytes: 36344
// https://atcoder.jp/contests/dp/tasks/dp_a
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll n;
    cin >> n;
    ll h[n];
    for (ll i = 0; i < n; i++)
        cin >> h[i];
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (ll i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	k, q := scanInt(), scanInt()
	d := scanInts(k)

	for i := 0; i < q; i++ {
		n, x, m := scanInt(), scanInt(), scanInt()
		dd := make([]int, k)
		copy(dd, d)
		for j := 0; j < k; j++ {
			dd[j] %= m
		}

		a := x
		c := 0
		for j := 0; j < k; j++ {
			cc := (n - 1 - j + k - 1) / k
			if dd[j] == 0 {
				c += cc
			}
			a += cc * dd[j]
		}
		c += a/m - x/m
		fmt.Fprintln(wr, n-1-c)
	}
}


Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 28;
const long long MOD = 1000000000 + 7;
void solve(int a) { cout << (a ? "Yes" : "No") << endl; }

int main()
{
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s)
	{
		a--;
	}
	else if (u == t)
	{
		b--;
	}
	cout << a<<" " << b << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABeginner solver = new ABeginner();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABeginner {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(100 * Math.max(10 - in.nextInt(), 0) + in.nextInt());
        }

    }
}



Measured memory_bytes: 23252
import collections

s = collections.deque(list(input()))
q = int(input())
rev = 0
for i in range(q):
    tfc = list(input().split())
    if tfc[0]=='1':
        rev = abs(rev-1)
    else:
        t,f,c = tfc
        if rev:
            if f=='1':
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if f=='1':
                s.appendleft(c)
            else:
                s.append(c)
if rev:
    t = []
    for i in range(len(s)):
        t.append(s.pop())
    print(''.join(t))
else:
    print(''.join(s))
'''
初期文字列 s が与えられ q 個のクエリを処理した後の文字列を求めます。
10^100回繰り返す根気があるなら自分でやってくれと思わなくもないです。
さて、各クエリではまず t が与えられます。t=1の時文字列を反転させます。
t=2の時はさらに f,c が与えられ、f=1の時文字列の先頭にcを加えます。
f=2の時文字列の末尾にcを加えます。
愚直に行おうとすると文字列の反転で O(len(s))、先頭への追加で 
O(len(s)) かかってしまい間に合いません。
そこでcollections.dequeを利用します。先頭、末尾への追加をO(1) で行えます。
注意する点は反転させると追加する位置が逆になることです。
なので現在の状態を管理しておく必要があります。
同様に出力する時も最終的な向きによって出力する順番が逆になります。
'''

Measured memory_bytes: 9180
n = int(input())
sp = [[0]*3 for i in range(n)]

for i in range(n):
  s, m = input().split()
  sp[i][0] = s
  sp[i][1] = -int(m)
  sp[i][2] = i

sp.sort()
for s, n, i in sp:
  print(i+1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#define N 1000

int max(int a,int b){
  if(a>=b)return a;
  else return b;
}

int lcs(char x[],char y[]){
  int m,n,i,j,c[N+1][N+1],maxlen=0;

  m=strlen(x);
  n=strlen(y);

  for(i=0;i<=m;i++)c[i][0]=0;
  for(i=1;i<=n;i++)c[0][i]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1])c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);

      maxlen=max(maxlen,c[i][j]);
    }
  }
  return maxlen;
}

int main(){
  int n,i;
  char str1[N+1],str2[N+1];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s%s",str1,str2);
    printf("%d\n",lcs(str1,str2));
  }
  return 0;
}



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

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

int main(){
	    int H, W; cin >> H >> W;
        vector<string> S(H);
        rep(i, H) cin >> S[i];

        int ans = 0;
        rep(i, H){
            rep(j, W){
                if(S[i][j] == '#') continue;
                Graph dist(H, vector<int>(W, -1));
                queue<pair<int, int>> que;

                dist[i][j] = 0;
                que.push(make_pair(i, j));

                while(!que.empty()){
                    int x = que.front().first;
                    int y = que.front().second;
                    que.pop();
                    rep(dir, 4){
                        int n_x = x + dx[dir];
                        int n_y = y + dy[dir];
                        if(n_x < 0 || n_x >= H || n_y < 0 || n_y >= W) continue;
                        if(S[n_x][n_y] == '#') continue;
                        if(dist[n_x][n_y] == -1){
                            que.push(make_pair(n_x, n_y));
                            dist[n_x][n_y] = dist[x][y] + 1;
                        }
                    }
                }
                rep(ix, H){
                    rep(jy, W){
                        if(dist[ix][jy] == -1) continue;
                        ans = max(ans, dist[ix][jy]);
                    }
                }
            }
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int Z_algo(string s) {
    int n = s.length();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R - L] == s[R]) R++;
            z[i] = R - L; R--;
        }
        else {
            int k = i - L;
            if (z[k] < R - i + 1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R - L] == s[R]) R++;
                z[i] = R - L; R--;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < n; i++) mx = max(mx, min(i, z[i]));
    return mx;
}
const int mxN = 1e9 +7;

int main() {
    long long n;
    cin >> n;
    n--;
    cout << ((n * (n + 1ll)) / 2ll);
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);} 


void solve()
{
	ll w,s,sum=0;
	cin>>s>>w;
	if(s>w)
	{
		cout<<"safe";
	}
	else
		cout<<"unsafe";
	
	return;
}

int main()
{
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
num = [int(i) for i in input().split()]

count = 0
flag = True
for i in range(n):
    if num[i] != i+1:
        count += 1

    if count > 2:
        flag = False
        print('NO')
        break


if flag:
    print('YES')


        
        


Measured memory_bytes: 2940
n, m = map(int, input().split())
lrd = [list(map(int, input().split())) for _ in range(m)]


class WeightedUnionFind:
    def __init__(self, x):
        self.p = [e for e in range(x)]
        self.rank = [0] * x
        self.weight = [0] * x

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def find_set(self, u):
        if u != self.p[u]:
            v = self.find_set(self.p[u])
            self.weight[u] += self.weight[self.p[u]]
            self.p[u] = v

        return self.p[u]

    def unite(self, u, v, w):
        w += self.weight[u]
        w -= self.weight[v]

        u = self.find_set(u)
        v = self.find_set(v)

        if self.rank[u] < self.rank[v]:
            u, v = v, u
            w = -w

        if self.rank[u] == self.rank[v]:
            self.rank[u] += 1

        self.p[v] = u

        self.weight[v] = w

    def get_weight(self, u):
        self.find_set(u)
        return self.weight[u]

    def diff(self, u, v):
        return self.get_weight(v) - self.get_weight(u)


wuf = WeightedUnionFind(n)

for l, r, d in lrd:
    l -= 1
    r -= 1

    if wuf.same(l, r):
        #print(l, r, d, wuf.diff(l, r), wuf.weight)
        if wuf.diff(l, r) != d:
            print("No")
            exit()

    else:
        wuf.unite(l, r, d)

print("Yes")


Measured memory_bytes: 58564
#include<iostream>
using namespace std;
int N;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		char c;cin>>c;
		if(c=='Y')
		{
			cout<<"Four"<<endl;
			return 0;
		}
	}
	cout<<"Three"<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		double inputInt;
		try {
			inputInt = Double.parseDouble(input.readLine());
			System.out.printf("%.6f %.6f",(Math.PI * inputInt * inputInt),(Math.PI  * 2 * inputInt));
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}


	}

}



Measured memory_bytes: 24744
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, s.size()) {
        if (s[i] != t[i])
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3784
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
A = list(map(int,readline().split()))
B = sum(A)
if B > N:
    print(-1)
else:
    print(N-B)


Measured memory_bytes: 9816
#include "bits/stdc++.h"
using namespace std;
#define mod 1e9+7
#define FOR(a,c)   for ( int (a)=0; (a)<(c); (a)++)
#define FORL(a,b,c)  for ( int (a)=(b); (a)<=(c); (a)++)
#define FORR(a,b,c)  for (  int (a)=(b); (a)>=(c); (a)--)
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define POB pop_back
#define MP make_pair

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

ll W,S;
cin>>S>>W;
if(W>=S)
    cout<<"unsafe";
else
    cout<<"safe";
return 0;
}

Measured memory_bytes: 3648
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
int n,a[100005],b[100005];
ll ans;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=n;i>=1;i--){
		if((a[i]+ans)%b[i]==0)
		continue;
		ans=((a[i]+ans)/b[i]+1)*b[i]-a[i];
	}
	cout<<ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
v = list(map(int,input().split()))
nk = min(n,k)
can = []
left = []
for i in range(nk+1):
  if i != 0:
    left.append(v[i-1])
  right = []
  for j in range(nk-i+1):
    if j != 0:
      right.append(v[-j])
    tmp = left + right
    tmp.sort()
    now = sum(tmp)
    rest = min(k-i-j,len(tmp))
    for h in range(rest):
      if tmp[h] < 0:
        now -= tmp[h]
    can.append(now)
    #print(i,j,now,tmp)
print(max(can))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
LL mod=1000000007;
LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


struct edge {int to;int cost;};
const int M_N=300;
int L;

vector<edge> G[M_N+1];
    P d[M_N+1][M_N+1];

int main(){
    int n,m;cin >> n >> m >> L;
    for (int i = 0; i < m; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        int c;cin >> c;
        if(c>L) continue;
        G[x].pb({y,c});
        G[y].pb({x,c});
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = mp(INF,INF);
        }
    }
    function<void(int)> dijkstra = [&](int s){
        priority_queue<pair<P,int> ,vector<pair<P,int>>,greater<pair<P,int>>> que;
        que.push({{0,-L},s});
        while(!que.empty()){
            pair<P,int> p=que.top();que.pop();
            int v=p.second;
            int t=-p.first.second;
            int l=p.first.first;
            if(d[s][v].first<l) continue;
            else if(d[s][v].first==l&&d[s][v].second>t) continue;
            for(int i=0;i<G[v].size();i++){
                edge e=G[v][i];
                if(e.cost>t){
                    if(d[s][e.to].fs>l+1||(d[s][e.to].fs==l+1&&d[s][e.to].sc<L-e.cost)){
                        d[s][e.to] = P(l+1,L-e.cost);
                        que.push({{l+1,-(L-e.cost)},e.to});
                    }
                }
                else{
                    if(d[s][e.to].fs>l||(d[s][e.to].fs==l&&d[s][e.to].sc<t-e.cost)){
                        d[s][e.to] = P(l,t-e.cost);
                        que.push({{l,-(t-e.cost)},e.to});
                    }
                }
            }
        }
    };
    for (int i = 0; i < n; i++) {
        dijkstra(i);
    }
    int q;cin >> q;
    for (int i = 0; i < q; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        int ans = d[x][y].fs;
        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
from collections import defaultdict

def prime_factorization(n):
    arr=[]
    temp=n
    for i in range(2,int(n**0.5)+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp//=i
            arr.append([i,cnt])
    
    if temp!=1:
        arr.append([temp,1])
    
    if arr==[]:
        arr.append([n,1])
    
    return arr

N=int(input())
mod=10**9+7
primes=defaultdict(int)
for n in range(1,N+1):
    for num,cnt in prime_factorization(n):
        primes[num]+=cnt

ans=1
for n,cnt in primes.items():
    if n==1:
        continue
    ans*=cnt+1
    ans%=mod
print(ans)

Measured memory_bytes: 9496
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = arg[0].split("");
    const B = arg[1].split("");
    const C = arg[2].split("");
    
    let now = "a";
    
    while(true) {
        // console.log("now:" + now);
        // console.log("A:" + A);
        // console.log("B:" + B);
        // console.log("C:" + C);
        // console.log("--------")
        
        if(now === "a") {
            if(A.length === 0) break;
            let temp = A.shift();

            now = temp;
        } else if(now === "b") {
            if(B.length === 0) break;
            let temp = B.shift();
            
            now = temp;
        } else {
            if(C.length === 0) break;
            let temp = C.shift();
            
            now = temp;
        }
    }
    
    let answer;
    
    if(now === "a") {
        answer = "A";
    } else if(now === "b") {
        answer = "B";
    } else {
        answer = "C";
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
/*  ex3_2
    potter0723sw  */

#include <stdio.h>

int main(void) {
	int N,poo;
	scanf("%d", &N);
	poo = N % 10; //pooはplace of oneの略
	if(poo == 2 || poo == 4 || poo == 5 || poo == 7 || poo == 9){//１の位を参照するために%10をした
    	printf("hon\n");
    }else if(poo == 0 || poo == 1 || poo == 6 || poo == 8){
    	printf("pon\n");
    }else printf("bon\n");
	return 0;
}


Measured memory_bytes: 1660
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// main function
int main()
{
	string S = "";
	char last = 'A';

	cin >> S;
	Rep(i, S.length()) {
		if (S[i] == last) {
			cout << "Bad" << endl;
			return 0;
		}

		last = S[i];
	}
	cout << "Good" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  //操作 A, 操作 B 合計でN
  //の電光掲示板の整数に Kを足したもの
  int i = 1;
  //最初の整数
  while(N > 0){
    if(i*2 < i+K){
		i *= 2;
    }else{
      i += K;
    }
    N--;
  }
  cout << i << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
static int compare(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return bNum-aNum;
}
int main(void)
{
    int k, n, i;
    int h[10*10*10*10*10], ans=1000000000;
    scanf("%d%d", &n, &k);
    for(i=0;i<n;i++){
        scanf("%d", &h[i]);
    }
    qsort(h, n, sizeof(int), compare);
    for(i=0;i<n-k+1;i++){
        if(h[i]-h[i+k-1]<ans) ans=h[i]-h[i+k-1];
    }
    printf("%d\n", ans);
    return 0;
}
    

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
class sieve_of_eratosthenes {
public:
  vector<bool> is_prime;
  vector<int> prime_numbers;
  vector<vector<int>> prime_divisors;
  vector<vector<int>> divisors;

  sieve_of_eratosthenes(int n)
    : is_prime(vector<bool>(n))
    , prime_numbers(vector<int>(0))
    , prime_divisors(vector<vector<int>>(n))
    , divisors(vector<vector<int>>(n))
  {
    for (int i = 1; i < n; i++) {
      if (is_prime[i] = divisors[i].size() == 1) prime_numbers.push_back(i);
      for (int j = i; j < n; j += i) {
        divisors[j].push_back(i);
        if (is_prime[i]) prime_divisors[j].push_back(i);
      }
    }
  }
};
int main() {
  int n;
  cin >> n;
  sieve_of_eratosthenes siv(55556);
  auto prm = siv.prime_numbers;
  vector<int> ret(0);
  int cnt = 0;
  for (auto it = prm.begin(); it != prm.end(); it++) {
    int p = *it;
    if (p % 5 == 1) {
      ret.push_back(p);
      if (++cnt == n) break;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ret[i] << (i < n - 1 ? ' ' : '\n');
  }
  cout << flush;
  return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int n,num;
    map<int,int> m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>num;
        m[num]++;
        if(m[num]>1){
            cout<<"NO";
            exit(0);
        }
    }
    cout<<"YES";
}


Measured memory_bytes: 9600
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

using namespace std;

long long dp(int a){
	if(a==0) return 1;
	else if(a==1) return 1;
	else if(a==2) return 2;
	else {
	return dp(a-3)+dp(a-2)+dp(a-1);
	}
}

int main() 
{
	int n;
	while(cin >> n , !(n==0))
	{
		long long day = dp(n);
		
		if(day%3650==0)
		cout << day/3650 << endl;
		else 
		cout <<day/3650 +1 << endl;
	}
	return 0 ;
}

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

int dp[101][10001] = {};
int val[101], wei[101];

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

    for(int i = 1; i <= n; i++)  cin >> val[i] >> wei[i];

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= w; j++){
            if(wei[i] > j)
                dp[i][j] = dp[i-1][j];
            else if(wei[i] <= j)
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-wei[i]] + val[i]);
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}


Measured memory_bytes: 7008
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;


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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    ll h1,h2,m1,m2;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll mi = m2-m1;
    if(h1 != h2){
        mi = (h2-h1-1)*60 + m2 + 60-m1;
    }

    cout << max(0ll,mi-k) << "\n";

    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int H,W;
    cin>>H>>W;
    int h,w;
    cin>>h>>w;
    int x;
    int y;
    int v;
    int z;
    x = H*W;
    y = h*w;
    z = H*w;
    v = W*h;
    cout<<x-z-v+y<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    char a;
    cin >> a;
    if (a >= 'a' && a <= 'z') cout << 'a';
    else cout << 'A';
}



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

int main(){
    int N;
    cin>>N;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    cout<<a.at(N-1)-a.at(0)<<endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
print("ABC" + str(N))

Measured memory_bytes: 5144
#include<cstdio>
#include<algorithm>
#define ll long long 
struct r{
	int w,s,v;
}a[1050];
ll dp[20050],ans;
int lim,n;
bool cmp(r a,r b){return a.w+a.s<b.s+b.w;}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d%d%d",&a[i].w,&a[i].s,&a[i].v),lim=std::max(a[i].s,lim);
	std::sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++){
		for (int j=a[i].s;j>=0;j--)dp[j+a[i].w]=std::max(dp[j+a[i].w],dp[j]+a[i].v);
		for (int j=1;j<=lim;j++)dp[j]=std::max(dp[j],dp[j-1]);
	}
	for (int i=1;i<=20000;i++)ans=std::max(dp[i],ans);
	printf("%lld",ans);
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<bool> ok(n+1, false);
  vector<int> pena(n+1);
  int ans=0;
  rep(i,m){
    int p;
    string s;
    cin >> p >> s;
    if(s == "AC" && !ok[p]){
      ans ++;
      ok[p] = true;
    }
    if(s == "WA" && !ok[p]) pena[p]++;
  }
  int sum = 0;
  for(int i=1; i<=n; i++){
    if(ok[i]) sum += pena[i];
  }
  cout << ans << " " << sum << endl;
}


Measured memory_bytes: 3776