akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    vector<int> e(1000001,0);
    for(int i = 0; i < N; ++i) e[A[i]]++;
    for(int i = 1; i < 1000001; ++i) {
        if(!e[i]) continue;
        for(int j = 2*i; j < 1000001; j += i) {
            e[j]=0;
        }
        if(e[i]!=1) e[i]=0;
    }   
    int ans = 0;
    for(int i = 0; i < N; ++i) ans += e[A[i]];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7988
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int H=Integer.parseInt(sc.next());
		int N=Integer.parseInt(sc.next());
		int aaa = 0;
		for(int i=0;i<N; i++) {
			aaa += Integer.parseInt(sc.next());
		}
		if(aaa>=H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i,n){
		cin >> h[i];
	}
	
	vector<int> cost(n);
	rep(i,n){
		cost[i] = INF;
	}
	cost[0] = 0;
	
	rep(i,n-1){
		for (int j = 1; j <= k ; ++j) {
			if (i-j+1 >= 0){
				cost[i+1] = min(cost[i+1], cost[i+1-j] + abs(h[i+1] - h[i+1-j]));
			}
		}
	}
	
	cout << cost[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
    int N,X,T;
    scanf("%d %d %d",&N,&X,&T);
    if (N <= 1000)
    {
        if (X <= 1000)
        {
            if (T <= 1000)
            {
                if ((N % X) == 0)
                {
                    printf("%d",N/X*T);
                }
                else
                {
                    printf("%d",((N/X)+1)*T);
                }
            }
            else
            {
            }
        }
        else
        {
        }
    }
    else
    {
    }
}

Measured memory_bytes: 1736
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b, h;
    
    scanf("%d%d%d", &a, &b, &h);
    
    printf("%d", (a+b)*h/2);
    
    return 0;
}



Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c;
  cin >> a >> b >> c;
  rep(i, 1, b + 1) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define X first
#define Y second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll>P;

int main(){
  int N,K;
  cin >> N >> K;
  vector<P>points;
  set<int> set_y;
  set<int> set_x;
  for(int i = 0 ; i < N ; i++){
    int x,y;
    cin >> x >> y;
    points.push_back(P(x,y));
    set_x.insert(x);
    set_y.insert(y);
  }

  vector<int>vec_y = vector<int>(set_y.begin(), set_y.end());
  vector<int>vec_x = vector<int>(set_x.begin(), set_x.end());

  vector<P> candidates;
  for(int i = 0 ; i < vec_y.size() ; i++){
    for(int j = 0 ; j < vec_x.size() ; j++){
      candidates.push_back(P(vec_x[j],vec_y[i]));
    }
  }

  ull area = 1e19;

  for(int i = 0 ; i < candidates.size() ; i++){
    for(int j = 0 ; j < candidates.size() ; j++){
      if(i == j)continue;
      P p1 = candidates[i];
      P p2 = candidates[j];

      P sp = P(min(p1.X, p2.X), min(p1.Y, p2.Y));
      P ep = P(max(p1.X, p2.X), max(p1.Y, p2.Y));

      int count = 0;

      for(int k = 0 ; k < points.size() ; k++){
        P p = points[k];
        if(!(sp.X <= p.X && p.X <= ep.X))continue;
        if(!(sp.Y <= p.Y && p.Y <= ep.Y))continue;

        count++;
        if(count == K){

          ull a = ull(ep.X - sp.X) * ull(ep.Y - sp.Y);
          area = min(area,a);
          break;
        }
      }
    }
  }
  cout << area << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	new DPL4().doIt();
    }
    class DPL4{
    	ArrayList<Integer> array = new ArrayList<Integer>();
    	int bsp(int num){
    		int first = 0;
    		int last = array.size()-1;
    		int mid = 0;
    		if(first < last)mid = first / last;;
    		if(array.get(last) < num)return array.size();
    		while(last - first > 1){
    			if(array.get(mid) < num){
    				first = mid;
    				mid = (mid + last)/2;
    			}
    			else{
    				last = mid;
    				mid = (mid + first)/2;
    			}
    		}
    		if(array.get(first) > num)return first;
    		else return last;
    	}
    	void doIt(){
    		int n = sc.nextInt();
    		for(int i = 0;i < n;i++){
    			int num = sc.nextInt();
    			if(array.size() == 0)array.add(num);
    			else{
    				int pos = bsp(num);
    				if(pos == array.size())array.add(num);
    				else array.set(pos,num);
    			}
    		}
    		System.out.println(array.size());
    	}
    }
}

