akhauriyash/Code-Regression huggingface dataset:
#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)

typedef long long ll;
#define INF 1e9

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



int main(){
  int N, cnt = 0;
  cin >> N;
  vector<int> sosu(N+1,0);
  vector<pair<int, int>> s;
  FOR(i, 2, N+1){
    if(sosu[i] == 0){
      cnt++;
      s.push_back(make_pair(i, 0));
      for(int j = 2; j * i <= N; ++j){
        sosu[j*i]=1;
      }  
    }
  }

  FOR(i, 1, N+1){
    int x = i;
    REP(j, cnt){
      while(x % s[j].first == 0){
        s[j].second++;
        x /= s[j].first;
      }
    }
  }
  ll ans = 1;
  REP(i, cnt){
    if(s[i].second != 0){
      ans *= s[i].second+1;
      ans = ans % (ll)(1e9+7);
    }
  }

  cout << ans  << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define MAXN 200005
#define INT_SIZE 32
#define debug cout<<"we are debugging"<<endl;
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
const ll MAX = 2000000;
ll fac[MAX], finv[MAX], inv[MAX];
void cmbinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i=2;i<MAX;i++) {
		fac[i] = fac[i-1]*i%MOD;
		inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i] = finv[i-1]*inv[i]%MOD;
	}
}
ll cmb(ll n, ll k) {
	if(n<k) return 0;
	if(n<0 || k<0) return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main()
{
     fast;
     cmbinit();
    ll n;
    cin>>n;
    ll ans=fast_expo(10,n);
    ans%=MOD;
    ll val=0,ans1;
    for(ll i=1;i<=n;i++)
    {
         ans1=((cmb(n,i))%MOD*(fast_expo(8,n-i))%MOD)%MOD;
         val=val+ans1;
         val%=MOD;
    }
    val=((val%MOD)*(2%MOD))%MOD;
    ll ans3=fast_expo(8,n)%MOD;
    val=(val+ans3)%MOD;
    cout<<(ans-val+MOD)%MOD;
}


Measured memory_bytes: 50496
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, a, b, ab, comp;
char s[20];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		int len = 0;
		for (; s[len] != 0; len++)
			if (s[len] == 'A' && s[len + 1] == 'B')
				comp++;

		if (s[0] == 'B' && s[len - 1] == 'A')
			ab++;
		else if (s[0] == 'B')
			b++;
		else if (s[len - 1] == 'A')
			a++;
	}
	if (a == 0 && ab != 0)
		a++, ab--;
	if (b == 0 && ab != 0)
		b++, ab--;
	if (a != 0 && b != 0)
		comp += ab + 1, a--, b--;
	comp += min(a, b);
	printf("%d\n", comp);
}

