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

int main(){
  int n;
  cin>>n;
  int x=n;
  int cnt=0;
  while(x>9){
    cnt+=x%10;
    x/=10;
  }
  cnt+=x;
  if(n%cnt==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
N=input()
B=map(int, raw_input().split())

L=[]
for k in range(N):
	for i in range(N-(k+1),-1,-1):
		num=i+1
		if B[i]==num:
			L.append(B[i])
			del B[i]
			break

L.reverse()

if len(B)==0:
	for x in L:
		print x
else:
	print -1
	

Measured memory_bytes: 29036
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long p = 1;
		
		for(int i = 1; i <= n; i++){
			p = (p*i) % (long)(Math.pow(10, 9)+7);
		}
		System.out.println(p);
	}
}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

/* ---------------------- ここまで ---------------------- */
typedef long long ll;

void Main()
{
	int N;
	cin >> N;

	int x = N % 10;
	if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
		cout << "hon";
	}
	else if (x == 0 || x == 1 || x == 6 || x == 8) {
		cout << "pon";
	}
	else {
		cout << "bon";
	}
	return;
}

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

Measured memory_bytes: 3640
def main():
    l = list(input())
    n = len(l)
    dp = [[0,0] for _ in range(n+1)]
    dp[0][1] = 1
    for i in range(n):
        dp[i+1][0] += dp[i][0]*3
        if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
        dp[i+1][0] %= 10**9+7
        dp[i+1][1] %= 10**9+7
    print(sum(dp[n])%(10**9+7))

if __name__ == "__main__":
    main()

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

