akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 200001
#define ll long long
#define pi pair<int , int>
#define pip pair<pi ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
// this is triplet class , which will help us .
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
// this is for finding inversing multiplicative module of a number.
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
    lps[i] = j+1;
   i++;
   j++;
  }
  else{
    if(j != 0){
     j = lps[j-1];
    }
    else{
     lps[i] = 0;
     i++;
    }
  }
 }
 return lps[len-1];
}




int dp[1000002];
int mark[1000002];
int main(){
   ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    cout.tie(NULL);
     int n;
     cin>>n; 
     int arr[n];
     //memset(dp ,  , sizeof(dp));
     memset(mark , -1 , sizeof(mark));
     for(int i = 0 ; i < n ; i++){
       cin>>arr[i];
       dp[arr[i]] = true;
     }
     int gcd = arr[0];
     for(int i = 1 ; i <  n;i++){
       gcd =  __gcd(arr[i] , gcd);
     }
     for(int i = 1 ; i <= 1e6 ; i++){
       dp[i] = i;
     }
     bool ok = true;
     for(int i = 2 ; i <= 1e6 ; i++){
          if(dp[i] == i){
              for(int j = 2*i ; j <= 1e6 ; j+=i){
                    dp[j] = min(dp[j] , i);
              }
              // if(!ok)break;
          }
     }

     for(int i = 0 ; i < n ; i++){
           int x = arr[i];
           while(x > 1){
              int l = dp[x];
              if(mark[l] != -1){
                ok = false;
                break;
              }
              while(x%l == 0){
                 x = x/l;
                 mark[l]++;
              }
           }
           if(!ok)break;
     }
     if(!ok && gcd != 1){
      cout<<"not coprime"<<endl;
     }
     else if(!ok){
        cout<<"setwise coprime"<<endl;
     }
     else{
      cout<<"pairwise coprime"<<endl;
     }

    
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

vector<ll> A,B;
ll N;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N % 2 == 1){
        cout << B[N/2] - A[N/2] + 1 << endl;
    }else{
        cout << (B[N/2]+B[N/2-1]) - (A[N/2]+A[N/2-1]) + 1 << endl;
    }
    return 0;
}

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


int main() {
	long long X; cin >> X;
	for (long long i = 1; i <= X; i++) {
		if (i*(i + 1) / 2 >= X) {
			cout << i << endl;
			return 0;
		}
	}
}





Measured memory_bytes: 256
local x = io.read("*n")
while true do
  local lim = math.ceil(math.sqrt(x))
  local f = true
  for i = 2, lim do
    if x ~= i and x % i == 0 then
      f = false
      break
    end
  end
  if f then print(x) break else x = x + 1 end
end


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