Measured memory_bytes: 128
n=int(input())
a=[tuple(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    ans += ((a[i][0] - a[j][0])**2 +(a[i][1] - a[j][1])**2 )**0.5
    
print(ans / n*2)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

int main(void) {
    int a, b;
    cin >> a >> b;
    string ans;
    if (a == b) ans = "Draw";
    else if (a == 1) ans = "Alice";
    else if (b == 1) ans = "Bob";
    else {
        ans = (a < b ? "Bob" : "Alice");
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i;
    int temp;
    int h[3];
    
    for(i=0;i<3;i++){
        h[i]=0;
    }
    
    for(i=0;i<10;i++){
        scanf("%d",&temp);
        if(h[0]<temp){
            h[2]=h[1];
            h[1]=h[0];
            h[0]=temp;
        }else if(h[1]<temp){
            h[2]=h[1];
            h[1]=temp;
        }else if(h[2]<temp){
            h[2]=temp;
        }
    }
    
    for(i=0;i<3;i++){
        printf("%d\n",h[i]);
    }
    
    return 0;
}

Measured memory_bytes: 600
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int x;
		int y;

		while(true){
			x = sc.nextInt();
			y = sc.nextInt();
			if (x == 0 && y == 0) { break; }
			if (x > y) {
				int z = x;
				x = y;
				y = z;
			}
			sb.append(x).append(" ").append(y).append("\n");
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 35276
'''ika tako
bit桁ごとに考える。「XORを取り、その後足し算」という計算過程では
他の桁が影響することはないので、桁毎に独立に考えて問題ない。
N = 5
A = {   1   2   3   4   5 }   ↓
    { 001 010 011 100 101 }
たとえば2桁目を取り出すと
       0   1   1   0   0
各ペアでXORを取ると、(0,1)は'1'となり、(0,0)(1,1)は'0'となる。 
0はいくら足しても0なので、(0,1)の数だけわかれば良い。
それは、(0の個数)×(1の個数)で計算できる。
    0が3個、1が2個
→  XORを取ったとき、2桁目について'1'が立っているペア
　　　　　　　　　　　=合計に足される回数は 3x2=6
→  2進数の2桁目は2を表すので、合計に足される値は6x2=12
これを各桁について足し合わせる。
'''
n = int(input())
aaa = list(map(int, input().split())) 
MOD = 10 ** 9 + 7
ans = 0
m = 1#取り出したい桁、これを１つずつ増やしていく
for i in range(60):#上限は2＾60なので、60が上限
    bit = sum(a & m for a in aaa)
    #＆演算子は論理積、両方のビットが1の場合に1が返る
    #L=[a for a in aaa]  与えられたN個の整数を全列挙
    #この整数の各ビットをチェックする
    #print(L)
    #bit //= m こっちが原文、下の行は、下のプログラムに合わせてみた
    bit >>= i
    #print(bit)
    non_bit = n - bit
    ans = (ans + bit * non_bit * m) % MOD
    #ｍは上記、2桁目を表す2と同様、取り出した桁がpだとすると2^(p-1)
    m <<= 1#ビットを１つずつ左シフト、取り出したい桁をずらして求める
print(ans)
'''
結局この計算は Ai のすべての組み合わせ(Ai 自身同士は含まない)の 
XOR の合計なので、Ai のあるビットの立っている数の合計を c とすると、
Ai のあるビットが0であった場合により計算結果に立つビットの数は 
c、Ai のあるビットが1であった場合により計算結果に立つビットの数は 
N - c になるので、あるビットに関する計算結果は c * (N -c) の
ビットシフトした値になる. 結果として以下の計算で解ける.
N = int(input())
A = list(map(int, input().split())) 
result = 0
for bit in range(60):
    m = 1 << bit　すべてのビットを調べる
    c = sum(a & m for a in A) >> bit　
    ビット分、戻して、その桁に立っているビット数を算出
    result += (c * (N - c)) << bit　
    ビット分（上記の2桁目の2）調整、イメージとしては2のべき乗倍
    result %= 1000000007
print(result)
'''

Measured memory_bytes: 42156
r,c=[int(x) for x in str(input()).split()]
image=[[0 for x in range(0,c+2)]]
for i in range(1,r+1):
  x=list(str(input()))

  d=[0]
  for i in range(0,c):
    if x[i]=='.':
      d.append(0)
    else:
      d.append(1)
  d.append(0)

  image.append(d)
image+=[[0 for x in range(0,c+2)]]

counter=0
for x in range(1,r+1):
  for y in range(1,c+1):
    if image[x][y]==1:
      s=image[x-1][y]
      t=image[x+1][y] 
      u=image[x][y-1] 
      v=image[x][y+1]
      if s+t+u+v==0:

        counter=-1
if counter==-1:
  print('No')
else:
  print('Yes')

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

int main(int argc, char const *argv[]) {
int N,max,ans,tmp;
ans = 1;
    std::cin >> N>>max;
    for (size_t i = 0; i < N-1; i++) {
        std::cin >> tmp;
        if(max<=tmp){
            max=tmp;
            ans++;
        }
    }
    std::cout << ans << '\n';
    return 0;
}


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

using namespace std;

int max(int a,int b)
{
    return (a>b)?a:b;
    
}


int main()
{
  int n;

    cin>>n;

    vector<int> dp(3,0);

    vector<int> hap(3);

  for(int i=0;i<n;i++)
{   
    vector<int> dp_init(3,0);

    for(int i=0;i<3;i++)
        cin>>hap[i];


    for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
                if(i!=j)
                dp_init[j]=max(dp_init[j],dp[i]+hap[j]);


        }    


      dp=dp_init;  


}



cout<<max(dp[0],max(dp[1],dp[2]));



}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())
N =n*(n-1)//2

a = [[int(j)-1 for j in readline().split()] for _ in range(n)]
g = [[] for i in range(N)]
indegree = [0]*N

def encode(x,y):
    if x > y: x,y = y,x
    return y*(y-1)//2 + x

for i in range(n):
    for j in range(n-2):
        p,q = encode(i,a[i][j]), encode(i,a[i][j+1])
        g[p].append(q)
        indegree[q] += 1

"""
トポロジカルソート
q をheapq にしたりすると、辞書順にとりだしたりとかができる。
返り値：DAG ならトポソのひとつを返す。ループがあれば-1を返す
"""
"""
g: グラフの隣接行列
indegree: 流入辺の数を数えた配列
"""
def topological_sort_queue(g,indegree):
    q = [i for i,c in enumerate(indegree) if c == 0] #流入辺0の点の集合
    L = [] #ソート結果をためておく配列
    ans =[0]*len(g)
    a = 0
    while q:
        v = q.pop()
        L.append(v)
        for c in g[v]: #配る
            ans[c] = max(ans[c],ans[v]+1)
            a = max(a,ans[c])
            indegree[c] -= 1 #辺 node -> child を削除する
            if indegree[c] == 0:
                q.append(c)
    if len(L) != N: #print("サイクル検出")
        return -1
    else: #return(L)
        return(a+1)        

print(topological_sort_queue(g,indegree))


Measured memory_bytes: 134492
#include<cstdio>
using namespace std;
inline int read()
{
    int x=0;bool f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=0;c=getchar();}
    while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return f?x:-x;
}
int n,k,s;
int main()
{
    n=read(),k=read(),s=read();
    for(int i=0;i<k;i++) printf("%d ",s);
    if(s!=1e9)
        for(int i=k;i<n;i++) printf("1000000000 ");
    else
        for(int i=k;i<n;i++) printf("1 ");
    puts("");
    return 0;
}


Measured memory_bytes: 1280
s = list(input())
n = len(s)
sign = 0
limit_1 = int((n-1)//2)

judge = limit_1%2
if judge == 0:
  limit_2 = int(limit_1//2)
elif judge == 1:
  limit_2 = int((limit_1+1)//2)

for i in range(limit_2):
  if not (s[i] == s[i-limit_1]):
    sign = 1

if s[:limit_1] != s[limit_1+1:] :
  sign = 1

if sign == 0:
  ans = "Yes"
elif sign == 1:
  ans = "No"
  
print(ans)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int n,m,sum=0,i,j;
    cin>>n>>m;
    for(i=1;i<=m;++i)
    {
        cin>>j;
        sum+=j;
    }
    if(sum<=n)
        cout<<n-sum;
    else
        cout<<-1;
}

Measured memory_bytes: 3652
def bubbleSort(A,N):
    flag = 1 #????????????????????£??????????????????????????????????????¨??????
    i = 0

    while flag:
        flag = 0
        for j in range(N-1,i,-1):
            if int(A[j][1]) < int(A[j-1][1]):
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
        i += 1
    return A


def selectionSort(A,N):
    for i in range(0,N-1):
        minj = i
        j=i+1
        for j in range(j,N):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        tmp = A[minj]
        A[minj] = A[i]
        A[i] = tmp
    return A

def isStable(ori,sorted):
    for i in range(len(ori)-1):
        for j in range(i+1, len(ori)-1):
            for a in range(len(ori)):
                for b in range(a+1, len(ori)):
                    if ori[i][1] == ori[j][1] and ori[i] == sorted[b] and ori[j] == sorted[a]:
                        return 'Not stable'
    return 'Stable'

def output(A):
    for i in range(len(A)):  # output
        if i == len(A) - 1:
            print(A[i])
        else:
            print(A[i], end=' ')

if __name__ == '__main__':

    N = int(input())

    numbers = input().split(' ')
    n1 = numbers.copy()
    n2 = numbers.copy()

    A = bubbleSort(n1,N)

    output(A)
    print(isStable(numbers,A))

    B = selectionSort(n2,N)

    output(B)
    print(isStable(numbers, B))

Measured memory_bytes: 7896
N = int(input())
src = [int(input()) for i in range(N)]
idx = {a:i for i,a in enumerate(src)}

size = [1] * N
ss = list(sorted(src))

es = []
gr = [[] for i in range(N)]
while len(ss) > 1:
    a = ss.pop()
    k = size[idx[a]]
    b = a + 2*k - N
    if b == a or b not in idx:
        print(-1)
        exit()
    size[idx[b]] += k
    ai,bi = idx[a],idx[b]
    es.append((ai,bi))
    gr[ai].append(bi)
    gr[bi].append(ai)

from collections import deque
dist = [N] * N
dist[idx[ss[0]]] = 0
q = deque([idx[ss[0]]])
while q:
    v = q.popleft()
    for to in gr[v]:
        if dist[to] < N: continue
        q.append(to)
        dist[to] = dist[v] + 1

if all(d<N for d in dist) and sum(dist) == ss[0]:
    for a,b in es:
        print(a+1, b+1)
else:
    print(-1)

Measured memory_bytes: 44876
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] c = new int[26];
		for(int i = 0; i < 26; i++) {
			c[i] = sc.nextInt();
		}
		int[][] s = new int[d][26];
		for(int i = 0; i < d; i++) {
			for(int j = 0; j < 26; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		int[] lastDay = new int[26];
		for(int i = 0; i < 26; i++) {
			lastDay[i] = 0;
		}
		long result = 0;
		for(int i = 1; i <= d; i++) {
			long max = result;
			int check = 0;
			for(int j = 0; j < 26; j++) {
				long temp = 0;
				temp += s[i-1][j];
				for(int k = 0; k < 26; k++) {
					if(k != j&&i!=d) {
						temp -= c[k]*(i-lastDay[k]);
					}
				}
				if(max < temp+result) {
					max = temp+result;
					check = j;
				}
			}
			lastDay[check] = i;
			System.out.println(check+1);
		}
	}
}


Measured memory_bytes: 46948
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define y0 isdnfviu
#define y1 asinhiv
#define fst first
#define snd second

int main()
{
	int n;
    cin>>n;
    cout<<n+n*n+n*n*n;
}


Measured memory_bytes: 3596
# coding: utf-8
import numpy as np

# AとB(行と列の移動量)を入れ替えた場合も対称になりたつ。
N = int(input())
# numpyを使うため、文字を文字コードの数字に置き換えている(ord関数)
S = [list(map( ord, list(input()) )) for _ in range(N)]
Sarr = np.array(S)
# 配列をひとまとめにしてタイル状に複製して配置
# 行, 列のアクセスインデックスが行、列の大きさを飛び越えると
# それぞれ先頭にインデックスを戻す必要があるところを行列を拡張して対応する
Sext = np.tile(Sarr, [2,1])[:-1,:]
# 拡張は行方向だけで良さそう
#Sext = np.tile(Sarr, [2,2])[:-1,:-1]

cnt = 0
for i in range(N):
    # 行について1つずつずらしたスタート位置で配列を取得し、
    # 転置したものと等しくなっていれば、良い配列
    # 行と列の移動量の差(A-B)が同一のときは対角線成分に対して
    # 線対称を判定する要素の組み合わせが変わらない。
    # そのため、列は探索せずに、N倍すればよい
    ar = Sext[i:i+N, 0:N]
    cnt += N * (ar == ar.T).all()

print(cnt)

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




  



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif*/
  string nish;
  cin>>nish;
  int siz=nish.size();
  vector<vector<long long int >>dp(siz+1,vector<long long int >(13,0));
  dp[0][0]=1;
  for(int i=0;i<siz;i++)
  {

  	for(int j=0;j<10;j++)
  	{
  		int index=nish[i]-'0';
  		if(nish[i]=='?')
  		{
  			index=j;
  		}
  		for(int k=0;k<13;k++)
  		{
  			int number=(10*k+index)%13;
  			dp[i+1][number]+=dp[i][k];
  			dp[i+1][number]%=1000000007;
  		}
  		if(nish[i]!='?')break;
  	}
  }

  cout<<dp[siz][5]<<endl;
	return 0;
}

Measured memory_bytes: 16648
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b < c || d < a) {
        cout << 0 << endl;
    } else {
        cout << min(b, d) - max(a, c) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let ac = 0;
    let wa = 1;
    let tle = 2;
    let re = 3;
    let mut ans = vec![0i64; 4];
    for s_i in s {
        match s_i.as_str() {
            "AC" => ans[ac] += 1,
            "WA" => ans[wa] += 1,
            "TLE" => ans[tle] += 1,
            "RE" => ans[re] += 1,
            _ => unreachable!(),
        }
    }

    println!("AC x {}", ans[ac]);
    println!("WA x {}", ans[wa]);
    println!("TLE x {}", ans[tle]);
    println!("RE x {}", ans[re]);
}


