akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 1000010
#define se second
#define fi first
using namespace std;
string s,ns;
pair<int,char> a[5];
int n,vi[N],s1,s2,s3;
int main(){
	cin>>s;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	for (int i=1;i<n;i++)if (s[i]==s[i-1])vi[i]=0;
	for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
	s=ns;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	for (int i=1;i<=n;i++)a[s[i-1]-'A'].fi++;
	for (int i=0;i<3;i++)a[i].se='A'+i;
	sort(a,a+3);
	for (int i=0;i<=n;){
		int ne=i+1;
		while (ne<=n&&s[ne-1]!=a[0].se)ne++;
		if (ne>i+1){
			if (ne==i+2){if (s[i]==a[1].se) s2++;else s3++;}else s1++;
		}
		i=ne;
	}
	if (s3>s1+s2){
		if (s[n-1]==a[2].se&&n>1&&s[n-2]==a[0].se){n--;a[2].fi--;s3--;}
		for (int i=0;i<=n&&s3>s1+s2;){
			int ne=i+1;
			while (ne<=n&&s[ne-1]!=a[0].se)ne++;
			if (ne==i+2&&s[i]==a[2].se){s3--;if (i)a[0].fi--;a[2].fi--;vi[i+1]=0;vi[i]=0;}
			i=ne;
		}
		if (a[1].fi>a[2].fi){swap(a[1],a[2]);swap(s2,s3);}
		for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
		s=ns;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	}
	for (int i=0;i<=n&&a[2].fi>a[1].fi;){
		int ne=i+1;
		while (ne<=n&&s[ne-1]!=a[0].se)ne++;
		if (ne>i+2){if (s[i]==a[2].se){a[2].fi--;vi[i+1]=0;}if (s[ne-2]==a[2].se&&a[2].fi>a[1].fi){a[2].fi--;vi[ne-1]=0;}}
		i=ne;
	}
	for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
	s=ns;n=s.length();ns="";for (int i=1;i<=n;i++)vi[i]=1;
	for (int i=0;i<=n&&a[1].fi>a[0].fi;){
		int ne=i+1;
		while (ne<=n&&s[ne-1]!=a[0].se)ne++;
		while ((i+3<ne||(i+3==ne&&(i==0||ne==n+1)))&&a[1].fi>a[0].fi){vi[i+1]=0;vi[i+2]=0;i+=2;a[1].fi--;}
		i=ne;
	}
	for (int i=1;i<=n;i++)if (vi[i])ns+=s[i-1];
	cout<<ns<<endl;
	return 0;
}

Measured memory_bytes: 8160
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
 
int main() {
    int x,y;
    cin>>x>>y;
    int ans=0;
    if(x==1)ans+=300000;
    else if(x==2)ans+=200000;
    else if(x==3)ans+=100000;
    if(y==1)ans+=300000;
    else if(y==2)ans+=200000;
    else if(y==3)ans+=100000;
    if(x==1&&y==1)ans+=400000;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % (1LL * n * (n + 1) / 2) != 0) {
    cout << "NO" << endl;
    return 0;
  }
  a[n] = a[0];
  long long k = sum / (1LL * n * (n + 1) / 2);
  vector<int> dif(n);
  for (int i = 0; i < n; i++) {
    dif[i] = a[i + 1] - a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (dif[i] == k) continue;
    else if (dif[i] > k) {
      cout << "NO" << endl;
      return 0;
    } else {
      long long tmp = k - dif[i];
      if (tmp % n != 0) {
        cout << "NO" << endl;
        return 0;
      } else {
        cnt += tmp / n;
      }
    }
  }
  cout << (cnt == k ? "YES" : "NO") << endl;
  return 0;	
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

S = input()
key = 'keyence'
K = []

if key in S:
    print('YES')
    exit()


for i in range(len(key)+1):
    K.append([key[:i],key[i:]])

for i in range(len(K)):
    if S[:len(K[i][0])] == K[i][0] and S[len(S)-len(K[i][1]):] == K[i][1]:
        print('YES')
        exit()
print('NO')




Measured memory_bytes: 3064
/*
ID: arthurc4
TASK: test
LANG: C++11
*/

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<bool> vb;
typedef vector<vb> vvb;

typedef map<string,int> msi;
typedef map<int,int> mii;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll; // note 'single' ls

typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++)

#define REPb(j, d, c) \
for (int j = int(d); j >= int(c); j--)

#define pb \
push_back

#define ff \
first

#define ss \
second

