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

using namespace std;

#define int long long

const int N = 1e5 + 100;
const int INF = 1e15;
int dp[N][4], h[N][4], n, k;

int sol(int idx, int p) {
    if (idx == n + 1) return 0;
    int &ans = dp[idx][p];
    if (ans != -1) return ans;
    for (int i = 1; i <= 3; i++) {
        if (i != p) {
            ans = max(ans, sol(idx + 1, i) + h[idx][i]);
        }
    }
    return ans;
}

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i][1] >> h[i][2] >> h[i][3];
    memset(dp, -1, sizeof(dp));
    cout << sol(1, 0) << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin>>t;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,string>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, m, sum, A[500010], Map[100][100], rui[100][100], dp[5000];
char S[100][100]; bool check = false;	vector<ll> v;
bool  check1[100][100];

queue <ll> qy, qx;

ll BFS(ll y, ll x) {

	qy.push(y);  qx.push(x);

	while (!qy.empty() && !qx.empty()) {

		y = qy.front();  x = qx.front();
		qy.pop(); qx.pop();
		ll gx, gy;
		for (int i = 0; i < 4; i++) {
			gy = y + dy[i]; gx = x + dx[i];
			

			if (gy >= 0 && gy < n && 0 <= gx && gx < m && S[gy][gx] == '.' && !check1[gy][gx]) {
				qy.push(gy);  qx.push(gx);
				Map[gy][gx] = min(Map[y][x] + 1, Map[gy][gx]);
				check1[gy][gx] = true;
			}
		}
	}
		return 0;
	}

	
	int main() {
		//Code Line
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> S[i][j];
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				Map[i][j] = INF;
			}
		}



		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (S[i][j] == '.') {
					Map[i][j] = 0;
					BFS(i, j);
				}
				


				
				for (int k = 0; k < n; k++) {
					for (int l = 0; l < m; l++) {
						if (Map[k][l] < INF && Map[k][l] > rui[k][l])rui[k][l] = Map[k][l];

					}
				}

				for (int k = 0; k < n; k++) {
					for (int l = 0; l < m; l++) {
						Map[k][l] = INF;
						check1[k][l] = false;
					}
				}

			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
			
				if (rui[i][j] < INF) {
					c = max(c, rui[i][j]);
				}
				
			}
			
		}

		cout << c << endl;
		return 0;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main(){
string s;
cin>>s;
ll sum=0;
for(int i=0;i<s.size();i++){
    string a="";
    a+=s[i];
    sum+=(stoi(a));
}
if(sum==0 || sum%9==0){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
}


Measured memory_bytes: 3756
def main():
    N = int(input())
    Ls = list(map(int, input().split()))
    l_max = max(Ls)
    l_sum = sum(Ls) - l_max
    if l_max < l_sum:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([4, 2, 5, 1, 3]), 3)

    def test_2(self):
        self.assertEqual(think([4, 3, 2, 1]), 4)

    def test_3(self):
        self.assertEqual(think([1, 2, 3, 4, 5, 6]), 1)

    def test_4(self):
        self.assertEqual(think([5, 7, 4, 2, 6, 8, 1, 3]), 4)

    def test_5(self):
        self.assertEqual(think([1]), 1)


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(p):
    dp = [0 for _ in range(len(p) + 1)]
    count = 1
    dp[1] = p[0]
    for i in range(1, len(p)):
        if p[i] <= dp[i]:
            count += 1
            dp[i + 1] = p[i]
        else:
            dp[i + 1] = dp[i]
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

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

public class hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var n = int.Parse(line[0]);
		var m = int.Parse(line[1]);
		line = Console.ReadLine().Trim().Split(' ');
		var a = Array.ConvertAll(line, int.Parse);
		line = Console.ReadLine().Trim().Split(' ');
		var b = Array.ConvertAll(line, int.Parse);
		var pand = new List<int>();
		var por = new List<int>();
		getList(pand, por, a, b, n, m);
		Console.WriteLine("{0} {1}", pand.Count(), por.Count());
		if (pand.Count() > 0) Console.WriteLine(string.Join("\n", pand));
		if (por.Count() > 0) Console.WriteLine(string.Join("\n", por));
	}
	static void getList(List<int> pand, List<int> por, int[] a, int[] b, int n, int m)
	{
		var pa = 0; var pb = 0;
		while (true)
		{
			if (a[pa] == b[pb])
			{
				pand.Add(a[pa]);
				por.Add(a[pa]);
				pa++;
				pb++;
			}
			else if (a[pa] > b[pb])
			{
				por.Add(b[pb]);
				pb++;
			}
			else
			{
				por.Add(a[pa]);
				pa++;
			}
			if (pa == n)
			{
				while (pb < m) { por.Add(b[pb]); pb++; }
				break;
			}
			if (pb == m)
			{
				while (pa < n) { por.Add(a[pa]); pa++; }
				break;
			}
		}
	}
}