Measured memory_bytes: 7800
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: u32 = sc.next();
    for a in 1..10 {
        for b in 1..10 {
            if a * b == n {
                println!("Yes");
                std::process::exit(0);
            }
        }
    }
    println!("No");
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}


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

int main() {
  int H,N,A,cnt=0;
  cin >> H >> N;
  for(int i=0;i<N;i++){
    cin >> A;
    cnt+=A;
  }
  if(H<=cnt){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N,L=map(int,input().split())
arr=[]
flg=0
sumall=0
for c in range(N):
    if(L+c==0):
        flg=1
    arr.append(L+c)
    sumall+=L+c
arr.sort()
sum=0

if(flg==0):
    if(sumall>0):
        for c in range(N-1):
           sum+=arr[c+1]
    else:
        for c in range(N-1):
            sum+=arr[c]
else:
    sum=sumall
print(sum)

Measured memory_bytes: 3064
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    ll result = 0;
    rep(i, k) {
        result += p[i];
    }
    cout << result << endl;
    return 0;
}


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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);

ll n,k;

int main(){
    SPEED
    cin>>n>>k;
    if(n==k){
        cout<<0;
        return 0;
    }
    if(n<k){
        cout<<min(n,abs(n-k));
        return 0;
    }
    ll tmp = n - (n/k)*k;
    cout<<min({n,tmp,abs(k-tmp)});
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>


int main(){
  long long n,m;
  scanf("%lld",&n);
  scanf("%lld",&m);

  if(n*2>=m){
    if(m%2==0){
      printf("%lld\n",m/2);
    }
    else{
      printf("%lld\n",(m-1)/2);
    }
  }

  else{
    
    if(m%2==1){m=m-1;}

    long long k=n+m/2;
    if(k%2==1){k=k-1;}

    printf("%lld\n",k/2);
  
    
  }
  return 0;

}



Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string S;
  while (cin >> S) {
    vector<int> cnt(3, 0);
    for (char c : S) ++cnt[c - 'a'];
    int m = min({cnt[0], cnt[1], cnt[2]});
    bool res = cnt[0] - m <= 1 && cnt[1] - m <= 1 && cnt[2] - m <= 1;
    cout << (res ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp60 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = st[0];
            int B = st[1];
            int K = st[2];

            int max = Gcd(A, B);

            //Console.WriteLine(max);

            int cnt = 0;
            int ans = 0;

            for (int i = max; i >= 1; i--) {
                if (max % i == 0) {
                    cnt++;
                }
                if (cnt == K) {
                    ans = i;
                    break;
                }
            }


            Console.WriteLine(ans);
        }

        static int Gcd(int a, int b) {
            if (a < b) {
                return Gcd(b, a);
            }

            while(b != 0) {
                int remain = a % b;
                a = b;
                b = remain;
            }
            return a;

        }
    }
}

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

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}
	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
	a %= m;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