// LL OR INT ???
// DELETED IFSTREAM ???
int main()
{
	//ifstream cin("input.txt");
	//ifstream cin("test.in");
	//ofstream cout("test.out");

	int N;
	cin >> N;

	vi H = {0};

	REP(i, 1, N)
	{
		int h;
		cin >> h;
		H.pb(h);
	}

	vi cost(N+1);
	cost[1] = 0;
	cost[2] = abs(H[2] - H[1]);

	//cout << cost[1] << " " << cost[2] << " ";

	REP(i, 3, N)
	{
		cost[i] = min(cost[i-1] + abs(H[i]-H[i-1]), cost[i-2] + abs(H[i]-H[i-2]));
		//cout << cost[i] << " ";
	}
	//cout << endl;

	cout << cost[N] << endl;

	return 0;
}

Measured memory_bytes: 1144
#include <cstdio>

int main()
{
	int n,sum=0; scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		int x; scanf("%d",&x);
		if(x%2==1&&i%2==1) sum++;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 1676
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int x,d, k;
   cin>>x>>k>>d;
   x=abs(x);
   long long int steps=k-min(k, x/d);
       x-=min(k, (x/d))*d;
       k=steps;
       if(k%2==0) cout<<abs(x)<<endl;
       else cout<<abs(x-d)<<endl;
}

Measured memory_bytes: 3648
n = int(input())
ab = []
for _ in range(n):
    a,b = [int(x) for x in input().split()]
    ab.append([a,b])

tmp = 0
for x in ab[::-1]:
    x[0] += tmp
    if x[0] % x[1] != 0: 
        tmp += x[1] - (x[0] % x[1])

print(tmp)

Measured memory_bytes: 24308
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while(scan.hasNext()) {

            String line;
            try {
                line = scan.nextLine();
            }catch(java.util.NoSuchElementException e) {
                break;
            }

            int[] hand = new int[5];

            String[] cardNum = line.split(",");

            for(int i = 0; i < 5; i++) {
                hand[i] = Integer.parseInt(cardNum[i]);
            }

            int[] number = new int[14];
            for(int i = 0; i < 5; i++) {
                number[hand[i]] += 1;
            }

            int paircount = 0;
            ArrayList<Integer> list = new ArrayList<Integer>();
            for(int i = 0; i < 14; i++) {
                if(number[i] > 1) {
                    list.add(number[i]);
                }
                if(number[i] == 2) {
                    paircount += 1;
                }
            }

            boolean isStraight = false;
            int count = 0;
            for(int i = 0 ; i < 14 ; i++) {
            	if(number[i] == 1) {
            		count++;
            	}else if(number[i] ==0) {
            		count = 0;
            	}
            	if(i == 13 && count == 4) {
            		if(number[1] == 1) {
            			count++;
            		}
            	}
            	if(count == 5) {
            		isStraight = true;
            		break;
            	}
            }

            if(list.contains(4)) {
                System.out.println("four card");
            }else if(list.contains(3) && list.contains(2)) {
                System.out.println("full house");
            }else if(isStraight){
            	System.out.println("straight");
            } else if(list.contains(3)) {
                 System.out.println("three card");
            }else if(paircount == 2) {
                System.out.println("two pair");
            }else if(paircount == 1) {
                System.out.println("one pair");
            }else {
            	System.out.println("null");
            }

		}
	}

}



Measured memory_bytes: 25908
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, y, s;
    cin >> x >> y;
    if(y%2==0)
    {
        s = x + (y / 2);
        cout<<s<<endl;
    }
    else
    {
        s = x + y;
        cout<<s<<endl;
    }
}


Measured memory_bytes: 3612
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>

//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    struct T
    {
    public:
        ll a;
        ll b;
        ll c;
    };
    vector<T> t;
    cin >> N;
    rep(i, N)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        t.push_back({a,b,c});
    }
    vector<T> h(N, {0,0,0});
    //
    h[0].a = t[0].a;
    h[0].b = t[0].b;
    h[0].c = t[0].c;
    //
    for(ll i=1;i<N;++i)
    {
        ll i1 = i - 1;
        h[i].a = t[i].a + max(h[i1].b, h[i1].c);
        h[i].b = t[i].b + max(h[i1].a, h[i1].c);
        h[i].c = t[i].c + max(h[i1].a, h[i1].b);
    }
    auto& l = h.back();
    auto lm = max({ l.a, l.b, l.c });
    cout << lm;
}

