akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




double a;

int main() {

	cin >> a;

	cout << a * PI * 2 << endl;

	return 0;
}


Measured memory_bytes: 3752
n = int(input())

def prime_factorise(n):
    a = []
    tmp = n
    for i in range(2, int(n**0.5//1 + 1)):
        if tmp % i == 0:
            index = 0  # 指数
            while tmp % i == 0:
                index += 1
                tmp //= i
            a.append([i, index])

    if tmp != 1:
        a.append([tmp, 1])

    return a

x = prime_factorise(n)
count = 0


for i in range(len(x)):
    if x[0][0] == 1:
        break

    k = x[i][1]  # 指数の値
    for j in range(k):
        if n % (x[i][0] ** (j+1)) == 0:
            n //= x[i][0] ** (j+1)
            count += 1
            k -= (j+1) #指数の値をへらす

        elif n % (x[i][0]**(j+1)) != 0:
            break
        # ここの分岐とおるか？
        if k <= 0:
            break

print(count)

Measured memory_bytes: 9500
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
N = ii()
A = lmis()

if N == len(set(A)):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 26168
// ABC 063 B - Varied

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
	string S;
	cin >> S;

	int size;
	size = S.size();
	bool flag = false;
	
	for(int i = 1; i <size ; i++){
		for(int j = 0 ; j < i ; j++){
			if(S.substr(i,1) == S.substr(j,1)){
				flag = true;
			}
		}
	}

	if(flag == true){
		cout << "no" << endl;
	}
	else{
		cout << "yes" << endl;
	}
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair
#define r0 return 0

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

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n, x;
    int sum;
    cin >> n >> x;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(all(v));
    sum = accumulate(all(v), 0);
    cout << ((x - sum) / v[0]) + n << endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size();

    int a = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0 && S[i] != '0') {
            a++;
        } else if (i % 2 == 1 && S[i] != '1') {
            a++;
        }
    }
    int b = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0 && S[i] != '1') {
            b++;
        } else if (i % 2 == 1 && S[i] != '0') {
            b++;
        }
    }

    cout << min(a, b) << endl;
}


Measured memory_bytes: 512
using System;


namespace aoj3a
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i = 1; i <= 10001; i++)
            {
                string str = Console.ReadLine();
                if(str == "0")
                {
                    break;
                }
                Console.WriteLine("Case " + i + ": " + str);
            }
        }
    }
}

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

#define MAX 2020
int n;
int m;
int q;

int s[MAX][MAX];

int im[MAX][MAX];

int t[MAX][MAX];
int y[MAX][MAX];
bool bot[MAX][MAX];
char buf[MAX];

int belong[MAX][MAX];
int id[MAX][MAX];

struct UF{
	vector<int> belong;
	vector<int> size;
	void resize(int n){
		belong.assign(n + 1, -1);
		size.assign(n + 1, 1);
	}
	inline int root(int b){
		if (belong[b] == -1){
			return b;
		}
		belong[b] = root(belong[b]);
		return belong[b];
	}
	void merge(int a, int b){
		a = root(a);
		b = root(b);
		if (a == b)return;
		belong[a] = b;
		size[b] += size[a];
	}
};
UF uf;

int node[MAX][MAX];
int ed[MAX][MAX];