const int N = 5e5 + 100;
int bit[N], prv[N]; 
void upd(int x,int y){
	while(x < N){
		bit[x] += y;
		x += (x&(-x));
	}
}
int query(int l){
	int ans = 0;
	while(l > 0){
		ans += bit[l];
		l -= (l&(-l));
	}
	return ans;
} 
int query(int l,int r){
	assert(l <= r);
	return query(r) - query(l - 1);
}
vector<pair<int,int>> queries[N];
void solve(){
	int n,q;
	cin >> n >> q;
	vector<int> c(n + 1);
 
	for(int i = 1; i <= n ; ++i){
		cin >> c[i];
	}
	vector<int> ans(q);
	for(int i = 0; i < q; ++i){
		int l,r;
		cin >> l >> r;
		queries[r].push_back({l,i});
	}
 
	for(int i = 1; i <= n; ++i){
		if (prv[c[i]] != 0){
			upd(prv[c[i]], -1);
		}
 
		prv[c[i]] = i;
		upd(i,1);
 
		for(auto e: queries[i]){
			ans[e.second] = query(e.first, i);
		}
	}
	for(auto e: ans){
		cout << e << "\n";
	}
}
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	solve();
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 44164
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
using ll = long long;
using pint = pair <int, int>;

pint	vect[] = {pint(-1, 0), pint(0, 1), pint(1, 0), pint(0, -1)};
int		h, w;