Measured memory_bytes: 7564
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
int cnt(0);
void insertionSort(vector<int>&A, int g) {
	rep(i, g, A.size()) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && v < A[j]) {
			A[j + g] = A[j];
			cnt++;
			j -= g;
		}
		A[j + g] = v;
	}
}
vector<int>g;
void shellSort(vector<int>&A) {
	for (int x = A.size(); x > 0; x >>= 1)g.emplace_back(x);
	rep(i, 0, g.size()) {
		insertionSort(A, g[i]);
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int>A(n);
	rep(i, 0, n)cin >> A[i];
	shellSort(A);
	cout << g.size() << endl;
	rep(i, 0, g.size())cout << g[i] << (i == g.size()-1 ? '\n' : ' ');
	cout << cnt << endl;
	rep(i, 0, n)cout << A[i] << endl;
	return 0;
}

Measured memory_bytes: 6676
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Point> red = new ArrayList<Point>(n);
		for (int i = 0; i < n; i++) {
			Point p = new Point();
			p.x = sc.nextInt();
			p.y = sc.nextInt();
			red.add(p);
		}
		List<Point> blue = new ArrayList<Point>(n);
		for (int i = 0; i < n; i++) {
			Point p = new Point();
			p.x = sc.nextInt();
			p.y = sc.nextInt();
			blue.add(p);
		}
		sc.close();

		// blueをxの昇順にソート
		Collections.sort(blue, new Comparator<Point>() {
			public int compare(Point o1, Point o2) {
				return o1.x - o2.x;
			}
		});

		int ans = 0;
		for (int i = 0; i < n; i++) {
			Point p = blue.get(i);
			Point m = getYMaxRed(red, p.x, p.y);
			if (m != null) {
				red.remove(m);
				ans++;
			}
		}
		System.out.println(ans);
	}

	static class Point {
		int x, y;
	}

	static Point getYMaxRed(List<Point> red, int x, int y) {
		Point max = null;
		for (Point p : red) {
			if (p.x > x || p.y > y) {
				continue;
			}
			if (max == null || max.y < p.y) {
				max = p;
			}
		}
		return max;
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	vector<int> q(n);
	rep(i, n)
	{
		q[i] = p[i] - x;
	}

	int ans, a;
  a=0;
	int count = 0;
	bool tf = false;
	rep(i, n+1)
	{
		if (i % 2 == 0) a = i / 2;
		else a = -(i + 1) / 2;
		count=0;
		rep(t, n)
		{
			if (a != q[t])
			{
				count++;
			}
        } 
		if (count == n)
		{
				tf = true;
		}
		
		if (tf) break;
	}

  
	cout << a + x << "\n";


	return 0;
}

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

#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int N; cin >> N;
    int a[N];
    for (int i = 0; i < N; i++) cin >> a[i];
    int mn = INT_MAX;
    for (int i = -100; i <= 100; i++) {
        int sum = 0;
        for (int j = 0; j < N; j++) {
            sum += (a[j] - i) * (a[j] - i);
        }
        mn = min(mn, sum);
    }
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 256
// https://youtu.be/pKOPnK1JPLE?t=6099

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

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }

    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

