akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
  int n, m;
  while (scanf(" %d %d ", &n, &m) == 2) {
    int N = n + m, a = 10, i;
    for (i = 0;;i++) {
      if ((N /= a) == 0) {break;}
    }
    printf("%d\n", i + 1);
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  char s[8];
  char t[8];
  int i,j;
  int ans,ans2;
  int n;
  char tmp;
  scanf("%d",&n);
  while(n>0){
    scanf("%s",s);
    for(j=0;j<8;j++)t[j]=s[j];

    for(i=0;i<8;i++){
      for(j=7;i<j;j--){
	if(s[j]<s[j-1]){
	  tmp=s[j];
	  s[j]=s[j-1];
	  s[j-1]=tmp;
	}
	if(t[j]>t[j-1]){
	  tmp=t[j];
	  t[j]=t[j-1];
	  t[j-1]=tmp;
	}
      }
    }
    
    ans=atoi(s);
    ans2=atoi(t);
    printf("%d\n",ans2-ans);
    n--;
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n,ans1=0, ans2=0, p=0, p1, p2;
	cin >> n;

	vector<int> x(n, 0);
	for (int i=0; i<x.size(); i++)
		cin >> x[i];

	for(auto i:x)
		p += i;
	p1 = p/n;
	p2 = (p+n-1)/n;

	for (int i=0; i<x.size(); i++) {
		ans1 += pow(abs(x[i] - p1),2);
		ans2 += pow(abs(x[i] - p2),2);
	}

	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    rep(i, N)
    {
        ans += i + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc;
LL ar[50000001];
LL br[50000001];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n;
        s=0;
        for(i=1; i<=200; i++)
        {
            for(j=1; j<=200; j++)
            {
                for(l=1; l<=200; l++)
                {
                    k=(i*i)+(j*j)+(l*l)+(i*j)+(i*l)+(l*j);
                    u[k]++;
                    if(k>10000)
                    {
                        s=1;
                        break;
                    }
                }
            }
        }
        for(i=1; i<=n; i++)
        {
            cout<<u[i]<<endl;
        }

    }
    return 0;
    //IN
    //AL
}


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

using namespace std;

int main(void){
  int g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y;
  cin >> x >> y;
  if(g[x] == g[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    XY=[tuple(map(int,input().split())) for i in range(n-1)]
    graph=[[]for _ in range(n)]
    for x,y in XY:
        graph[x-1].append(y-1)
        graph[y-1].append(x-1)
    queue=deque([0])
    visited=[False]*n
    use=[False]*n
    #i番目に訪れた頂点までについて，i番目の頂点を白に塗る塗り方，黒
    dp=[[0,0] for _ in range(n)]
    mod=10**9+7
    while queue:
        node=queue[-1] #末尾の要素がvisited→葉に着いた
        if not visited[node]:
            visited[node]=True
            for xnode in graph[node]:
                if visited[xnode]:continue
                queue.append(xnode)
        else:
            queue.pop()
            b,w=1,1
            for xnode in graph[node]:   
                if use[xnode]:
                    w=w*(dp[xnode][0]+dp[xnode][1])%mod
                    b=b*dp[xnode][0]%mod 
            dp[node][0]=w%mod
            dp[node][1]=b%mod 
            use[node]=True
    print(sum(dp[0])%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 83420
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
 
    string S;
    cin >> S;
    
    int ans = 0;
    
    for(int i = 0; i < S.size(); i++){
        
        int count = 0;
        
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            count++;
            for(int j = i + 1; j < S.size(); j++){
                if(S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T'){
                    count++;
                }
                else{
                    break;
                }
            }
            ans = max(ans, count);
        }    
    }
    
    cout << ans << endl;
}


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

class Main {

	public static int[] color;
	public static int red, blue;
	public static List<Integer>[] e;

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

		e = new List[n];
		for (int i = 0; i < n; i++) e[i] = new ArrayList<>();
		for (int i = 0; i < n - 1; i++) {
			int v = sc.nextInt() - 1;
			int w = sc.nextInt() - 1;
			e[v].add(w);
			e[w].add(v);
		}

		color = new int[n];
		color[0] = 1;
		red = 1;
		blue = 0;

		dfs(0);
		StringBuilder sb = new StringBuilder();
		int a1 = 1, a2 = 2, a3 = 3;
		if (red > n / 3 && blue > n / 3) {
			for (int i = 0; i < n; i++) {
				if (color[i] == 1) {
					if (a1 <= n) {
						sb.append(a1);
						a1 += 3;
					} else {
						sb.append(a3);
						a3 += 3;
					}
				} else {
					if (a2 <= n) {
						sb.append(a2);
						a2 += 3;
					} else {
						sb.append(a3);
						a3 += 3;
					}
				}
				sb.append(" ");
			}
		} else if (red < blue) {
			for (int i = 0; i < n; i++) {
				if (color[i] == 1) {
					sb.append(a3);
					a3 += 3;
				} else {
					if (a2 <= n) {
						sb.append(a2);
						a2 += 3;
					} else if (a1 <= n) {
						sb.append(a1);
						a1 += 3;
					} else {
						sb.append(a3);
						a3 += 3;
					}
				}
				sb.append(" ");
			}
		} else {
			for (int i = 0; i < n; i++) {
				if (color[i] == 2) {
					sb.append(a3);
					a3 += 3;
				} else {
					if (a1 <= n) {
						sb.append(a1);
						a1 += 3;
					} else if (a2 <= n) {
						sb.append(a2);
						a2 += 3;
					} else {
						sb.append(a3);
						a3 += 3;
					}
				}
				sb.append(" ");
			}
		}

		System.out.println(sb.deleteCharAt(sb.length() - 1).toString());
	}

	private static void dfs(int v) {
		for (int i = 0; i < e[v].size(); i++) {
			if (color[e[v].get(i)] != 0) continue;
			if (color[v] == 1) {
				color[e[v].get(i)] = 2;
				blue++;
			} else if (color[v] == 2) {
				color[e[v].get(i)] = 1;
				red++;
			}
			dfs(e[v].get(i));
		}
	}
}


Measured memory_bytes: 151556
p1=input()
p2=input()
ans=""
if len(p1)==len(p2):
    for i in range(len(p1)):
        ans+=p1[i]
        ans+=p2[i]
else:
    for i in range(len(p1)-1):
        ans+=p1[i]
        ans+=p2[i]
    ans+=p1[-1]
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  string s;
  cin>>s;
  int ans=100000;
  for(char i='a';i<='z';i++){
    int cnt=0;
    int ma=0;
    rep(j,s.size()){
      if(s[j]!=i)ma=max(ma,++cnt);
      else cnt=0;
    }
    ans=min(ans,ma);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

int main()
{
    double a;
    double area, length;
    cin >> a;
    area = a * a * M_PI;
    length = 2 * a * M_PI;

    cout << fixed << setprecision(15);
    cout << area << " " << length << endl;

    return 0;
}


Measured memory_bytes: 3276
#include <queue>

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define FOR(i, l, r) for(int i = (l); i <= (r); i++)
#define REP(i, l, r) for(int i = (l); i != (r); i++)
#define DFR(i, l, r) for(int i = (l); i >= (r); i--)
#define DRP(i, l, r) for(int i = (l); i != (r); i--)

using namespace std;

#define DEBUG(arg...) fprintf(stderr, arg)

namespace FI {
	const int SIZE = 1 << 18 | 1;
	char buf[SIZE], *front, *back;

	void NextChar(char &c) {
		if(front == back) back = (front = buf) + fread(buf, 1, SIZE, stdin);
		c = (front == back) ? (char)EOF : *front++;
	}

	template<typename T> void NextNum(T & x) {
		char c; int f = 1;
		for(NextChar(c); c > '9' || c < '0'; NextChar(c)) if(c == '-') f = -1;
		for(x = 0; c >= '0' && c <= '9'; NextChar(c)) x = (x << 3) + (x << 1) + c - '0';
		x *= f;
	}
}

typedef long long LL;

const int maxn = 200000 + 47;

int n, m, num[maxn][2];
int head[maxn], to[maxn << 1], nxt[maxn << 1], tot;
char s[maxn];
bool vis[maxn];
queue<int> q;

void add(int u, int v) {
	to[++tot] = v, nxt[tot] = head[u], head[u] = tot;
	to[++tot] = u, nxt[tot] = head[v], head[v] = tot;
}

int main() {
	memset(head, -1, sizeof head);
	
	scanf("%d%d%s", &n, &m, s + 1);
	for(int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		add(u, v);
		num[u][s[v] == 'B']++;
		num[v][s[u] == 'B']++;
	}
	for(int i = 1; i <= n; i++) if(!num[i][0] || !num[i][1]) q.push(i), vis[i] = true;
	while(!q.empty()) {
		int u = q.front(); q.pop();
		for(int i = head[u]; i != -1; i = nxt[i]) {
			int v = to[i];
			num[v][s[u] == 'B']--;
			if((!num[v][0] || !num[v][1]) && !vis[v]) q.push(v), vis[v] = true;
		}
	}
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 6400
class uft():
    def __init__(self,n):
        #pは代表元か-1
        self.p=[ -1 for i in range(n)]
        #ランク　木の深さ
        self.r=[ 1 for i in range(n)]
        #要素数
        self.e=[ 1 for i in range(n)]
        
    def find(self,x):
        if(self.p[x]==-1):
            return x
        else:
            self.p[x]=self.find(self.p[x])
            return self.find(self.p[x])
        
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            return
        
        if(self.r[x]>self.r[y]):
            tmp=x
            x=y
            y=tmp
        
        if(self.r[x]==self.r[y]):
            self.r[y]+=1
        
        self.e[y]+=self.e[x]
            
        if(x!=y):
            self.p[x]=y
        return
    
    def tsize(self,x):
        return self.e[self.find(x)]
n,m=map(int,input().split())

uf=uft(n)
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    uf.unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,uf.tsize(i))
print(ans)

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

namespace ABC102B
{
    public class B_MaximumDifference
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine();
            Console.WriteLine(CalcMaximumDiff(N, ai));
        }

        public static int CalcMaximumDiff(int N, string Ai)
        {
            var intAiList = Ai.Split(' ').Select(int.Parse).ToList();

            // 配列を昇順ソートし、1番目の要素と、最後の要素の差を返す
            intAiList.Sort();
            return intAiList[^1] - intAiList[0]; 
        }
    }
}


Measured memory_bytes: 28152
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

A,B = II()
if (A+B)%2 ==0:
  print((A+B)//2)
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int num[100010];
int main(){
    int n;
    cin>>n;
    int count=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
        if(num[i]==i) count++;
    }
    if(!count){
        cout<<0<<endl;
        return 0;
    }
    count=0;
    for(int i=1;i<=n;i++){
        if(num[i]==i){
            count++;
            swap(num[i],num[i+1]);
        }
    }
    cout<<count<<endl;
}


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

int main() {
    long n, k, cur = 1, cnt = 1;
    cin >> n >> k;
    vector<long> a(n);
    vector<bool> flag(n, true);
    rep(i, n) cin >> a.at(i);
    bool f = true;
    do {
        k--;
        f &= flag.at(cur - 1);
        flag.at(cur - 1) = false;
        cur = a.at(cur - 1);
    } while(k > 0 && f);
    long temp = a.at(cur - 1);
    while(k > 0 && temp != cur) {
        cnt++;
        temp = a.at(temp - 1);
    }
    k %= cnt;
    rep(i, k) cur = a.at(cur - 1);
    cout << cur << endl;
}

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

using namespace std;
typedef long long ll;

int n,w;
pair<ll,ll> a[105];
ll dp[100005][105];
const int inf = 0x3f3f3f3f;

int main()
{   cin>>n>>w;
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        cin>>a[i].second;
    }
    memset(dp,inf,sizeof(dp));
    dp[0][0]=0;
    dp[a[0].second][0]=a[0].first;
    ll ans=-1;

    for(int it=0;it<n-1;it++){
        for(int p=0;p<=1e5;p++){
            if(dp[p][it]!=inf){
               dp[p][it+1]=min(dp[p][it],dp[p][it+1]);
            if(dp[p][it]+a[it+1].first<=w){
                dp[p+(a[it+1].second)][it+1]=min(dp[p+(a[it+1].second)][it+1],dp[p][it]+(a[it+1].first));
                ans=max(ans,p+a[it+1].second);
            }

            }
  
        }
    }
	cout<<max(ans,a[0].second);


    return 0;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long M  = 1e9+7;
 
 
signed main(){
    fast;
 	int n,k; cin >> n >> k;
 	if(500*n >=k){
 		cout << "Yes" << endl;
 	}   
 	else{
 		cout << "No" << endl;
 	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,k; cin >> n >> k;
    int ans = 1000000000;
    for (int i = 0; i < n; i++) {
        int cnt = 1;
        for (int j = 0; j < n; j++) {
            if (j <= i) cnt *= 2;
            else cnt += k;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
 
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
 
struct Edge {
	int u, v, c;
	void read() {
		std::cin >> u >> v >> c;
		u--;v--;
	}
};
 
int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m, p;
	std::cin >> n >> m >> p;
	std::vector<Edge> edges(m);
	for(int i = 0; i < m; i++) {
		edges[i].read();
		edges[i].c = p - edges[i].c;
	}
	const long long INF = 1e18;
	std::vector<long long> dist(n, INF);
	auto bellman = [&]() {
	    for(int i = 0; i < n; i++) {
	        for(auto e : edges) {
	            if(dist[e.u] < INF) {
	                dist[e.v] = std::min(dist[e.v], dist[e.u] + e.c);
	            }
	        }
	    }
	};
	dist[0] = 0;
	bellman();
	auto ori = dist;
	long long ans = dist[n-1];
	bellman();
	for(int i = 0; i < n; i++) {
	    if(dist[i] != ori[i]) {
	        dist[i] = -INF;
	    }
	}
	bellman();
	if(ans == dist[n-1]) {
		ans = std::max(-ans, 0LL);
	} else {
		ans = -1;
	}
	std::cout << ans << '\n';
	
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
vector<int>prime;
vector<bool>mark(2e5 + 7, true);
vector<long long>fact(1e6 + 20);
long long mod = 1e9 + 7;
long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}
void sieve(int n){
    int lim = sqrt(n);
    mark[1] = false;
    for(int i = 4; i <= n; i = i + 2){
        mark[i] = false;
    }
    prime.push_back(2);
    for(int i = 3; i <= n; i = i + 2){
        if(mark[i]){
            prime.push_back(i);
            if(i <= lim){
                for(int j = i * i; j <= n; j = j + 2 * i){
                    mark[j] = false;
                }
            }
        }
    }
}
int main(){
    sieve(100010);
    fact[0] = 1;
    for(long long i = 1; i <= 1000000; i++){
        fact[i] = (fact[i - 1] * i) % mod;
    }
    int n, m;
    cin >> n >> m;
    vector<long long>power;
    for(int i = 0; i < prime.size(); i++){
        if(m % prime[i] == 0){
            int cnt = 0;
            while(m % prime[i] == 0){
                m = m/prime[i];
                cnt++;
            }
            power.push_back(cnt);
        }
    }
    if(m != 1){
        power.push_back(1);
    }
    long long ans = 1;
    for(int i = 0; i < power.size(); i++){
        long long cur = (fact[power[i]] * fact[n - 1]) % mod;
        cur = bigmod(cur, mod - 2);
        cur = (cur * fact[power[i] + n - 1]) % mod;
        ans = (ans * cur) % mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 10984
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll q1,b,c1,c2,q2;
  cin >> q1;
  while(q1!=0){
    cin >> b >> c1 >> c2 >> q2;
    ll x1=0,x2=0,m=min(c1,c2);
    bool f=false;
    //cout << b-min(c1,c2)*q1 << endl;
    
    if(c1<=c2){
      if(b<c1*q2+c2*(q1-q2)) f=true;
      while(b>=c1*(x1+1)&&x1<q2) x1++;
      while(b>=c1*x1+c2*(x2+1)) x2++;
      if(x1==0) f=true;
      if(f) cout << "NA" << endl;
      else cout << x1 << " " << x2 << endl;
      cin >> q1;
    }else{
      if(b<m*q1) f=true;
      ll s=c1-c2,sum=0;
      sum=q1*m;
      while(b-sum>=s*(x1+1)&&x1<q1&&x1<q2) {
        x1++; 
        //cout << b-sum<<":"<<s*x1<<endl;
        //cout << x1<<":"<<c1*x1<<endl;
      }
      if(x1==q1)
        while(b>=c1*(x1+1)&&x1 + 1<=q2) x1++;
      //while(b>=c1*x1+c2*(x2+1)) x2++;
      
      if(x1==0) f=true;
      x2=0;
      while(b>=c1*x1+c2*(x2+1)) x2++;
      if(f) cout << "NA" << endl;
      else cout << x1 << " " << x2 << endl;
      //cout << c1*x1+c2*x2 << endl;
      cin >> q1;
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define int ll
vector<int> dp;

int32_t main(){
	int n;
	cin >> n;
	vector<int> arr(n, 0);
	for(int i = 0 ; i < n ; i ++){
		cin >> arr[i];
		}
	dp.assign(n, INT_MAX);
	dp[0] = 0;
	for(int i = 1; i < n ; i ++){
		if(i>0)
			dp[i] = min(dp[i], dp[i-1]+abs(arr[i]-arr[i-1]));
		if(i>1)
			dp[i] = min(dp[i], dp[i-2]+abs(arr[i]-arr[i-2]));
		}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
int n,m;
int sum,a[100050];
bool ans=0;
int main(){
	sum=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		sum+=a[i];
		if(sum>m){
			ans=1;
			printf("%d\n",i-1);
			break;
		}
	}
	if(ans==0){
		printf("%d\n",n+(m-sum)/a[1]);
	}
}

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

#define MAX 200002

int n;

vector<long long int> v;
vector<long long int> vv;


int can[MAX];

#define MOD 1000000007LL

long long int k[MAX];

vector<int> ng;

int main(){
	k[0] = 1;
	for (int i = 1; i < MAX; i++){
		k[i] = k[i - 1];
		k[i] *= (long long int)(i);
		k[i] %= MOD;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	long long int way = 1;
	long long int rest = 0;
	int cer = -1;
	for (int i = 0; i < n; i++){
		cer += 2;
		rest++;
		if (cer>v[i]){
			ng.push_back(i);
			cer -= 2;
			way *= rest;
			way %= MOD;
			rest--;
		}
	}
	way *= k[rest];
	way %= MOD;
	printf("%lld\n", way);
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	string S;
	cin >> S;

	vector<int> cnt(256);
	bool result = true;

	for( auto c: S ) {
		cnt[c] += 1;

		if( cnt[c] > 1 ) {
			result = false;
			break;
		}
	}

	cout << (result ? "yes\n" : "no\n");

	return 0;
}


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

typedef long long ll;
typedef long double ld;

int main()
{

  ll A,B,C,K,ans = 0;
  cin >> A >> B >> C >> K;

  if(K <= A + B + C){
    if(K > A){
      ans += A;
      K -= A;
      if(K > B){
        K -= B;
        if(K > C){
          ans -= C;
        }else{
          ans -= K;
        }
      }
    }else{
      ans += K;
    }
  }

  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<string> s;
	int n = next<int>();
	while(n--) s.insert(next<string>());
	cout<<s.size()<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 19216
N, X = map(int,input().split())
x = list(map(int,input().split()))

x = [abs(X-xx) for xx in x]

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

ans = x[0]
for i in range(1,N):
  ans = gcd(ans, x[i])
print(ans)

Measured memory_bytes: 14252
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();
		int R = 0, B = 0;
		for (int i = 0; i < s.length(); i++) {
			if (String.valueOf(s.charAt(i)).equals("R"))
				R++;
			else
				B++;
		}
		System.out.println(R > B ? "Yes" : "No");
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int N;

void dfs(string s, char mx){
    if(s.length() == N) cout << s << endl;
    else {
        for(char c = 'a'; c <= mx; c++){
            char next = c == mx ? mx + 1 : mx;
            dfs(s + c, next);
        }
    }
}

int main() {
    cin >> N;
    dfs("", 'a');
    return 0;
}




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

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

void solve() {
	int x; cin >> x;
    if(x >= 30) {
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl;
    }
}

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

Measured memory_bytes: 3648
import java.math.BigDecimal;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        ArrayDeque<String> stack = new ArrayDeque<>();
        for (int i=0; i<s.length(); i++){
            if (s.charAt(i) == '0'){
                stack.offerLast("0");
            }else if (s.charAt(i) == '1'){
                stack.offerLast("1");
            }else if (s.charAt(i) == 'B'){
                if (!(stack.isEmpty())){
                    stack.pollLast();
                }
            }
        }
        for (String b : stack){
            System.out.print(b);
        }
        System.out.println();
    }
}

Measured memory_bytes: 23764
#include <cassert>
#include <iostream>

int f(int x)
{
    return x * x;
}
int main()
{
    while(true){
        int d;
        std::cin >> d;
        if(std::cin.eof()) break;
        
        int s = 0;
        for(int x = d; x < 600; x += d){
            s += d * f(x);
        }
        std::cout << s << std::endl;;
    }
    return 0;
}

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

using namespace std;

char DIR[3005][3005];


void printLCS(int l1,int l2,string str){
    if(l1==0 || l2==0){
        return ;
    }
    if(DIR[l1][l2]=='A'){
        printLCS(l1-1,l2-1,str);
        cout<<str[l1-1];
    }
    else if(DIR[l1][l2]=='U'){
        printLCS(l1-1,l2,str);
    }
    else{
        printLCS(l1,l2-1,str);
    }


}

void findLCS(string str1,string str2){

    int l1=str1.length();
    int l2=str2.length();

    int M[l1+1][l2+1];

    for(int i=0;i<=l1;i++){
        M[i][0]=0;
    }
    for(int i=0;i<=l2;i++){
        M[0][i]=0;
    }


    for(int i=0;i<=l1;i++){
        for(int j=0;j<=l2;j++){
            DIR[i][j]='N';
        }
    }


    for(int i=1;i<=l1;i++){
        for(int j=1;j<=l2;j++){
            if(str1[i-1]==str2[j-1]){
                M[i][j]=M[i-1][j-1]+1;
                DIR[i][j]='A';
            }
            else{
                if(M[i-1][j]>=M[i][j-1]){
                    M[i][j]=M[i-1][j];
                    DIR[i][j]='U';
                }
                else{
                    M[i][j]=M[i][j-1];
                    DIR[i][j]='L';
                }
            }
        }
    }

  /*  for(int i=0;i<=l1;i++){
        for(int j=0;j<=l2;j++){
            cout<<M[i][j]<<" ";
        }
        cout<<endl;
    }*/

    printLCS(l1,l2,str1);


}

int main()
{
    string str1,str2;
    cin>>str1>>str2;
    findLCS(str1,str2);
    return 0;
}


Measured memory_bytes: 62400
#include <stdlib.h>
#include <iostream>
#include <list>
using namespace std;

struct node{
	int parent_id;
	int child_num;
	int* children;
};
void print_children(int *children, int size);
int get_depth(node* g, int id);
int main(){
	int n;
	cin >> n;
	node* g = (node*)calloc(n, sizeof(node));
	// initialize
	for(int i = 0; i < n; ++i){
		g[i].parent_id = -1;
	}
	//input data
	for(int i = 0; i < n; ++i){
		int id;
		int child_num;
		cin >> id;
		cin >> child_num;
		g[id].child_num = child_num;
		g[id].children = (int*)malloc(child_num * sizeof(int));
		for(int j = 0; j < child_num; ++j){
			int child_id;
			cin >> child_id;
			g[child_id].parent_id = id;
			g[id].children[j] = child_id;
		}
	}

	for(int i = 0; i < n; ++i){
		cout << "node " << i
		<< ": parent = " << g[i].parent_id
		<< ", depth = ";
		int depth = get_depth(g, i);
		cout << depth;
		if(depth == 0){
			cout << ", root";
		}else{
			if(g[i].child_num == 0){
				cout << ", leaf";
			}else{
				cout << ", internal node";
			}
		}
		cout << ", [";
		print_children(g[i].children, g[i].child_num);
		cout << "]" << endl;
	}
	return 0;
}

void print_children(int *children, int size){
	for(int j = 0; j < size; ++j){
		 	cout << children[j];
		 	if(j != size-1){
		 		cout << ", ";
		 	}
	}

}
int get_depth(node* g, int id){
	int depth = 0;
	int current_id = id;
	while(g[current_id].parent_id != -1){
		++depth;
		current_id = g[current_id].parent_id;
	}
	return depth;
}

Measured memory_bytes: 6280
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,q;
    ll k;
    cin >> n >> k >> q;

    vector<int> a(q);
    for(auto &x:a)cin >> x;

    vector<int> point(n,0);
    for(int i=0;i<q;i++){
        point[a[i]-1]++;
    }

    for(int i=0;i<n;i++){
        if(k-q+point[i]<=0){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if ( n == m)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#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 S, W;
    cin >> S >> W;
    string ans;
    if (W >= S) ans = "unsafe";
    else ans = "safe";

    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int ans = 0;
  for (int i = 1; i <= a; i++) {
    int cnt = 0;
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 4 && i % 2 != 0) ans++;
  }
  cout << ans << endl;
}

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

ans = []
while n > 0:
    p = n % 26
    if p == 0:
        p = 26
        n //= 26
        n -= 1
    else:
        n //= 26
    ans.append(chr(ord('a')-1+p))

ans.reverse()
print(''.join(ans))

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N,K;
pv<int,int> v;
llvec ans;

void input() {
	cin>>N>>K;
	init(v,K);
	ans.resize(N+1);
}

void solve() {
	sort(all(v),[&](intpair l, intpair r){
		return l.fi < r.fi;
	});
	ans[1]=1;
	for(int i=1, n=0; i<N; i++) {
		n += ans[i]; n%=MPRIME9;
		for(int j=0; j<K; j++) {
			if(i+v[j].fi>N) break;
			int s=i+v[j].fi, t=i+v[j].se+1;
			ans[s] = (ans[s]+n)%MPRIME9;
			if(t<=N) ans[t] = (MPRIME9+ans[t]-n)%MPRIME9;
		}
	}
	cout<<ans[N]<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 4772
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: &str = s.trim();
    let t = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
    for i in 0..7 {
        if s == t[i] {
            println!("{}", 7 - i);
            return;
        }
    }
}

fn main() {
    run();
}

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

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> map(h, vector<char>(w));
    vector<vector<int>> visit(h, vector<int>(w));
    queue<P> q;
    // すべての白マスの数を数える
    int white = 0;

    rep(y, h) {
        string s;
        cin >> s;
        rep(x, w) {
            map[y][x] = s[x];
            visit[y][x] = -1;
            if (s[x] == '.') white++;
        }
    }

    P start = P(0, 0);
    P goal = P(h-1, w-1);
    q.push(start);
    // startとgoalを含めて使ったマスの数を数えたいので1からスタートする
    visit[start.first][start.second] = 1;

    auto bfs = [&]() {
        while(!q.empty()) {
            P v = q.front(); q.pop();
            auto check = [&](int y, int x) {
                if (x < 0 || x >= w || y < 0 || y >= h) {
                    return;
                }
                if (map[y][x] == '#') {
                    return;
                }
                if (visit[y][x] != -1) {
                    return;
                }
                visit[y][x] = visit[v.first][v.second] + 1;
                q.push(P(y, x));
            };
            check(v.first + 1, v.second);
            check(v.first, v.second + 1);
            check(v.first - 1, v.second);
            check(v.first, v.second - 1);
        }
    };
    bfs();

    if (visit[goal.first][goal.second] == -1) {
        cout << -1 << endl;
    } else {
        cout << white - visit[goal.first][goal.second] << endl;
    }
     
    return 0;
}



Measured memory_bytes: 3632
import heapq
n = int(input())
A = list(map(int,input().split()))
L = A[:n]
R = A[2*n:]
R = list(map(lambda x:-x,R))
sum_l = [sum(L)]
sum_r = [sum(R)]
heapq.heapify(L)
heapq.heapify(R)
for i in range(n):
    elem = A[n+i]
    heapq.heappush(L,elem)
    sum_l.append(sum_l[-1] + elem -heapq.heappop(L))
for i in range(n):
    elem = -A[2*n-1-i]
    heapq.heappush(R,elem)
    sum_r.append(sum_r[-1] + elem -heapq.heappop(R))
ans = -float('inf')
sum_r = sum_r[::-1]
for i in range(len(sum_l)):
    ans = max(ans,sum_l[i] + sum_r[i])
print(ans)

Measured memory_bytes: 117044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const ll MOD2 = 1e9 + 7;
const ll MOD3 = 1e9 + 9;

ll n , ans , v[MAXN] , c[MAXN];

int main() {
    fast_io;

    cin >> n;
    for(ll i = 0 ; i < n ; i++) cin >> v[i];
    for(ll i = 0 ; i < n ; i++) cin >> c[i];

    for(ll i = 0 ; i < n ; i++) ans += max(0LL , v[i] - c[i]);
    cout << ans << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 2304
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    string s;
    cin>>s;
    int sum = 0;
    for(auto i :s){
        sum+=i-'0';
    }
    if(sum%9==0)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
    
 
    return 0;
}


Measured memory_bytes: 3800
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, L = MAP()
    aji = 0
    minv = inf
    minv_ = 0
    for i in range(N):
        aji += L + i
        if abs(L + i) < minv:
            minv = abs(L + i)
            minv_ = L + i
    print(aji - minv_)

if __name__ == '__main__':
    main()


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var X = int.Parse(input[0]);
            var Y = int.Parse(input[1]);

            var tsuru = 2;
            var kame = 4;

            for (int i = 0; i <= X; i++)
            {
                if (tsuru * i + kame * (X - i) == Y)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 17868
#!/usr/bin/env python3
#ABC74 C

a,b,c,d,e,f = map(int,input().split())

s = f//(100*a)
t = f//(100*b)
u = f//c
v = f//d

concentration = 0
solution = 0
suger = 0
for A in range(s+1):
    for B in range(t+1):
        for C in range(u+1):
            for D in range(v+1):
                if 100*a*A + 100*b*B + c*C + d*D <= f:
                    if (a*A+b*B)*e >= (c*C + d*D):
                        if 100*a*A + 100*b*B + c*C + d*D != 0:
                            if concentration < (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D):
                                concentration = (c*C + d*D)/(100*a*A + 100*b*B + c*C + d*D)
                                solution = 100*a*A + 100*b*B + c*C + d*D
                                suger = c*C + d*D
if solution == 0:
    solution = 100*a
print(solution,suger)


Measured memory_bytes: 43372
#include <iostream>
#include<math.h>
using namespace std;

int main()
{
    long long int n,d,x,y;
    cin>>n>>d;
	int count=0;
    for(int i=0;i<n;i++)
    {
    	cin>>x>>y;
    	long long int a = x*x+y*y;
    	
    	if(a<=d*d)
    	{
    		count+=1;
		}
    	
	}
	cout<<count<<endl;
}


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

int main(){
    int N;
    cin >> N;
    int score = 0;
    for(int i = 1; i <= N; i++){
        score += i;
        if(score >= N){
            for(int j = 1; j <= i; j++){
                if(score != N + j){
                    cout << j << endl; 
                }
            }
            return 0;
        }
    }
}


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

int main(void) {
  int n, flag = 0, ans;
  char c[4];

  if(scanf("%d", &n) != 0);

  while(1) {
    sprintf(c, "%d", n);
    for(int i = 1; i < 3; i++) {
      if(c[i] == c[0]) {
        flag++;
      }
    }
    if(flag == 2) {
      ans = n;
      break;
    }
    flag = 0;
    n++;
  }

  printf("%d", n);

  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		int i = 0;
		while(i < n){
			
			int currentX = 0;
			int currentY = 0;
			
			int furtherX = 0;
			int furtherY = 0;
			while(true){
				String[] tmp = br.readLine().split(" ");
				int dx = Integer.parseInt(tmp[0]);
				int dy = Integer.parseInt(tmp[1]);
				
				if(dx == 0 && dy == 0){
					break;
				}
				currentX += dx;
				currentY += dy;
				
				int curDist = currentX*currentX + currentY*currentY;
				int furDist = furtherX*furtherX + furtherY*furtherY;
				
				if(curDist > furDist || (curDist == furDist && currentX > furtherX)){
					furtherX = currentX;
					furtherY = currentY;
				}
				/*
				if(currentX == 0 && currentY == 0){
					break;
				}*/
			}
			System.out.println(furtherX + " " + furtherY);
			
			i++;
		}
	}
}

Measured memory_bytes: 26460
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

int main() {
    int a, b;
    cin >> a >> b;
    string aa(b, to_string(a)[0]), bb(a, to_string(b)[0]);
    cout << min(aa, bb) << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	    int a=gi();
	    int b=gi();

	    
	    System.out.print(a-b+1);
//	    if ((a<=c && c<=b)|| (b<=c && c<=a)) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n, k;
    cin >> n >> k;
    
    priority_queue<int> q;
    rep(i,n){
        int l; cin >> l;
        q.push(l);
    }
    
    int ans = 0;
    while(k--){
        ans += q.top();
        q.pop();
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256