bool	coordi_check(pint p){
	if (p.first < 0 || p.second < 0)
		return false;
	if (p.first >= h || p.second >= w)
		return false;
	return true;
}
int		main(void)
{
	cin >> h >> w;
	char	s[h][w];
	int		d[h][w];
	int		black = 0;
	int		i, j, v;
	i = 0;
	while (i < h){
		j = 0;
		while (j < w){
			cin >> s[i][j];
			if (s[i][j] == '#')
				black++;
			d[i][j] = INF;
			j++;
		}
		i++;
	}
	d[0][0] = 1;
	queue<pint> q;
	pint	now;
	q.push(pint(0,0));
	while (!(q.empty())){
		v = 0;
		while (v < 4){
			now.first = q.front().first + vect[v].first;
			now.second = q.front().second + vect[v].second;
			if (coordi_check(now)){
				if (s[now.first][now.second] == '.' && d[now.first][now.second] == INF){
					d[now.first][now.second] = d[q.front().first][q.front().second] + 1;
					q.push(now);
				}
			}
			v++;
		}
		q.pop();
	}
	if (d[h - 1][w - 1] == INF)
		cout << -1 << endl;
	else
		cout << h * w - black - d[h - 1][w - 1] << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a==1 && b ==2 || a==2 && b==1){
      System.out.println(3);
    }else if(a==2 && b==3 || a==3 && b==2){
      System.out.println(1);
    }else if(a==3 && b==1 || a==1 && b==3){
      System.out.println(2);
    }
  }
}