Measured memory_bytes: 70100
N = int(input())
S = []
for i in range(N):
    S.append(input())
T = []
for i in range(N):
    tmp = ''
    for j in range(N):
        tmp += S[j][i]
    T.append(tmp[:])
#print(S)
#print(T)

ans = 0
for i in range(N):
    #print(i)
    flag = True
    for y in range(N):
        #print(S[y][i:]+S[y][:i])
        #for x in range(N):
            #if x==y:
            #    continue
            #print(x,y,(x+i)%N, S[y][(x+i)%N],S[(x+i)%N][y])
            #if S[y][(x+i)%N]!=S[(y+i)%N][x]:
        #print(y, T[(y+i)%N], S[y][i:]+S[y][:i])
        if T[(y+i)%N]!=S[y][i:]+S[y][:i]:
            flag = False
            break
    if flag:
        ans += 1

print(ans*N)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		System.out.println(kaijo(scan.nextLong()));
	}

	private static long kaijo(long n){
		if(n == 0){
			return 1;
		}else{
			return n * kaijo(n - 1);
		}
	}
}

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

int N;
vector<int> arr;

int main() {
    scanf("%d", &N);
    arr.resize(N);
    int mx = 0, mn = 1e9;
    for(int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);
        mx = max(mx, arr[i]);
        mn = min(mn, arr[i]);
    }

    if((mx + 1) / 2 > mn) {
        printf("Impossible");
        return 0;
    }

    vector<int> chk(mx + 1, 0);
    for(int i = 0; i < N; i++) {
        chk[ arr[i] ]++;
    }
    for(int i = mx; i >= (mx + 1) / 2; i--) {
        if(mx % 2 == 0 && i == mx / 2) {
            if(chk[i] == 1) continue;
            else {
                printf("Impossible");
                return 0;
            }
        }
        if(mx % 2 == 1 && i == (mx + 1) / 2) {
            if(chk[i] == 2) continue;
            else {
                printf("Impossible");
                return 0;
            }
        }
        if(chk[i] < 2) {
            printf("Impossible");
            return 0;
        }
    }
    printf("Possible");
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

int main() {
    int x, n; cin >> x >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v.at(i);
    }
    int sub = 1000000;
    int ans;
    rep(i, 102){
        bool flag = false;
        for(auto j : v){
            if(i == j) {
                flag = true;
                break;
            }
        }
        if(flag) continue;
        if(sub > abs(x-i)){
            sub = abs(x-i);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (a[a[i] - 1] == i + 1) {
      res++;
    }
  }
  std::cout << res / 2 << std::endl;
}

Measured memory_bytes: 640
# coding:utf-8

import sys
from collections import Counter, deque

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


N = I()
A = [I() for _ in range(N)]

A.sort()
B = deque()

