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

int main() {
  int a, b, c, d;
  int l, r;
  cin >> a >> b >> c >> d;
  
  l = a + b;
  r = c + d;

  if (l > r) {
    cout << "Left" << endl;
  } else if (l == r) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

const int s[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(int argc, char** argv)
{
	int k;
	scanf("%d", &k);
	printf("%d\n", s[k - 1]);
	return 0;
}

Measured memory_bytes: 128
program unevennumbers

implicit none

integer::n,i,l,count=0,t=0

read*,n

!print*,n

do i=1,n
   if(i<10) then
      count=count+1
   else if(10<=i .and. i<100)then
      continue
   else if(100<=i .and. i<1000)then
      count=count+1
   else if(1000<=i .and. i<10000)then
      continue
   else if(10000<=i .and. i<100000)then
      count=count+1
   else
      continue
   end if
end do

print*,count

end program unevennumbers

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

typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pb push_back
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

bool sosu(int x){
    rep2(j,2,sqrt(x)+1){
        if(x%j==0)return false;
    }
    return true;
}

int main() {
    vi a(100001,0);
    vi b(100001);
    for(int i=3;i<100001;i+=2){
        if(sosu(i)&&sosu((i+1)/2)){
            a.at(i)=1;
        }
    }
    int k=0;
    rep(i,100001){
        k+=a.at(i);
        b.at(i)=k;
    }
    /*
    rep2(i,2,2018){
        cout<<i<<" "<<a.at(i)<<endl;
    }
    */
    
    int n;
    cin>>n;
    rep(i,n){
        int l,r,ans=0;
        cin>>l>>r;
        /*
        rep2(i,l,r+1){
            if(i==1)continue;
            if(i%2==0)continue;
            if(i!=3&&((i+1)/2)%2==0)continue;
            if(sosu(i)&&sosu((i+1)/2)){
                //cout<<i<<endl;
                ans++;
            }
        }*/
        
        cout<<b.at(r)-b.at(l-1)<<endl;
    }
    
}

Measured memory_bytes: 1408
import sys
import queue


def solve(k):
    q = queue.Queue()
    for i in range(1, 10):
        q.put(i)
    for i in range(k):
        n = q.get()
        if i == k - 1:
            return n
        if n % 10 == 0:
            q.put(n * 10)
            q.put(n * 10 + 1)
        elif n % 10 == 9:
            q.put(n * 10 + 8)
            q.put(n * 10 + 9)
        else:
            l = n % 10
            q.put(n * 10 + l - 1)
            q.put(n * 10 + l)
            q.put(n * 10 + l + 1)


def main():
    input = sys.stdin.buffer.readline
    k = int(input())
    print(solve(k))


if __name__ == "__main__":
    main()


Measured memory_bytes: 18984
import sys
import math
def main():
    for line in sys.stdin:
        x = int(line)
        h = int(input())

        if x != 0 and h != 0:
            s1 = x * math.sqrt(4 * (h ** 2) + x ** 2)
            s2 = s1 + x ** 2
            print("{:.6f}".format(s2))
        else:
            break

if __name__ == "__main__":
    main()

Measured memory_bytes: 7780
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
//#define endl "\n"
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	int n; cin>>n;
	int a[n];
	f(i,n) cin>>a[i];
	int gcd = a[0];
	for(int i=1;i<n;i++) gcd = __gcd(gcd, a[i]);
	unordered_map<int,int> mp;
	int flag = 0;
	f(i,n){
		mp[a[i]]++;
		if(mp[a[i]] > 1 && a[i] > 1){
			flag = 1;
		}
	}
	if(flag){
		if(gcd == 1) cout<<"setwise coprime"<<endl;
		else cout<<"not coprime"<<endl;
	}
	else{
		for(int i=2;i<=1000000;i++){
			if(flag) break;
			int cnt = 0;
			ll x = i*2;
			if(mp.count(i)) cnt = 1;
			for(int j=3;x<=1000000;j++){
				if(mp.count(x)) cnt += mp[x];
				if(cnt > 1){
					flag = 1;
					break;
				}
				x = i*j;
			}
		}
		if(flag){
			if(gcd == 1) cout<<"setwise coprime"<<endl;
			else cout<<"not coprime"<<endl;
		}
		else cout<<"pairwise coprime"<<endl;
	}
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 46348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner kb=new Scanner(System.in);
		String ret=kb.next();
		int count=0;
		for(int i=0;i<ret.length();i++){
			if(ret.charAt(i)=='2'){
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 22224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

int main()
{
	std::string s;
	std::cin >> s;
	if (s[0] == s[1] || s[0] == s[2]||s[1]==s[2]) {
		std::cout << "No" << std::endl;
	}
	else
	{
		std::cout << "Yes" << std::endl;
	}
    return 0;
}



Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    # 数が入っているのと、
    # 箱の中が0かどうかを判別するものを定義する
    # 全部まず1個入ってる
    # 赤は最初だけ!!!!!!!!
    nums = [1] * n
    In = [False] * n
    In[0] = True
    for i in range(m):
        a,b = map(lambda x:int(x) - 1, input().split())
        nums[a] -=1
        nums[b] +=1
        if In[a]:
            In[b] = True
        if nums[a] == 0:
            In[a] = False
    cnt = 0
    #print(In)
    for i in range(n):
        if In[i]:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()


Measured memory_bytes: 4596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#define ll long long
using namespace std;

const int N = 100010;

inline int read() {
	int jg = 0, jk = getchar() - '0';
	while(jk < 0 || jk > 9)  jk = getchar() - '0';
	while(jk >= 0 && jk <= 9)
		jg *= 10, jg += jk, jk = getchar() - '0';
	return jg;
}

int n, m, dis[30][30], ans;
char s[30][30];

struct node {
	int x, y;
}tp, d[4];
queue<node> q;

void solve(int x, int y) {
	memset(dis, -1, sizeof(dis));
	q.push((node){x, y});
	dis[x][y] = 0;
	while(!q.empty()) {
		tp = q.front(), q.pop();
		for(int i = 0; i < 4; ++i) {
			int xx = tp.x + d[i].x, yy = tp.y + d[i].y; 
			if(s[xx][yy] == '.' && dis[xx][yy] == -1)
				dis[xx][yy] = dis[tp.x][tp.y] + 1, q.push((node){xx, yy});
		}
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			ans = max(ans, dis[i][j]);
}

int main() {
	//freopen("a.txt", "r", stdin);
	n = read(), m = read();
	d[0].y = -1, d[1].y = 1, d[2].x = -1, d[3].x = 1;
	for(int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			if(s[i][j] == '.')
				solve(i,j);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	unsigned long long x, y, i;
	int count = 0;

	scanf("%llu%llu", &x, &y);

	for (i = x; i <= y; i *= 2){
		++count;
	}
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = A.copy()
for i in range(n):
    if A[i] >= B[i]:
        A[i] -= B[i]
    else:
        tmp = B[i] - A[i]
        A[i] = 0
        A[i + 1] -= tmp if A[i + 1] >= tmp else A[i + 1]

print(sum([c - a for (c, a) in zip(C, A)]))


Measured memory_bytes: 18624
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            memo = A[i]
            A[i] = A[j]
            A[j] = memo
    memo = A[i+1]
    A[i+1] = x
    A[r] = memo
    return i+1, A

n = int(input())
a = list(map(int, input().split()))

index, aList = partition(a, 0, len(a)-1)
aList[index] = "[" + str(aList[index]) + "]"

print(*aList)


Measured memory_bytes: 16388
n, m = map(int, input().split())

h = list(map(int, input().split()))

ans = []

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        ans.append(a)
    elif h[b-1] < h[a-1]:
        ans.append(b)
    elif h[a-1] == h[b-1]:
        ans.append(a)
        ans.append(b)
x = set(ans)

print(n-len(x))


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



int main(){
  int i,n,q,j,count=0;
  int *S;
  scanf("%d",&n);
  S=malloc((n+1)*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&S[n]);
    j=0;
    while(1){
      if(S[j]==S[n]){
        if(j!=n) count++;
        break;
      }
      j++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 632
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b,c=0;
	string s;
	cin >> a >> b >> s;
	if (s[a]=='-') {
		c = 1;
	}
	for (int i = 0; i < a + b + 1;i++) {
		if (s[i]=='-'&&i!=a) {
			c = 0;
		}
	}
	if (c==1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    print(sum([True for i in range(1, N+1) if len(str(i))%2 == 1]))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;
ll n,k;
ll arr[N];ll ans=1e10;
int main()
{  fast
   cin>>n>>k;
   for(int i=1;i<=n;i++)
   cin>>arr[i];
   ll lo=0,hi=1e18;
   while(lo+1<hi){
   	ll mid=(lo+hi)/2;
	ll cnt=0;
	for(int i=1;i<=n;i++) {

		cnt+=(arr[i]/mid);
		if(arr[i]%mid==0)
		cnt--;
	}
//	cout<<mid<<" "<<cnt<<endl;
	if(cnt<=k){
		ans=min(ans,mid);
		hi=mid;
	}
	else
	lo=mid;
   }
   cout<<hi;
}

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

int main(){
    typedef pair <string, int> P;
    queue <P> q;

    int num, qms;
    int res = 0;
    string first;
    int second;
    cin >> num >> qms;

    for (int i = 0; i < num; i++){ 
        cin >> first >> second;
        q.push(P(first,second));
    }

    while(!q.empty()){

        if(q.front().second <= qms) {
            res += q.front().second;
            P p = q.front(); q.pop();
            cout << p.first << " " << res << "\n";
        }
        else {
            P p = q.front(); q.pop();
            res += qms;
            p.second = p.second - qms;
            q.push(p);
        }
    }

    return 0;
}



Measured memory_bytes: 6168
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int INF = INT_MAX / 4;

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

struct State
{
	int y, x, d;
	State( int y, int x, int d ) : y( y ), x( x ), d( d )
	{
		return;
	}

	bool operator < ( const State &a ) const
	{
		return x < a.x;
	}
};

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

	for ( int w, h; cin >> w >> h, w | h; )
	{
		VVI board( h, VI( w ) );
		FOR( line, board )
		{
			FOR( a, line )
			{
				cin >> a;
			}
		}
		VI cs( 4 );
		FOR( c, cs )
		{
			cin >> c;
		}

		vector<VVI> costs( h, VVI( w, VI( 4, INF ) ) );
		costs[0][0][0] = 0;
		// →↓←↑

		priority_queue< pair<int,State>, vector< pair<int,State> >, greater< pair<int,State> > > que;
		que.push( MP( 0, State( 0, 0, 0 ) ) );

		while ( !que.empty() )
		{
			int c = que.top().fst;
			State cur = que.top().snd;
			que.pop();

			if ( costs[ cur.y ][ cur.x ][ cur.d ] < c )
			{
				continue;
			}

			REP( i, 0, 4 )
			{
				const int d = ( cur.d + i ) % 4;
			
				const int ny = cur.y + dy[d];
				const int nx = cur.x + dx[d];

				if ( !( 0 <= ny && ny < h && 0 <= nx && nx < w ) )
				{
					continue;
				}

				const int nc = c + ( i == board[ cur.y ][ cur.x ] ? 0 : cs[i] );
				if ( nc < costs[ ny ][ nx ][d] )
				{
					costs[ ny ][ nx ][d] = nc;
					que.push( MP( nc, State( ny, nx, d ) ) );
				}
			}
		}

		cout << *min_element( ALL( costs.back().back() ) ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1392
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

const long long mod = 1e9 + 7;

long long dp[1010][1010] = {};
vector<string> a(1010);

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++)
        cin >> a[i];

    dp[0][0] = 1;
    for (int i = 1; i < H; i++) {
        if (a[i][0] == '#') break;
        dp[i][0] = dp[i - 1][0];
    }
    for (int i = 1; i < W; i++) {
        if (a[0][i] == '#') break;
        dp[0][i] = dp[0][i - 1];
    }

    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (a[i][j] == '#') continue;
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
        }
    }

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


Measured memory_bytes: 9216
N = int(input())
a,b,c = list(map(int,input().split()))
dpa = a
dpb = b
dpc = c
for i in range(1,N):
    dpap = dpa
    dpbp = dpb
    dpcp = dpc
    a,b,c = list(map(int,input().split()))
    dpa = max(dpbp + a, dpcp + a)
    dpb = max(dpap + b, dpcp + b)
    dpc = max(dpap + c, dpbp + c)
print(max(dpa,dpb,dpc))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int x, y;
	cin >> x >> y;

	loop(i,0,x+1)
	{
		int a = i;
		int b =  x-i;

		if(a*2 + b*4 == y){
			cout << "Yes";
			return;
		} 
		if(a*4 + b*2 == y)
		{
			cout << "Yes";
			return;
		}
	}

	cout << "No";
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3656
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long k=sc.nextLong();
		int[][] dub=new int[n][61];
		int[] a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt()-1;
			dub[i][0]=a[i];
		}
		for(int i=1; i<=60; i++){
			for(int j=0; j<n; j++){
				dub[j][i]=dub[dub[j][i-1]][i-1];
			}
		}
		int now=0;
		while(k>0){
			for(int i=60; i>=0; i--){
				if(k>=1L<<i){
					k-=1L<<i;
					now=dub[now][i];
				}
			}
		}
		System.out.println(now+1);
	}
}


Measured memory_bytes: 129532
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=305;
typedef long long ll;
ll f[N][N][N],res;int a[N],n,L;
int main(){
	scanf("%d%d",&n,&L);
	fp(i,1,n)scanf("%d",&a[i]);
	memset(f,0x3f,sizeof(f));
	R ll inf=f[0][0][0];
	f[0][0][0]=0;
	fp(i,0,n-1)fp(j,0,min(i,L))fp(k,0,i)
		if(f[i][j][k]!=inf){
			cmin(f[i+1][j][i+1],f[i][j][k]+max(a[i+1]-a[k],0));
			if(j<L)cmin(f[i+1][j+1][k],f[i][j][k]);
		}
	res=inf;
	fp(i,0,n)cmin(res,f[n][L][i]);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 221952
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll a,b,c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    rep(i,1000000){
        if((b*i+c)%a==0)return YES,0;
    }
    NO;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if((x < W) && (y < H) && (x > 0) && (y > 0)){
        
        if((W - x >= r) && (H - y >= r))cout << "Yes" << endl;  
        else cout << "No" << endl;
        
        
        
    }else if((x < W) && (y < H) && (x < 0) && (y < 0)){    //おかしい
        if(((-1) * W + x >= r) && ((-1) *H + y >= r)) cout << "Yes" << endl;
        else cout << "No" << endl;
        
        
    }else if((x < W) && (y < H) && (x < 0)){
        if(((-1) *W + x >= r) && (H - y >= r))  cout << "Yes" << endl;
        else cout << "No" << endl;
        
    }else if((x < W) && (y < H) && (y < 0)){
        if((W - x >= r) && ((-1) * H + y >= r))  cout << "Yes" << endl;
        else cout << "No" << endl;
        
    
    }else cout << "No" << endl;
    
    return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long

int f(int n){
	if(n & 1){
		int t = (n + 1) / 2;
		if(t & 1){
			return 1;
		}else{
			return 0;
		}
	}else{
		int t = (n + 1) / 2;
		if(t & 1){
			return 1 ^ n;
		}else{
			return n;
		}
	}
}

main(){

	int a, b;

	cin >> a >> b;


	cout << (f(a - 1) ^ f(b)) << endl;



	return 0;
}

Measured memory_bytes: 256
program agc033a
  implicit none
  character(1000) s
  integer h,w,x,y
  integer,allocatable :: grid(:,:)

  read *,h,w
  allocate(grid(w,h))

  do y = 1,h
     read *,s
     do x = 1,w
        grid(x,y) = merge(0,1000000,s(x:x)=='#')
     end do
  end do

  do x = 2,w
     grid(x,:) = merge(grid(x-1,:)+1,grid(x,:),grid(x,:)-grid(x-1,:)>1)
     grid(w-x+1,:) = merge(grid(w-x+2,:)+1,grid(w-x+1,:),grid(w-x+1,:)-grid(w-x+2,:)>1)
  end do

  do y = 2,h
     grid(:,y) = merge(grid(:,y-1)+1,grid(:,y),grid(:,y)-grid(:,y-1)>1)
     grid(:,h-y+1) = merge(grid(:,h-y+2)+1,grid(:,h-y+1),grid(:,h-y+1)-grid(:,h-y+2)>1)
  end do

  print *,maxval(grid)
end program agc033a


Measured memory_bytes: 4352
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    ll n=in();
    string s;
    cin>>s;
    ll a=0;
    ll ans=1;
    rep(i,2*n){
        if((s[i]=='B')^(i%2)){
            a++;
        }
        else{
            ans*=a;
            ans%=MOD;
            a--;
            if(a==-1){
                cout<<0;return 0;
            }
        }
    }
    if(a>0){cout<<0;return 0;}
    rep(i,n){
        ans=ans*(i+1)%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{ 
    char W[11], Ti[30]; 
    int i, count=0; 

    scanf("%s", W); 
    while(1)
    { 
        scanf(" %s", Ti); 
        if(strcmp(Ti, "END_OF_TEXT") == 0)
        {
        break; 
        }

        for(i = 0; Ti[i] != '\0'; i++)
        { 
            Ti[i] = tolower(Ti[i]); 
        } 
        
        if(strcmp(Ti, W) == 0)
        { 
            count++; 
        } 
    } 

    printf("%d\n", count); 
    return 0; 
} 


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

typedef long long int ll;
string s;
ll q, t, f;
char c;

int main() {
    cin >> s >> q;
    string pref = "", suff = "";
    bool reversed = 0;
    for(ll i = 0; i < q; ++i) {
        cin >> t;
        if(t == 1) {
            reversed = 1 - reversed;
        } else {
            cin >> f >> c;
            if(f == 1) {
                if(reversed) suff += c;
                else pref += c;
            } else {
                if(reversed) pref += c;
                else suff += c;
            }
        }
    }

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

    s = pref + s + suff;

    if(reversed) reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}

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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x, y, a;
    int x_min=0, x_max=w, y_min=0, y_max=h;
    for(int i=0; i<n; i++) {
        cin >> x >> y >> a;
        if(a==1 && x_min<x) x_min=x;
        else if(a==2 && x_max>x) x_max=x;
        else if(a==3 && y_min<y) y_min=y;
        else if(a==4 && y_max>y) y_max=y;
    }

    if(x_max<x_min || y_max<y_min) cout << '0' << endl;
    else cout << (x_max-x_min) * (y_max-y_min) << endl;
    return 0;
}



Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		System.out.println(Main.calc(s.nextInt(), s.nextInt()));
	}
	public static String calc(int n,int y) {
		for(int i=0;i<=n;i++) {
			for(int j=0;i+j<=n;j++) {
				int k = n-(i+j);
				if(i+j+k==n && i*10000+j*5000+k*1000==y) {
					return i+" "+j+" "+k;
				}
			}
		}
		return "-1 -1 -1";
	}
}

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

int main(){
  int n; cin>>n;
  vector<long long> a(3*n);
  for(int i=0;i<3*n;i++)cin>>a[i];
  
  sort(a.rbegin(),a.rend());
  
  long long ans=0;
  for(int i=1;i<2*n;i+=2)ans+=a[i];
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())
    X = list(map(int,input().split()))

    avg_min = int(sum(X) / len(X))
    avg_max = avg_min+1

    ans_min = [ (x - avg_min) ** 2 for x in X]
    ans_max = [ (x - avg_max) ** 2 for x in X]

    print(min(sum(ans_min),sum(ans_max)))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn =1010;
int mp[maxn][maxn];
int col[maxn];
int row[maxn];
int te[maxn][maxn];
int main(){

    int n,m,a,b;
    scanf("%d%d%d%d",&n,&m,&a,&b);
    for(int i = 1;i<=b; ++i){
        for(int j = 1;j<=m;++j){
            te[i][j] = 1;
        }
    }
    for(int i = 1;i<=n;++i){
        for(int j = 1;j<=a;++j){
            te[i][j]^=1;
        }
    }
    for(int i =1;i<=n;++i){
        for(int j = 1;j<=m;++j){
            printf("%d",te[i][j]);
        }
        printf("\n");
    }
    /*
    for(int i = 0;i<n;++i)row[i] = a,col[i] = b;
    if(n==1){
        if(b!=0){
            cout<<-1<<endl;
            return 0;
        }
        for(int i = 0;i<n;++i){
            if(a){
                a--;
                cout<<1;
            }
            else cout<<0;
        }
        cout<<endl;
        return 0;
    }

    for(int i = 0;i<n;++i){

        for(int j = 0;j<m;++j){
            if(col[j]&&row[i]){
                col[j]--;
                row[i]--;
                te[i][j]=1;
            }
            else{
                te[i][j] = 0;
            }
        }

    }
    int flag = 0;
    for(int i = 0;i<n;++i){
        if(row[i])flag = 1;
    }
    for(int i = 0;i<m;++i){
        if(col[i])flag = 1;
    }
    if(flag)cout<<-1<<endl;
    else{
        for(int i = 0;i<n;++i){
            for(int j = 0;j<m;++j){
                printf("%d",te[i][j]);
            }
            printf("\n");
        }
    }

    */

}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll mod=1e9+7;
int main() {
  /*  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    int b[n];
    int l=0;
    for(int i=0;i<n;i++){
    	int x=a[i];
    	for(;i<n;i++){
    		if(a[i]!=x) break;
    	}
    	i--;
    	b[l++]=x;
    }
    n=l;
    vector<vector<int>> v(200001); 
    ll dp[n+1];
    dp[n]=1;
    dp[n-1]=1;
    v[b[n-1]].push_back(n-1);
    for(int i=n-2;i>=0;i--){
    	v[b[i]].push_back(i);
    	dp[i]=dp[i+1];
    	if(v[b[i]].size() >= 2){
    		dp[i]=(dp[i]+dp[ v[b[i]][(int)v[b[i]].size()-2] ] )%mod;
    	}
    }
    cout<<dp[0];
}

Measured memory_bytes: 14336
#include<iostream>
#include<complex>
using namespace std;
int main(){
  complex<double> a,b,c,d;
  while(cin >>a.real()>>a.imag()>>b.real()>>b.imag()>>c.real()>>c.imag()>>d.real()>>d.imag()){
    if(d.real()<a.real() || b.real()<c.real() || d.imag()<a.imag() || b.imag()<c.imag()) cout <<"NO"<<endl;
    else cout <<"YES"<<endl;
  }
  return 0;
}

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

int main() {
  long long N;
  cin >> N;

  vector<long long> v(N + 1);
  v[0] = 2;
  v[1] = 1;
  for (long long i = 2; i < N + 1; i++) v[i] = v[i - 1] + v[i - 2];
  cout << v[v.size() - 1] << endl;
}


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

void solve(long long N, long long R) {
    if (N < 10) {
        ll ans = R + 100 * (10 - N);
        cout << ans << endl;
        return;
    } else {
        cout << R << endl;
        return;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    long long N;
    std::cin >> N;
    long long R;
    std::cin >> R;
    solve(N, R);
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] arr = new int[N];

        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr);

        int count = 0;
        long sum = 0;
        sum += (long) arr[N - 1];
        count++;
        int i = N - 2;

        while(count < N - 1) {
            sum += (long) arr[i];
            count += 1;

            if(count + 1 < N) {
                sum += (long) arr[i];
                count += 1;
                i--;
            }
        }

        System.out.println(sum);
    }
}


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

int main() {
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);

    if (a[0] == a[1])
        cout << a[2];
    else
        cout << a[0];
    cout << endl;

    return 0;
}


Measured memory_bytes: 3632
/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define			endl			"\n"


using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        swap(a,b);
    if(a%b==0 || b==0)
        return b;
    else
        return gcd(b,a%b);
}



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



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}





int main()
{
    fast;
    ll n,d,cnt=0;
    cin>>n>>d;
    rep(i,n)
    {
    	ll x,y;
    	cin>>x>>y;
    	sqrtl((ll)(x*x) + (ll)(y*y))<=d?cnt++:cnt+=0;
	}
	cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3704
S = input()
s_list = list(S)

acgt = list("ACGT")

max_length = 0
max_length_bottom = 0

tmp_length = 0
for i, s in enumerate(s_list):
    if s in acgt:
        tmp_length += 1
    if tmp_length > max_length:
        max_length = tmp_length
#         max_length_bottom =i
    if s not in acgt:
        tmp_length = 0
        
print(max_length)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    map<pair<int, int>, ll> countPair;
    for (int i = 1; i <= 9; ++i)
    {
        for (int j = 1; j <= 9; ++j)
        {
            pair<int, int> p = make_pair(i, j);
            countPair[p] = 0;
        }
    }
    for (ll i = 1; i <= N; ++i)
    {
        if (i % 10 != 0)
        {
            int firstDigit, lastDigit;
            firstDigit = i % 10;
            ll num = i;
            while(num != 0)
            {
                if (num / 10 == 0) lastDigit = num % 10;
                num /= 10;
            }
            pair<int, int> p = make_pair(firstDigit, lastDigit);
            countPair[p]++;
        }
    }

    ll ans = 0;
    for (int i = 1; i <= 9; ++i)
    {
        for (int j = 1; j <= 9; ++j)
        {
            pair<int, int> p = make_pair(i, j);
            pair<int, int> q = make_pair(j, i);
            ans += countPair[p] * countPair[q];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
r, c = map(int, input().split())
A = [[0 for i in range(c + 1)] for j in range(r + 1)]

for i in range(r):
    l = list(map(int, input().split()))
    for j in range(c):
        A[i][j] = l[j]
        A[r][j] += l[j]
    A[i][c] = sum(l)
    A[r][c] += sum(l)

for i in range(r + 1):
    for j in range(c):
        print(A[i][j], "", end = "")
    print(A[i][c])



Measured memory_bytes: 6752
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

sum = 0
minus = 0
min_abs = 10 ** 9
n.times do |i|
  sum += a[i].abs
  minus += 1 if a[i] < 0
  min_abs = a[i].abs if min_abs > a[i].abs
end

sum -= 2 * min_abs if minus%2 == 1

puts(sum)

Measured memory_bytes: 9732
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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;
    cin>>a>>b>>c;
    if(a+b+c<=21)out("win");
    else out("bust");
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'

using namespace std ;

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{

    lli n,k;
    cin>>n>>k;

    cout<<n-k+1<<endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N=int(input())
ans=dict()
cnt=0

for _ in range(N):
    A=int(input())
    if((A in ans)==False):
        ans[A]=1
    else:
        ans[A]+=1

for value in ans.values():
    if(value%2==1):
        cnt+=1

print(cnt)


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define yes cout<<"Yes"<<nl
#define no cout<<"No"<<nl
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  ll n,sum=0,p;
  cin>>n;
  p=n;
  while(p>0)
  {
    sum+=p%10;
    p/=10;
  }
  if(n%sum==0)
    yes;
  else
    no;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
 long long a,b,c,k;
  cin>>a>>b>>c>>k;
 long long sum=0;
 
   if(k<=a)
    cout<<k;
  else if(k>=a&&k<=(a+b))
    cout<<a;
  else if(k>(a+b))
    cout<<a-(k-(a+b));
 else
   cout<<a-c;
  return 0;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n), sum(n+1, 0);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	rep(i,n) sum[i+1] = sum[i] + a[n-1-i];
	ll ok = 0, ng = 1e18;
	while(ng - ok > 1){
		ll mid = (ok + ng) / 2;
		ll score = 0;
		rep(i,n){
			score += n - (lower_bound(a.begin(), a.end(), mid-a[i]) - a.begin());
		}
		if(score >= m) ok = mid;
		else ng = mid;
	}
	ll ans = 0, cnt = 0;
	rep(i,n){
		ll idx = n - (lower_bound(a.begin(), a.end(), ok-a[i]) - a.begin());
		ans += a[i] * idx + sum[idx];
		cnt += idx;
	}
	if(cnt > m) ans -= ok * (cnt - m);
	cout << ans << endl;
	return 0;
}


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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else if(k-a<=b) cout<<a;
    else cout<<2*a+b-k;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    String rawInput = sc.next();
    
    String input = "^" + rawInput + "$";
    char[] map = input.toCharArray();
    char[] ts = new char[q]; 
    char[] ss = new char[q]; 
    for (int i = 0; i < q; i++) {
      String t = sc.next();
      String s = sc.next();
      ts[i] = t.charAt(0);
      ss[i] = s.charAt(0);
    }
    
    int aliveMin = 1;
    int aliveMax = n;
    
    for (int i = q-1; i >= 0; i--) {
//      System.out.printf("i: %d, aliveMin: %d, aliveMax: %d\n", i, aliveMin, aliveMax);
      if (ss[i] == 'L') {
        if (map[aliveMin] == ts[i]) {
          aliveMin++;
        }
        if (map[aliveMax + 1] == ts[i]) {
          aliveMax++;
        }
      } else {
        if (map[aliveMin - 1] == ts[i]) {
          aliveMin--;
        }
        if (map[aliveMax] == ts[i]) {
          aliveMax--;
        }
      }
    }
//      System.out.printf("i: %d, aliveMin: %d, aliveMax: %d\n", 0, aliveMin, aliveMax);
    
    if (aliveMax >= aliveMin) {
      System.out.println(aliveMax - aliveMin + 1);
    } else {
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 67696
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

#define FUTAGO(x) ((x) ? "Yay!" : ":(")

int dp[33333][9];
int kyo(string S, string T) {
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= S.size(); ++i) {
		for (int j = 1; j <= T.size(); ++j) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (S[i - 1] == T[j - 1]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
		}
	}
	return dp[S.size()][T.size()];
}

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int ans = 0;
	for (char c1 = '0'; c1 <= '9'; ++c1)
		for (char c2 = '0'; c2 <= '9'; ++c2)
			for (char c3 = '0'; c3 <= '9'; ++c3)
			{
				string T; T.push_back(c1); T.push_back(c2); T.push_back(c3);
				if (kyo(S, T) == 3) {
					++ans;
				}
			}
	cout << ans << endl;
	return 0;
}

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


int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n)
    cin >> a[i] >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n % 2 == 1)
    cout << b[n/2] - a[n/2] + 1 << endl;
  else
  {
    int l = (a[n/2] + a[n/2-1]) / 2;
    int h = (b[n/2] + b[n/2-1]) / 2;
    int ans = (h - l) * 2 + 1;
    if ((a[n/2] + a[n/2-1]) % 2 == 1)
      ans--;
    if ((b[n/2] + b[n/2-1]) % 2 == 1)
      ans++;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int c=0;
  c+=max(a,b);
  if(a>=b)
    a--;
  else
    b--;
  c+=max(a,b);
  cout<<c<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  vector<ll> count(100001);
  ll sum = 0LL;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    count[a]++;
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    sum += count[b] * (c - b);
    count[c] += count[b];
    count[b] = 0;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 4040
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

template <typename T> void max_self(T& a,T b)
{
  a = max(a,b);
}

const int nax = 305;
double p[nax][nax][nax], ex[nax][nax][nax];


int main() 
{

   //Didnot understand fully, just replicated errichto's code
int n,k;
cin>>n>>k;
//cout<<" n = "<<n<<" k = "<<k<<endl;
vector<int> ar(n);
for(int i=0;i<n;i++)
{
  cin>>ar[i];
  //cout<<ar[i]<<endl;
}
//dp[i] represents first guy wins with i stones remaingin in the pile
vector<bool> dp(k+1);

for(int stones=0;stones<=k;stones++)
{
  for(auto c:ar)
  {
    if(stones>=c && !dp[stones-c])
    {
      dp[stones] = true;
    }
  }
}
if(dp[k])
{
  cout<<"First"<<endl;
}
else
{
  cout<<"Second"<<endl;
}
return 0;
}


Measured memory_bytes: 256