Measured memory_bytes: 52560
from collections import deque

N,M = map(int,input().split())
room_g = [[] for i in range(N+1)]

for i in range(M):
  a,b = map(int,input().split())
  room_g[a].append(b)
  room_g[b].append(a)
  
sign = [-1]*(N+1)
sign[0] = 0
sign[1] = 0

d = deque()
d.append(1)

while d:
  x = d.popleft()
  for i in room_g[x]:
    if sign[i] != -1:
      continue
    sign[i] = x
    d.append(i)
    
ans = sign[2:]
print("Yes")
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 34612
# -*- coding: utf-8 -*-
from collections import deque
h,w = map(int, input().split())
m = ["#"*(w+2)] + ["#"+input()+"#" for _ in range(h)] + ["#"*(w+2)]

cnt = 0
for hi in range(1,h+1):
    for wi in range(1,w+1):
        if m[hi][wi]==".":
            cnt += 1

inf = 10**9
d = [[inf]*(w+2) for _ in range(h+2)]
q = deque([(1,1,1)])
d[1][1] = 1
while len(q):
    ch,cw,r = q.popleft()

    for hi,wi in [[ch+1,cw],[ch,cw+1],[ch-1,cw],[ch,cw-1]]:
        if m[hi][wi]=="." and d[hi][wi]>r+1:
            d[hi][wi]=r+1
            q.append((hi,wi,r+1))

if d[h][w]==inf:
    print(-1)
else:
    print(cnt-d[h][w])

Measured memory_bytes: 3316
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}


int main(void) {

  int a, b;
  cin >> a >> b;
  for (int n = 1; n <= 100000; n++) {
    int x = 8 * n / 100;
    int y = n / 10;
    if (x == a && y == b) {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>



int main(){
  ll int a,b,n;
  cin>>a>>b>>n;
  ll ans=0;
  if(n>=b){
      ans = floor(a*(b-1)/b);
      
  }
  else{
      ans = floor(a*n/b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a,g):
	global cnt
	for i in range(g,len(a)):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= len(a):
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)

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

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        string s;
        cin >> s;
        vector<string> ans;
        string st;
        st += s[0];
        ans.push_back(st);
        string pp;
        for(lld i = 1; i < s.size(); i++) {
            string temp = ans.back();
            pp += s[i];
            if(pp == temp) {
                continue;
            } else {
                ans.push_back(pp);
                pp.clear();
            }
        }
        cout << ans.size() << "\n";
    }
}

Measured memory_bytes: 11016
p = f = 0
n, a, b = map(int, input().split())
q = print

for i in input():
    if i == "a" and p < a + b:
        p += 1
        q("Yes")

    elif i == "b" and p < a + b and f < b:
        p += 1
        f += 1
        q("Yes")
    
    else:
        q("No")

Measured memory_bytes: 4016
#include <iostream>

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int arr[n];
    int idx=-1;
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        if(arr[i]==1) idx = i;
    }
    if(n==k) {
        cout<<1; return 0;
    }
    int p=0;
    for(int i=0;i<n-1;){
        for(int j=0;j<k;j++){
            i++;
        }
        i--;
        p+=1;
    }
    cout<<p;
}


Measured memory_bytes: 640
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n,x; cin>>n>>x;
  int cnt = 1;
  int num = 0;
  int k;
  rep(i,n){
    cin>>k;
    num += k;
    if (num > x) {
      cout << cnt << endl;
      return 0;
    }else{
      cnt++;
    }
  }
  cout << cnt << endl;

}


Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <map>

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

typedef pair<int, double> pii;

class Inf{
public:
    int position;
    int used;
    double cost;

    bool operator<(const Inf &a) const{
        return a.cost<cost;
    }

    Inf(int p, double c, int u){
        position = p;
        cost = c;
        used = u;
    }
};