int main() {
	int f=0;
	for (int i = 0; i < MAX; i++){
		for (int j = 0; j < MAX; j++){
			id[i][j] = f;
			f++;
		}
	}
	uf.resize(MAX*MAX);
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++) {
		scanf("%s", buf);
		for (int j = 0; j < m; j++) {
			s[i][j] = buf[j] - '0';
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			bool T = false;
			if (s[i][j] == 0)continue;
			node[i][j]++;
			if (i) {
				if (s[i - 1][j])T = true;
			}
			bool Y = false;
			if (j) {
				if (s[i][j - 1])Y = true;
			}
			if (T || Y) {

			}
			else {
				im[i][j]++;
			}
			ed[i][j] += T;
			ed[i][j] += Y;
			if (T&&Y)im[i][j]--;
			if (T == true && Y == false) {
				t[i][j]++;
				uf.merge(id[i][j], id[i - 1][j]);
			}
			if (T == false && Y == true) {
				y[i][j]++;
			}
			if (T&&Y) {
				bot[i][j]++;
				t[i][j]++;
				y[i][j]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < m; j++) {
			im[i][j] += im[i][j - 1];
			t[i][j] += t[i][j - 1];
			node[i][j] += node[i][j - 1];
			ed[i][j] += ed[i][j - 1];
		}
	}
	for (int j = 0; j < m; j++) {
		for (int i = 1; i < n; i++) {
			im[i][j] += im[i - 1][j];
			y[i][j] += y[i - 1][j];
			ed[i][j] += ed[i - 1][j];
			node[i][j] += node[i - 1][j];
		}
	}
	while (q--) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1--;
		y1--;
		x2--;
		y2--;
		int sum = node[x2][y2];
		if (x1&&y1) {
			sum += node[x1 - 1][y1 - 1];
		}
		if (x1) {
			sum -= node[x1 - 1][y2];
		}
		if (y1) {
			sum -= node[x2][y1 - 1];
		}
		sum -= ed[x2][y2];
		if (x1&&y1) {
			sum -= ed[x1 - 1][y1 - 1];
		}
		if (x1) {
			sum += ed[x1 - 1][y2];
		}
		if (y1) {
			sum += ed[x2][y1 - 1];
		}
		sum += t[x1][y2];
		if (y1)sum -= t[x1][y1 - 1];
		sum += y[x2][y1];
		if (x1)sum -= y[x1 - 1][y1];
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 150528
S = input()
T = input()
s_dict = {}
t_dict = {}
duplicate_flag = 0
for s,t in zip(S,T):
    if not s in s_dict:
        s_dict[s] = t
        if not t in t_dict:
            t_dict[t] = s
        else:
            print("No")
            exit()
    elif s_dict[s] != t:
        print("No")
        exit()
else:
    print("Yes")


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

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(b, n*a) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define nl '\n'
#define ff first
#define ss second
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

void dfs(const vector<int> g[], int vis[],
	 vector< pair<int,int> >&p,
	 vector< pair<int,int> >&v, int u) {
  vis[u] = 2;
  v.emplace_back(p[u]);
  for(auto&ch:g[u]) {
    if( vis[ch] == 0 ) {
      dfs(g, vis, p, v, ch);
    }
  }
  vis[u] = 1;
}

size_t foo(vector< pair<int,int> > &x) {
  vector<int> u, v, ret( 2 * x.size() );
  for(auto&p:x) u.emplace_back(p.ff), v.emplace_back(p.ss);
  sort(u.begin(), u.end()); sort(v.begin(), v.end());
  return set_intersection(u.begin(), u.end(),
			  v.begin(), v.end(), ret.begin()) - ret.begin();
}

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

  int n, m; cin >> n >> m;
  vector< pair<int, int> > p(1+n);
  for(int i=1; i<=n; i++) {
    cin >> p[i].ff; p[i].ss = i;
  }
  vector< int > g[1+n];
  for(int i=1; i<=m; i++) {
    int x, y; cin >> x >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  int vis[1+n];
  fill(vis, vis+1+n, 0);
  int ans = 0;
  for(int i=1; i<=n; i++)
    if( not vis[i] ) {
      vector< pair<int,int> > v;
      dfs(g, vis, p, v, i);
      // for(auto&p: v) cerr << p.ff << ',' << p.ss << ' ' ; cerr << nl;
      ans += foo(v);
    }
  cout << ans << nl;

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int n, k;
    cin >> n >> k;
    vector<ll> V(n);
    for (auto &i : V)
        cin >> i;
    sort(V.begin(), V.end());
    cout << accumulate(V.begin(), V.begin() + k, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 3620
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
CB = [list(map(int, input().split()))[::-1] for _ in range(M)]
CB.sort()
C, B = list(map(list, zip(*CB)))
b = B.pop()
c = C.pop()
ans = []
for a in A:
    if a < c:
        ans.append(c)
        b -= 1
    else:
        ans.append(a)
    if b == 0:
        if B:
            b = B.pop()
            c = C.pop()
        else:
            c = -1

print(sum(ans))


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

const int INF = 1e9 + 5;
            
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    // dp[i] = min value to reach stone n
    int h[n];
    for(int i = 0; i < n; i++)
        cin >> h[i];
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j : {i + 1, i + 2})
        {
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4716
#include <stdio.h>

int grd(int a,int b){
    int tmp,r;
    if(a<b){
        tmp = b;
        b = a;
        a = tmp;
    }
    while(b>0){
        r = a%b;
        a = b;
        b = r;
    }
    return a;
}

int main(){
  int a,b,c;
  scanf("%d %d",&a,&b);
  c = grd(a,b);
  printf("%d\n",c );
  return 0;

}



Measured memory_bytes: 2144
from math import *
n = int(input())
ps = set(range(2, 55556))
for i in range(2, floor(sqrt(55555) + 1)):
    if i in ps:
        k = 2
        while(i*k <= 55555):
            if i*k in ps:
                ps.remove(i*k)
            k += 1
ans = []
i = max(ps)
while len(ans) < n and i <= 55555:
    if i in ps:
        ans.append(i)
    i -= 5
print(*ans)

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }
    long long cnt = 0;
    unordered_map<string, int> arr{{"non", 0}, };
    
    for(int i = 0; i < N; i++){
        if(arr.find(S[i]) != arr.find("non")){
            cnt += arr[S[i]];
            arr[S[i]] ++;
        }
        else arr.emplace(S[i],1);
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 17700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public class Point
		{
            public long x;
            public long y;

            public Point(long[] xy)
			{
                x = xy[0];
                y = xy[1];
			}
		}

        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            var n = nm[0];
            var m = nm[1];

            var ab = new Point[n];
            var cd = new Point[m];

            for (int i = 0; i < n; i++) {
                ab[i] = new Point(Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray());
			}

            for (int i = 0; i < m; i++) {
                cd[i] = new Point(Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray());
            }

            for(int i = 0; i < n; i++) {
                var max = long.MaxValue;
                var minIndex = -1;
                var student = ab[i];

                for(int j = 0; j < m; j++) {
                    var point = cd[j];
                    var distance = Math.Abs(point.x - student.x) + Math.Abs(point.y - student.y);
                    if (distance < max) {
                        minIndex = j;
                        max = distance;
					}
                }

                Console.WriteLine(minIndex + 1);
            }
        }
    }
}



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