int main(){
    int N;
    cin >> N;
    int A[100000];
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    map<int, int> list{};
    for (int i = 0; i < N; i++){
        list.emplace(A[i],0);
        list[A[i]]++;
    }
    int count = 0;
    for (auto x : list){
        if (x.second % 2 == 1){
            count++;
        }
    }
    cout << count << endl;

    /*for (int i = 0; i < list.size(); i++){
        cout << list[i] << endl;
    }*/
   /* 
   list.emplace(4, 1);
   list.emplace(5, 2);
   cout << list[4] << endl;
   list[4] = list[4] + 6;
   cout << list[4] << endl;
   list.emplace(4, 3);
   cout << list[4] << endl;
   */
   return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL dp[2005][2005];

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

    int s;
    cin >> s;

    LL sum[2005] = {};
    LL res = 0;
    for(int i = 1; i <= s / 3; ++i) {
        for(int j = s; j >= 3; --j) {
            if(i == 1) {
                dp[i][j] = 1;
                sum[j + 3]++;
                if(j == s) ++res;
            } else {
                if(j == s) {
                    res += sum[j];
                    res %= MOD;
                }
                dp[i][j] = sum[j];
                sum[j] = 0;
                sum[j + 3] += dp[i][j];
                sum[j + 3] %= MOD;
            }
        }

        for(int j = 3; j <= s; ++j) {
            sum[j] += sum[j - 1];
            sum[j] %= MOD;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 14072
program main;
var
    n : LongInt;
    m, i, a : integer;
begin
    readln(n, m);
    for i := 1 to m do begin
        read(a);
        n := n - a;
    end;

    if n < 0 then
        writeln(-1)
    else
        writeln(n);
end.

Measured memory_bytes: 1380
//01
#include<iostream>
#include<stack>

using namespace std;

int main(){
  stack<int> s;
  for(int n;cin>>n;){
    if(n){
      s.push(n);
    }else{
      cout<<s.top()<<endl;
      s.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()

	if N % 2 == 1:
		print(0)
		sys.exit()

	ans = 0
	base = 10
	while True:
		if base > N:
			break

		tmp = N // base
		ans += tmp
		base *= 5

	#nene = N // 10
	#manaka = N // 50
	#rinko = N // 250

	#tmp2 = goo(N)
	#print(tmp2)
	#print(nene)
	#print(manaka)
	#print(rinko)
	print(ans)

def goo(val):
	if val < 2:
		return 1
	else:
		bbb = goo(val-2)
		aaa = val * bbb
		#print("{} x {}".format(val,bbb))
		return aaa

if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int GCD(int x,int y)
{
	return y==0?x:GCD(y,x%y);
}
int a,b;
int main()
{
	while(~scanf("%d %d",&a,&b))
	{
		if(a<b)
			swap(a,b);
		printf("%d %d\n",GCD(a,b),a/GCD(a,b)*b);
	}
}

Measured memory_bytes: 2668
#include <iostream>
#include <string.h>
#include <algorithm>
#define MAX 1000

using namespace std;

string s,t;
int dp[MAX + 1][MAX + 1];

int LCS(void){

  for( int i = 0 ; i < s.size() ; i++ ){
    for( int j = 0 ; j < t.size() ; j++ ){
      if( s[i] == t[j] ){
	dp[i + 1][j + 1] = dp[i][j] + 1;
      }else{
	dp[i + 1][j + 1] = max( dp[i + 1][j] , dp[i][j + 1]);
      }
    }
  }
  return dp[s.size()][t.size()];
}


int main(void){

  int n;
  cin >> n;
  while(n--){

    memset(dp, 0 , sizeof(dp) );

    cin >> s >> t;
    cout << LCS() << endl;

  }
  return 0;
}

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

public class Hello
{
	static void Main(string[] args)
    {
        var num1 = Console.ReadLine();
        var blnRet = false;

        foreach (char c in num1)
        {
            if (c == '7')
            {
                blnRet = true;
            }
        }

        if (blnRet)
        {
            Console.Write("Yes");
        }
        else
        {
            Console.Write("No");
        }

    }
}

Measured memory_bytes: 25692
#include <iostream>
#include <vector>
using namespace std;
int main(){

  vector <int> a;
  int n,b,i;
 
  cin>>n;
  for(i=0;i<n;i++){
    cin>>b;
    a.push_back(b);
  }

  for(i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl;
  
  for(i=1;i<n;i++){
    for(int j=0;j<i;j++){
      if(a[i]<a[j]){
	a.insert(a.begin()+j,a[i]);
	a.erase(a.begin()+i+1);
      }
    }
    
    for(int j=0;j<n-1;j++) cout<<a[j]<<" ";
    cout<<a[n-1]<<endl;
  }
  
  return 0;

}




Measured memory_bytes: 3132
from collections import defaultdict

def append(m, printed, cand_a, cand_b, cand_c):
    key = "{}-{}-{}".format(cand_a, cand_b, cand_c)
    key2 = "{}-{}-{}".format(cand_a-1, cand_b, cand_c)
    key3 = "{}-{}-{}".format(cand_a, cand_b-1, cand_c)
    key4 = "{}-{}-{}".format(cand_a, cand_b, cand_c-1)
    if not key in printed \
            and cand_a < len(A) \
            and cand_b < len(B) \
            and cand_c < len(C) \
            and not key in m \
            and not key2 in m \
            and not key3 in m \
            and not key4 in m :
        m[key] = A[cand_a] + B[cand_b] + C[cand_c]
    return m

def solve(X, Y, Z, K, A, B, C):
    a = 0
    b = 0
    c = 0

    n_print = 0
    memo = {}
    printed = defaultdict(lambda: False)
    while True:
        summ = A[a] + B[b] + C[c]
        printed["{}-{}-{}".format(a, b, c)] = True

        print(summ)

        n_print += 1
        if n_print == K:
            break

        memo = append(memo, printed, a+1, b, c)
        memo = append(memo, printed, a, b+1, c)
        memo = append(memo, printed, a, b, c+1)

        max_k = max(memo, key=memo.get)
        a, b, c = max_k.split("-")
        a = int(a)
        b = int(b)
        c = int(c)
            
        memo.pop(max_k)

if __name__ == "__main__":
    X, Y, Z, K = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())), reverse=True)
    B = sorted(list(map(int, input().split())), reverse=True)
    C = sorted(list(map(int, input().split())), reverse=True)
    solve(X, Y, Z, K, A, B, C)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back

main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int a,p;
	cin>>a>>p;

	cout<<(p+3*a)/2;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n;
VVI v(10, VI(10, 0));
ll ans;

int main()
{
    cin>>n;
    FOR(i,1,n+1) {
        //cout<<i<<" "<<i%10<<" "<<(int)(i / pow(10, (int)log10(i)))<<endl;
        v[i%10][(int)(i / pow(10, (int)log10(i)))]++;
    }
    FOR(i,1,10) FOR(j, 1, 10) {
        ans += v[i][j] * v[j][i];
        //cout<<i<<" "<<j<<" "<<v[i][j] * v[j][i]<<endl;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<int> cnt(n + 1, 0);
    int ans = 0;
    for(int i = 1; i <= n; ++ i) {
        for(int j = i; j <= n; j += i) ++ cnt[j];
        if(cnt[i] == 8 && i & 1) ++ ans;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3620
/* Language: C++14 (GCC 5.4.1)
   time: 102 ms
   Memory: 1024 KB */

#include <cstdio>
#include <cstring>
#define MAX_N 100001

bool IsPrime[MAX_N + 1];

// 愚直な素数列挙
void get_primes() {
    IsPrime[0] = false; IsPrime[1] = false;
 
    for (int i = 2; i < MAX_N; i++) {
        for (int j = 2; j*j <= i; j++) {
            if (i % j == 0) { IsPrime[i] = false; }
        }
    }
}

int main() {
    int Q, l, r;
    int cnt[MAX_N + 1] = {0};

    memset(IsPrime, 1, sizeof(IsPrime));
    get_primes();

    for (int i = 3; i <= MAX_N; i += 2) {
        if (IsPrime[i] && IsPrime[(i+1)/2]) { cnt[i]++; }
    }
    // 2017 に似てる数の累積和をとっている
    for (int i = 1; i <= MAX_N; i++) {
        cnt[i] += cnt[i-1];
    }

    scanf("%d", &Q);

    while (Q--) {
        scanf("%d %d", &l, &r);
        printf("%d\n", cnt[r] - cnt[l-1]);
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int main(){
  ll x;
  cin >> x;
  int i = 0;
  ll ans= 100;
  while(ans < x){
    ans = (ans * 1.01)/1;
    i++;
  }
cout << i<< endl;
}


Measured memory_bytes: 3632
const main = (lines: string) => {
  const data = lines.split("\n");
  const foodTypes = data[1].split(" ").map(str => parseInt(str, 10));
  const satisfactions = data[2].split(" ").map(str => parseInt(str, 10));
  let specialRule = data[3].split(" ").map(str => parseInt(str, 10));
  let result = 0;

  foodTypes.forEach((food, index) => {
    result += satisfactions[food - 1];

    if (food - foodTypes[index - 1] === 1) {
      result += specialRule[food - 2];
    }
  });

  console.log(result);
};

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

Measured memory_bytes: 7372
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
    int a,b;
    int input;
    while(1)
    {
        scanf("%d",&input);
        if(input == 0) break;
        char suma[1000000],sumb[1000000];
        int karia = 0,karib = 0;
        for(int i = 0;i<input;i++)
        {
            scanf("%d %d",&a,&b);
            if(a>b) karia+=a+b;
            else if(a<b) karib += a+b;
            else
            {
                karia += a;
                karib += b;
            }
        }
        sprintf(suma,"%d",karia);
        sprintf(sumb,"%d",karib);
        printf("%s %s\n",suma,sumb);

    }
    return 0;
}

Measured memory_bytes: 1048
s = input()
l = len(s)
sp = 0
gp = l - 1

while sp < l:
  if s[sp] == 'A':
    break
  sp += 1
  
while gp >= -1:
  if s[gp] == 'Z':
    break
  gp -= 1

if gp > sp:
  print(gp - sp + 1)
else:
  print(0)


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
#define pb push_back
#define fi first
#define sc second
#define pi pair<int,int>
#define pii pair<int,pair<int,int>>
int main()
{
    int k,x;
    scanf("%d%d",&k,&x);
    if(k*500>=x) printf("Yes");
    else printf("No");
    return 0;
}


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

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  int e=abs(a-b);
  int f=abs(b-c);
  int g=abs(c-a);
  if ( (e<=d && f<=d) || g<=d)
  cout << "Yes" << endl;
  else 
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,T,a;
  int A = 1001;
  cin >> N >> T;
  int c[N],t[N];
  for(int i=0;i<N;i++){
    cin >> c[i] >> t[i];
  }
  for(int i=0;i<N;i++){
    if(t[i]<=T && A > c[i])
    A = c[i];
    a = i+1;
  }
  if(A < 1001)
  cout << A << endl;
  else
  cout << "TLE" << endl;
}


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

int main(){
  int sum, n;
  string num;

  while(true){
    sum = 0;
    getline(cin, num);
    for(int i = 0; i <= 1000; i++){
      if(num[i] == '\0') break;
      n = num[i] - '0';
      sum += n;
    }
    if(sum == 0) break;
    cout << sum << endl;
  }
}

Measured memory_bytes: 1176
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int w, h;
    while (cin >> w >> h, w) {
        vector<int> a(w);
        for (int &ai: a) cin >> ai;
        vector<int> b(h);
        for (int &bi: b) cin >> bi;
        int sum = 0;
        for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) {
            if (a[i] == b[j]) {
                sum += a[i]; a[i] = b[j] = 0;
            }
        }
        sum += accumulate(a.begin(), a.end(), 0);
        sum += accumulate(b.begin(), b.end(), 0);
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
//
// Created by ?????°?????? on 2016/03/21.
//

#include <iostream>
using namespace std;
const int MAX = 500000;
const int SENTINEL = 2000000000;
int A[MAX/2 + 2],B[MAX/2 + 2];
int cnt;

void merge(int P[],int n,int alpha,int gamma,int beta){
    int n1 = gamma - alpha;
    int n2 = beta - gamma;
    for (int i = 0; i < n1 ; ++i)A[i] = P[alpha + i];
    for (int i = 0; i < n2 ; ++i)B[i] = P[gamma + i];
    A[n1] = SENTINEL;
    B[n2] = SENTINEL;
    int i=0; int j=0;
    for (int k = alpha; k < beta ; ++k) {
        cnt ++;
        if(A[i] <= B[j]){
            P[k] = A[i++];
        }else{
            P[k] = B[j++];
        }
    }
}

void mergesort(int P[],int n,int alpha,int beta){
    if(alpha + 1 < beta){
        int gamma = (alpha + beta)/2;
        mergesort(P,n,alpha,gamma);
        mergesort(P,n,gamma,beta);
        merge(P,n,alpha,gamma,beta);
    }
}

int main (){
    int P[MAX] ,n,i;
    cnt = 0;
    cin >> n;

    for (int i = 0; i < n; ++i)cin >> P[i];
    
    mergesort(P,n,0,n);
    
    for (int i = 0; i < n ; ++i) {
        if (i) cout << " ";
        cout << P[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}

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

int main(){
  ll a;cin>>a;
  cout<<a*a<<endl;
}

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

using namespace std;
using ll = long long;

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

  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int need = 0;
  while (a >= b) {
    b *= 2;
    need++;
  }
  while (b >= c) {
    c *= 2;
    need++;
  }
  if (need <= k) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N_MAX = 3000;
int main()
{
  int x,y,z,k,l,i,j;
  long long a[N_MAX],b[N_MAX],c[N_MAX],d[N_MAX];
  long long t,u;
  cin >> x >> y >> z >> k;
  priority_queue<long long, vector<long long>,greater<long long>> q;
  for(i=0;i<x;i++)
    cin >> a[i];
  for(i=0;i<y;i++)
    cin >> b[i];
  for(i=0;i<z;i++)
    cin >> c[i];
  sort(a,a+x,greater<long long>());
  sort(b,b+y,greater<long long>());
  sort(c,c+z,greater<long long>());
  for(i=0;i<x;i++)
    for(j=0;j<y;j++){
      t=a[i]+b[j];
      if(q.size()<k){
        q.push(t);
      }else{
        u=q.top();
        if(t>u){
          q.pop();
          q.push(t);
        }
      }
    }
  l=min(k,x*y);
  for(i=l-1;i>=0;i--){
    d[i]=q.top();
    q.pop();
  }
  for(i=0;i<l;i++)
    for(j=0;j<z;j++){
      t=d[i]+c[j];
      if(q.size()<k){
        q.push(t);
      }else{
        u=q.top();
        if(t>u){
          q.pop();
          q.push(t);
        }
      }
    }
  for(i=k-1;i>=0;i--){
    d[i]=q.top();
    q.pop();
  }
  for(i=0;i<k;i++)
    cout << d[i] << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=998244353,MAX=1e2+2;

ll n;
ll a[82];

int main(){
    IOS;
    cin>>n;
    ll res=1000,mn=inf;
    lp(i,0,n){
        cin>>a[i];
        if(i){
            if(a[i]<=a[i-1])
                mn=min(mn,a[i]);
            else{
                ll cnt=res/mn;
                res=res-cnt*mn;
                res=res+cnt*a[i];
                mn=a[i];
            }

        }
        else mn=a[i];
    }
    cout<<res;

}
/*

*/


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

template <ll mod>
struct modular {
    ll value;
    modular(ll x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }

    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        ll a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            ll t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        value = value * a % mod;
        if (value < 0) value += mod;
        return *this;
    }
    modular& operator^=(modular other) {
        ll r = 1, x = value, n = other.value;
        while (n > 0) {
            if (n & 1) r = r * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        value = r;
        return *this;
    }
    modular operator+(modular rhs) {
        return modular(*this) += rhs;
    }
    modular operator-(modular rhs) {
        return modular(*this) -= rhs;
    }
    modular operator*(modular rhs) {
        return modular(*this) *= rhs;
    }
    modular operator/(modular rhs) {
        return modular(*this) /= rhs;
    }
    modular operator^(modular rhs) {
        return modular(*this) ^= rhs;
    }
    bool operator==(modular rhs) {
        return value == rhs.value;
    };
    bool operator!=(modular rhs) {
        return value != rhs.value;
    };
    bool operator<(modular rhs) {
        return value < rhs.value;
    }
};
template <ll mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <ll mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    return stream << x.value;
}
template <ll mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
}
const ll mod = 1e9 + 7;
using mint = modular<mod>;

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

    int n;
    cin >> n;
    vector<mint> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<mint> e(n + 1);
    mint s;
    e[1] = s = 1;
    rep(i, 2, n + 1) {
        e[i] = s / mint(i) + 1;
        s += e[i];
    }
    s = 1;
    rep(i, 2, n + 1) s *= i;
    mint ans;
    rep(i, 0, n) {
        ans += a[i] * (e[i + 1] + e[n - i] - 1) * s;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  long long n;
  cin >> n;
  int a = 0, b = 0;
  while (n) {
    a += n % 10;
    if (n < 10) b += n - 1;
    else b += 9;
    n /= 10;
  }
  cout << max(a, b) << endl;
}

Measured memory_bytes: 256
n,m,x,y = map(int,raw_input().split())
xx = map(int,raw_input().split())+[x]
yy = map(int,raw_input().split())+[y]
mxx = max(xx)
miyy = min(yy)
if mxx < miyy:
    print "No War"
else:
    print "War"

Measured memory_bytes: 28012
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

vector<int> v;

int calculate(int x)
{
	int sum = 0;
	for(auto &a : v)
	{
		sum += (pow(a-x,2));
	}
	return sum;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin >> n;
	v = vector<int> (n);
	for(int i =0; i<n ; ++i)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());


	int mini = 1000000;
	for(int i = v[0]; i<= v[n-1] ; i++)
	{
		mini = min(mini, calculate(i));
	}

	cout << mini;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   int a,b;
   while(cin>>a>>b)
   {
     int kk=a+b;
     if(kk%2==0) cout<<(kk/2)<<endl;
     else cout<<((kk+1)/2)<<endl;             
   }
   return 0;
 }
 

      

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int[] s = new int[5];
		int min = 10;
		int p = 0;

		// 整数の入力
		for(int n=0;n<5;n++){
			s[n] = sc.nextInt();
			int val = s[n]%10;
			if(val<min&&val!=0){
				p=n;
				min=val;
			}
		}
		if(min==10)min=0;
		int sum = 0;

		for(int n=0;n<5;n++){
			if(n!=p&&s[n]%10!=0){
				sum=sum+s[n]+10-s[n]%10;
			} else {
				sum+=s[n];
			}
		}

		// 出力
		System.out.println(sum);
	}
}

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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003
#define MM 1000000000
#define MN 1000000000000000000

int main()
{
    ios;
    ll i,n,ans=0;
    cin>>n;
    ll a[n];
    rep(i,n)
        cin>>a[i];
    sort(a,a+n,greater<int>());
    ll j=0;
    rep(i,n)
    {
        if(i==0)
            continue;
        if(j==0)
        {
            ans+=a[j];
            j++;
        }
        else
        {
            if(i==n-1)
                ans+=a[j];
            else
                ans+=2*a[j];
            j++;
            i++;
        }
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n, g;
    cin >> n >> g;
    vector<int> p(n), c(n);
    for(int i = 0; i < n; ++i)
        cin >> p[i] >> c[i];
    int ans = MOD;
    for(int i = 0; i < (1 << n); ++i){
        int sum = 0;
        int cnt = 0;
        for(int j = 0; j < n; ++j)
            if(i & (1 << j)){
                sum += (j + 1) * 100 * p[j] + c[j];
                cnt += p[j];
            }
        int diff = g - sum;
        for(int j = n - 1; j >= 0; --j)
            if(~i & (1 << j)){
                int cn = max(0, min((diff + (100 * (j + 1)) - 1) / (100 * (j + 1)), p[j]));
                cnt += cn;
                diff -= 100 * (j + 1) * cn;
            }
        if(diff <= 0)
            chmin(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
"""
kari1 = '2000 8'
kari2 = '0 2 4 5 8 9'
in1 = kari1.split()
in2 = kari2
"""
in1 = input().split()
in2 = input()

tukaeru = []
for num1 in range(10):
    if str(num1) not in in2:
        tukaeru.append(str(num1))
nedan = []
for num1 in range(len(in1[0])):
    nedan.append(in1[0][num1])

idx1 = 0
for item1 in nedan:
    if item1 not in tukaeru:
        break
    idx1 = idx1 + 1

if idx1 < len(nedan): #編集開始桁位置取得
    while idx1 >= 0:
        if tukaeru[-1] <= nedan[idx1]:
            idx1 = idx1 - 1
        else:
            break

    if idx1 == -1: #桁追加必要
        if tukaeru[0] == '0':
            nedan.insert(0, tukaeru[1])
        else:
            nedan.insert(0, tukaeru[0])
        idx1 = 1
    else: #桁追加不要
        for item1 in tukaeru:
            if item1 > nedan[idx1]:
                nedan[idx1] = item1
                break
        idx1 = idx1 + 1

    for idx1 in range(idx1, len(nedan)):
        nedan[idx1] = tukaeru[0]

print(''.join(nedan))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    string s;
    cin>>s;
    ll cnt=0;
    rep(i,n-2){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
n = int(input())
if n == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+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

a = factorization(n)

cnt = 0
for i in range(len(a)):
    tmp = a[i][1]
    for j in range(1,100):
        tmp -= j
        if tmp >= 0:
            cnt += 1
        else:
            break

print(cnt)

Measured memory_bytes: 9500
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    b = list(map(int, input().split()))
    lst = b[:]
    for i in range(N,0,-1):
        j = i
        a = 0
        while j <=N: a, j = a^lst[j-1], j+i
        lst[i-1] = a
    ans = [i+1 for i in range(N) if lst[i]]
    print(len(ans))
    print(*ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 68344
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

ll fact(int n)
{
    ll res = 1;
    for(int i = 2; i < n + 1; i++)
    {
        res *= i;
        res %= MOD;
    }
    return res;
}

ll pow2(ll base, int index, int mod) //a to the power of b mod p
{
    if(index == 1) return base;
    if(!(index % 2))
    {
        ll ret = pow2(base, index/2, mod);
        return (ret * ret) % mod;
    }
    return (base * pow2(base, index - 1, mod)) % mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //let a be the number of times we move to (i + 1, j + 2)
    //let b be the number of times we move to (i + 2, j + 1)
    /*
    we have the following equations:
    2a + b = x
    2b + a = y
    where a, b, are non-negative integers
    */
    int x, y; cin >> x >> y;
    if((2 * y - x) % 3 || (2 * x - y) % 3)
    {
        cout << 0;
        return 0;
    }
    int a = (2 * y - x)/3;
    int b = (2 * x - y)/3;
    if(a < 0 || b < 0)
    {
        cout << 0;
        return 0;
    }
    ll tmp = (fact(a + b) * pow2(fact(a), MOD - 2, MOD)) % MOD;
    cout << (tmp * pow2(fact(b), MOD - 2, MOD)) % MOD;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s1, s2;

int main()
{
	cin >> s1 >> s2;
	
	reverse(s1.begin(), s1.end());

	if (s1 == s2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdbool.h>

#define sml(ch) (('a' <= ch && ch <= 'z') ? true : false)
#define TR(flg) ((flg == true) ? 1 : 0)

int main(void) 
{
  char str[11];
  scanf("%s", str);
  int i, len, c_pos = -1;
  bool flg1 = false, flg2 = false, flg3 = true;
  for(len = 0; str[len] != '\0'; ++len);
  
  if( str[0] == 'A') { flg1 = true; }
  for(i = 2; i < len-1; ++i) {
    if( str[i] == 'C') {
      if(flg2) { flg2 = false; break; }
      else { flg2 = true; c_pos = i; }
    }
  }
  
  for(i = 1; i < len; ++i) {
    if( (i != c_pos) && (!sml(str[i])) ) { flg3 = false; break; }
  }
  
  
  //printf("c_pos = %d\n", c_pos);
  //printf("len = %d\n", len);
  //printf("1: %d 2: %d 3: %d\n", TR(flg1), TR(flg2), TR(flg3));
  if( flg1 && flg2 && flg3) { printf("AC\n"); } 
  else { printf("WA\n"); }
  
  return 0;
}

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

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

const ll mod = 1000000007;

struct info {
    ll cost, limit;
};
bool comp(const info& a, const info& b) {
    return a.limit < b.limit;
}


int main() {
    int n;
    cin >> n;
    vector<info> AB(n);
    rep(i,n) {
        cin >> AB[i].cost >> AB[i].limit;
    }
    sort(AB.begin(), AB.end(), comp);
    ll t = 0;
    rep(i,n) {
        if (t + AB[i].cost <= AB[i].limit) {
            t += AB[i].cost;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
const int mx = 5e5;
const ll mod = 998244353;
ll res[mx + 5];
int main() {
	res[1] = 1;
	int n, k;
	cin >> n >> k;
	vector <pair <int, int>> vec(k);
	for (int i = 0; i < k; ++i) {
		cin >> vec[i].first >> vec[i].second;
	}
	for (int i = 2; i <= n; ++i) 
    {
		for (int j = 0; j < k; ++j) 
        {
			if (i - vec[j].first < 1)
				continue;
          
			if (i - vec[j].second < 1)
				res[i] += res[i - vec[j].first];
          
			else
				res[i] += res[i - vec[j].first] - res[i - vec[j].second - 1];
          
			res[i] %= mod;
		}
		if (i != n)
			res[i] += res[i - 1];
	}
	cout << res[n] << endl;
}


Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   int n;
   cin>>n;
   unordered_set<string>st;

   for(int  i =0;i<n;i++)
   {
      cin>>s;
      st.insert(s);
   }
   cout<<st.size()<<endl;
}

Measured memory_bytes: 17612
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

string s;
int mas[N][30];
int to[N] , n;
bool used[N];
vector <int> g;

void print(int ind){
    while(ind != n){
        cout<<s[ind];
        ind = to[ind];
    }
    cout<<endl;
}

int main(){
    cin>>s;
    n = (int)s.size();
    for(int j=0;j<26;j++) mas[0][j] = -1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<26;j++)mas[i][j] = mas[i-1][j];
        int x = s[i-1] - 'a';
        mas[i][x] = i-1;
    }
    g.push_back(n);
    used[n] = true;
    while(true){
        vector <int> gg;
        for(int i=0;i<26;i++){
            for(int j=0;j<(int)g.size();j++){
                int ind = g[j];
                if(mas[ind][i] == -1){
                    cout<<char('a' + i);
                    print(ind);
                    return 0;
                }
                int id = mas[ind][i];
                if(used[id] == false){
                    used[id] = true;
                    gg.push_back(id);
                    to[id] = ind;
                }
            }
        }
        g.clear();
        for(int i=0;i<(int)gg.size();i++) g.push_back(gg[i]);
    }
    return 0;
}



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

int main()
{
	ios::sync_with_stdio(false);
	int r;
	while(cin>>r)
	{
		if(r<1200)
			cout<<"ABC"<<endl;
		else if(r<2800)
			cout<<"ARC"<<endl;
		else
			cout<<"AGC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//
    // Created by rajshah9914 on 29/03/20.
    //


    #include <bits/stdc++.h>
    using namespace std;
    const long long INF=1e9+7;
    int main()
    {
        long long n,c,a,b,sum=0;
        cin>>n>>c;
        vector<long long>w,val;

        //dp[i]= min wt of items with value exactly i
        for(long long i=0;i<n;i++)
        {
            cin>>a>>b;
            w.push_back(a);
            val.push_back(b);
        }
        for(long long i:val)
            sum+=i;
        vector<long long>dp(sum+5,INF);
        dp[0]=0;
        for(long long i=0;i<n;i++)
        {
            for(long long j=sum;j>=val[i];j--)
            {
                dp[j]=min(dp[j],w[i]+dp[j-val[i]]);
            }
        }
        long long ans=0;
        for(long long i=0;i<=sum;i++)
        {
            if(dp[i]<=c)
                ans=max(ans,i);
    //        ans=min(ans,dp[i]);
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 1024
#include<iostream>
#include<string>

using std::cout;
using std::cin;
using std::endl;

int main(){
    long long int X,yen=100;
    int count=0;
    cin >> X;
    while(yen < X){
        yen *= 1.01;
        count++;
    }
    cout << count;
}

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

int main() {
    int n,k,temp=0;
    cin >> n>>k;
    int b=min((k-1),n);
    double value=0,steps=0;
    for(int i=1;i<=n;i++)
    {
        temp = i;steps=0;
        while(temp<k)
        {
            temp *=2;
            steps++;
        }
        //cout << steps<<endl;
        value +=(pow(0.5,steps))/n;
    }
    cout <<setprecision (12)<< value;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int[] eratosthenes(int n) {
		boolean[] dp = new boolean[n+1];
		List<Integer> prime = new LinkedList<Integer>();
		for (int i = 2; i <= n; i++) {
			if (i % 7 == 1 || i % 7 == 6) {
				if (dp[i]) continue;
				prime.add(i);
				for (int j = i+i; j <= n; j += i) 
					dp[j] = true;
			}
		}
		
		int[] ret = new int[prime.size()];
		int count = 0;
		for (int num : prime)
			ret[count++] = num;
		
		return ret;
	}
	
	void run() {
		int n;
		int[] prime = eratosthenes(400000);
		while (true) {
			n = sc.nextInt();
			if (n == 1) break;
			out.printf("%d:", n);
			int index = 0;
			while (prime[index] <= n) {
				if (n % prime[index] == 0 && ((n/prime[index])%7 == 1 || (n/prime[index])%7 == 6)) {
					out.printf(" %d", prime[index]);
				}
				index++;
			}
			out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 36088
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, d, e, f, g, h;
	a = 0; b = 0; c = 0; d = 0; e = 0; f = 0; g = 0; h = 0;
	cin >> a >> b >> c >> d;
	e = a * b;
	f = c * d;
	if (e >= f)
		g = e;
	else g = f;
	cout << g;
	cin >> h;
	return 0;
}

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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] aaa = Console.ReadLine().Split(' ');
            string[] ans = new string[N+1];

            for (int stuNo = 1; stuNo <= N; stuNo++)
            {
                int order = int.Parse(aaa[stuNo-1]);
                ans[order] = stuNo.ToString()+" ";
            }

            Console.WriteLine(string.Join("",ans));
            Console.ReadLine();
        }

    }


}


Measured memory_bytes: 30040
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

//入力
int N;
long long h[100100];

//DPテーブル
long long dp[100100];

int main()
{
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
        cin >> h[i];

    //初期化（最小化問題なので、INFに初期化）
    for (int i = 0; i < 100100; ++i)
        dp[i] = INF;

    //初期条件
    dp[0] = 0;

    //ループ
    for (int i = 0; i < N; ++i)
    {
        for (int j = 1; j <= K; ++j)
        {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    //答え
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
string a="keyence";
string s;
int cnt;
int main()
{
	cin>>s;	
	for(int i=0;i<7;i++) 
	{
		if (s[i] == a[i]) 
		{
			cnt++;	
		}
		if (s[s.size() - 1 - i] == a[6 - i]) 
		{
			cnt++;
		}
	}
	cout <<(cnt >= 7 ? "YES" : "NO");
}


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

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

    vector<int> r(M * 2);
    for (int i = 0; i < M * 2; i++)
    {
        cin >> r.at(i);
    }

    for (int i = 0; i < N; i++)
    {
        int count = 0;
        for (int j = 0; j < M * 2; j++)
        {
            if (i + 1 == r.at(j))
            {
                count += 1;
            }
        }
        cout << count << endl;
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int64_t MOD = 1000000007;
  int64_t ten = 1;
  int64_t nine = 1;
  int64_t eight = 1;
  for(int i = 0; i < N; i++) {
    ten *= 10;
    ten %= MOD;
    nine *= 9;
    nine %= MOD;
    eight *= 8;
    eight %= MOD;
  }
  int64_t ans = ten - 2 * nine + eight;
  ans += 4 * MOD;
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N, K = map(int,input().split())
    h = list(map(int, input().split()))
    dp = [0]*(N)

    #2:初期値
    dp[0] = 0

    #3:dp実行部(貰うDP)(配るDPでは事項時間制限に間に合わない)
    for i in range(1,N):
        L = [dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)

    #4:出力
    print(dp[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 14016