int main(){
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        //freopen("test.txt","r",stdin);
        //freopen("output.txt","w",stdout);
    #endif*/
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
 
    int k,x;cin>>x>>k;
    set<int> s;
    for(int i=0;i<x;i++){
        s.insert(max(k-i,(int)-1e6));
        s.insert(min(k+i,(int)1e6));
    }
    for(auto it:s){
        cout<<it<<" ";
    }   

    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
typedef long long ll;
const int tmax=3010;
const int nmax=3010; 
long DP[nmax][tmax];

 

int main() {
    int i,n; 
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<ll> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int ans=0;
    for(int i=1;i<n-1;i++){
        if (p[i-1] < p [i] && p[i] < p [i+1]){
            ans++;
        }else if(p[i-1] > p [i] && p[i] > p [i+1]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=11092019;
const int nmax=201234;

int n,x[112],res,tmp,tmp2;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",&x[i]);
        res+=x[i];
    }
    res=res/n;
    for(int i=0;i<n;++i){
        tmp+=(x[i]-res)*(x[i]-res);
        tmp2+=(x[i]-res-1)*(x[i]-res-1);
    }
    if(tmp<tmp2)
        res=tmp;
    else
        res=tmp2;
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 60;

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

  ld *p = new ld[N + 1];
  ld *q = new ld[N + 1];
  FOR(i, 1, N)
  {
    cin >> p[i];
    q[i] = 1 - p[i];
  }

  ld **dp = new ld *[N + 1];
  FOR(i, 0, N)
  {
    dp[i] = new ld[N + 1];
    FOR(j, 0, N)
    {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;

  FOR(i, 1, N)
  {
    dp[i][0] = dp[i - 1][0] * q[i];
    FOR(j, 1, N)
    {
      dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * q[i];
    }
  }

  ld ans = 0;
  FOR(i, N / 2 + 1, N)
  {
    ans += dp[N][i];
  }

  printf("%.30Lf\n", ans);

  return 0;
}

Measured memory_bytes: 141056
using System;
using System.Linq;

namespace Recursion___Divide_and_Conquer
{
    class Merge_Sort
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
           var c= MergeSort(A, 0, A.Length );
            for (int i = 0; i < A.Length-1; i++)
                Console.Write(A[i] + " ");
            Console.WriteLine(A.Last());
            Console.WriteLine(c);
        }

        static int Merge(int[] A, int left, int mid, int right)
        {
            var c = 0;
            var n1 = mid - left;
            var n2 = right - mid;
            var L = new int[n1 + 1];
            var R = new int[n2 + 1];
            for (int i = 0; i < n1; i++)
                L[i] = A[left + i];
            for (int i = 0; i < n2; i++)
                R[i] = A[mid + i];
            L[n1] = R[n2] = int.MaxValue;
            var p = 0; var q = 0;
            for (int k = left; k < right; k++, c++)
                if (L[p] <= R[q]) A[k] = L[p++];
                else A[k] = R[q++];
            return c;
        }

        static int MergeSort(int[] A, int left, int right)
        {
            var c = 0;
            if (left + 1 < right)
            {
                var mid = (left + right) / 2;
                c+=MergeSort(A, left, mid);
                c+=MergeSort(A, mid, right);
                c+=Merge(A, left, mid, right);
            }
            return c;
        }
    }
}

Measured memory_bytes: 87564
from sys import stdin
W,H,N = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

x1 = 0
x2 = W
y1 = 0
y2 = H

for i in data:
    if i[2] == 1:
        x1 = max(x1,i[0])
    if i[2] == 2:
        x2 = min(x2,i[0])
    if i[2] == 3:
        y1 = max(y1,i[1])
    if i[2] == 4:
        y2 = min(y2,i[1])
#print(x1,x2,y1,y2)
ans = max(x2-x1,0) * max(y2-y1,0)
print(ans)

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    if n < 1000 {
        println!("ABC");
    } else {
        println!("ABD");
    }
}


Measured memory_bytes: 4352
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        char b;
        cin >> b;
        if (b == 'A') cout << "T" << endl;
        if (b == 'T') cout << "A" << endl;
        if (b == 'C') cout << "G" << endl;
        if (b == 'G') cout << "C" << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans1 = A * X + B * Y;
    ll ans = 0;
    ll cx = 0, cy = 0;

    while (cx < X && cy < Y) {
        ans += 2 * C;
        cx++;
        cy++;
    }

    if (cx == X) {
        cx = cy;
        X = Y;
        A = B;
    }

    while (cx < X) {
        if (A < 2 * C) {
            ans += A;
            cx++;
        }
        else {
            ans += 2 * C;
            cx++;
        }
    }

    cout << min(ans, ans1) << LF;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


//int rx[505][505] = {};
		int ry[505][505] ;
		//int sx[505][505] = {};
		//int sy[505][505] = {};
int main() {

	int a, b;
	while (1) {
		cin >> a >> b; if (!a && !b)break;
		string p[505];
		for (int i = 0; i < a; i++)
			cin >> p[i];        
		for (int i = 0; i < a + 3; i++) {
			for (int j = 0; j < b + 3; j++)
				ry[i][j] = 0;
		}
		
		for (int i = 0; i < b; i++) {
			for (int j = a-1; j >=0; j--) {
				if (p[j][i] == '.') {
				//	cout << "#";
					ry[j][i]++;
					if (j&&p[j - 1][i] == p[j][i])ry[j - 1][i]+=ry[j][i];
				}
			//	cout << endl;
			//	cout << "#";
			}

		}
		int m = 0;
		for (int i = 0; i < a; i++) {
			vector<int>h;
			bool f[505] = {};
			for (int k = 0; k < b; k++) {
		//		cout << ry[i][k] << endl;
				if(ry[i][k]&&!f[ry[i][k]])h.push_back(ry[i][k]);
					f[ry[i][k]] = 1;
			}
			int T = 0,R=0;
		//	cout << h.size();
			for (T = 0; T < h.size(); T++) {
			//while(h.size()>=T){
				int W = 0;
				int n=h[T];
				R = 0;
			//	cout << n;
				for (int j = 0; j < b; j++) {
					R++;
				//	cout << n << " " << R<<" ";
					if (ry[i][j] < n)R = 0;
					m = max(m, R*n);
					
				//	cout << m << endl;
				}
				//cout << T;
				//T++;
			}
		}
		cout << m << endl;


	}


	return 0;

}

Measured memory_bytes: 4188
#include<iostream>
using namespace std;
 
int main(){
  long long int n;
  cin>>n;
  long long int ans=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      ans=ans+i;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < b; i++) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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

int main( void ) {
	int e, ee, y, z, min;

	for ( ; scanf( "%d", &e ), min = e; printf( "%d\n", min ) ) {
		for ( z = 0; y = sqrt( ee = e - z * z * z ), ee >= 0; z++ )
			if ( ee - y * y + y + z < min )
				min = ee - y * y + y + z;
	}

	return 0;
}

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

int main(){
	int n;
	cin >> n;
	string b;
	string a[n];
	int flag = 0;
	for(int i=0;i<n;i++){
		cin >> b;
		a[i] = b;
	}
	for(int i=1;i<n;i++){
		if(a[i][0]==a[i-1][a[i-1].length()-1]){
			flag = 1;
		}
		else{
			flag = 0;
			i = n;
		}
		for(int j=i;j<n;j++){
			if(a[i-1]==a[j]){
				flag = 0;
				i = n;
			}
		}
	}
	if(flag==1){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n) {
        if(a[i]%2 != 0)
            continue;

        if(a[i]%3!=0 && a[i]%5!=0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

int n, a, b, c, d;
string s;
bool cd = false;

int next_action(int now_position, int you, bool is_exist) {
	int next;
	if (is_exist) return now_position;
	if (now_position + 1 > n || now_position + 2 > n) next = -1;
	if (cd) {
		if (s[now_position + 1] == '.') next = 1;
		else if (s[now_position + 2] == '.') next = 2;
		else next = -1;
	}
	else {
		if (s[now_position + 1] == '.' && now_position + 1 != you) next = 1;
		else if (s[now_position + 2] == '.'&& now_position + 2 != you) next = 2;
		else next = -1;
	}
	return next;
}

int main() {
	
	cin >> n >> a >> b >> c >> d >> s;
	a--;
	b--;
	c--;
	d--;
	n--;

	bool a_ans = false, b_ans = false, ok = false;
	int a_now = a, b_now = b, next;

	if (c > d) {
		for (int i = b; i <= d; ++i) {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				ok = true;
				cd = true;
			}
			else {
				cd = true;
			}
		}
	}
	else ok = true;

	while (ok) {
		if (a_now == c) a_ans = true;
		if (b_now == d) b_ans = true;
		if (a_ans && b_ans) break;

		next = next_action(b_now, a_now, b_ans);
		if (next < 0) break;
		if (b_ans == 0) b_now += next;

		next = next_action(a_now, b_now, a_ans);
		if (next < 0) break;
		if (a_ans == 0)a_now += next;


	}
	
	if (a_ans && b_ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a, b;

    cin >> n >> a >> b;

    cout << min(a * n, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(X) (x).begin(),(x).end()
using namespace std;

ll sumKeta(ll x){
  ll sum=0;
  while(1){
    sum += x%10;
    x/=10;
    if(x==0){
      break;
    }
  }
  return sum;
}

int main() {
  ll N;
  cin >> N;
  ll min=sumKeta(1)+sumKeta(N-1);
  for(ll i=2;i<=N/2;i++){
    ll tmp=sumKeta(i)+sumKeta(N-i);
    if(tmp<min){
      min=tmp;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
using namespace std;
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}
const int N = 1e5;
unordered_map<int, int > mp;
vector<int> adj[N];

signed main(){

    fastIO
 	
    int n , x, y;
    cin >> n >> x >> y;
    --x, --y;
    
    for (int i = 0; i < n-1; i++){
    	adj[i].pb(i+1);
    	adj[i+1].pb(i);
    }
    adj[x].pb(y);
    adj[y].pb(x);

    auto bfs = [&](int start){
    	int lvl[(int)1e5];
    	fill (lvl, lvl + N, 1e9);
    	int vis[(int)1e5];
    	memset(vis, 0, sizeof(vis));
    	lvl[start] = 0;
    	queue<int> q;
    	q.push(start);
    	while(!q.empty()){
    		int p = q.front();
    		q.pop();
    		if (vis[p]) continue;
	    		vis[p] = true;
    		for (auto i : adj[p]){
    			if (lvl[i] <= lvl[p] + 1) continue;
    			lvl[i] = lvl[p] + 1;
    			if (i > start){
    				// trace(i, p, lvl[i]);
    				mp[lvl[i]]++;
    			}
    			q.push(i);
    		}
    	}
    };

    for (int i = 0; i < n-1; i++){
    	// trace(i);
    	bfs(i);
    }
    for (int i = 1; i < n; i++){
    	cout << mp[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

	ll n;
	cin >> n;
	vector<ll> v(n);
	for(ll i=0; i<n; i++)
        cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());
    ll ans=0, cnt=n-2;
    ans+=v[0];
    for(ll i=1; i<n && cnt>0; i++){
        ans+=v[i];
        cnt--;
        if(cnt==0)
            break;
        ans+=v[i];
        cnt--;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4780
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
signed main()
{
int n,a[2];
cin>>n>>a[0]>>a[1];
sort(a,a+2);
if((a[1]-a[0])%2==0)
    cout<<(a[1]-a[0])/2<<endl;
else
    {
        if((a[1]-a[0])==1)
            cout<<min(a[1]-1,n-a[0]);
        else
            cout<<min(((a[1]+a[0]-1)/2),n-((a[1]+a[0]-1)/2));

    }
    }


Measured memory_bytes: 256
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        if(a!=b||b!=c){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    cnt = [0] * N
    for _ in range(M):
        a, b = LI_()
        cnt[a] += 1
        cnt[b] += 1

    # 「全ての頂点が偶数回登場する」は必要条件
    # 奇数回登場する頂点があると、それに繋がる辺の中に必ず奇数になる辺が出るから
    # 深さ1の木を考えると、全ての頂点が偶数回登場するならば、
    # 葉iの登場回数=葉iに繋がる辺の数字より、全ての辺の数字が偶数
    if len([i for i in cnt if i % 2 == 0]) == N:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 11424
#include <stdio.h>
int n, s;
int dfs(int n, int s, int l) {
    int i, c=0;
    if(s<l) return 0;
    if(n<=0) return 0;
    if(n==1) {
        if(s<=9) return 1;
        return 0;
    }
    
    for(i=l; i<=s; i++) {
        c += dfs(n-1, s-i, i+1);
    }
    return c;
}

int main(void){
    while(scanf("%d%d\n", &n, &s)) {
        if(n == 0 && s == 0) break;
        int count = dfs(n, s, 0);
        printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 2048
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
vector<pair<int,int>> ans;

bool solve() {
	int mxbit=0; while((2LL<<mxbit)<=n) ++mxbit;
	if((1<<mxbit)+1>n) return false;

	int a=1<<mxbit,b=a+1,c=1;
	ans.clear();
	ans.PB(MP(a,b));
	ans.PB(MP(b,c));
	ans.PB(MP(c,a+n));
	ans.PB(MP(a+n,b+n));
	ans.PB(MP(b+n,c+n));
	for(int i=2;i+1<a;i+=2) {
		int x=i,y=x+1;	
		if(y==n-a) swap(x,y);
		ans.PB(MP(c,y));
		ans.PB(MP(y,x));
		ans.PB(MP(c+n,x+n));
		ans.PB(MP(x+n,y+n));
	}
	for(int i=b+1;i+1<=n;i+=2) {
		int x=i,y=x+1;
		ans.PB(MP(c,y));
		ans.PB(MP(y,x));
		ans.PB(MP(c+n,x+n));
		ans.PB(MP(x+n,y+n));
	}
	if(n%2==0) {
		int x=n-a,z=n;
		ans.PB(MP(b,z));
		ans.PB(MP(x+n,z+n));
	}
	return true;
}

void run() {
	scanf("%d",&n);
	if(!solve()) { printf("No\n"); return; }
	printf("Yes\n");
	REPSZ(i,ans) printf("%d %d\n",ans[i].first,ans[i].second);

}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 4208
N,K = map(int,input().split())
res = 0

# (a,b,c)=(k/2,k/2,k/2)
if K%2==0:
    res += (1 + (N-K//2)//K)**3

# (a,b,c)=(k,k,k)
res += (N//K)**3

print(res)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n,m,i,x[100000],y[100000],ans=0;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++) scanf("%d",&x[i]);
    qsort(x,m,sizeof(x[i]),asc);
    for(i=1;i<m;i++){
        y[i-1] = x[i]-x[i-1];
    }
    qsort(y,m-1,sizeof(y[i]),asc);
    for(i=0;i<m-n;i++) ans+=y[i];
    printf("%d",ans);
}

Measured memory_bytes: 1396
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = (A - 1) * (B - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
  CIN(n,a,b);
  if(a>b)swap(a,b);
  COUT(max(0,b-(n+a)));

  return 0;
}

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



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

    int ans = 0;
    int a;

    for(int c = 1; c <= N-1; c++){
        for(a = 1; a * a < N-c; a++){
            if ( (N-c)%a == 0 ) {
                ans += 2;
            }
        }
        if (a * a == N-c){
            ans += 1;
        }
    }


    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
long long n,k,tmp,h[10000000],F[10000000];
int main()
{
    //freopen("FROG2.INP","r",stdin);
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>h[i];
    for (int i=2;i<=n;i++)
    {
        F[i]=10E15;
        for (int j=1;j<=k;j++)
            if (i-j>0) F[i]=min(F[i-j]+abs(h[i]-h[i-j]),F[i]);
      		else break;
    }
    cout<<F[n]<<endl;
    return 0;
}



Measured memory_bytes: 3072
N, M = map(int, input().split())
L = [None] * M
R = [None] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())
L = max(L)
R = min(R)
print(R - L + 1 if R - L + 1 >= 0 else 0)

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

int main(){
  int s1s2s3,s1,s2,s3;
  cin >> s1s2s3;
  s3 = s1s2s3%2;
  s2 = ((s1s2s3-s3)%100)/10;
  s1 = (s1s2s3-(10*s2+s3))/100;
  cout << s1+s2+s3 <<endl;
}

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

char s[10];

int main(){
	scanf("%s", s);
	bool ans  = 0;
	for(int i=0;i<strlen(s)-1;i++){
		if(s[i] == 'A' && s[i+1] == 'C') ans = 1;
	}
	if(ans) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict 
# from bisect import *
# from heapq import *
# import math
# mod = 10**9+7

N = input()
A = list(map(int, input().split()))
M = 10**6+1
spf = [i for i in range(M)]
for i in range(2, M):
    if spf[i] == i:
        for j in range(i+i, M, i):
            spf[j] = i
cnt = defaultdict(int)
for a in A:
    ps = set()
    while a != 1:
        ps.add(spf[a])
        a = a // spf[a]
    for p in ps:
        cnt[p] += 1
if all([x < 2 for x in cnt.values()]):
    print("pairwise coprime")
    exit()
gcd = lambda x, y : x if y == 0 else gcd(y, x % y)
x = A[0]
for a in A[1:]:
    x = gcd(x, a)
if x == 1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 216968
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int field[110][110];
int h, w, ex, ey;
char c;
short dp[110][110][110][110];

#define my_max(x,y) ((x) < (y)?(y):(x))
#define my_min(x,y) ((x) < (y)?(x):(y))

int cnt(int il, int ir, int jl, int jr){
    if(il > ir || jl > jr)return 0;
    il--,jl--;
    return field[ir][jr] + field[il][jl] - field[ir][jl] - field[il][jr];
}

int cnti(int il, int ir, int jl, int jr, int i){
    int ill = i, irr = i, jll = jl, jrr= jr;
    ill = my_max(ill, ir - ex + 1);
    irr = my_min(irr, il + h -ex);
    jll = my_max(jll, jr - ey + 1);
    jrr = my_min(jrr, jl + w - ey);
    return cnt(ill, irr, jll, jrr);
}

int cntj(int il, int ir, int jl, int jr, int j){
    int ill = il, irr = ir, jll = j, jrr= j;
    ill = my_max(ill, ir - ex + 1);
    irr = my_min(irr, il + h -ex);
    jll = my_max(jll, jr - ey + 1);
    jrr = my_min(jrr, jl + w - ey);
    return cnt(ill, irr, jll, jrr);
}

int main(){
    cin >> h >> w;
    for(int i = 1;i <= h;i++){
        for(int j = 1;j <= w;j++){
            cin >> c;
            if(c == 'o')field[i][j] = 1;
            if(c == 'E')ex = i, ey = j;
            field[i][j] -= field[i-1][j-1] - field[i-1][j] - field[i][j-1];
        }
    }

    for(int iwidth = 0;iwidth <= h;iwidth++){
        for(int jwidth = 0;jwidth <= w;jwidth++){
            for(int il = 1;il+iwidth <= h;il++){
                int ir = il + iwidth;
                for(int jl = 1;jl + jwidth <= w;jl++){
                    int jr = jl + jwidth;
                    int tmp = dp[il][ir][jl][jr];
                    dp[il-1][ir][jl][jr] = my_max(dp[il-1][ir][jl][jr], tmp + cnti(il,ir,jl,jr,il-1));
                    dp[il][ir+1][jl][jr] = my_max(dp[il][ir+1][jl][jr], tmp + cnti(il,ir,jl,jr,ir+1));
                    dp[il][ir][jl-1][jr] = my_max(dp[il][ir][jl-1][jr], tmp + cntj(il,ir,jl,jr,jl-1));
                    dp[il][ir][jl][jr+1] = my_max(dp[il][ir][jl][jr+1], tmp + cntj(il,ir,jl,jr,jr+1));
                }
            }
        }
    }
    cout << dp[1][h][1][w] << endl;    
    return 0;
}

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

int fun(int a ,int b){
    if(a<b){
        int t=a;
        a=b;b=t;
    }
    if(b==0)return a;
    return fun(b,a%b);
}

int main() {
    int a,b;
    cin >> a >> b;
    cout << fun(a,b) << endl;
}


Measured memory_bytes: 3048
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <ctype.h>
#include <algorithm>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  string s; 
  while(getline(cin, s)) {
    int slide = 0;
    rep(i, s.size()-4) {
      if(islower(s[i]) == 0) continue;
      rep(j, 26) {
        string sub;
        rep(k, 4) sub += (s[i+k]-'a'+j+52)%26 + 'a';
        if(sub.substr(0,3) == "the") slide = j;
        else if(sub == "this" || sub == "that") slide = j;
      }
      if(slide != 0) break;
    }
    rep(i, s.size()) {
      if(islower(s[i]) != 0)printf("%c", (s[i]-'a'+slide+52)%26 + 'a');
      else cout << s[i];
    }
    cout << endl;
  }
}

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

int n, m;

void solve(){
//	cout << n << " " << m << "\n";
	vector<int> h, w;
	h.resize(n+1, 0);
	w.resize(m+1, 0);
	for(int i=1; i<=n; ++i) cin >> h[i];
	for(int i=1; i<=m; ++i) cin >> w[i];
	for(int i=1; i<=n; ++i)
		h[i] += h[i-1];
	for(int i=1; i<=m; ++i)
		w[i] += w[i-1];
	map<int, int> mp;
	for(int i=0; i<n; ++i)
		for(int j=i+1; j<=n; ++j){
			if(mp.find(h[j]-h[i]) == mp.end()){
				mp.insert(make_pair(h[j]-h[i], 1));
			}else{
				++mp[h[j]-h[i]];
			}
		}
	long long ans = 0;
	for(int i=0; i<m; ++i)
		for(int j=i+1; j<=m; ++j){
			if(mp.find(w[j]-w[i]) != mp.end()){
//				cout << w[j] - w[i] << " " << ans << "\n";
				ans += mp[w[j]-w[i]];
			}
		}
	cout << ans << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) return 0;
		solve();
	}
}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC\n";
  } else {
    cout << "ABC\n";
  }
  return 0;
}

Measured memory_bytes: 3664
n = int(input())
s = str(input())
cnt = 0
for i in range(1000):
    x = str(i).zfill(3)
    i1 = s.find(x[0])
    i2 = s[i1+1:].find(x[1])
    i3 = s[i1+i2+2:].find(x[2])
    if -1 not in (i1, i2, i3):
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <stdio.h>
int A[101][101];
int main(){
  int i,j,n,z,t,s;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&z,&t);
    for(j=0;j<t;j++){
      scanf("%d",&s);
      A[i][s-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",A[i][j]);
      if(j==n-1)printf("\n");
      else printf(" ");
    } 
  }



  return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int n, ans =0;
    cin >> n;
    int a[n];
    bool flag = true;
    for(int i = 0; i< n; i++){
        cin >> a[i];
    }
    while(flag){
        flag = false;
        for(int i = 0; i<n-1; i++){
            if(a[i] > a[i+1]){
                int temp = a[i+1];
                a[i+1] = a[i];
                a[i] = temp;
                ans += 1;
                flag = true;
            }
        }
    }
    for(int i = 0; i< n-1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl << ans << endl;
    return 0;
}


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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int d = 0;
    int l = 0;
    int count = 1;

    for(int i=0; i<n; i++){
      l = sc.nextInt();
      d = d + l;
      if(d<=x){
        count += 1;
      }else{
        break;
      }
    }

     System.out.println(count);

  }
}


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

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

int main ()
{
	int k;
  	cin >> k;
  	int sum = 0;
  	for (int i = 1; i < k+1; i++)
    {
    	for (int j = 1; j < k+1; j++)
        {
        	for (int l = 1; l < k+1; l++)
            {
            	sum += gcd(gcd(i,j),l);
            }
        }
    }
  	cout << sum << endl;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
int n, a[4];
int l[8];
int ans = 1e9;
int useNow[8];
int use[8];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void solve(int idx) {
	if (idx < n) {
		REP(i, 4) {
			useNow[idx] = i;
			solve(idx + 1);
		}
		return;
	}
	int cnt[4] = { 0 };
	int sum[4] = { 0 };
	int ansTmp = 0;
	REP(i, n) {
		cnt[useNow[i]]++;
		sum[useNow[i]] += l[i];
	}
	REP(i, 3) {
		if (cnt[i] == 0)return;
	}
	REP(i, 3) {
		ansTmp += (cnt[i] - 1) * 10;
		ansTmp += (int)abs(sum[i] - a[i]);
	}
	ans = Min(ans, ansTmp);
}

int main() {
	scanf("%d%d%d%d", &n, &a[0], &a[1],&a[2]);

	REP(i, n) {
		scanf("%d", &l[i]);
	}
	solve(0);
	PRINTD(ans);
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    ll a, b, c; cin >> a >> b >> c;
    ll e = 0;

    ll g = min(b, c);
    b -= g; c -= g; e += 2 * g;
    ll h = min(a, c);
    a -= h; c -= h; e += h;
    ll i = b;
    b -= i; e += i;
    ll j = min(c, 1ll);
    c -= j; e += j;

    cout << e << endl;
}

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


int main ()
{
    long long n,x;
    cin>>n;
    vector<long long>v;

    while(n--) cin>>x,v.push_back(x);

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

    long long s = 0;

    for(long long i=0;i<v.size()-1;i++)
    {
        s+=v[i];
    }

    if(s>v[v.size()-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long

void print(int n){ cout << n << endl; }

//main------------------------------------------------------------------------------------------

struct fenwick{
    vector<int> bit;
    int s;

    fenwick(int n){
        s = n;
        rep(i,0,n+1) bit.push_back(0);
    }

    int sum(int i){
        if(i < 1) return 0;
        return bit[i] + sum(i - (i & -i));
    }

    int add(int i, int x){
        if(i > s) return 0; 
        bit[i] += x;
        add(i +(i & -i), x);
    }


};

signed main(){
    
    fenwick bit = fenwick(100001);

    int n, q; cin >> n >> q;

    rep(i,0,q){
        int op, x,y;
        cin >> op >> x >> y;
        
        if( op == 0){
            bit.add(x,y);
        }else{
            print(bit.sum(y) - bit.sum(x-1));
        }

    }
    
  
    



}   


Measured memory_bytes: 3736
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int count=0;
  cin>>s;
  rep(i,4){
    if(s[i]=='2'){
      count++;
    }
  }
  cout<<count<<'\n';
  return(0);
}


Measured memory_bytes: 256
s = input()
l = s[:2]
r = s[2:]

if(int(l) >= 1 and int(l) <=12 and int(r) <= 12 and int(r) >= 1):
    print('AMBIGUOUS')
else :
    if(int(l) <= 12 and int(l) >= 1):
        print('MMYY')
    else:
        if(int(r) <= 12 and int(r) >= 1):
            print('YYMM')
        else:
            print('NA')
            

Measured memory_bytes: 9180
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstring>
#include <iomanip>
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;
const int N = 1e5 + 5;
const int D = 15;

int n, m, q;
vector<int> g[N];
int v[N], d[N], c[N];
int vis[N];
int ans[N];

void dfs(int node, int dist, int color) {
	vis[node] = dist;
	if (ans[node] == 0) ans[node] = color;
	if (dist == 0) return;
	for (int v : g[node]) {
		if (vis[v] >= dist - 1) continue;
		dfs(v, dist - 1, color);
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> v[i] >> d[i] >> c[i];
	}

	memset(vis, -1, sizeof(vis));
	for (int i = q - 1; i >= 0; i--) {
		if(vis[v[i]] < d[i]) dfs(v[i], d[i], c[i]);
	}

	for (int i = 1; i <= n; i++) cout << ans[i] << '\n';

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<char, int> mp;
    for(char c='a';c<='z';++c)mp[c] = INT_MAX;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        map<char, int> m;
        for(auto c : s){
            m[c]++;
        }
        for(char c='a';c<='z';++c){
            mp[c] = min(mp[c], m[c]);
        }
    }

    string ans;
    for(char c='a';c<='z';++c){
        while(mp[c] > 0){
            ans.push_back(c);
            mp[c]--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
int h,w,nx,ny,dx[]={0,0,-1,1},dy[]={1,-1,0,0},MAX,ch[20][20];
string dp[20];
queue<pair<int,int>> que;
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>dp[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(dp[i][j]=='.'){
                for(int tt=0;tt<20;tt++)for(int uu=0;uu<20;uu++)ch[tt][uu]=0;
                ch[i][j]=1;
                que.push({i,j});
                while(que.size()){
                    auto q=que.front();
                    que.pop();
                    for(int k=0;k<4;k++){
                        nx=q.F+dx[k];
                        ny=q.S+dy[k];
                        if(0<=nx&&nx<h&&0<=ny&&ny<w&&dp[nx][ny]=='.'){
                            if(ch[nx][ny]==0){
                                ch[nx][ny]=ch[q.F][q.S]+1;
                                MAX=max(MAX,ch[nx][ny]);
                                que.push({nx,ny});
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<MAX-1<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int[][][] r = new int[4][3][10];
		int n = s.nextInt();
		for (int i = 0; i < n; ++i) {
			r[s.nextInt() - 1][s.nextInt() - 1][s.nextInt() - 1] += s.nextInt();
		}
		for (int i = 0; i < 4; ++i) {
			if (i != 0) {
				System.out.println("####################");
			}
			for (int j = 0; j < 3; ++j) {
				for (int k = 0; k < 10; ++k) {
					System.out.print(" " + r[i][j][k]);
				}
				System.out.println();
			}
		}
	}
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

PII a[51];
PII b[51];
pair<LL, LL> c[51];

int main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i].first >> b[i].second;
    }
    for (int i = 0; i < n; ++i) {
        c[i].first = abs (a[i].first - b[0].first) + abs (a[i].second - b[0].second);
        c[i].second = 1;
        for (int j = 1; j < m; ++j) {
            int d = abs (a[i].first - b[j].first) + abs (a[i].second - b[j].second);
            if (d < c[i].first) {
                c[i].first = d;
                c[i].second = j+1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << c[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  while(1){
    char s[10000]={'\0'};
    gets(s);
    if(!strcmp(s,"END OF INPUT"))break;
    int n=0;
    rep(i,10000){if(s[i]=='\0')break;n++;}
    //cout<<n<<endl;
    int co=0;
    rep(i,n){
      if(s[i]==' '){cout<<co;co=0;}
      else co++;
    }
    cout<<co<<endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	int cnt = 0;
	rep(i,n){
		int h;
		cin >> h;
		cnt += (h >= k);
	}
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 256