int main(void){
    int n,m,p,a,b;
    while(cin>>n>>m>>p>>a>>b,n|m|p|a|b){
        int ticket[8];
        rep(i,n){
            cin >> ticket[i];
        }
        vector<vector<pii>> road(31);

        rep(i,p){
            int x,y,z;
            cin >> x >> y >> z;
            road[x].push_back(pii(y,z));
            road[y].push_back(pii(x,z));
        }
        priority_queue<Inf> Q;
        Q.push(Inf(a, 0, 0));
        bool flg[31][1<<8+1] = {0};
        double ans = -1;
        while(!Q.empty()){
            Inf q = Q.top();
            int position = q.position;
            Q.pop();
            if(flg[position][q.used]){
                continue;
            }
            flg[position][q.used] = true;
            if(position==b){
                ans = q.cost;
                break;
            }

            rep(i, road[position].size()){
                pii r = road[position][i];
                rep(k,n){
                    if(q.used&(1<<k)){
                        continue;
                    }
                    int p = r.first;
                    double c = r.second/ticket[k]+q.cost;
                    int u = q.used+(1<<k);
                    Q.push(Inf(p,c,u));
                }
            }
        }
        if(ans<0){
            cout << "Impossible" << endl;
        }else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 16208
# ABC062 B - Picture Frame
H,W = map(int,input().split())
L = [[] for _ in range(H+2)]

for i in range(H+2):
    if i == 0 or i == H+1:
        a = '#'*(W+2)
        L[i].append(a)
        continue

    S = input()
    for j in range(len(S)):
        if len(S) == 1:
            if j == 0:
                L[i].append('#')
                L[i].append(S[j:j+1])
                L[i].append('#')
        else:
            if j == 0:
                L[i].append('#')
                L[i].append(S[j:j+1])
                continue
            if j == len(S)-1:
                L[i].append(S[j:j+1])
                L[i].append('#')
                continue
            L[i].append(S[j:j+1])

for l in L:
    print(*l,sep='') 

Measured memory_bytes: 4596
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  list($k) = explode(" ", trim(fgets(STDIN)));

  $ans=1;
  for($i=0;$i<$n;$i++){
    if($ans >= $k){
      $ans+=$k;
    }else{
      $ans*=2;
    }
  }
  echo $ans;
  
  echo PHP_EOL;

Measured memory_bytes: 16036
from collections import deque
s = deque(input())
num = int(input())
cnt = 0
for i in range(num):
  a = input().split()

  if a[0] == '2':
    if (int(a[1])+cnt)%2==1:
      s.appendleft(a[2])
    else:
      s.append(a[2])
  else:
    cnt += 1
if cnt%2 == 1:    
	s.reverse()
print("".join(s))
  

Measured memory_bytes: 8428
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  
  long long ans = 0;
  
  if(K - A > 0){
    ans = ans + A;
    K = K - A;
  }
  
  else if(A >= 0){
    ans = ans + K;
    cout << ans << endl;
    return 0;
  }
  
  if(K - B > 0){
    ans = ans;
    K = K - B;
  }
  
  else if(B >= K){
    cout << ans << endl;
    return 0;
  }
  
  if(K - C > 0){
    ans = ans - C;
    cout << ans << endl;
  }
  
  else if(C >= K){
    ans = ans - K;
    cout << ans << endl;
  }
    
    
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n;
  cin>>n;
  set<char> st;
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    st.insert(c);
  }
  if(st.size()==3){
    cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
      Scanner scan = new Scanner(System.in);
      String s = scan.next();
      String t = scan.next();
      int count=0;
      for(int i=0; i<3; i++) {
        if(s.charAt(i)==t.charAt(i)){
          count++;
        }
      }
      System.out.println(count);
    }
}

Measured memory_bytes: 23252
N = int(input())
arr = list(map(int, input().split()))
a = dict()
for i in arr:
    if i in a.keys():
        a[i] += 1
    else:
        a[i] = 1
ans = 0
for i in a.keys():
    if a[i] < i:
        ans += a[i]
    elif a[i] > i:
        ans += a[i] - i
print(ans)