Measured memory_bytes: 21712
# coding: utf-8
# Your code here!
a, b, c = map(int, input().split())

max_value = a
min_value = b

if a < b:
    max_value = b
    min_value = a
if c > max_value:
    middle_value = max_value
    max_value = c

elif c < min_value:
    middle_value = min_value
    min_value = c
else:
    middle_value = c
    
print(min_value, middle_value, max_value)


Measured memory_bytes: 5600
import java.util.Arrays;
import java.util.Scanner;

// ABC171-B
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] fruitList = new int[N];
		for (int i = 0; i < N; i++) {
			fruitList[i] = sc.nextInt();
		}
		Arrays.sort(fruitList);

		int sum = 0;
		for (int i = 0; i < K; i++) {
			sum += fruitList[i];
		}

		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 38864
import math

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

def seikai(x):
    count = 0
    for i in range(n):
        count += math.ceil(a[i] / x) - 1

    if(count <= k):
        return 1
    else:
        return 0

l = 0
r = 10 ** 9
while(r - l > 1):
    temp = (r + l) // 2
    if(seikai(temp) == 1):
        r = temp
    else:
        l = temp

print(r)

Measured memory_bytes: 104368
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

x = STR()
l = len(x)
stack = []
for i in range(l):
    if x[i] == 'S':
        stack.append('S')
    elif not len(stack) or stack[len(stack)-1] == 'T':
        stack.append('T')
    else:
        stack.pop()
print(len(stack))


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

int main() {
  string s;
  cin >> s;
  int size = s.size(),ans=1000;
  for(int i=0; i<size-2; i++) {
    int num = 753 - stoi(s.substr(i,3));
    ans = min(abs(num),ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    //ll t;
    //cin>>t;
    //while(t--)
    //{
       
    //}
    ll n,k;
    cin>>n>>k;
    ll ans=min(n%k,k-n%k);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

typedef long long ll;
const int Max = 1e6;
using namespace std;

int main(){
	int n;
	cin >> n;
	if(n == 3 || n == 7 || n == 5)
		cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    vector<ll> V;
    list<double> VL;
    cin >> N;
    V.resize(N);
    for(ll i = 0;i < N;i++) cin >> V[i];
    sort(V.begin(), V.end());
    for(auto &i: V) VL.push_back(i);
    while(VL.size() > 1) {
        double a, b;
        a = VL.front();
        VL.pop_front();
        b = VL.front();
        VL.pop_front();
        VL.push_front((a + b) / 2);
    }
    cout << fixed << setprecision(5) << VL.front() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m,x,y,z = 0;
  int sx,sy;
  int mx = -500,my = 500;

  cin >> n >> m >> x >> y;

  for(int i = 0;i < n;i++){
	cin >> sx;
	if(sx > mx)swap(sx,mx);
  }

  for(int j = 0;j < m;j++){
	cin >> sy;
	if(sy < my)swap(sy,my);
  }

  for(int i = x + 1;i <= y;i++){
	if(i > mx && i <= my){
	  z = 1;
	  break;
	}
  }

  if(z) cout << "No War" << endl;
  else  cout << "War" << endl;
  return 0;
}


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

int main(){
  
  int a;
  cin >> a;
  
  if( a == 111 ){
    
    cout << 999 << endl;
    
  }
  
  else if( a == 119 ){
    
    cout << 991 << endl;
    
  }
  
   else if( a == 191 ){
    
    cout << 919 << endl;
    
  }
  
  else if( a == 199 ){
    
    cout << 911 << endl;
    
  }
  
  else if( a == 911 ){
    
    cout << 199 << endl;
    
  }
  
   else if( a == 919 ){
    
    cout << 191 << endl;
    
  }
  else if( a == 991 ){
    
    cout << 119 << endl;
    
  }
  
  else if( a == 999 ){
    
    cout << 111 << endl;
    
  }
  
}


Measured memory_bytes: 256
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll> > v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    ll dp[n+1][w+1];
    FILL(dp,0);
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<v[i-1].first;j++){
            dp[i][j] = dp[i-1][j];
        }
        for(ll j=v[i-1].first;j<=w;j++){
            dp[i][j] = max(v[i-1].second + dp[i-1][j-v[i-1].first],dp[i-1][j]);
        }
    }
    cout<<dp[n][w];
    return 0;
}