state = 1
for i in range(N // 2):
    if state:
        B.append(A[i])
        B.appendleft(A[-(i + 1)])
    else:
        B.append(A[-(i + 1)])
        B.appendleft(A[i])
    state ^= 1
if N % 2:
    median = A[N // 2]
    if abs(B[0] - median) < abs(B[-1] - median):
        B.append(median)
    else:
        B.appendleft(median)

ans = 0
for i in range(N - 1):
    ans += abs(B[i] - B[i + 1])
print(ans)


Measured memory_bytes: 8156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }

    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3636
#include<cmath>
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e,f,k;
  cin>>a>>b>>c>>d>>e>>k;
  f=abs(a-e);
  if(f<=k){
  cout<<"Yay!"<<endl;
  }
  else if(f>k){
  cout<<":("<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;

int N,W;
int dp[111][20020];

signed main() {
    IOS();
    cin>>N>>W;
    vint v(N),w(N);
    rep(i,0,N){
        cin>>v[i]>>w[i];
    }
    
    rep(i,0,111)rep(j,0,20020)dp[i][j]=INF;
    dp[0][0]=0;
    rep(i,0,N){
        rep(j,0,10010){
            if(dp[i][j]==INF)continue;
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j+v[i]],dp[i][j]+w[i]);
        }
    }
    
    int ans=0;
    rep(j,0,20020){
        if(dp[N][j]>W)continue;
        chmax(ans,j);
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 20560
package main

import "fmt"

func main() {
	var d, t, s int
	fmt.Scanf("%d %d %d", &d, &t, &s)

	i := d / s
	if d%s != 0 {
		i += 1
	}

	if i <= t {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main()
{
	char c;
	int d, a;
	ld x = 0, y = 0;
	int deg = 90;
	while (cin >> d >> c >> a, d | a) {
		ld ar = deg * acosl(-1) / 180;
		x += d * cosl(ar);
		y += d * sinl(ar);
		deg -= a;
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}

Measured memory_bytes: 3292
import sys
import copy
from collections import deque

def main():
    s = []
    for _ in range(3):
        s += list(map(int,input().split()))
    goal = [1,2,3,4,5,6,7,8,0]
    st = set()
    inf = 1000000007
    move = [[1,3], #0がi番目にいる時に交換できる位置
            [0,2,4],
            [1,5],
            [0,4,6],
            [1,3,5,7],
            [2,4,8],
            [3,7],
            [4,6,8],
            [5,7]]

    def bfs():
        k = 0
        for i in range(9):
            if s[i] == 0: k = i #空の位置
        dq = deque()
        dq.append([s, k, 0]) #局面、0の位置、ステップ数
        st.add(''.join(map(str, s)))
        while dq:
            state = dq.popleft()
            t, i, steps = state[0], state[1], state[2]
            if t == goal: return steps
            for j in move[i]:
                u = copy.copy(t)
                u[i], u[j] = u[j], u[i] #0を移動
                if ''.join(map(str, u)) in st:continue #同一局面があったのでスキップ
                dq.append([u, j, steps+1])
                st.add( ''.join(map(str, u)))

    print (bfs())

if __name__ == '__main__':
    main()





Measured memory_bytes: 33180
import Data.List

main = do
    let toInt = (read :: String -> Int)
    line1 <- getLine
    let ws = words line1
    let n = toInt $ ws !! 0
    let k = toInt $ ws !! 1
    line2 <- getLine
    let ps = take n $ map toInt $ words line2
    print $ sum $ take k $ sort ps


Measured memory_bytes: 5092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] hw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();


                if (hw[0] == 0 && hw[1] == 0)
                {
                    break;
                }
                for(int i = 0; i < hw[0]; i++)
                {
                    for(int j = 0; j < hw[1]; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9420
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
sys.setrecursionlimit(500000)


N,A,B,C = map(int,input().split())
ABC = [A,B,C]
S = []
SS = ('A','B','C')
d = [0,0,0]
flag = True
for i in range(N):
    s = input()
    if s=="AB":
        S.append(2)
        d[0] += 1
        d[1] += 1
    elif s=="BC":
        S.append(0)
        d[1] += 1
        d[2] += 1
    else:
        S.append(1)
        d[2] += 1
        d[0] += 1
ans = []
for i in range(N):
    x,y = (S[i]+1)%3,(S[i]+2)%3
    if ABC[x]<ABC[y]:
        ans.append(SS[x])
        ABC[y] -= 1
        ABC[x] += 1
    elif ABC[x]>ABC[y]:
        ans.append(SS[y])
        ABC[y] += 1
        ABC[x] -= 1
    else:
        if i < N-1:
            if S[i+1]==y:
                ans.append(SS[x])
                ABC[y] -= 1
                ABC[x] += 1
            else:
                ans.append(SS[y])
                ABC[y] += 1
                ABC[x] -= 1
        else:
            ans.append(SS[y])
            ABC[y] += 1
            ABC[x] -= 1




    if ABC[0]<0 or ABC[1]<0 or ABC[2]<0:
        flag = False
        break


if flag:
    print('Yes')
    print(*ans,sep='\n')
else:
    print('No')








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

int xxx(int v)
{
    int s=0;
    while(v)s+=v%10,v/=10;
    return s;
}
int main()
{
    int n,x,y,s=0;
    cin>>n>>x>>y;

    for(int i=1;i<=n;i++)
    {
        int k=xxx(i);
        if(k>=x&&k<=y)s+=i;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll t=0,c=0,d=0,h,w,n,min=100000000000,k,ans=0;
    string s,s2;
    cin >> s >>s2;
    for(int i=0;i<3;i++){
        if(s[i]==s2[i]) t++;
    }
    
    cout << t <<endl;

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, A, B = map(int, rl().split())
    s = [[0] * W for _ in range(H)]
    for i in range(B):
        for j in range(A, W):
            s[i][j] = 1
    for i in range(B, H):
        for j in range(A):
            s[i][j] = 1
    for si in s:
        print(''.join(map(str, si)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 51164
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<3;i++){
    if(s[i]=='R'){
      ans++;
    }else if(ans!=0){
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
//e4-e5-f4
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
//#include "ext/pb_ds/assoc_container.hpp"
//#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define PI 3.14159265359
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define sl set<ll>
#define usl unordered_set<ll>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vpl vector<pll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define P 1000000007
#define Q 1000000006
#define inf 1e18
#define N 100005
#define M 105
//using namespace boost::multiprecision; 
//using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);
vl adj[N];
ll vis[N], b[N], w[N];
void dfs(ll s){
    ll black=1,white=1;
    for(auto u:adj[s]){
        if(!vis[u]){
            vis[u]=1;
            dfs(u);
            (black *= w[u]) %= P;
            (white *= (w[u]+b[u])%P ) %= P;
        }
    }
    b[s] = black;
    w[s] = white;
}
void solve(){
    ll n;
    cin>>n;
    f(i,1,n){
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    vis[1]=1;
    dfs(1);
    cout<<(b[1]+w[1])%P;
}

signed main() {
    teevra_gati
        
    solve();

    return 0;
}

Measured memory_bytes: 19760
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a, b,c,d;
    string S;
    //cin >> S;
    cin >> a>>b>>c;//>>d;
    ll answer = 0;

    answer = min(a*b,c);
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define MAX_N 10000
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;
int dp[MAX_N]={};
bool d[MAX_N]={};
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<P> v[100001];
int main() {
	int n;
	cin>>n;
	int a[100001]={};
	rep(i,n){
		int a1;
		cin>>a1;
		a[a1]++;
	}
	bool flg=true;
	if(n%2==0){
		rep(i,n/2){
			if(a[i*2+1]!=2)flg=false;
		}
	}else{
		if(a[0]!=1)flg=false;
		rep(i,n/2){
			if(a[i*2+2]!=2)flg=false;
		}
	}
	ll t=1;
	if(flg){
		rep(i,n/2)t=(t*2)%1000000007;
		cout<<t<<endl;
	}else{
		cout<<"0"<<endl;
	}

	return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    double N=sc.nextInt();
    double ans;
    double count=0;
    for(int i=1; i<=N; i++){
      if(i%2.0==1){
        count++;
      }
    }
    ans=count/N;
    System.out.println(ans);

  }
}


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

int n,arr[2][510],ans[2][510];

int main()
{
    cin>>n;
    for(int i=0;i<2;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];
    ans[0][0]=arr[0][0];
    for(int i=1;i<n;i++)
    	ans[0][i]=ans[0][i-1]+arr[0][i];
    ans[1][0]=arr[0][0]+arr[1][0];
    for(int i=1;i<n;i++)
        ans[1][i]=max(ans[0][i],ans[1][i-1])+arr[1][i];
    cout<<ans[1][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
	string s;
	char a[15];
	int w=0;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='0')
		{
			w++;
			a[w]=s[i];
		}
		if(s[i]=='1')
		{
			w++;
			a[w]=s[i];
		}
		if(s[i]=='B')
		{
			if(w==0)
			{
				continue;
			}
			else
			{
				w--;
			}
		}
	}
	for(int i=1;i<=w;i++)
	{
		printf("%c",a[i]);
	}
	printf("\n");
	return 0;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  int a, b;
  bool flag;
  string s;
  string num="1234567890";
  cin >> a >> b;
  cin >> s;

  for(int i=0; i<a; i++){
    for(int j=0; j<10; j++){
      if(s[i]==num[j]){
      flag=true;
      }
    }
    if(!flag){
      cout << "No" << endl;
      return 0;
    }
    flag=false;
  }

  flag=false;

  if(s[a]!='-'){
    cout << "No" << endl;
    return 0;
  }

  for(int i=0; i<b; i++){
    for(int j=0; j<10; j++){
      if(s[a+1+i]==num[j]){
      flag=true;
      }
    }
    if(!flag){
      cout << "No" << endl;
      return 0;
    }
    flag=false;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int l,r; cin >>  l >> r;
  int ans = 2018;
  FOR(i,l,l+2022){
      FOR(j,i+1,i+2022){
          if(l<=i && i <= r && l <= j && j <= r){
              ans = min(ans , ((i%2019)*(j%2019))%2019);
          }
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

main() {
  int  a, b, d, r;
  double f;

  scanf("%d %d", &a, &b);

  d = a / b;
  r = a % b;
  f =(double)a / (double)b;

  printf("%d %d %f\n", d, r, f);

  return 0;
}

Measured memory_bytes: 636
N = int(input())
for h in range(3501):
    for n in range(3501):
        if 4*h*n - N*n - N*h == 0:
            continue
        w = N*h*n / (4*h*n - N*n - N*h)
        if w > 0 and int(w) == w:
            print(h, n, int(w))
            exit()


Measured memory_bytes: 40684
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

const int MAXN = 1000005;
int main() {
  int s;
  cin >> s;
  vector<int> a(MAXN);
  bool ok = false;
  int i = 1;
  a[0] = 0;
  a[1] = s;
  while(!ok) {
    i++;
    if(a[i - 1] % 2 == 0)
      a[i] = a[i - 1] / 2;
    else
      a[i] = 3 * a[i - 1] + 1;
    rep(j, i) if(a[j] == a[i]) ok = true;
  }
  cout << i << endl;
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n;
int a[2][100],dp[2][100];

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

	cin>>n;
	REP(i,2) REP(j,n) cin>>a[i][j];
	dp[0][0]=a[0][0];
	REP(i,2) {
		REP(j,n) {
			if(i==0&&j==0) continue;
			if(i==0) dp[i][j]=max(dp[i][j],dp[i][j-1]+a[i][j]);
			else {
				if(j!=0) dp[i][j]=max(dp[i][j],dp[i][j-1]+a[i][j]);
				dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i][j]);
			}
		}
	}
	cout<<dp[1][n-1]<<endl;

	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back
#define ll long long
#define MOD 1000000007

int abs(int x)
{
  if (x < 0) return - x;
  return x;
}

int main(void)
{
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vec<int> l(n);
  rep(i, n) cin >> l[i];
  int ans = MOD;

  rep(i, 1 << (2 * n)) {
    int t = - 30;
    int x = 0, y = 0, z = 0;
    int flag0 = 0, flag1 = 0, flag2 = 0;
    rep(j, n) {
      int st = (i >> (2 * j)) % 4;
      if (st == 0) {
        x += l[j];
        flag0 = 1;
      } else if (st == 1) {
        y += l[j];
        flag1 = 1;
      } else if (st == 2) {
        z += l[j];
        flag2 = 1;
      }
      if (st < 3) t += 10;
    }
    if (flag0 * flag1 * flag2 == 0) continue;
    t += abs(a - x);
    t += abs(b - y);
    t += abs(c - z);

    if (t < ans) ans = t;
  }
  cout << ans << endl;
  return 0;
}


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

class Main {

	void solve() {

		int x = inint(), a = inint(), b = inint();
		out.println((x-a)%b);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 23636
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=[-10**9]+A+[10**9]
#print(A)

import bisect

H=A[-2]*2
L=0

while abs(H-L)>2:
    Mid=(H+L)//2
    #print(H,Mid,L)
    cnt=0
    for i in range(1,N+1):
        cnt+=N+1-bisect.bisect_left(A,Mid-A[i])
        
    if cnt>M:
        L=Mid
    else:
        H=Mid
#print(L,H)
X=0
Y=0
Yc=0
for j in range(15):
    Mid2=L-4+j
    cnt=0
    for i in range(1,N+1):
        cnt+=N+1-bisect.bisect_left(A,Mid2-A[i])
        #print(Mid2,cnt)
    if cnt>M:
        X=Mid2
        Xc=cnt
    elif cnt==M:
        X=Mid2
        Y=Mid2
        Yc=cnt
    else:
        Y=Mid2
        Yc=cnt
        break
#print(X,Y)


R=[0]
for i in range(1,len(A)):
    R.append(R[-1]+A[i])
#print(R)
ans=0
for i in range(1,N+1):
    cnt=N+1-bisect.bisect_left(A,Y-A[i])
    #print(cnt)
    if cnt>0:
        ans+=cnt*A[i]
        ans+=R[N]-R[N-cnt]
        #print(ans)
    #print(ans)
ans+=X*(M-Yc)
print(ans)

Measured memory_bytes: 65568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll n,q;
string s;
char t[200020],d[200020];
int solt(ll x){
    for(int i = 0; i < q; i++){
        if(s[x] == t[i]){
            if(d[i] == 'L') x--;
            if(d[i] == 'R') x++;
        }
        if(x == -1) return 1;
        if(x == n) return 2;
    }
    return 0;
}
int main(){
    cin >> n >> q >> s;
    for(int i = 0; i < q; i++){
        cin >> t[i] >> d[i];
    }
    ll mid;
    ll ls = -1; 
    ll rs = n;
    while(ls < rs-1){
        mid = (ls + rs)/2;
        if(solt(mid) == 1) ls = mid;
        else rs = mid;
    }
    ll lt = -1;
    ll rt = n;
    while(lt < rt-1){
        mid = (lt+rt)/2;
        if(solt(mid) == 2) rt = mid;
        else lt = mid;
    }
    cout << rt - ls - 1 << endl;
    return 0;
}



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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;

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 n, m;
vvint G;
int dp[100005];
vint deg;   //各頂点の入次数

void Main() {
    cin >> n >> m;
    G.assign(n, vint());
    deg.assign(n, 0);
    rep(i, m) {
        int x, y; cin >> x >> y;
        --x, --y;
        G[x].pb(y);
        ++deg[y];
    }

    qint q;
    rep(v, n) {
        if (deg[v] == 0)q.push(v);
    }

    // BFS
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (const auto& nv : G[v]) {
            deg[nv]--;
            if (deg[nv] == 0) {
                q.push(nv);
                chmax(dp[nv], dp[v] + 1);
            }
        }
    }

    int res = 0;
    rep(i, n)chmax(res, dp[i]);
    cout << res << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,N;
  string S;
  cin >>N>>S>>K;
  char t=S.at(K-1);
  string ans;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=t){ans.push_back('*');}
    else{ans.push_back(S.at(i));}
  }
   cout <<ans<<endl;
}

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

using namespace std;
map<int,int>M;
int main()
{
    int n;
    cin>>n;
    int a[n];
    long long int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        M[a[i]]++;
        sum+=a[i];
    }
    int q;
    cin>>q;
    int b[q],c[q];
    for(int i=0;i<q;i++)
    {
        cin>>b[i]>>c[i];
        sum+=(M[b[i]]*(c[i]-b[i]));
        M[c[i]]+=M[b[i]];
        M[b[i]]=0;
        cout<<sum<<endl;
    }

}


Measured memory_bytes: 9228
#include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


vector<int>v;
vector<int>a;
int sum=0;
int c=0;
int m;

void f(int sum,int i){

	if(i==v.size()){
	if(sum%10==0) c++;
    return;
	}

	rep(j,m)

	if(v[i]%2==1) f(sum+(2*a[j])/10+(2*a[j])%10,i+1);
	else f(sum+a[j],i+1);
}

int main(){

    int n,p;
	string ID;

	cin >> n;
	cin >> ID;
	cin >> m;
	rep(i,m){
	cin >> p;
    a.push_back(p);
	}

	reverse(ID.begin(),ID.end());

	rep(i,n){
	if(ID[i]!='*'){
	if(i%2==1)
    sum+=(2*(ID[i]-'0'))/10+(2*(ID[i]-'0'))%10;
	else sum+=ID[i]-'0';
	}
	}

    rep(i,n)
	if(ID[i]=='*')
	v.push_back(i);

    f(sum,0);

    cout << c << endl;

	return 0;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
#define MOD 1000000007

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

    map<string,int> m;
    REP (i,N) {
        string s;
        cin >> s;
        m[s]++;
    }

    cout << SIZE(m) << endl;

    return 0;
}


Measured memory_bytes: 19104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	//Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	
	void prog()
	{
		//cin = new Scanner();

		for (int i = 0; i < 9; i++)
		{
			for (int j = 0; j < 9; j++)
			{
				Console.WriteLine("{0}x{1}={2}",i+1,j+1,(i+1)*(j+1));
			}
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s;
    cin>>s;
    rep(i,0,sz(s)-1){
        if(s[i]=='?') s[i]='D';
    }
    cout<<s<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

Measured memory_bytes: 3736
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Score> scores = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            String s = sc.next();
            int p = sc.nextInt();
            scores.add(new Score(s, p, i));
        }
        Collections.sort(scores, (e1, e2) -> {
            if (!e1.s.equals(e2.s)) {
                return e1.s.compareTo(e2.s);
            } else {
                return e2.score - e1.score;
            }
        });
//        System.out.println(scores);
        for (Score score : scores) {
            System.out.println(score.no);
        }

        sc.close();
    }

    static class Score {
        String s;
        int score;
        int no;

        Score(String s, int score, int no) {
            this.s = s;
            this.score = score;
            this.no = no;
        }

        @Override
        public String toString() {
            return "(s=" + s + ", score=" + score + ", no=" + no + ")";
        }
    }
}


Measured memory_bytes: 26836
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

typedef long long ll;
 string convertToTitle(ll n) {

    string res;

    char tmp;

    while(n){

        n -= 1;

        tmp = 'a' + n % 26;

        res = tmp + res;

        n /= 26;

    }

    return res;

}
int main() {
	ll n;
	cin >> n;
	cout << convertToTitle(n) << endl;

	return 0;
}


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

#define LIM 1000000
int all[LIM];
int odd[LIM];

int main()
{
    for (int i = 0; i < LIM; i++){
        all[i] = i;
        odd[i] = i;
    }
    for (int i = 0; i < LIM; i++){
        int x = i * (i + 1) * (i + 2) / 6;
        if (x > LIM) break;
        for (int j = x; j <= LIM; ++j){
            all[j] = min(all[j], all[j-x] + 1);
        }
        if (x % 2 == 1){
            for (int j = x; j <= LIM; ++j){
                odd[j] = min(odd[j], odd[j-x] + 1);
            }
        }
    }

    int n;
    while (true) {
        cin >> n;
        if (n == 0) break;
        cout << all[n] << " " << odd[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 8972
#include    <stdio.h>

int    main(void)

{ 

    int a,b; 

    scanf("%d",&a);  

    scanf("%d",&b);

    if(a < b){   

    printf("a < b\n"); 

    }

     if(a > b){   

    printf("a > b\n");

    }  

   if(a == b){ 

   printf("a == b\n"); 

    }   

    return 0;

}  

Measured memory_bytes: 580
n = int(input())
edges = [set() for _ in range(n)]
for i in range(n-1):
    u,v,w = [int(i)-1 for i in input().split()] 
    edges[u].add((v,w+1))
    edges[v].add((u,w+1))
ans = [-1]*n
q = [(0,0,-1)]
while q:
    v,d,p = q.pop()
    if d%2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1
    for u,w in edges[v]:
        if u == p:
            continue
        q.append((u,d+w,v))
for i in range(n):
    print(ans[i])


Measured memory_bytes: 53460
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
int n;
char s[12];
void dfs(int step, char c){
    if(step==n + 1){ cout << (s+1) << endl; return; }
    for(char ch = 'a'; ch <= c + 1; ch++) dfs(step+1,max(s[step]=ch,c));
}
int main(){
    cin >> n; dfs(1,'a'-1);
    return 0;
}

Measured memory_bytes: 1536
n, m = map(int, input().split())
AB = []
for i in range(n):
  AB.append(list(map(int, input().split())))
AB.sort()
use = 0
ans = 0
for i in range(n):
  use += AB[i][1]
  if use <= m:
    ans += AB[i][0]*AB[i][1]
  else:
    ans += AB[i][0]*(AB[i][1] - (use - m))
    break
print(ans)

Measured memory_bytes: 60760
s = str(input())

n = len(s)
c = 0

for i in range(n):
    if s[i] == "R":
        j = i
        a = 0
        while s[j] == "R" and j < n-1:
            a += 1
            j += 1
        if j == n-1 and s[j] == "R":
            a += 1
        c = max(a,c)

print(c)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a[3];
    rep(i, 0, 3) cin >> a[i];
    sort(a, a + 3);
    int x = a[2] - a[0];
    int y = a[2] - a[1];
    int ans = 0;
    ans += y;
    x -= y;
    if (x % 2 == 0) ans += x / 2;
    else ans += (x / 2) + 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
 
    private static ArrayList<ArrayList<Character>> X = new ArrayList<ArrayList<Character>>(),
                                                   Y = new ArrayList<ArrayList<Character>>();

    public static void main(String[] args) {
 
        //input
         Scanner sc = new Scanner(System.in);
         int      N = sc.nextInt();
 
         char[] c_ar;
         ArrayList<Character> a;
		 for(int i = 0;i < N;i++){
        	 for(int j=0;j<2;j++){
        		 c_ar = sc.next().toCharArray();
        		 a = new ArrayList<Character>(); 
        		 for(char c:c_ar){a.add(c);}
        		 if   (j==0){X.add(a);}
       			 else       {Y.add(a);}
        	 }
         }

         //calculation
		 int[] result = new int[N];
		 for(int i=0;i<N;i++){
			 result[i] = LCS_length(X.get(i),Y.get(i));
		 }

         //output
         for (int i:result) {System.out.println(i);}
    }

    private static int LCS_length(ArrayList<Character> X,ArrayList<Character> Y){
    	int     m = X.size(),
    	        n = Y.size(),
    	        i,j;
    	int[][] c = new int[m+1][n+1];
    	
    	for(i=0;i<m+1;i++){c[i][0]=0;}
    	for(i=1;i<n+1;i++){c[0][i]=0;}
    	for(i=1;i<m+1;i++){
    		for(j=1;j<n+1;j++){
    			if   (X.get(i-1) == Y.get(j-1)){c[i][j] = c[i-1][j-1]+1;}
    			else {
    				if   (c[i-1][j] > c[i][j-1]){c[i][j] = c[i-1][j];}
    				else                        {c[i][j] = c[i][j-1];}
    			}
    		}
    	}
    	return c[m][n];
   }
}

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

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

  int count = 0, maxv = 0;

  rep(i, s.length()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
        count++;
        maxv = max(count, maxv);
    } else {
        count = 0;
    }
  }
  
  cout << maxv << endl;

  return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000003;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  return factorials;
}

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  auto factorials = MakeFactorialTable(P - 1);

  auto solve_fn = [&]() -> FiniteField {
    int x, d, n;
    cin >> x >> d >> n;
    if (d == 0) {
      return Power(FiniteField(x), n);
    }
    if (x == 0) {
      return 0;
    }

    FiniteField k = FiniteField(x) / d;
    if (k.Value() + n - 1 >= P) {
      return 0;
    }

    return factorials[k.Value() + n - 1] / factorials[k.Value() - 1] * Power(d, n);
  };

  int q_count;
  cin >> q_count;
  for (int q_id = 0; q_id < q_count; q_id++) {
    cout << solve_fn() << endl;
  }
}

Measured memory_bytes: 8704