Measured memory_bytes: 18168
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow ---question galat mat padhna */
{
    fast;
    ll n;
    cin>>n;
    set<ll>prime;
    if(n==1)
    {
        cout<<0<<endl;
        return 0;
    }
    ll x=n;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
        {
            prime.insert(i);
            while(x%i==0)
            {
                x/=i;
            }
        }
    }
    if(x>2)prime.insert(x);
    ll ans=0;
    for(auto p:prime)
    {
        ll x=p;
        while(n%x==0)
        {
            ans++;
            n/=x;
            x=x*p;
        }
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;
typedef long long int lli;

int main() {
	lli N;
	vector<lli> A;

	cin >> N;
	for(lli i=0; i<N; i++) {
		lli a;
		cin >> a;
		A.push_back(a);
	}

	sort(A.begin(), A.end());

	if(N%2 == 0) {
		lli sum = 0;
		for(lli i=0; i<N; i++) {
			if(i+1 == N/2) {
				sum -= A[i];
			} else if(i+1 == N/2+1){
				sum += A[i];
			} else if(i+1 < N/2){
				sum -= 2 * A[i];
			} else {
				sum += 2 * A[i];
			}
		}
		cout << sum << endl;
	}  else {
		lli sum1 = 0;
		lli sum2 = 0;
		for(lli i=0; i<N; i++) {
			if(i+1 == (N+1)/2) {
				sum1 -= A[i];
			} else if(i+1 == (N-1)/2){
				sum1 -= A[i];
			} else if(i+1 < (N+1)/2){
				sum1 -= 2 * A[i];
			} else {
				sum1 += 2 * A[i];
			}
			if(i+1 == (N+1)/2) {
				sum2 += A[i];
			} else if(i+1 == (N+3)/2) {
				sum2 += A[i];
			} else if(i+1 < (N+1)/2) {
				sum2 -= 2 * A[i];
			} else {
				sum2 += 2 * A[i];
			}
		}
		cout << max(sum1, sum2) << endl;
	}


}


Measured memory_bytes: 1776
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <unordered_map>  
#include <climits>

using namespace std;


class Main {
public:
	int number(string strA, string strB) {
		int cnt = 0;
		for (int i = 0;i < strA.size();i++) {
			if (strA[i] != strB[i]) cnt++;
		}
		return cnt;
	}
};

int main()
{
	Main m;
	string s;
	string correct = "CODEFESTIVAL2016";

	cin >> s;

	cout << m.number(s,correct) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	h[0]--;
	for (int i = 0; i < n - 1; i++) {
		if (h[i] > h[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
		if (h[i] < h[i + 1]) h[i + 1]--;
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    REP(i,1000){
        string X;
        if(i < 10) X = "00" + to_string(i);
        if(10 <= i && i < 100) X = "0" + to_string(i);
        if(100 <= i) X = to_string(i);
        int snum = 0;
        REP(j,N){
            if(S[j] == X[snum]) snum++;
        }
        if(snum == 3){ans++;}
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
from collections import Counter

N = int(input())

count_counter = Counter()
result = 0
over = 0

for i in input().split():
    count_counter[int(i) // 400] += 1

for key in count_counter.keys():
    if key < 8:
        result += 1
    else:
        over += count_counter[key]

if result == 0:
    print(1, over)
else:
    print(result, result+over)

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

int main(void) {
    int n, d, i, j, k, ans;
    double dist;
    ans = 0;
    scanf("%d %d", &n, &d);

    double cord[n][d];

    for (i = 0; i < n; i++) {
        for (j = 0; j < d; j++) {
            scanf("%lf", &cord[i][j]);
        }
    }

    for (i = 0; i < n; i++) {
        for (j = i + 1; j < n; j++) {
            dist = 0.0;
            for (k = 0; k < d; k++) {
                dist += pow(cord[i][k]-cord[j][k], 2);
            }
            dist = sqrt(dist);
            if (ceil(dist) == floor(dist)) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

void distribute(int p, vector<ll>& counter, map<int, set<int>>& edge) {
  for (auto& child : edge[p]) {
    edge[child].erase(p);
    counter[child] += counter[p];
    distribute(child, counter, edge);
  }
}

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

  int n, q;
  cin >> n >> q;
  map<int, set<int>> edge;
  vector<ll> counter(n, 0);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    edge[a].insert(b);
    edge[b].insert(a);
  }

  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    counter[p] += x;
  }

  distribute(0, counter, edge);

  for (auto& v : counter) {
    cout << v << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 69632
N , M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N): a.append(a[i] + A[i])
for i in range(M): b.append(b[i] + B[i])
ans,j=0,M
for i in range(N+1):
  if a[i]>K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47504
#include<iostream>
#include<algorithm>
using namespace std;
long long int h[200005];
int main(void)
{
    long long int n,k,sum=0;
    cin >> n >> k;
    for(long long int i=1;i<=n;i++)
        cin >> h[i];
    sort(h+1,h+n+1);
    for(long long int i=1;i<=n-k;i++)
        sum+=h[i];

    cout<<sum;

}


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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			char a = chr[0].charAt(0);
			char b = chr[1].charAt(0);
			char c = chr[2].charAt(0);
			System.out.println(""+a+b+c);

		}
	}
}


Measured memory_bytes: 25340
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
string s;
LL ans = 0;
/**********************************************/

int ctoi(char c){
    return (int)(c - '0');
}

void dfs(LL i, string str_input){
    string str = str_input;
    if(i == s.size()){
        LL sum = 0;
        LL num = 0;
        REP(j, str.size()){
            if(str[j] == '+'){
                sum += num;
                num = 0;
            }else if(str[j] != '+'){
                num *= 10;
                num += ctoi(str[j]);
            }
        }
        sum += num;
        ans += sum;
        return;
    }
    str = str + s[i];
    dfs(i+1, str);
    if(i < s.size()-1){
        str = str + "+";
        dfs(i+1, str);
    }
    return;
}

signed main(){
    cin >> s;
    
    dfs(0, "");

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,X;
	cin >> N >> X;
	int D[N+1];
	D[0] = 0;
	int ans=N+1;
	rep(i,0,N){
		int L;
		cin >> L;
		D[i+1] = D[i] + L;
		if(D[i+1]>X){ 
			ans = i+1;
			break;
		}
	}
	cout << ans << endl;
}	

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
bool check(int (&field)[8][8],int x,int y){
	if(x<0 || x>=8 || y<0 || y>=8 || (field[y][x] == 0)){
		return false;
	}
	return true;
}

int main(){
	int inptf[8][8] = {0}, i, j, x, y;
	string str;
	char btype;
	while(true){
		i=0;
		while(cin>>str){
			for(j=0;j<8;j++){
				inptf[i][j] = str[j] - '0';
			}
			i++;
			if(i==8) break;
		}
		if(i<8) break;
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				if(inptf[i][j] != 0){
					y = i;
					x = j;
					i=j=8;
				}
			}
		}
		if(check(inptf , x, y) &&	//[][] A
		   check(inptf , x, y+1) &&	//[][]
		   check(inptf , x+1, y) &&	
		   check(inptf , x+1, y+1))	
			btype='A';
			
		if(check(inptf , x, y) &&	//[] B
		   check(inptf , x, y+1) &&	//[]
		   check(inptf , x, y+2) &&	//[]
		   check(inptf , x, y+3))	//[]
			btype='B';
		if(check(inptf , x, y) &&	//[][][][] C
		   check(inptf , x+1, y) &&	
		   check(inptf , x+2, y) &&	
		   check(inptf , x+3, y))	
			btype='C';
		if(check(inptf , x, y) &&	//  [] D
		   check(inptf , x, y+1) &&	//[][]
		   check(inptf , x-1, y+1) &&	//[]
		   check(inptf , x-1, y+2) )	
			btype='D';
		if(check(inptf , x, y) &&	//[][] E
		   check(inptf , x+1, y) &&	//  [][]
		   check(inptf , x+1, y+1) &&	
		   check(inptf , x+2, y+1))	
			btype='E';
		if(check(inptf , x, y) &&	//[]   F
		   check(inptf , x, y+1) &&	//[][]
		   check(inptf , x+1, y+1) &&	//  []
		   check(inptf , x+1, y+2))	
			btype='F';
		if(check(inptf , x, y) &&	//  [][]G
		   check(inptf , x+1, y) &&	//[][]
		   check(inptf , x, y+1) &&
		   check(inptf , x-1, y+1))	
			btype='G';
		cout<<btype<<endl;
	}
}

Measured memory_bytes: 1176
#include<cstdio>
#include<vector>
#include<map>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=100005,fx[9][2]={{0,0},{0,-1},{0,-2},{-1,0},{-1,-1},{-1,-2},{-2,0},{-2,-1},{-2,-2}};
map<pair<int,int>,int>m;
long long h,w,n;
long long ans[15];
int main()
{
	scanf("%lld %lld %lld",&h,&w,&n);
	ans[0]=(h-2)*(w-2);
	for(long long i=1;i<=n;i++)
	{
		long long x,y;
		scanf("%lld %lld",&x,&y);
		for(long long o=0;o<9;o++)
		{
			pair<int,int>a;
			a.first=x+fx[o][0];
			a.second=y+fx[o][1];
			if(1<=a.first&&a.first<=h-2&&1<=a.second&&a.second<=w-2)
			{
				ans[m[a]]--;
				m[a]++;
				ans[m[a]]++;
			}
		}
	}
	for(long long i=0;i<=9;i++)
		printf("%lld\n",ans[i]);
}

Measured memory_bytes: 56448
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n ;
    vector<ll> a(n),b(n);
    vector<pll> ans(n);
    rep(i,n){
        cin >> a[i] >> b[i];
        ans.push_back({a[i]+b[i],i});
    }
    sort(ans.rbegin(),ans.rend());
    ll cnt=0;
    ll tot=0;
    while(cnt<n){
        if(cnt%2==0){
            tot+=a[ans[cnt].se];
        }
        else{
            tot-=b[ans[cnt].se];
        }
        cnt++;
    }
    cout << tot << endl;
}

Measured memory_bytes: 7944
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

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

int main(void) {
  string s;
  cin >> s;
  int q;
  cin >> q;
  string head, tail;

  bool rev=false;
  rep(i,q){
    int t;
    cin >> t;
    if(t==1){ // han ten
      if(rev){rev=false;}
      else{rev=true;}
    } else {
      int f;
      cin >> f;
      char c;
      cin >> c;

      if(rev^(f==1)){
        head.push_back(c);
      } else {
        tail.push_back(c);
      }
    }
  }

  if(rev){
    reverse(all(tail));
    reverse(all(s));
    cout << tail << s << head;
  } else {
    reverse(all(head));
    cout << head << s << tail;
  }
}


Measured memory_bytes: 1088
fun main() {
    val n = readLine()?.toInt() ?: return
    val s1 = readLine() ?: return
    val s2 = readLine() ?: return
    val m = 1000000007L
    var i = 0
    val p = mutableListOf<String>()
    while (i < s1.length) {
        if (s1[i] == s2[i]) {
            p.add("v")
        } else {
            p.add("h")
            i++
        }
        i++
    }
    val t = p.foldIndexed(0L) { index, a, b ->
        if (a == 0L) {
            if (b == "v") {
                3L
            } else {
                6L
            }
        } else {
            a * if (b == "v") {
                if (p[index - 1] == "v") {
                    2L
                } else {
                    1L
                }
            } else {
                if (p[index - 1] == "v") {
                    2L
                } else {
                    3L
                }
            } % m
        }
    }
    println(t.toString())
}


Measured memory_bytes: 34512
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

 int a,b,m;
 cin>>a>>b>>m;
 int a1[a+1],b1[b+1],mn1=INT_MAX,mn2=INT_MAX;
 for(int i=1;i<=a;i++)
 cin>>a1[i],mn1=min(mn1,a1[i]);
 for(int i=1;i<=b;i++)
 cin>>b1[i],mn2=min(mn2,b1[i]);
 int ans=mn1+mn2,x,y,z;
 for(int i=1;i<=m;i++)
 {
      cin>>x>>y>>z;
      ans=min(ans,a1[x]+b1[y]-z);
 }
 
 cout<<ans;
 
 
 
 
} 

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
	
	int n, k;

	scanf("%d %d",&n,&k);

	if (n%2==1) {
		n++;
	}
	if (k<=n/2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
from libcpp cimport *
from libcpp.vector cimport vector


cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cdef cppclass dsu:
        dsu()
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
cdef dsu uf = dsu(N)
for _ in range(Q):
    t, u, v = map(int, input().split())
    if t == 0:
        uf.merge(u, v)
    else:
        if uf.same(u, v):
            print(1)
        else:
            print(0)

"""
import os
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve


Measured memory_bytes: 10848
n,m = map(int,input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
else:
    ans = n*m
    ans = ans - 2*n - (2*(m-2))
    print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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 <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  vector<vector<ll> > pos(n,vector<ll>(2));
  REP(i,n){
    cin>>pos[i][0];
    cin>>pos[i][1];
  }
  map<pair<ll, ll>, int> ans;
  
  REP(i,n){
    FOR(j,i+1,n){
      pair<ll,ll> t = make_pair(pos[i][0]-pos[j][0],pos[i][1]-pos[j][1]);
      if(t.first<0||(t.first==0&&t.second<0))t=make_pair(-t.first, -t.second);
      if(ans.find(t)!=ans.end()){
	ans.at(t)=ans.at(t)+1;
      }
      else{
	ans.insert(make_pair(t, 1));
      }
    }
  }
  int res=0;
  for(auto i=ans.begin();i!=ans.end(); ++i){
    res=max(res,i->second);
  }
  
  cout<<n-res;
      
   
    
}


Measured memory_bytes: 384
sx,sy,tx,ty = map(int, input().split())

ans = []
for i in range(sy, ty):
    ans.append('U')
for i in range(sx, tx):
    ans.append('R')
for i in range(ty, sy, -1):
    ans.append('D')
for i in range(tx, sx-1, -1):
    ans.append('L')
for i in range(sy, ty+1):
    ans.append('U')
for i in range(sx-1, tx):
    ans.append('R')
for i in range(ty+1, ty, -1):
    ans.append('D')
for i in range(tx, tx+1):
    ans.append('R')
for i in range(ty, sy-1, -1):
    ans.append('D')
for i in range(tx+1, sx, -1):
    ans.append('L')
for i in range(sy-1, sy):
    ans.append('U')
print(''.join(ans))

Measured memory_bytes: 40176
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader();
		int[] arr = new int[3];
		
		for (int i=0; i<3; i++)
			arr[i] = in.nextInt();
		
		Arrays.sort(arr);
		
		if (isHaiku(arr))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
	
	public static boolean isHaiku(int[] arr) {
		int[] haiku = {5, 5, 7};
		for (int i=0; i<3; i++)
			if (arr[i] != haiku[i])
				return false;
		return true;
	}
	
	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
const long long MOD = 1000000007;
typedef long long ll;

ll n,a,b;
string s,t,u;

int main() {
  cin >> s >> t >> a >> b >> u;
  u==s ? a-- : b--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
const int N=3e5+10;
set<pii>s;
int r[N],c[N],id1[N],id2[N];
int main()
{
	int h,w,m;
	scanf("%d%d%d",&h,&w,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		s.insert(mp(x,y)),r[x]++,c[y]++;
	}
	for(int i=1;i<=h;i++)id1[i]=i;
	for(int i=1;i<=w;i++)id2[i]=i;
	sort(id1+1,id1+1+h,[&](int x,int y){return r[x]>r[y];});
	sort(id2+1,id2+1+w,[&](int x,int y){return c[x]>c[y];});
	int done=0,res=0;
	for(int i=1;i<=h&&r[id1[i]]==r[id1[1]]&&!done;i++)
	for(int j=1;j<=w&&c[id2[j]]==c[id2[1]]&&!done;j++)
	if(s.find(mp(id1[i],id2[j]))==s.end())res=max(res,r[id1[i]]+c[id2[j]]),done=1;
	else res=max(res,r[id1[i]]+c[id2[j]]-1);
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 22572
let () =
  Scanf.scanf "%d %d" @@ fun b a ->
  let w = 100 in
  let res = Array.init 50 (fun _ -> Array.make 100 '.') in

  let r = (b+48)/50 - 1 in

  (* A *)
  let la = 2*r + 4 in
  for i = 0 to (a-2) do
    let x = i / (w/2) * 2 in
    let y = i mod (w/2) * 2 in
    res.(la + x).(y) <- '#';
  done;

  (* B *)
  for i = 0 to 2*r+1 do res.(i).(0) <- '#' done;
  for i = 0 to r do
    for j = 0 to w-1 do res.(2*i+1).(j) <- '#' done;
  done;
  for i = 0 to r-1 do
    for j = 0 to (w-2)/2 do res.(2*i).(2*j) <- '#' done;
  done;
  if r >= 0 then
    for i = 0 to (b+48) mod 50 do
      res.(2*r).(2*i) <- '#';
    done
  else res.(0).(0) <- '#';

  print_endline "50 100";
  res |> Array.iter @@ fun r ->
    r |> Array.iter print_char;
    print_newline ();

Measured memory_bytes: 384
N,M=map(int,input().split())
S=list(input())
S=S[::-1]
ans=[]
P=0
for i in range(1,N+1):
    if P==N:
        break
    for j in range(M+1):
        if P+(M-j)<=N and S[P+(M-j)]=="0":
            ans.append(M-j)
            P+=M-j
            if M-j==0:
                print(-1)
                exit()
            break
ans=ans[::-1]
if 0 in ans:
    print(-1)
else:
    print(*ans)

Measured memory_bytes: 55672
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
				
		long N = scan.nextLong();
		long A = scan.nextLong();
		long B = scan.nextLong();
		long k = 0;

		if(1<=N && N<=Math.pow(10,18) && 0<=A && 0<=B && 0<A+B && A+B<=Math.pow(10,18)){
			if(A+B<=N){
				k = N/(A+B);
				
				if(N-k*(A+B)>A){
					System.out.println( A*k + (N-k*(A+B)) - (N-(k*(A+B)+A)));
				}
				else{
					System.out.println( A*k + (N-k*(A+B)));
				}
				
			}
			else if(A+B>N && A<=N){
				System.out.println(A);
			}
			else{
				System.out.println(N);
			}
		}
	}
}

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

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int a1,a2,a3;
	cin >> a1 >> a2 >> a3;
	if(a1+a2+a3>=22)
		cout << "bust" << endl;
	else 
		cout << "win" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

priority_queue<int> pq;
int cnt[334334];

int main(void){
	int n,i,a,p=0,r,l;
	cin >> n; r = n;
	for(i=0; i<n; ++i){
		cin >> a; --a;
		++cnt[a];
	}
	for(i=0; i<334334; ++i){
		if(cnt[i]){
			pq.push(cnt[i]);
		}
	}
	for(i=1; i<=n; ++i){
		while((!pq.empty()) && i-p>1){
			l = pq.top();
			if(l<=(r-l)/(i-p-1)){
				break;
			}
			pq.pop();
			r -= l;
			++p;
		}
		cout << r/(i-p) << endl;
	}
	return 0;
}


Measured memory_bytes: 3572
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
 a_j.to_i
end

if arr[0] >= arr[1]
  a = arr[0]
  arr[0] -= 1
else
  a = arr[1]
  arr[1] -= 1
end


if arr[0] >= arr[1]
  b = arr[0]
else
  b = arr[1]
end

x = a + b

puts x

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(std::string C){
    char ch = *(C.c_str());
    cout << (char)(ch+1) << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    std::string C;
    std::cin >> C;
    func(C);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x;
    bool flag=false;
    int p=-1;
    for(int i=0;i<n;i++){
        int v;
        cin>>v;
        if(v>0&&!flag){
            p=i;
            flag=true;
        }

        x.push_back(abs(v));
    }
    if(p==-1)p=n;
    x.insert(x.begin()+p,0);
    //for(int i=0;i<=n;i++)cout<<x[i]<<" ";
    int ans=1e9;
    for(int i=0;i<=k;i++){
        int left=p-i;
        int right=p+k-i;
        if(left<0||n<right)continue;
        int t=max(x[left],x[right])+2*min(x[left],x[right]);
        ans=min(ans,t);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

long long inv(long long n, long long m)
{
    return powmod(n, m-2, m);
}

int main()
{
    long long H, W, A, B;
    cin>>H>>W>>A>>B;

    long long M = 1000000007LL;
    long long c1 = 1LL;
    for (int i=0; i<H-A-1; i++)
    {
        c1 *= B+H-A-i-1;  c1 %= M;
        c1 *= inv(i+1, M);  c1 %= M;
    }
    long long c2 = 1LL;
    for (int i=0; i<A-1; i++)
    {
        c2 *= W-B+A-i-2;  c2 %= M;
        c2 *= inv(i+1, M);  c2 %= M;
    }
    long long ans = 0LL;
    for (int i=0; i<W-B; i++)
    {
        //cout<<c1<<" "<<c2<<endl;
        ans += c1*c2%M;  ans %= M;
        c1 *= inv(B+i+1, M);  c1 %= M;
        c1 *= B+H-A+i;  c1 %= M;
        c2 *= inv(W-B+A-i-2, M);  c2 %= M;
        c2 *= W-B-i-1;  c2 %= M;
    }
    cout<<ans<<endl;
}


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

int main() {
    string s;
    while (cin >> s) {
        string ox = "ox";
        string res = "d";
        for (int i=0; i<2; ++i) {
            bool ok = false;
            if (s[0] == ox[i] && s[0] == s[1] && s[1] == s[2]) ok = true;
            if (s[3] == ox[i] && s[3] == s[4] && s[4] == s[5]) ok = true;
            if (s[6] == ox[i] && s[6] == s[7] && s[7] == s[8]) ok = true;
            if (s[0] == ox[i] && s[0] == s[3] && s[3] == s[6]) ok = true;
            if (s[1] == ox[i] && s[1] == s[4] && s[4] == s[7]) ok = true;
            if (s[2] == ox[i] && s[2] == s[5] && s[5] == s[8]) ok = true;
            if (s[0] == ox[i] && s[0] == s[4] && s[4] == s[8]) ok = true;
            if (s[2] == ox[i] && s[2] == s[4] && s[4] == s[6]) ok = true;
            if (ok) res = ox[i];
        }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main() {
  double l;
  cin >> l;
  double result = pow(l / 3, 3);
  printf("%14f\n", result);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<unordered_map>
#include<string.h>
#include<math.h>
using namespace std;
using ll = long long;
int main(){
    string S;
    cin >> S;
    if(S == "SUN")cout << 7;
    if(S == "MON")cout << 6;
    if(S == "TUE")cout << 5;
    if(S == "WED")cout << 4;
    if(S == "THU")cout << 3;
    if(S == "FRI")cout << 2;
    if(S == "SAT")cout << 1;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int> > vvi;
#define rep(i,n) for (int i=0;i<n;i++)

ll mod = 1e9+7;

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

Measured memory_bytes: 256