akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int r,d,x;cin>>r>>d>>x;
  rep(i,10){
    x = r*x-d;
    cout << x << endl;
  }
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n,m,t;
	cin >> n >> m >> t;
	vi data(n);
	REP(i,n) cin >> data[i];
	int ans = 0;
	if (data[0] - m > 0) ans += (data[0] - m);
	for(int i = 0; i < n-1; i++){
		int t = data[i+1] - data[i] - 2 * m;
		if(t > 0) ans += t;
	}
	if((t - (data[data.size() - 1] + m)) > 0) ans += (t - (data[data.size() - 1] + m));
	cout << ans << endl;
}

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

const long long mod = 1e9 + 7;

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

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

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

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

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

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

const vs res = { "AC", "WA", "TLE", "RE" };

int main(){
    int n;
    cin >> n;
    vs s(n);
    rep(i, n) cin >> s[i];
    map<string, int> cnt;
    rep(i, n) cnt[s[i]]++;
    for (auto t : res) {
        cout << t << " x " << cnt[t] << endl;
    }
    return 0;
}


Measured memory_bytes: 6348
n,m = map(int,input().split())
dist = [list(map(int,input().split())) for i in range(10)]
dist.append([0]*10)
for k in range(10):
  for i in range(10):
    for j in range(10):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 0
for i in range(n):
  a = list(map(int,input().split()))
  for j in a:
    ans += dist[j][1]
print(ans)

Measured memory_bytes: 9236
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n, k; readV(n, k);
  int[] x, y; string[] s; readM(n, x, y, s);

  foreach (i; 0..n) if (s[i] == "W") x[i] += k;
  auto k2 = k*2;
  x[] %= k2; y[] %= k2;

  auto c = new int[][](k2*2+1, k2*2+1);
  auto setImos(int x, int y)
  {
    c[y][x]++;
    c[y][x+k]--;
    c[y+k][x]--;
    c[y+k][x+k]++;
  }

  foreach (xi, yi; lockstep(x, y)) {
    setImos(xi+1, yi+1);
    setImos(xi+k+1, yi+k+1);
  }

  foreach (i; 0..k2*2+1)
    foreach (j; 1..k2*2+1)
      c[i][j] += c[i][j-1];
  foreach (j; 0..k2*2+1)
    foreach (i; 1..k2*2+1)
      c[i][j] += c[i-1][j];

  auto d = new int[][](k2, k2);
  foreach (i; 0..k2*2)
    foreach (j; 0..k2*2)
      d[i%k2][j%k2] += c[i][j];

  auto r = 0;
  foreach (i; 0..k2)
    foreach (j; 0..k2)
      r = max(r, d[i][j]);

  writeln(r);
}


Measured memory_bytes: 89724
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	long int n, k, l;
	
	scanf("%ld %ld", &n, &k);
	
	l=n%k;
	
	if(l>k-l)printf("%ld", k-l);
	else if(l<=k-l)printf("%ld", l);
	
	
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    int a;
    cin >> a;

    cout <<a * a*a<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