string tolower(string T) {
  
  string lowerT;
  
  for (int i = 0; i < T.size(); i++) {
    if ('A' <= T.at(i) && T.at(i) <= 'Z') {
      lowerT += T.at(i) + 32;
    }
    else if ('a' <= T.at(i) && T.at(i) <= 'z') {
      lowerT += T.at(i);
    }
  }
  
  return lowerT;
  
}

int main() {
  
  string W; cin >> W; int ans = 0;
  
  while (true) {
    
    string T; cin >> T;
    
    if (T == "END_OF_TEXT") break;
    
    T = tolower(T);
    
    if (W == T) ans++;
    
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3212
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int a, b, c; cin >> a >> b >> c;
    int ans = min(c, b / a);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c; cin>>a>>b>>c;
  int max;
  max=a;
  if(max<b){max=b;}
  if(max<c){max=c;}
  cout<<a+b+c-max<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int y, m, d;

  while ( scanf ( "%d%d%d", &y, &m, &d ) == 3 )
  {
    const int eval = y * 10000 + m * 100 + d;

    if ( eval >= 19890108 )
    {
      printf ( "heisei %d %d %d\n", y - 1988, m, d );
    }
    else if ( eval >= 19261225 )
    {
      printf ( "showa %d %d %d\n", y - 1925, m, d );
    }
    else if ( eval >= 19120730 )
    {
      printf ( "taisho %d %d %d\n", y - 1911, m, d );
    }
    else if ( eval >= 18680908 )
    {
      printf ( "meiji %d %d %d\n", y - 1867, m, d );
    }
    else
    {
      puts ( "pre-meiji" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
using namespace std;
int N_MAX = 200000;
typedef pair<long long,int> P;
int main()
{
  int n,i,j,k;
  long long t,res=0;
  long long a[N_MAX],b[N_MAX];
  P p;
  priority_queue<P> q;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  for(i=0;i<n;i++){
    cin >> b[i];
    p.first=b[i];
    p.second=i;
    q.push(p);
  }
  i=n-1;j=0;k=1;
  while(!q.empty()){
    p=q.top(); q.pop();
    j=p.second;
    i=(j+n-1)%n;
    k=(j+1)%n;
    if(b[j]==a[j])
      continue;
    if(b[j]-b[i]-b[k]<a[j]){
      cout << "-1" << endl;
      return 0;
    }
    t=(b[j]-a[j])/(b[i]+b[k]);
    b[j]-=(b[i]+b[k])*t;
    p.first=b[j];
    q.push(p);
    res+=t;
  }
  for(i=0;i<n;i++)
    if(a[i]!=b[i]){
      cout << "-1" << endl;
      return 0;
    }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 9456
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    
    int a[n][m],b[m];
    long long int c[n];
    for(int i=0;i<n;i++){
        c[i] = 0;
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i] += a[i][j] * b[j];
        }
    }

    for(int i=0;i<n;i++){
        cout << c[i] << endl;
    }
}


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

int main() 
{

	int n; cin>>n;
	int a[n],b[n],c[n-1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int sm=0;
	vector<int>idx;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		sm+=b[i];
		
	}
	for(int i=0;i<n-1;i++)
	{
		cin>>c[i];
	}
	for(int i=1;i<n;i++)
	{
		if(a[i]-a[i-1]==1)
		{
			idx.push_back(a[i-1]-1);
		}
		
	}
	//cout<<sm<<" ";
	for(auto x: idx)
	{
		sm+=c[x];
	}
	
	cout<<sm;
	

}

Measured memory_bytes: 256
from time import time
from random import randrange

def calc():
    s = 0
    last = [-1] * 26
    for i, t in enumerate(A):
        s += S[i][t]
        last[t] = i
        for j, c in enumerate(C):
            s -= c * (i - last[j])
    return s

sTime = time()
D = int(input())
C = [int(a) for a in input().split()]
S = [[int(a) for a in input().split()] for _ in range(D)]
A = [randrange(26) for _ in range(D)]
ans = calc()
while time() - sTime < 1.8:
    d = randrange(D)
    i = A[d]
    for k in range(d)[::-1]:
        if A[k] == i:
            prev = k
            break
    else:
        prev = -1
    for k in range(d + 1, D):
        if A[k] == i:
            prev_ne = k
            break
    else:
        prev_ne = D
    for j in range(26):
        t = S[d][j] - S[d][i]
        for k in range(d)[::-1]:
            if A[k] == j:
                new = k
                break
        else:
            new = -1
        for k in range(d + 1, D):
            if A[k] == j:
                new_ne = k
                break
        else:
            new_ne = D
        t += C[j] * (d - new) * (new_ne - d) - C[i] * (d - prev) * (prev_ne - d)
        if t > 0:
            A[d] = j
            ans += t
            prev, prev_ne = new, new_ne
            i = j
print(*[a + 1 for a in A], sep = "\n")

Measured memory_bytes: 80084
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i, n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";

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 modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}


signed main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) cout << a * b << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <vector>
#include <iostream>

using namespace std;
string s, t;

set <string> T;

struct data
{
	string t, s;
} a [10];

int n, d [100000], step;
string str;
vector <string> q;

bool ck (string s, int tp)
{
	string hehe = "";
	for (int now = 0; now < (int) s.length (); )
	{
		if (s.substr (now, a[tp].t.length ()) == a[tp].t)
		{
			hehe += a[tp].s;
			now += (int) a[tp].t.length ();
		}
		else
		{
			hehe += s[now];
			++now;
		}
	}
	return str == hehe;
}

bool dfs (string ts, int tp, int now)
{
	if (now == (int) str.length ())
	{
		if (T.find (ts) == T.end () && ck (ts, tp))
		{
			T.insert (ts);
			d[q.size ()] = step + 1;
			q.push_back (ts);
			if (ts == t)
				return 1;
		}
		return 0;
	}
	bool flag = 0;
	if (str.substr (now, a[tp].s.length ()) == a[tp].s)
		flag |= dfs (ts + a[tp].t, tp, now + (int) a[tp].s.length ());
	flag |= dfs (ts + str[now], tp, now + 1); 
	return flag;
}

void bfs ()
{
	T.clear ();
	T.insert (s);
	q.clear ();
	q.push_back (s);
	string x = s;
	d[0] = 0;
	for (int head = 0; head < (int) q.size (); x = q[++head])
	{
		str = x;
		step = d[head];
		for (int i = 0; i < n; ++i)
			if (x.find (a[i].s) != string:: npos)
			{
				if (dfs ("", i, 0))
				{
					cout << step + 1 << endl;
					return ;
				};
			}
		if (head == (int) q.size () - 1) break;
	}
	cout << -1 << endl;
}

int main ()
{
	while (1)
	{
		cin >> n;
		if (n == 0) break;
		T.clear ();
		for (int i = 0; i < n; ++i) cin >> a[i].t >> a[i].s;
		cin >> t;
		cin >> s;
		bfs ();
	}
	return 0;
}

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

int main()
{
  int N, K, Q;cin >> N >> K >> Q;
  vector<int> players(N, 0);
  rep(i, Q) {
    int A; cin >> A;
    players.at(A-1)++;
  }

  rep (i, players.size()) {
    cout << ((K - Q + players.at(i) > 0) ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
const int maxn=1e5+10;

int main()
{
    int sx,sy,tx,ty;
    scanf("%d%d%d%d",&tx,&ty,&sx,&sy);
    for(int i = ty; i < sy; ++i) {
        printf("U");
    }
    for(int i = tx; i < sx; ++i) {
        printf("R");
    }
     for(int i = ty; i < sy; ++i) {
        printf("D");
    }
    for(int i = tx; i < sx; ++i) {
        printf("L");
    }
    printf("L");
     for(int i = ty; i < sy+1; ++i) {
        printf("U");
    }
    for(int i = tx; i < sx+1; ++i) {
        printf("R");
    }
    printf("DR");
     for(int i = ty; i < sy+1; ++i) {
        printf("D");
    }
    for(int i = tx; i < sx+1; ++i) {
        printf("L");
    }
    printf("U\n");
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def prime_factorize(N):
    res = []
    for i in range(2, int(math.sqrt(N)) + 1):
        if N % i != 0:
            continue

        num = 0
        while N % i == 0:
            N /= i
            num += 1
        
        res.append([i, num])

    if N != 1:
        res.append([N, 1])

    return res


N = I()
P = prime_factorize(N)

ans = 0
for p in P:
    p = p[1]
    tmp = 0

    for i in range(1, 10**12):
        if p >= i:
            p -= i
            tmp += 1
        else:
            break
    
    ans += tmp

print(ans)


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

int main() {
  int n;
  cin>>n;
  long long a[210],b[210];
  a[0]=0;
  a[1]=1;
  b[0]=0;
  b[1]=1;
  long long ans=0,count=0;
  for(int i=2;i<201;i++){
    for(int j=i;j>1;j--){
        ans+=j*b[i/j];
        count+=b[i/j];
      }
      b[i]=i*i*i-count;
    a[i]=ans+b[i];
    count=0;
    ans=0;
  }
  cout<<a[n]<<endl;
}





Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
int32_t main()
{
	int a,b,c,d;cin >> a >> b >> c >> d;
	int ans = max({a*c,a*d,b*c,b*d});
	if(0 >= a and 0 <= b) ans = max(ans,0LL);
	if(0 >= c and 0 <= d) ans = max(ans,0LL);
	cout << ans;nl;
    		
}

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

int main() {
    int a,b;cin>>a>>b;
    if(2*b>a)cout<<0<<endl;
    else cout<<a-2*b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    string s3=s2.substr(0,s1.length());
   // cout<<s3<<endl;
    if(s3==s1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<vector>
#include<set>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = (int)1e5 + 5;
using namespace std;

int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	if(x < a || x > a + b) puts("NO");
	else puts("YES");
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct Edge{
    ll dst;
    ll weight;
    Edge(ll dst, ll weight): dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const ll INFLL = LLONG_MAX/3;
const ll MAX_V = 500;

ll dist[MAX_V][MAX_V];

void WarhshallFloyd(Graph &G){
	ll V = G.size();
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(i==j) dist[i][j] = 0;
			if(i!=j) dist[i][j] = INFLL;
		}
	}
	for(int i=0;i<V;i++){
		for(int j=0;j<(int)G[i].size();j++){
			Edge e = G[i][j];
			dist[i][e.dst] = e.weight;
		}
	}

	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	return;
}

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

    ll N, M, L;
    cin >> N >> M >> L;
    Graph G(N), H(N);
    REP(i, M){
    	ll A, B, C;
    	cin >> A >> B >> C;
    	A--, B--;
    	Edge e(B, C);
    	Edge f(A, C);
    	G[A].push_back(e);
    	G[B].push_back(f);
    }

    WarhshallFloyd(G);

    /*
    REP(i, N){
    	REP(j, N){
    		cout << dist[i][j] << " ";
    	}
    	cout << endl;
    }
    */

    REP(i, N){
    	REP(j, N){
    		if(dist[i][j] <= L){
    			Edge e(j, 1);
		    	Edge f(i, 1);
		    	H[i].push_back(e);
		    	H[j].push_back(f);
    		}
    	}
    }

    WarhshallFloyd(H);

    ll Q;
    cin >> Q;

    REP(i, Q){
    	ll s, t;
    	cin >> s >> t;
    	s--, t--;
    	cout << (dist[s][t]>=INFLL ? -1 : dist[s][t]-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 8576
#define ll long long
#define ldd long double
#define mpp make_pair
#define pb push_back
#define ff first
#define ss second
#include<bits/stdc++.h>
using namespace std;
int main(){
    ll n,m,y,x,z,h,t,i,j,k;
    ll cnt=0,cnt1=0,sum=0,sum1=0,flag=0,flag1=0,maxi=LLONG_MIN,mini=LLONG_MAX,temp=0,ans=0;
    //freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>temp;
        sum+=temp;
    }
    if(sum<=n){
        cout<<n-sum<<endl;
    }
    else
        cout<<-1<<endl;
return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string t;
    cin >> t;
    ll n=t.size();
    ll sum=0;
    ll ctr=0;
    rp(i,n){
        if(t[i]=='0'){
            if(i&1){
                if(ctr&1){
                    sum+=(ctr+1)/2;
                    ctr++;
                }
                else sum+=ctr/2;
            }else{
                if(ctr%2==0){
                    sum+=ctr/2+1;
                    ctr++;
                }
                else sum+=(ctr+1)/2;
            }
        }
    }
    if(n&1){
        print((n/2)*(n/2+1)+(n+1)/2-sum);
    }
    else print((n/2)*(n/2+1)-sum);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3788
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int r = sc.nextInt();

        if (r < 1200) {
            System.out.println("ABC");
        } else if (r < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
    }
}


Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = 1; i < 12; i++){
        if(i*1000 >= n){
            cout << i*1000-n << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
n=int(input())
c=0
l=[3,5,7]
L=[]
for i1 in l:
  for i2 in l:
    for i3 in l:
      for i4 in l:
        for i5 in l:
          L.append(10000*i1+1000*i2+100*i3+10*i4+i5)
for i in range(min(n+1,10000)):
  l=str(i)
  if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
for j in L:
  for i in range(j,n+1,100000):
    l=str(i)
    if '3' in l and '5' in l and '7' in l and '0' not in l and '1' not in l and '2' not in l and '4' not in l and '6' not in l and '8' not in l and '9' not in l:c+=1
print(c)

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

int main(){
  int a[100];
  for (int i = 0; i < 100; i++ ) {
      a[i] = 0;
  }
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    int num;
    cin >> num;
    a[i] = num;
  }
  sort(a, a+N, greater<int>());
  int A=0;
  int B=0;
  for(int i=0;i<N;i = i+2){
    A += a[i];
    B += a[i+1];
  }
  int q = A - B;
  cout << q << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	double r;
	cin >> r;
	cout << fixed;
	cout << setprecision(20) << r * r * 3.141592653589 << " " << r * 2 * 3.141592653589 << endl;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
/* Coding Space*/
int main(){
  int n,a,b; cin >> n >> a >> b;
  cout << min(b,n*a) << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int a[3];
    int damy;
    cin >> a[0] >> a[1] >> a[2];
    
    for(int i = 0; i < 3; i++)
    {
        for(int j = i; j > 0; j--)
        {
            if(a[j] < a[j-1])
            {
            damy = a[j];
            a[j] = a[j-1];
            a[j-1] = damy;
            }
        }
    }
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
using namespace std;
typedef pair<double, int> pdi;
typedef long long int ll;

int main() {
    int n; cin >> n;
    vector<pdi> a(n);
    vector<int> ans(n);
    rep(i,0,n) {
        double inp; cin >> inp;
        a[i] = make_pair(inp, i);
    }

    sort(a.begin(), a.end());
    rep(i,0,n) {
        pdi init = make_pair(a[i].first, -1);
        int win = lower_bound(a.begin(), a.end(), init) - a.begin();
        pdi temp = make_pair(a[i].first, 20000000);
        int k = upper_bound(a.begin(), a.end(), temp) - a.begin() - 1;
        int draw = k - win;
        int lose = n - draw;   

        // printf("debug: win = %d, draw = %d, idx = %d\n", win, draw, a[i].second);
        
        int point = 3 * win + 1 * draw;
        ans[ a[i].second ] = point;    
    }

    rep(i,0,n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4592
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int N;
  N = s.size();
  int count=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      if(s.at(i)== 'R' || s.at(i)== 'U' || s.at(i)== 'D'){
        continue;
      }
      else{
        count = count + 1;
        break;
      }
    }
    else{
      if(s.at(i)== 'L' || s.at(i)== 'U' || s.at(i)== 'D'){
        continue;
      }
      else{
        count = count + 1;
        break;
      }
    }
  }
  if(count==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String nl = System.getProperty("line.separator");
		StringBuilder p = new StringBuilder(1000);
		StringBuilder d = new StringBuilder(".");
		StringBuilder s = new StringBuilder("#");
		StringBuilder k = new StringBuilder(100);
		Scanner r = new Scanner(System.in);
		int h, w, i, ww;
		String u;
		for (i = 0; i < 4; ++i) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		for ( ; (h = r.nextInt()) + (w = r.nextInt()) > 0; ) {
			for ( ; w > ww; ww += ww) {
				d.append(d);
				s.append(s);
			}
			p.append(u = s.substring(0,w)).append(nl);
			k.setLength(0);
			k.append(d.substring(0, w)).append(nl)
			.replace(0, 1, "#").replace(w - 1, w, "#");
			for (i = h - 2; i > 0; --i) {
				p.append(k);
			}
			p.append(u).append(nl).append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18380
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> p(n), q(n), r(n);
	REP(i, n) {
		cin >> p[i];
	}
	REP(i, n) {
		cin >> q[i];
	}
	REP(i, n) {
		r[i] = i + 1;
	}
	int ind = 0;
	int a, b;
	do {
		bool flag = true;
		REP(i, n) {
			if (p[i] != r[i]) {
				flag = false;
			}
		}
		if (flag) {
			a = ind;
		}
		flag = true;
		REP(i, n) {
			if (q[i] != r[i]) {
				flag = false;
			}
		}
		if (flag) {
			b = ind;
		}
		ind++;
	} while (next_permutation(all(r)));
	put(abs(a - b));
	return 0;
}


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

std::vector<int> digits(long n);
bool isPalindrome(std::vector<int> digits);

int main() {
    long a, b, p = 0;
    std::cin >> a >> b;

    while(a <= b) {
        if(isPalindrome(digits(a))) {
            ++p;
        }

        ++a;
    }

    std::cout << p << "\n";
}

// ------------------------------------------------------- //
std::vector<int> digits(long n) {
    std::vector<int> vec;

    while(n > 0) {
        vec.push_back(n % 10);
        n /= 10;
    }

    return vec;
}

bool isPalindrome(std::vector<int> digits) {
    int i = 0;
    int j = digits.size()-1;

    while(i < j) {
        if(digits[i] != digits[j]) {
            return false;
        }

        ++i;
        --j;
    }

    return true;
}

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

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vector<pair<ll,ll> > combi(M);
    rep(i,M){
        cin >> combi[i].first >> combi[i].second;
    }
    vector<pair<ll,ll> > ans_vec(0);
    rep(i,N){
        ans_vec.push_back(pair<ll,ll>(vec[i],1));
    }
    rep(i,M){
        ans_vec.push_back(pair<ll,ll>(combi[i].second, combi[i].first));
    }
    sort(all(ans_vec));
    ll len = ans_vec.size();
    ll ans = 0;
    ll cnt = 0;
    for (ll i = len - 1; i >= 0; i--){
        if (cnt + ans_vec[i].second <= N){
            ans += ans_vec[i].first * ans_vec[i].second;
            cnt += ans_vec[i].second;
        }
        else{
            ans += ans_vec[i].first * (N - cnt);
            cnt = N;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, sum = 0;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10)
      sum ++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    int l[n];
    for(int i=0; i<n; i++){
        scanf("%d", &l[i]);
    }
    int c=1, y=0;
    for(int i=0; i<n; i++){
        y += l[i];
        if(y <= x){
            c++;
        }
    }
    printf("%d", c);

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

bool primeCheck(int n, int k) {
	if (k == 1) return true;
	return (n % k != 0) && primeCheck(n, k - 1);
}

void solve_abc149_c() {
	ll X;
	ll ans;

	cin >> X;

	ans = 0;
	rep2(i, X, 2 * X){
		if (primeCheck(i, sqrt(X))){
			ans = i;
			break;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc149_c();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 200005
int head[M],to[M<<1],nxt[M<<1],tot;
inline void add(int a,int b){
	to[++tot]=b;
	nxt[tot]=head[a];
	head[a]=tot;
}
int n,sg[M];
void dfs(int x,int f){
	for(int i=head[x];i;i=nxt[i]){
		int y=to[i];
		if(y==f)continue;
		dfs(y,x);
		sg[x]^=(sg[y]+1);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b),add(b,a);
	}
	dfs(1,0);
	if(sg[1])puts("Alice");
	else puts("Bob");
	return 0;
}

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

int main(){
    int ans =0;
    int max = 0;
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i,N) cin >> H[i];
    for(int j = N-2; j>= 0;j--){
        if(H[j] >= H[j+1]){
            ans++;
            if(max < ans){
                max = ans;
            }
        }
        else{
            ans=0;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N);
  VEC(ll, T, N);
  VAR(ll, M);
  vl P(M), X(M);
  rep(i, 0, M) {
    in(P[i], X[i]);
  }
  ll ans = accumulate(all(T), 0);
  rep(i, 0, M) {
    print(ans - T[P[i] - 1] + X[i]);
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

  double a,b;

  while(scanf("%lf %lf",&a,&b)!=EOF)
    {
      if(a<35.5 && 71>b) printf("AAA\n");
 
      else if(a<37.5 && 77>b) printf("AA\n");
 
      else if(a<40 && 83>b) printf("A\n");

      else if(a<43 && 89>b) printf("B\n");

      else if(a<50 && 105>b) printf("C\n");

      else if(a<55 && 116>b) printf("D\n");

      else if(a<70 && 148>b) printf("E\n");
 
      else printf("NA\n");
    }

  return 0;
}

Measured memory_bytes: 608