int main() {
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vector<P> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    ll ans = 0;
    BIT<ll> bit(n+1);

    rep(i, n) {
        ll x = p[i].first, h = p[i].second;
        h -= bit.sum(i);
        if (h <= 0) continue;
        ll num = (h + a - 1) / a;
        ans += num;
        ll damage = num * a;
        bit.add(i, damage);
        int j = upper_bound(p.begin(), p.end(), P(x+d*2+1, -1)) - p.begin();
        bit.add(j, -damage);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
int n;
vector<long long int> v;
long long int solve(int first_pon){
    long long int pon = first_pon, sum = 0, result = 0;
    REP(i,n){
        sum += v[i];
        if(pon>0&&sum>=0){
            result += sum + 1;
            sum = -1;

        }else if(pon<0&&sum<=0){
            result += (-sum) + 1;
            sum = 1;

        }
        if(sum>0){
            pon = 1;
        }else{
            pon = -1;
        }
    }
    return result;
}

int main(){

    
    cin >> n ;
    v = vector<long long int>(n);
    REP(i,n){
        cin >> v[i];
    }
    cout << (long long int)min(solve(1), solve(-1)) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
#define N 300000
int n, k, a[N];
int main(){
	n=read(), k=read();
	for (int i=1;i<=n;i++){
		a[i]=read();
		if (i>k)
			if (a[i]>a[i-k]) puts("Yes");
			else puts("No");
	}
    return 0;
}

Measured memory_bytes: 4460
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000000000000000;
const char END = '\n';

string S, T;
ll Ans = 1005 ,sub = 0;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> S >> T;

	rep(i, S.length() - T.length() + 1) {
		sub = 0;
		rep(j, T.length()) {
			if (S[i + j] != T[j])
				sub++;
		}
		if (Ans > sub)
			Ans = sub;
	}
	cout << Ans << END;

	return 0;
}

Measured memory_bytes: 3652
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from collections import deque


mod = 1000000007

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    commands = {"insert": lambda l,x:l.appendleft(x),
    "delete": lambda l,x:l.remove(x) if x in l else x,
    "deleteFirst": lambda l:l.popleft(),
    "deleteLast": lambda l:l.pop(),
    }
    l=deque()
    for i in range(n):
        c = sys.stdin.readline().split()
        if c[0]=="deleteFirst" or c[0]=="deleteLast":
            commands[c[0]](l)
        elif c[0] in commands:
            commands[c[0]](l,c[1])
            # l.append(commands[c](l.pop(),l.pop()))
    l_list=list(l)
    print(*l_list)



Measured memory_bytes: 71176
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 23 19:42:05 2019

@author: Yamazaki Kenichi
"""

N = int(input())
A = [list(map(int,input().split())) for i in range(N)]

tree = [[-1,-1,-1] for i in range(N)]
for i in range(N):
    tree[A[i][0]][1],tree[A[i][0]][2] = A[i][1],A[i][2]
    if A[i][1] != -1:
        tree[A[i][1]][0] = A[i][0]
    if A[i][2] != -1:
        tree[A[i][2]][0] = A[i][0]

def parent(u):
    return tree[u][0]
def lchild(u):
    return tree[u][1]
def rchild(u):
    return tree[u][2]
def depth(u):
    res = 0
    while parent(u) != -1:
        res += 1
        u = parent(u)
    return res
H = [-1 for i in range(N)]
def h(u):
    hl = h(lchild(u)) +1 if lchild(u) != -1 else 0
    hr = h(rchild(u)) +1 if rchild(u) != -1 else 0
    H[u] = max(hl,hr)
    return max(hl,hr)

for i in range(N):
    if parent(i) == -1:
        k = i
ans_pre = []
def pre(u):
    if u != -1:
        ans_pre.append(u)
    if lchild(u) != -1:
        pre(lchild(u))
    if rchild(u) != -1:
        pre(rchild(u))
pre(k)
ans_ino = []
def ino(u):
    if lchild(u) != -1:
        ino(lchild(u))
    if u != -1:
        ans_ino.append(u)
    if rchild(u) != -1:
        ino(rchild(u))
ino(k)
ans_pos = []
def pos(u):
    if lchild(u) != -1:
        pos(lchild(u))
    if rchild(u) != -1:
        pos(rchild(u))
    if u != -1:
        ans_pos.append(u)
pos(k)
print('Preorder')
print(" "+" ".join(map(str,ans_pre)))
print('Inorder')
print(" "+" ".join(map(str,ans_ino)))
print('Postorder')
print(" "+" ".join(map(str,ans_pos)))




Measured memory_bytes: 5640
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w;
    cin >> h >> w;
    vs a(h);
    cin >> a;
    set<int> eh,ew;
    rep(i,h) {
        bool flag = true;
        rep(j,w) if(a[i][j] == '#') flag = false;
        if(flag) eh.insert(i);
    }
    rep(i,w) {
        bool flag = true;
        rep(j,h) if(a[j][i] == '#') flag = false;
        if(flag) ew.insert(i);
    }
    rep(i,h) {
        if(eh.count(i)) continue;
        rep(j,w) {
            if(ew.count(j)) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,total;
	scanf("%d%d",&n,&total);
	total/=1000;
	int a,b,c;
	for(a=0; a<=total/10&&a<=n; a++)
		for(b=0; b<=total/5&&b<=n; b++) {
			c=n-a-b;
			if(a*10+b*5+c==total&&c<=n&&c>=0) {
				printf("%d %d %d\n",a,b,c);
				return 0;
			}
		}
	puts("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    S_A = input().rstrip()
    S_B = input().rstrip()
    S_C = input().rstrip()
    ia, ib, ic = 0, 0, 0

    next_turn = "A"
    while True:
        if next_turn == "A":
            if ia == len(S_A):
                break
            next_turn = S_A[ia].upper()
            ia += 1
        elif next_turn == "B":
            if ib == len(S_B):
                break
            next_turn = S_B[ib].upper()
            ib += 1
        elif next_turn == "C":
            if ic == len(S_C):
                break
            next_turn = S_C[ic].upper()
            ic += 1
    print(next_turn)


if __name__ == "__main__":
    main()


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

const int INF = 1e9;
const int M = 1010;
int n, m, k;
char b[11][M];

int main() {
    while (scanf("%d %d %d", &n, &m, &k) == 3) {
        for (int i = 0; i < n; i++) scanf("%s", b[i]); 
        int res = INF;
        for (int mask = 0; mask < 1 << n; mask++) {
            int tres = 0;
            vector<int> num(n, 0);
            for (int ib = 1; ib < n; ib++) {
                num[ib] = num[ib - 1];
                if ((mask >> ib & 1) != (mask >> (ib - 1) & 1)) num[ib]++, tres++;
            }
            int nh = num.back() + 1;
            vector<int> w(nh, 0);
            for (int j = 0; j < m; j++) {
                vector<int> tw(nh, 0);
                for (int i = 0; i < n; i++) if (b[i][j] == '1') tw[num[i]]++;

                for (auto &x : tw) if (x > k) {
                    tres = INF;
                    break;
                }

                bool needCut = 0;
                for (int i = 0; i < nh; i++) needCut |= tw[i] + w[i] > k;
                if (needCut) {
                    tres++;
                    w = tw;
                } else for (int i = 0; i < nh; i++) w[i] += tw[i];
            }
            res = min(res, tres);
        }
        printf("%d\n", res);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7; //10の9乗

ll F(ll A, ll B) {
    return max(log10(A)+1, log10(B)+1);
}

int main(){
    int N;
    cin >> N;
    vector<ll> a(N), S(N);
    for(int i=0; i<N; i++) cin >> a[i];
    S[0] = a[0];
    for(int i=1; i<N; i++) S[i] = S[i-1] + a[i];

    ll first_count = 0, second_count = 0, div = 0;
    vector<ll> T = S;
    // + - + - パターン
    for(int i=0; i<N; i++) {
        S[i] += div;
        if(i%2 == 0 && S[i] <= 0) {
            first_count += abs(S[i]) + 1;
            div += -S[i] + 1;
        }
        else if(i%2 == 1 && S[i] >= 0){
            first_count += abs(S[i]) + 1;
            div += -S[i] - 1;
        }
    }

    div = 0;
    // - + - + パターン
    for(int i=0; i<N; i++) {
        T[i] += div;
        if(i%2 == 0 && T[i] >= 0) {
            second_count += abs(T[i]) + 1;
            div += -T[i] - 1;
        }
        else if(i%2 == 1 && T[i] <= 0){
            second_count += abs(T[i]) + 1;
            div += -T[i] + 1;
        }
    }
    cout << min(first_count, second_count) << endl;
}

Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 7;
const int infint = (int)1e9;
const ll inf = (ll)1e18;
ll a[MAXN], dp[MAXN], n, fact[MAXN], facrev[MAXN];
ll pwr(ll a, ll b)
{
	if(b == 0)
		return 1;
	if(b == 1)
		return a;
	ll c = pwr(a, b / 2);
	c = (c * c) % MOD;
	if(b % 2)
		c = (c * a) % MOD;
	return c;
}
ll inv(ll p)
{
	return pwr(p, MOD - 2);
}
ll C(ll n, ll k)
{
	ll mul = fact[n];
	mul = (mul * facrev[k]) % MOD;
	mul = (mul * facrev[n - k]) % MOD;
	return mul;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	fact[0] = 1;
	for (int i = 1; i < MAXN; i++)
		fact[i] = fact[i - 1] * i % MOD;
	facrev[MAXN - 1] = inv(fact[MAXN - 1]);
	for (int i = MAXN - 1; i > 0; i--)
		facrev[i - 1] = (facrev[i] * i) % MOD;
	dp[0] = dp[1] = 1;
	for (int i = 2; i <= n; i++)
		dp[i] = i * dp[i - 1] % MOD + fact[i - 1], dp[i] %= MOD;
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		ll t_pre = C(n, n - i - 1) * fact[n - i - 1] % MOD * dp[i + 1] % MOD;
		ll t_nxt = C(n, i) * fact[i] % MOD * dp[n - i] % MOD;
		t_pre = (t_pre + t_nxt - fact[n] + MOD) % MOD;
		ans = (ans + t_pre * a[i] % MOD) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  ll N, K; std::cin >> N >> K;
  std::vector<ll> A(N); for(int i=0; i<N; i++) std::cin >> A[i];

  ll ans = 0, ret = 0;
  for(int i = 40; i>=0; --i) {
    ll mask = (1LL<<i);
    ll num_o = 0;
    for(int j=0; j<N; j++) if ( A[j] & mask ) num_o++;

    ll num_z = N - num_o;
    if ( num_o >= num_z ) ans += mask*num_o;
    else {
      if( mask + ret <= K ) {
        ans += num_z*mask;
        ret += mask;
      }
      else ans += mask*num_o;
    }
  }

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

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		double t = sc.nextInt();//
      	double x = sc.nextInt();//

		// 出力
		System.out.println(t/x);
	}

}




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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        s.insert(x);
    }
    if (s.size() == n) cout << "YES\n";
    else cout << "NO\n"; 
    return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vi wa(n), flag(n);
  REP(i, m) {
    int a; string s;
    cin >> a >> s;
    a--;
    if (s == "AC") {
      flag[a] = 1;
    }
    else {
      if (!flag[a])wa[a]++;
    }
  }
  int cnt = 0, p = 0;
  REP(i, n) {
    if (flag[i]) {
      cnt++;
      p += wa[i];
    }
  }
  cout << cnt << " " << p << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
bool done[N];

int n, m, x;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string x;
    cin >> x;
    for (auto &w : x)
        cout << 'x';
    return 0;
}


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

sys.setrecursionlimit(10 ** 7)

# 1 ✕ N
N, M = list(map(int, input().rstrip().split()))

# N ✕ M
A = list(tuple(map(int, input().rstrip().split())) for _ in range(M))

array = [[] for _ in range(N)]
for x, y in A:
    array[x - 1].append(y - 1)
    array[y - 1].append(x - 1)

before = [None] * N
before[0] = -1
q = collections.deque([0])

while len(q):
    node = q.popleft()
    for nxt in array[node]:
        if before[nxt] is not None:
            continue
        q.append(nxt)
        before[nxt] = node

print("Yes")
for i in range(1, N):
    print(before[i] + 1)

# # print(array)
# ans = dict((_, 1e9) for _ in range(N))
#
# # visit = [[] for _ in range(N)]
# queue = []
# queue.extend(array[0])
#
# # depth = 0
# while queue:
#     tmp = []
#     q = queue.pop()
#     for x in array[q]:
#         for n in array[x]:
#             if ans[n] != 1e9:
#                 ans[n] = x
#                 tmp.append(ans[n])
#
# if len(tmp) > 0:
#     queue.extend(tmp)
#
# print(ans)


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

int main(){
 ll a,b; cin>>a>>b;
  if(b%a==0) cout<<a+b<<endl;
  else cout<<b-a<<endl;
  
  
}

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

int main() {
  int h, n;
  cin >> h >> n;
  int sum = 0;
  rep(i,n) {
    int a;
    cin >> a;
    sum += a;
  }
  if (sum < h) puts("No");
  else puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,a,b,ans = 0;
    cin >> n >> a >> b;
    for(int i = 1;i <= n;i++)
    {
        int c = 0,t = i;
        for(int j = 0;j < 5;j++)
        {
            c += t % 10; t /= 10;
        }
        if(a <= c && c <= b){ans += i;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

std::string s;
int a, b, c, d;

void solve() {
    if (a+b+c+d == 7) {
        std::cout << a << '+' << b << '+' << c << '+' << d;
    } else if (a+b+c-d == 7) {
        std::cout << a << '+' << b << '+' << c << '-' << d;
    } else if (a+b-c+d == 7) {
        std::cout << a << '+' << b << '-' << c << '+' << d;
    } else if (a+b-c-d == 7) {
        std::cout << a << '+' << b << '-' << c << '-' << d;
    } else if (a-b+c+d == 7) {
        std::cout << a << '-' << b << '+' << c << '+' << d;
    } else if (a-b+c-d == 7) {
        std::cout << a << '-' << b << '+' << c << '-' << d;
    } else if (a-b-c+d == 7) {
        std::cout << a << '-' << b << '-' << c << '+' << d;
    } else if (a-b-c-d == 7) {
        std::cout << a << '-' << b << '-' << c << '-' << d;
    }
    std::cout << "=7" << std::endl;
}

int main() {
    std::cin >> s;
    a = s[0]-'0';
    b = s[1]-'0';
    c = s[2]-'0';
    d = s[3]-'0';
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n;

  while(cin>>n,n){
	int ans=0;
	FOR(i,1,n/2+1){
	  FOR(j,1,n/2+1){
		if((i+i+j)*(j+1)/2 == n )
		  //cout << i <<endl << j<< endl;//
		  ans++;
	  }
	}

	cout << ans << endl;

  }

}

Measured memory_bytes: 1160
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=5005;
const int mod=1000000007;
const int inv2=(mod+1)>>1;
template<typename _Tp1,typename _Tp2>Finline void add(_Tp1 &a,_Tp2 b){(a+=b)>=mod&&(a-=mod);}
template<typename _Tp1,typename _Tp2>Finline void sub(_Tp1 &a,_Tp2 b){(a-=b)<0&&(a+=mod);}
struct edge{
	int v,nxt;
}c[N<<1];
int front[N],edge_cnt;
Finline void addedge(int u,int v)
{
	c[++edge_cnt]=(edge){v,front[u]};
	front[u]=edge_cnt;
}
int dp[N][N],t[N];
int val[N];
int dfs(int x,int fa)
{
	int siz=1;
	dp[x][1]=1;
	for(int i=front[x];i;i=c[i].nxt)
	{
		int v=c[i].v;
		if(v==fa) continue;
		int tmp=dfs(v,x);
		memset(t,0,(siz+tmp+3)<<2);
		for(int j=0;j<=siz;++j) for(int k=0;k<=tmp;++k)	add(t[j+k],1ll*dp[x][j]*dp[v][k]%mod);
		memcpy(dp[x],t,(siz+tmp+3)<<2);
		siz+=tmp;
	}
	for(int i=1;i<=siz;++i) sub(dp[x][0],1ll*dp[x][i]*val[i]%mod);
	return siz;
}
ll fac[N],inv[N],ifac[N],pw[N];
int main()
{
	fac[0]=fac[1]=inv[0]=inv[1]=ifac[0]=ifac[1]=1;
	for(int i=2;i<N;++i) fac[i]=fac[i-1]*i%mod,inv[i]=inv[mod%i]*(mod-mod/i)%mod,ifac[i]=ifac[i-1]*inv[i]%mod;
	pw[0]=1;for(int i=1;i<N;++i) pw[i]=pw[i-1]*inv2%mod;
	for(int i=0;i<N;i+=2) val[i]=fac[i]*ifac[i>>1]%mod*pw[i>>1]%mod;
	int n;read(n);
	int x,y;
	for(int i=1;i<n;++i) read(x,y),addedge(x,y),addedge(y,x);
	dfs(1,0);
	printf("%d\n",(mod-dp[1][0])%mod);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

//a^b(mod 1000000007)
ll mod_pow(ll a, ll b){
 ll m= 1000000007;
 if(b == 0) return 1;
 if(b % 2 == 0){
   ll d = mod_pow(a,b/2);
   return (d*d)%m;
 }else return a%m*mod_pow(a,b-1)%m;
}

//nCr(mod 100000007)
//O(nlog(mod))
ll mod_comb(ll n,ll r){
 ll m=1000000007;
 if(r > n) return 0;
 if(n == r || r == 0) return 1;
 ll f1 = 1,f2 = 1;
 for(ll i = n; i >= n-r+1; i--) f1 = f1*i%m;
 for(ll i = r; i >= 1; i--) f2 = f2*i%m;
 return f1*mod_pow(f2,m-2)%m;
}

int main() {

  ll n,k, count=0, ans=0;
 
  cin >> n;
  cin >> k ;
  ll mod = 1000000007;

  for(ll i = k; i<=n+1; i++){
    ll left=0, right=0;
    left=i*(i-1)/2;
    
    if(n-i>=0){
      right=(n)*(n+1)/2 - (n-i)*(n-i+1)/2;
    }
    else {
      right=(n)*(n+1)/2;
    }
    ans+=(right-left+1)%mod;
  }


  cout << ans%mod << endl;
}

Measured memory_bytes: 3632
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}

#define int ll

void solve() {
	int n,m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

lower_lim = sum(A) * (1 / (4 * M))

if any(s < lower_lim for s in sorted(A, reverse=True)[:M]):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

ue = ["#"]*(w+2)
print(*ue,sep="")
for i in range(h):
    print("#",end="")
    print(*l[i],sep="",end="")
    print("#")

print(*ue,sep="")

Measured memory_bytes: 40432
//1〜10までの数を使って、n項の和をs+nにするという問題に置き換える。
#include<iostream>
using namespace std;

int dp[10][11][111];	//dp[今作った項][今使った数(昇順に使う)][今の和]

int main()
{
	int i,j,k,l;
	int n,s;
	
	while( cin >> n >> s ){
		if( !n )break;
		
		for( i = 0;i < 10;i++ ){
			for( j = 0;j < 11;j++ ){
				for( k = 0;k < 111;k++ ){
					dp[i][j][k] = 0;
				}
			}
		}
		dp[0][0][0] = 1;
		
		for( i = 0;i < n;i++ ){
			for( j = 0;j < 11;j++ ){
				for( k = 0;k <= s+n;k++ ){
					for( l = j+1;l < 11;l++ ){
						if( k+l > s+n )
							break;
						
						dp[i+1][l][k+l] += dp[i][j][k];
					}
				}
			}
		}
		int ans = 0;
		
		for( i = 0;i < 11;i++ ){
			ans += dp[n][i][s+n];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

// 1-indexed
// example: Bit::new(n, |x, y| *x += *y, 0)
struct Bit<T, F> {
    n: usize,
    dat: Vec<T>,
    op: F,
    unit: T,
}

impl<T: Clone, F: Fn(&mut T, &T)> Bit<T, F> {
    #[allow(dead_code)]
    fn new(n: usize, op: F, unit: T) -> Self {
        Bit {
            n: n,
            dat: vec![unit.clone(); n + 1],
            op: op,
            unit: unit,
        }
    }
    #[allow(dead_code)]
    fn from_vec(mut v: Vec<T>, op: F, unit: T) -> Self {
        let n = v.len();
        let mut dat = vec![unit.clone()];
        dat.append(&mut v);
        for i in 1..n {
            let j = i as i32;
            let b = (j & -j) as usize;
            let x = dat[i].clone();
            op(&mut dat[i + b], &x);
        }
        Bit {
            n: n,
            dat: dat,
            op: op,
            unit: unit,
        }
    }
    fn operate(&mut self, k: usize, a: &T) {
        let mut k = k;
        while k <= self.n {
            (self.op)(&mut self.dat[k], &a);
            let l = k as i32;
            k += (l & -l) as usize;
        }
    }
    fn accum(&self, k: usize) -> T {
        let mut k = k;
        let mut sum = self.unit.clone();
        while k > 0 {
            (self.op)(&mut sum, &self.dat[k]);
            let l = k as i32;
            k -= (l & -l) as usize;
        }
        sum
    }
}

fn main() {
  input! {
    n: usize,
    h: [usize; n],
    a: [i64; n]
  }
  let mut bit = Bit::new(n, |x, y| *x = cmp::max(*x, *y), 0);
  bit.operate(1, &0);
  for i in 0 .. n {
    let current = bit.accum(h[i]);
    bit.operate(h[i], &(current + a[i]));
  }
  println!("{}", bit.accum(n));
}


Measured memory_bytes: 13688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve() {
    ll n;
    int x, m;
    cin >> n >> x >> m;

    vector<int> cnt(m, 0);
    vector<int> cycle;
    int cur = x;
    ll ans = 0;

    while (n > 0) {
        cnt[cur]++;

        if (cnt[cur] == 2) cycle.push_back(cur);
        else if (cnt[cur] == 3) break;

        ans += cur;
        n--;

        cur = (1LL * cur * cur) % m;
    }
    

    if (!cycle.empty()) {
        ll cycle_sum = 0;
        for (int &el : cycle) {
            cycle_sum += el;
        }

        ll p = n / cycle.size();
        ll q = n % cycle.size();
        ans += p * cycle_sum;

        fori (i, 0, q) {
            ans += cycle[i];
        }
    }

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 3992
import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    try {
      @tailrec
      def sub(x: Int,y: Int): Unit = {
        if (x == 0 && y == 0) {} 
        else {
          val ans = if(x < y) Array(x,y) else Array(y,x)
          println(s"${ans(0)} ${ans(1)}")
          sub(sc.nextInt,sc.nextInt)
        }
      }
      sub(sc.nextInt,sc.nextInt)
    } catch {
      case e: NoSuchElementException =>
        println("error: stdin is not found. Please take numbers.")
    }
  }
}

Measured memory_bytes: 53148
from itertools import accumulate
from bisect import bisect_right

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

acca = [0] + list(accumulate(a))
accb = list(accumulate(b))
ans = 0

for i in range(n + 1):
    if k < acca[i]:
        break
    t = k - acca[i]
    ans = max(ans, bisect_right(accb, t) + i)
print(ans)


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

int main()
{
  ll l,r,d;
  cin>>l>>r>>d;
  ll a1,a2;
  a1=l/d;
  a2=r/d;
  if(l%d == 0)
    a2++;
  cout<<a2-a1<<"\n";
  return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

//????????¶?????????
public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		Pattern pThe = Pattern.compile("the");
		Pattern pThis = Pattern.compile("this");
		Pattern pThat = Pattern.compile("that");
		Matcher mThe;
		Matcher mThis;
		Matcher mThat;

		while(sc.hasNext()) {
			//?????????????????¨???
			String str = sc.nextLine();
			String code = "";

			for(int i = 0; i < 26; i++) {
				for(int $ = 0; $ < str.length(); $++) {
					if(str.charAt($) >= 'a' && str.charAt($) < 'z') {
						code += String.valueOf((char)(str.charAt($) + 1));
					} else if(str.charAt($) == 'z') {
						code += 'a';
					} else {
						code += str.charAt($);
					}
				}

				mThe = pThe.matcher(code);
				mThis = pThis.matcher(code);
				mThat = pThat.matcher(code);

				if(mThe.find() || mThis.find() || mThat.find()) {
					System.out.println(code);
					break;
				}

				str = code;
				code = "";

			}

		}
	}

}

Measured memory_bytes: 28388
#include<stdio.h>
 
int main(){
  char S[6];
  scanf("%s",S);
  if(S[0]=='S')
    printf("Cloudy\n");
  else if(S[0]=='R')
    printf("Sunny\n");
  else
    printf("Rainy\n");
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
    std::string S, T;
    int ans = 0;

    std::cin >> S >> T;

    for(int i = 0; i < S.size(); i++) {
        if(S.at(i) != T.at(i)) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3904
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>; 

//min <= n < max
bool f(ll n, vl &a){
    ll max_index = a.size();
    ll min_index = 0;
    while(max_index - min_index > 1){
        ll mid_index = (max_index+min_index)/2;
        if(n < a[mid_index]){
            max_index = mid_index;
        }else{
            min_index = mid_index;
        }
    }
    if(a[min_index] == n) return true;
    return false;
}

int main() {
    ll n;
    cin >> n;
    vl S(n);
    rep(i, n){
        cin >> S[i];
    }
    ll q;
    cin >> q;
    ll ans = 0;
    rep(i, q){
        ll t;
        cin >> t;
        if(f(t, S)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3508