using namespace std;
int main() {
    string s;
    string alpha="abcdefghijklmnopqrstuvwxyz";
    bool f[26]={false};
    cin>>s;
    for(int i=0;i<s.length();++i){
        for(int j=0;j<26;++j){
            if(s[i]==alpha[j]){
                f[j]=true;
            }
        }
    }
    for(int i=0;i<26;++i){
        if(!f[i]){
            cout<<alpha[i]<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}

Measured memory_bytes: 512
using System;

namespace Atcoder
{
    class ABC162_B
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);
            long sum = 0;
            for(int i = 1; i <= n; i++)
            {
                if(i % 3 != 0 && i % 5 != 0)
                {
                    sum += i;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


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

// 出力用関数
void trace(int A[], int N) {
  int i;

  for (i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertionSort(int A[], int N) {
  int j; // ソート済みからvを挿入する位置を探すループ変数
  int i; // 未ソートの先頭を示すループ変数
  int v; // A[i]の値を一時保存する変数

  for(i = 1; i < N; i++) { // 0は最初からソート済みとする
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v) { // jが0以上またはA[j]がvより大きいかぎり
      A[j + 1] = A[j]; // A[j + 1]に移動させる
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i;
  cin >> N;
  int A[N];

  for (i = 0; i < N; i++) {
    cin >> A[i]; // cinはスペースか改行で区切ってくれる
  }

  trace(A, N);
  insertionSort(A, N);

  return 0;
}



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

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

int main() {
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    int dx=tx-sx,dy=ty-sy;
    rep(i,dy) cout<<'U';
    rep(i,dx) cout<<'R';
    rep(i,dy) cout<<'D';
    rep(i,dx+1) cout<<'L';
    rep(i,dy+1) cout<<'U';
    rep(i,dx+1) cout<<'R';
    cout<<"DR";
    rep(i,dy+1) cout<<'D';
    rep(i,dx+1) cout<<'L';
    cout<<'U'<<endl;
}

Measured memory_bytes: 256
//In the name of God

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

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

const int N = 1e2+10 , mod = 1e9+7;

#define int ll

int w[N] , v[N] , dp[N][N * N * N / 10];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , W;
   cin >> n >> W;
   for(int i = 1 ; i <= n ; i++){
      cin >> w[i] >> v[i];
   }
   int ans = 0;
   for(int i = 1 ; i <= n ; i++){
      for(int j = 0 ; j <= W ; j++){
         dp[i][j] = dp[i - 1][j];
         if(j >= w[i])
            dp[i][j] = max(dp[i][j] , dp[i - 1][j - w[i]] + v[i]);
         ans = max(ans , dp[i][j]);
      }
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 105472
#include<bits/stdc++.h>
int cntb;
long long ans;
char s[200005];
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
		if(s[i]=='B')
			cntb++;
		else
			ans+=cntb;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
int n;
int x[110];
db avg;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i];
		avg+=x[i];
	}
	avg/=1.0*n;
	int tar=round(avg);
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=(tar-x[i])*(tar-x[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while(cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while(1){
		if(cur == nil) break;
		if(isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for(i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if(com[0] == 'i'){insert(key); np++; size++;}
		else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F') deleteFirst();
				else if(com[6] == 'L') deleteLast();
				}else{
					deleteKey(key); nd++;
				}
				size--;
			}
		}
		printList();
	return 0;
}





Measured memory_bytes: 33836
#include<stdio.h>
#include<string.h>
#define N 100

void BubbleSort(char (*)[3],int);
void SelectionSort(char (*)[3],int);

int main(){
  int i,j,n,temp,cnt=0,minj;
  char A[N][3],B[N][3],S[N][3];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",A[i]);
    strcpy(B[i],A[i]);
    strcpy(S[i],A[i]);
  }
  BubbleSort(B,n);
  SelectionSort(S,n);

  int check=0;
  for(i=0;i<n;i++){
    if(strcmp(B[i],S[i])!=0)check=1;
  }
  if(check==0) printf("Stable\n");
  else printf("Not stable\n");
  return 0;
}
void BubbleSort(char A[N][3],int n){
  int i,j;
  char temp[3];
      for(i=0;i<n;i++){
	for(j=n-1;j>i;j--){
	  if(A[j][1]<A[j-1][1]){
	  strcpy(temp,A[j]);
	  strcpy(A[j],A[j-1]);
	  strcpy(A[j-1],temp);
	  }
	}
      }
      for(i=0;i<n-1;i++){
	printf("%s ",A[i]);
      }
     printf("%s\n",A[n-1]);
     printf("Stable\n");
}
void SelectionSort(char A[N][3],int n){
  int i,j,minj;
  char temp[3];
    for(i=0;i<n;i++){
      minj=i;
      for(j=i;j<n;j++){
	if(A[j][1]<A[minj][1])minj=j;
      }
      strcpy(temp,A[i]);
      strcpy(A[i],A[minj]);
      strcpy(A[minj],temp);
    }
  for(i=0;i<n-1;i++){
  printf("%s ",A[i]);
  }
  printf("%s\n",A[n-1]);
}





Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  ll N;cin>>N;
  vector<int> vec(5,0);
  string s;
  REP(i,0,N){
    cin>>s;
    if(s.at(0)=='M')vec[0]++;
    if(s.at(0)=='A')vec[1]++;
    if(s.at(0)=='R')vec[2]++;
    if(s.at(0)=='C')vec[3]++;
    if(s.at(0)=='H')vec[4]++;
  }
  ll ans=0;

  REP(i,0,5)REP(j,i+1,5)REP(k,j+1,5){
    ans+=1LL*vec[i]*vec[j]*vec[k];
  }

  print(ans)

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    string s;
    cin >> s;
    int s_length = s.size();
    int ans = 0;
    vector<int> count(2020, 0);
    reverse(s.begin(), s.end());
    int x = 1;
    int modSum = 0;
    rep(i, s_length) {
        count[modSum]++;
        modSum = (modSum + (s[i] - '0') * x) % 2019;
        ans += count[modSum];
        x = (x*10) % 2019;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3728
use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
/*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        x:u64,
    }
    let mut result = 0;
    let mut price:u64 = 100;
    loop{
        if price >= x {
            println!("{}",result);
            break;
        }
        price = (price as f64 * 1.01) as u64;
        result += 1;
    }

}


Measured memory_bytes: 2192
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

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

using namespace std;
typedef long long ll;

int main() {

    ll N;
    cin >> N;
    ll A[N];
    ll a = 0;
    rep(i,N){
        cin >> a;
        A[a-1] = i+1;
    }
    rep(i,N){
        cout << A[i];
        if(i!=N-1) cout << " ";
    }
    cout << endl;
    return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  string s;
  cin>>n>>s;
  int ans=0,hoge;
  //蛻・牡縺吶ｋ蝣ｴ謇
  for (int i = 0; i < s.size(); ++i){
  	//蜑榊濠
  	std::map<char, bool> map1;
  	for (int j = 0; j < i; ++j)
  	{
    	auto itr=map1.find(s[j]);
    	if (itr==map1.end())map1[s[j]]=true;
  	}
  	//蠕悟濠
  	std::map<char, bool> map2;
  	for (int j = i; j < s.size(); ++j)
  	{
    	auto itr=map2.find(s[j]);
    	if (itr==map2.end())map2[s[j]]=true;
  	}
  	hoge=0;
    for(auto itr = map1.begin(); itr != map1.end(); ++itr) {
    	//cout<<i<<" "<<itr->first<<endl;
    	if (map2[itr->first])hoge++;
  	}
  	ans=max(ans,hoge);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
var x:longint;
procedure nhap;
var i,the:longint;
begin
   read(the);
   x:=x+the*100;
   read(the);
   x:=x+the*10;
   read(the);
   x:=x+the;
end;

procedure xuat;
begin
   if x mod 4=0 then write('YES')
      else write('NO');
end;
begin
   x:=0;
   nhap;
   xuat;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1000000000; //check the limits, dummy
inline ll pow5(int x)
{
	ll n=x;
	return n*n*n*n*n;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
   ll X;
   cin>>X;
   ll val=0;
   FOR(a,-120,121)
   {
   		FOR(b,-120,121)
   		{
   			val=pow5(a)-pow5(b);
   			if(val==X)
   			{
   				cout<<a<<' '<<b<<endl;
   				return 0;
   			}
   		}
   		
   }
	
	return 0;
}
 


Measured memory_bytes: 3664
wList = [list(input()) for _ in range(3)]
player = 0
player_dict = {
    'a': 0,
    'b': 1,
    'c': 2,
    0: 'A',
    1: 'B',
    2: 'C',
}
while 1:
    if wList[player] == []:
        break
    w = wList[player].pop(0)
    player = player_dict[w]
    
print(player_dict[player])

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int a,b;
  scanf("%d %d",&a,&b);
  
  if(a-1>b) printf("%d",a+a-1);
  else if(b-1>a) printf("%d",b+b-1);
  else printf("%d",a+b);
  
  return 0;
}

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

int main(){
    ll n;cin>>n;
    ll ans=0;
    rep(i,n+1){
        if(i==0) continue;
        ll num=(n/i);
        ans+=num*(num+1)*i/2;
    }

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

Measured memory_bytes: 3576
n, q = gets.split.map(&:to_i)
processes = []
total_time = 0

n.times do
  processes.push(gets.split)
end

while !processes.empty? do
  process = processes.shift

  name = process[0]
  time = process[1].to_i

  if time <= q
    total_time += time
    puts "#{name} #{total_time}"
  else
    total_time += q
    processes.push([name, time - q])
  end
end



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

#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define RFOR(i, a, b) for (int (i) = (b) - 1; (i) >= (a); (i)--)

#define SORT(v, n) sort(v, v + n)
#define VSORT(v) sort(v.begin(), v.end())
#define REVERSE(v, n) reverse(v, v + n)
#define SIZE(v) (sizeof(v) / sizeof(v[0]))
#define ALLCOUNT(v, n, x) count(v, v + n, x)

#define PUT(x)  cout << #x << ": " << x << endl
#define ll long long

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

using namespace std;

int main(){
    int count = 0;
    string s; cin >> s;
    for(int i = 1; i < s.size(); i++) {
        if(s[i] != s[i - 1]) count++;
    }
    cout << count << endl;
}

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

const int mxN = 2e3 + 5;
int cnt[mxN];

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	
	
	
	// |j - i|, |x - i| + 1 + |j - y|, |y - i| + 1 + |j - x|
	for(int i = 1; i <= n; ++i)
		for(int j = i + 1; j <= n; ++j) 
			++cnt[min(min(abs(j - i), abs(x - i) + 1 + abs(j - y)), abs(y - i) + 1 + abs(j - x))];
	for(int i = 1; i < n; ++i)
		cout << cnt[i] << '\n';
}			


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);


	int ans = 0;
	while(true){
		bool res = false;
		rep(i, n){
			if(a.at(i)%2 != 0)
				res = true;
		}
		
		if(res) break;

		rep(i, n) a.at(i) /= 2;
		ans++;
	}

	cout << ans << endl;
}

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

// int *dp, *hrr, n;

// int main(){
//     cin>>n;
//     hrr = new int[n], dp = new int[n];
//     for(int i=0;i<n;i++){
//         cin>>hrr[i];
//     }

//     dp[0] = 0;
//     dp[1] = abs(hrr[1]-hrr[0]) + dp[0];
//     for(int i=2;i<n;i++){
//         dp[i] = min(dp[i-1]+abs(hrr[i]-hrr[i-1]), dp[i-2]+abs(hrr[i]-hrr[i-2]));
//     }
//     int ans = dp[n-1];
//     delete[] hrr;
//     delete[] dp;
//     cout << ans;

//     return 0;
// }

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

int *hrr, *dp, n, ans;

int MinHealthUpto(int c){
    if(c>=n)return INT_MAX;
    if(dp[c]!=-1)return dp[c];
    ans = 0;
    if(c==0)ans=0;
    else if(c==1)ans=abs(hrr[1]-hrr[0]);
    else{
        ans = min(abs(hrr[c]-hrr[c-1])+MinHealthUpto(c-1), abs(hrr[c]-hrr[c-2])+MinHealthUpto(c-2));
    }
    dp[c] = ans;
    return ans;
}

int main(){
    cin>>n;
    hrr=new int[n];
    for(int i=0;i<n;i++){
        cin>>hrr[i];
    }
    dp=new int[n];
    for(int i=0;i<n;i++){
        dp[i]=-1;
    }
    int ans = MinHealthUpto(n-1);
    delete[] hrr;delete[] dp;
    cout << ans;
}

Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  string s;
  cin >> s;
  int ans=0;
  char tmp = s.at(0);
  REP(i, s.size()) {
    if(s.at(i)!=tmp){
      ans++;
    }
    tmp = s.at(i);
  }
  cout << ans  << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n=kbd.nextInt();
   int k=kbd.nextInt();
   int[] A= new int[n+1];


  for(int j=0;j<k;j++){
  int d=kbd.nextInt();
 for(int i=0;i<d;i++){
   A[kbd.nextInt()]++;
 }
}
int a=0;
  for(int j=1;j<=n;j++){
if(A[j]==0){
  a=a+1;
}
}
System.out.println(a);

}
}


Measured memory_bytes: 46208
#include<iostream>
main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

Measured memory_bytes: 5944
N = int(input())
T = input().split()
T = [int(n) for n in T]
t_length = 0
for o in T:
    t_length += o
P = []
X = []
M = int(input())
for p in range(0, M):
    tmp = input().split()
    P.append(int(tmp[0]))
    X.append(int(tmp[1]))
for q in range(0, M):
    print(t_length - T[P[q]-1] + X[q])

Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
p = []
res = [[] for i in range(m)]
for i in range(m):
    a,b = inpl()
    p.append((a,b,i))
p.sort()
cnt = 0
tmp = 0
for i,j in enumerate(p):
    if i == 0:
        tmp = j[0]
    if tmp == j[0]:
        cnt += 1
    else:
        tmp = j[0]
        cnt = 1
    res[j[2]] = [j[0],cnt] 
for i in res:
    print('{}{}'.format(str(i[0]).zfill(6),str(i[1]).zfill(6)))

Measured memory_bytes: 37312
#include<bits/stdc++.h>
using namespace std;
string s;
long long sum;
int main(){
    cin>>s;
    if(s[0]!='C') sum++;
    if(s[1]!='O') sum++;
    if(s[2]!='D') sum++;
    if(s[3]!='E') sum++;
    if(s[4]!='F') sum++;
    if(s[5]!='E') sum++;
    if(s[6]!='S') sum++;
    if(s[7]!='T') sum++;
    if(s[8]!='I') sum++;
    if(s[9]!='V') sum++;
    if(s[10]!='A') sum++;
    if(s[11]!='L') sum++;
    if(s[12]!='2') sum++;
    if(s[13]!='0') sum++;
    if(s[14]!='1') sum++;
    if(s[15]!='6') sum++;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

signed main(){
  string s,t;cin>>s>>t;

  int sn[101];
  memset(sn,-1,sizeof(sn));
  for(int i=0;i<s.size();i++){
    sn[i]=s[i]-'a';
  }
  int tn[101];
  memset(tn,-1,sizeof(tn));
  for(int i=0;i<t.size();i++){
    tn[i]=t[i]-'a';
  }

  sort(sn,sn+s.size());
  sort(tn,tn+t.size(),greater<int>());

  int cont=0;
  while(true){
    if(sn[cont]<tn[cont]){
      cout<<"Yes"<<"\n";
      return 0;
    }else if(sn[cont]>tn[cont]){
      cout<<"No"<<"\n";
      return 0;
    }
    cont++;
  }

}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = l[0], b = l[1], c = l[2];

            Console.WriteLine(b - a == c - b ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13396
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int h, w;
int maze[1010][1010];
vector<pair<int, pair<int, int>>> v;
int memo[1001000];
int ans;

int main() {
	cin >> h >> w;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> maze[i][j];
			v.push_back(mp(maze[i][j], mp(i, j)));
		}
	}
	sort(ALL(v));
	for (int i = 0; i < v.size(); i++) {
		int next = v[i].first;
		int sum = 0;
		pair<int, pair<int, int>> now = v[i];
		bool flag = false;
		for (int j = 0; j < 4; j++)
		{
			int x = now.second.first + dx[j],
				y = now.second.second + dy[j];
			if (0 > x || x >= h || 0 > y || y >= w)continue;
			if (maze[x][y] == -1) {
				maze[now.second.first][now.second.second] = -1;
				flag = true;
				ans++;
				break;
			}
			if (maze[x][y] > maze[now.second.first][now.second.second])continue;
			if (memo[maze[x][y]] != i + 1) {
				memo[maze[x][y]] = i + 1;
				sum++;
				next = maze[x][y];
			}
		}
		if (!flag && sum > 1) {
			ans++;
			maze[now.second.first][now.second.second] = -1;
		}
		else if (!flag)maze[now.second.first][now.second.second] = next;
	}
	cout << ans << endl;
}

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

using namespace std;

#define ft first
#define sd second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL)
#define inp freopen("code.in", "r+", stdin)
#define out freopen("code.out", "w+", stdout)
#define debug(os, var)                                     \
    (os) << "DBG: " << __FILE__ << "(" << __LINE__ << ") " \
         << #var << " = [" << (var) << "]" << endl

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long int ll;

int main()
{
    boost;
    //inp;
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; i++)
        ans += (ceil(n / (double)i)) - 1;
    cout << ans << endl;
}

Measured memory_bytes: 3668
fun main(args: Array<String>) {
    val (n, x, y) = readLine()!!.split(' ').map(String::toInt)
    val ansMap = Array(n + 1) { IntArray(n + 1) { 0 } }
    for (i in 1..n) {
        for (j in 1..n) {
            ansMap[i][j] = Math.abs(i - j)
        }
    }
    ansMap[x][y] = 1
    ansMap[y][x] = 1
    for (i in 1..n) {
        for (j in 1..n) {
            ansMap[i][j] = Math.min(ansMap[i][j], ansMap[i][x] + ansMap[y][j] + 1)
            ansMap[i][j] = Math.min(ansMap[i][j], ansMap[i][y] + ansMap[x][j] + 1)
        }
    }
    val ansArray = IntArray(n) { 0 }
    for (i in 1..n) {
        for (j in 1..n) {
            ansArray[ansMap[i][j]]++
        }
    }
    for (k in 1 until n) {
        println(ansArray[k] / 2)
    }
}

Measured memory_bytes: 54376
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// 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; }

using namespace std;

void addResult(int i,long int &result)
{
  if(i%15==0) ;
  else if(i%3==0) ;
  else if(i%5==0) ;
  else result+=i;
}

int main(void)
{
  int a;
  cin>>a;
  
  long int result=0;
  
  rep(i,0,a+1){
    addResult(i,result);
  }
  
  cout<<result<<endl;
}

Measured memory_bytes: 3628
"""
B - String Rotation
愚直に変換してチェックする
"""

s = input()
test = input()

for i in range(len(s)):
    s_right = s[i:]
    s_left = s[:i]

    s_rot = s_right + s_left
    
    #print(s_rot)

    if s_rot == test:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3060
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
h = LI()
dp = [float('INF')]*N
dp[0] = 0
for i,j in itertools.product(range(N),range(1,K+1)):
    if i+j>=N:
        continue
    dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])


Measured memory_bytes: 57312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,d,w,h,i,j,k,l,m,n,z;
	double	ans = 0;
	cin >> a >> b >> h >> m;
	double x = m*6;
	double y = h*30+(double)m/2;
	double rad = abs(x-y);
	if (rad>180.0) rad = 360.0 - rad;
	//cout << x << " " << y << " " << rad << endl;
	//cout << cos(0) << endl;
	//cout << cos(180.0*180.0/M_PI) << endl;
	//if (rad==180.0) {
	//	ans = a+b;
	//} else {
		ans = sqrt( a*a + b*b - 2*a*b*cos(rad/180.0*M_PI) );
	//}
	printf("%.10f\n",ans);
	return 0;
}


Measured memory_bytes: 4260
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Removing Robots
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_E2 = 1 << 19; // = 524288
const int MOD = 998244353;

/* typedef */

typedef pair<int,int> pii;

template <typename T, const int MAX_E2>
struct SegTreeMax {
  int e2;
  T nodes[MAX_E2];
  SegTreeMax() {}

  void init(int n) {
    for (e2 = 1; e2 < n; e2 <<= 1);
    //fill(nodes, nodes + MAX_E2, minf);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = max(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }

  T max_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return 0;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = max_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = max_range(r0, r1, k * 2 + 2, im, i1);
    return max(v0, v1);
  }
  T max_range(int r0, int r1) { return max_range(r0, r1, 0, 0, e2); }
};

/* global variables */

pii ps[MAX_N];
SegTreeMax<int,MAX_E2> st;
int dp[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++)
    scanf("%d%d", &ps[i].first, &ps[i].second);
  sort(ps, ps + n);

  st.init(n);

  for (int i = n - 1; i >= 0; i--) {
    int xi = ps[i].first, yi = xi + ps[i].second;
    int j = lower_bound(ps, ps + n, pii(yi, 0)) - ps;
    int m = st.max_range(i + 1, j);
    st.set(i, max(m, j));
  }

  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    int j = st.get(i);
    dp[i] = (dp[i + 1] + dp[j]) % MOD;
  }

  printf("%d\n", dp[0]);
  return 0;
}


Measured memory_bytes: 4480
import heapq
import sys


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    jobs = [tuple(map(int, input().split())) for _ in range(n)]
    jobs.sort()

    ans = 0
    index = 0
    hq = []
    # 働くのは0からm-1日後
    for i in range(m - 1, -1, -1):
        while index < n and i + jobs[index][0] <= m:
            heapq.heappush(hq, -jobs[index][1])
            index += 1
            if index == n:
                break
        if not hq:
            continue
        ans -= heapq.heappop(hq)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26500
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

def bfs(grid, src):
    """ BFS(グリッド、重みなし) """
    from collections import deque

    H, W = len(grid), len(grid[0])
    h, w = src
    directions = ((1, 0), (-1, 0), (0, 1), (0, -1))
    que = deque([(h, w, 0)])
    dist = list2d(H+2, W+2, -1)
    while que:
        h, w, c = que.popleft()
        if dist[h][w] != -1:
            continue
        dist[h][w] = c
        for dh, dw in directions:
            h2 = h + dh
            w2 = w + dw
            if grid[h2][w2] == '#':
                continue
            que.append((h2, w2, c+1))
    return dist

H, W = MAP()
grid = build_grid(H, W, '#', str, space=0, padding=1)

ans = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if grid[i][j] != '#':
            # 有効な全マスから最短距離試す
            res = bfs(grid, (i, j))
            for k in range(1, H+1):
                for l in range(1, W+1):
                    # 一番遠い場所
                    ans = max(ans, res[k][l])
print(ans)


Measured memory_bytes: 3440
k,q=map(int,input().split())
d=list(map(int,input().split()))

for _ in range(q):
    n,x,m = map(int,input().split())
    li = [0]*k
    tmp = 0
    for i in range(k):
        li[i] = d[i]%m
    cnt = x % m
    n -= 1
    for i in range(k):
        cnt += ( n//k + (n%k > i) ) * li[i]
        if li[i] == 0:
            tmp += ( n//k + (n%k > i) )
    print(n-cnt//m - tmp)

Measured memory_bytes: 50780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

int main(){
  int i,j;
  string s;
  cin>>s;
  int u=s.size();
  if(u%2==1) {
    cout<<"No"<<endl;
    return 0;
  }
  for(i=0;i*2<u;i++){
    if(s[i*2]!='h'||s[i*2+1]!='i'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;

}

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

c=0
for i in range(n):
      ci=min(a[i],b[i])
      c += ci
      b[i] -= ci
      ci1 = min(a[i+1],b[i])
      c += ci1
      a[i+1] -= ci1

print(c)
      

Measured memory_bytes: 19116
class Sieve: 
    
    def __init__(self, n=1):
        self.f = [0 for _ in range(n+1)]
        self.f[0] = -1
        self.f[1] = -1
        self.primes = []
        for i in range(2, n+1):
            if self.f[i]:
                continue
            self.primes.append(i)
            self.f[i] = i
            for j in range(i*i, n+1, i):
                if not self.f[j]:
                    self.f[j] = i
    
    def isPrime(self, x):
        return self.f[x] == x
    
    def factorList(self, x):
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res
    
    def factor(self, x):
        fl = self.factorList(x)
        if not len(fl):
            return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res

n = int(input())

s = Sieve(55555)
ans = []
i = 11
while len(ans) < n:
    if s.isPrime(i):
        ans.append(i)
    i += 10
print(*ans)

Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int a[3];
    int s=3;
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0]==a[1])s--;
    if(a[2]==a[1])s--;
    cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
#define mod 1000000007
int main() { 
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   char a;
   cin>>a;
   if(a>='A'&&a<='Z')
   cout<<"A";
   else
   cout<<"a";
  
  
  return 0;  
} 


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long idx=0;
    long N;
    cin >> N;
    long P;
    long count = 0;
    long min_num = INF;
    while(cin >> P)
    {
        if(min_num >= P)
        {
            count++;
        }
        min_num = min(min_num, P);
        idx++;
        if(N==idx) break;
    }

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

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private final static long MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		String keyence = "keyence";

		for (int i = 0; i < keyence.length(); i++) {
			if (S.startsWith(keyence.substring(0, i))) {
				if (S.endsWith(keyence.substring(i))) {
					System.out.println("YES");
					return;
				}
			}
		}

		System.out.println("NO");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22868
#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/2)-a.at(N/2-1)<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
#define SoArrt(a, n) sort(a, a + n);
#define SoArrtR(a, n) sort(a, a + n, std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	int a[n * 2];
	int ans = 0;

	int i, len = n * 2;

	rep(i, len) cin >> a[i];

	SoArrt(a, len);

	if (len % 2 == 1) repis(i, len, 1, 2) ans += a[i];
	else reps(i, len, 2) ans += a[i];

	Out(ans);
	
	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 100100
int n, m;
int a[N];
int b[N];
int c[N];
int d[N];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[a[i]%m]++;
		c[a[i]] ++;
	}
	int S = 0;
	S += b[0]/2;
	if (m >= 2) {
		int u = m/2;
		if (m%2 == 0) {
			S += b[u]/2;
		} else {
			u ++;
		}
		for (int i = 1; i < u; i ++) {
			int T = min(b[i], b[m-i]);
			S += T;
			d[i] = T;
			d[m-i] = T;
		}
		for (int i = 1; i < m; i++) if (i*2 != m && b[i] > d[i]) {
			int odd = 0;
			for (int j = i; j < N; j += m) {
				if (c[j]&1) odd++;
			}
			if (d[i] >= odd) {
				S += (b[i]-d[i])/2;
			} else {
				S += (b[i]-odd)/2;
			}
		}
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ENDL "\n"

typedef long long int llint;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (min(A, B) < C && C < max(A, B))
  {
    cout << "Yes" << ENDL;
  }
  else
  {
    cout << "No" << ENDL;
  }
  return 0;
}


Measured memory_bytes: 256