Measured memory_bytes: 79232
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=2e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int a[N],dp[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        dp[a[i]]=dp[a[i]-1]+1;
    }
    cout<<n-*max_element(dp+1,dp+1+n);
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n;
	cin >> n;
	if(n%111 == 0){
		cout << n << endl;
	}else{
		n+=111-n%111;
		cout << n << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <functional>
#include <numeric>
#include <random>
#include <memory.h>
#include <time.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

deque<int> q;

void rec(ll n,int d){
	if(n==1) return;
	
	if(n&1){
		rec(n-1,d+1);
		q.push_front(d);
	}else{
		rec(n/2,d+1);
		q.push_back(d);
	}
}

int main(void){
	ll n;
	cin >> n;
	rec(n+1,1);

	const int m=q.size();
	cout << m+80 << endl;
	rep(i,m) cout << (i?" ":"") << q[i];
	rrep(i,80) cout << " " << i+1;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    string s;
    map<string,int> mp;
    vector<int> t(n);
    fr(i,n){
        in>>s>>t[i];
        mp[s]=i;
    }
    in>>s;
    int j=mp[s];
    int ans{};
    ifr(i,n){
        if(i==j) break;
        ans+=t[i];
    }
    cout<<ans<<endl;
}

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

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

using ll = long long;

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

int main() {
  double a, b, x;
  cin >> a >> b >>x;
  double S = x/a;
  double ans;
  if(S<= a*b/2) {
    ans=atan(b*b/(2*S));
  }
  else if(S> a*b/2){
    ans = atan((2*a*b-2*S)/(a*a));
  }
  cout << fixed << setprecision(8);
  cout<<ans*180/pi<< endl;
}

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

int main(void)
{
    int N = 0;
    char S[4] = {0};
    scanf("%d", &N);
    int i = 0;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%s", S);
        if (strcmp(S, "AC") == 0)
        {
            ac++;
        }
        if (strcmp(S, "WA") == 0)
        {
            wa++;
        }
        if (strcmp(S, "TLE") == 0)
        {
            tle++;
        }
        if (strcmp(S, "RE") == 0)
        {
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

#define mp make_pair
#define P pair<int,int>
#define ll __int64

int n,m,d;
string t[10000];
bool c1(int y,int x){
	if(y+d>n)return 0;
	rep(i,d)if(t[y+i][x]=='#')return 0;
	return 1;
}

bool c2(int y,int x){
	if(x+d>m)return 0;
	rep(i,d)if(t[y][x+i]=='#')return 0;
	return 1;
}
int main(){
	cin>>n>>m>>d;
	rep(i,n)cin>>t[i];
	int ans=0;
	rep(i,n){
		rep(j,m){
				if(t[i][j]=='#')continue;
				if(c1(i,j)){ans++;}
				if(c2(i,j)){ans++;}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3232
# include <iostream>
using namespace std;
int n,x,y,z,s;
void work (void)
{
	int t;
	if (x>=y)
	t=x;
else t=y;
    if (z>t)
    t=z;
    s=(t<<n)+x+y+z-t;
    cout<<s;
}
int main (void)
{
	cin>>x>>y>>z;
	cin>>n;
	work ();
	return 0;
}


Measured memory_bytes: 256
s = list(input())
for _ in [0]*int(input()):
    cmd, a, b, *p = input().split()
    a = int(a); b = int(b) + 1
    if cmd == 'print':
        print(*s[a:b], sep='')
    if cmd == 'reverse':
        s[a:b] = reversed(s[a:b])
    if cmd == 'replace':
        s[a:b] = p[0]


Measured memory_bytes: 5736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {

  string s, t;
  cin >> s >> t;

  ll N, M; N = s.size(); M = t.size();
  vector< vector<ll > > dp(N + 1, vector<ll>(M + 1, 0));
  FOR(_i, N) {
    auto i = _i + 1;
    FOR(_j, M) {
      auto j = _j + 1;
      if (s[i-1] == t[j-1]) {
        dp[i][j] =
          max(dp[i][j], dp[i - 1][j - 1] + 1);
        /*  max(max(dp[i][j], max(dp[i][j - 1]+1,
            dp[i - 1][j - 1]+1)),
            dp[i - 1][j]+1);*/
      }
      else {
       	chmax(dp[i][j], dp[i-1][j]);
        chmax(dp[i][j], dp[i][j-1]);
      }
    }
  }

  string ans;
  ll next = 1;
  //FOR(_i, N) {
  //  auto i = _i + 1;
  //  FOR(_j, M) {
  //    auto j = _j + 1;
  //    if (dp[i][j] == next) {
  //      ans += t[j];
  //      next += 1;
  //      break;
  //    }
  //  }
  //}
  ll cnt = dp[N][M];
  ll i = N;
  ll j = M;
  //string ans;
  while (cnt) {
    while (dp[i][j] == cnt) {
      i -= 1;
    }
    i += 1;
    while ( dp[i][j] == cnt) {
      j -= 1;
    }
    j += 1;
    
    ans += s[i-1];
    cnt -= 1;
    i -= 1;
    j -= 1;

  }
  reverse(ALL(ans));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<int>v;
	for(int i=0; i<n; i++){
		int x;
		cin>>x;
		if(v.size()==0 || v.back()!=x){
			v.pb(x);
		}
	}
	int val[v.size()];
	for(int i=0; i<v.size(); i++){
		val[i]=0;
	}
	if(v.size()==1){
		cout<<1000;
		return 0;
	}
	if(v[0]<v[1]){
		val[0]=-1;
	}
	if(v[v.size()-1]>v[v.size()-2]){
		val[v.size()-1]=1;
	}
	for(int i=1; i<v.size()-1; i++){
		if(v[i]>v[i-1] && v[i]>v[i+1]){
			val[i]=1;
		}
		if(v[i]<v[i-1] && v[i]<v[i+1]){
			val[i]=-1;
		}
	}
	
	
	vector<int>bu;
	vector<int>se;
	for(int i=0; i<v.size(); i++){
		if(val[i]==-1){
			bu.pb(v[i]);
		}
		if(val[i]==1){
			se.pb(v[i]);
		}
	}


	int ans=1000;
	for(int i=0; i<bu.size(); i++){
		int num=ans/bu[i];
	
		ans=(ans%bu[i])+num*se[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3656
package main

import (
    "fmt"
    "strings"
)

func display(data [4][3][10]int) {
    for i:=0; i<4; i++ {
        for j:=0; j<3; j++ {
            for k:=0; k<10; k++ {
                fmt.Printf(" %d", data[i][j][k])
            }
            fmt.Println("")
        }
        if i <= 2 {
            fmt.Println(strings.Repeat("#", 20))
        }
    }
}

func main() {
    var data [4][3][10]int

    // 初期化
    for i:=0; i<4; i++ {
        for j:=0; j<3; j++ {
            for k:=0; k<10; k++ {
                data[i][j][k] = 0
            }
        }
    }

    // データ読み込み＆データ更新
    var n int
    var b, f, r, v int

    fmt.Scanf("%d", &n)
    for i:=0; i<n; i++ {
        fmt.Scanf("%d %d %d %d", &b, &f, &r, &v)
        data[b-1][f-1][r-1] += v
    }
    display(data)
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int MOD = 1e9 + 7;

int n, k;

int main() {
	
	FAST;
	
	cin >> n >> k;
	vector <int> a(n);
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if (k % 2 && a[n - 1] == 0) {
		cout << 0 << '\n';
		return 0;
	}
	int ans = 1;
	if (k % 2 && a[n - 1] < 0) {
		for (int i = 1; i <= k; i ++) {
			ans = 1LL * ans * a[n - i] % MOD;
			if (ans < 0) ans += MOD;
		}
		cout << ans << '\n';
		return 0;
	}
	int i = 0, j = n - 1;
	if (k % 2 && a[n - 1] > 0) {
			ans = a[n - 1];
			j --;
			k --;
	}
	k /= 2;
	while (k -- ) {
		intt left = 1LL * a[i] * a[i + 1];
		intt right = 1LL * a[j] * a[j - 1];
		if (left > right) {
			ans = 1LL * ans * (left % MOD) % MOD;
			if (ans < 0) ans += MOD;
			i += 2;
		}
		else {
			ans = 1LL * ans * (right % MOD) % MOD;
			if (ans < 0) ans += MOD;
			j -= 2;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int a,b;
	while(~getII(a,b)){
		int diff=b-a;
		int nB=(1+diff)*diff/2;
		printf("%d\n",nB-b);
	}
}


Measured memory_bytes: 256