akhauriyash/Code-Regression huggingface dataset:
/*input
5
1 2
1 3
3 4
3 5
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 200005;
vector < int > v[N];
vector < int > g[2];
int ans[N];

void dfs(int s, int p, int color)
{
  g[color].push_back(s);
  for(auto x: v[s]){
    if(x == p) continue;
    dfs(x, s, 1 - color);
  }
}

int main()
{
  ifalse;
  int n;
  cin >> n;
  for(int i = 1; i < n; i ++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }

  dfs(1, 0, 0);
  int d = n / 3;
  int two = (n + 1) / 3;
  int one = (n + 2) / 3;

  if(g[0].size() > g[1].size()) {
    swap(g[0], g[1]);
  }

  if(two <= g[0].size()) {
    for(int i = 0; i < two; i ++) {
      ans[g[0][i]] = 2;
    }
    for(int i = 0; i < one; i ++) {
      ans[g[1][i]] = 1;
    }
  } else if(one + two <= g[1].size()) {
    for(int i = 0; i < two; i ++) {
      ans[g[1][i]] = 2;
    }
    for(int i = 0; i < one; i ++) {
      ans[g[1][two + i]] = 1;
    }
  }

  int val[3] = {3, 1, 2};
  for(int i = 1; i <= n; i ++) {
    d = ans[i];
    ans[i] = val[ans[i]];
    val[d] += 3;
  }
  for(int i = 1; i <= n; i ++) {
    cout << ans[i], sp;
  }
  nl;
  return 0;
}

Measured memory_bytes: 21620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		int q = Integer.parseInt(br.readLine());
		int[] b = new int[q];
		int[] c = new int[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			b[i] = Integer.parseInt(sa[0]);
			c[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		long[] cnt = new long[100001];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
			cnt[a[i]]++;
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			long d = (c[i] - b[i]) * cnt[b[i]];
			sum += d;
			pw.println(sum);

			cnt[c[i]] += cnt[b[i]];
			cnt[b[i]] = 0;
		}
		pw.flush();
	}
}


Measured memory_bytes: 58456
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++){
    cin >> a[i];
  }
  vector<int> cnt(26, 0);
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cnt[a[i][j] - 'a']++;
    }
  }
  if (H % 2 == 0 && W % 2 == 0){
    bool ok = true;
    for (int i = 0; i < 26; i++){
      if (cnt[i] % 4 != 0){
        ok = false;
      }
    }
    if (ok){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (H % 2 == 0 || W % 2 == 0){
    bool ok = true;
    int cnt2 = 0;
    for (int i = 0; i < 26; i++){
      if (cnt[i] % 2 != 0){
        ok = false;
      }
      if (cnt[i] % 4 != 0){
        cnt2++;
      }
    }
    if (!ok){
      cout << "No" << endl;
    } else {
      if (H % 2 == 0){
        if (cnt2 <= H / 2){
          cout << "Yes" << endl;
        } else {
          cout << "No" << endl;
        }
      } else {
        if (cnt2 <= W / 2){
          cout << "Yes" << endl;
        } else {
          cout << "No" << endl;
        }
      }
    }
  } else {
    int cnt1 = 0;
    int cnt2 = 0;
    for (int i = 0; i < 26; i++){
      if (cnt[i] % 2 == 1){
        cnt1++;
      }
      if (cnt[i] % 4 >= 2){
        cnt2++;
      }
    }
    if (cnt1 <= 1 && cnt2 <= H / 2 + W / 2){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
  int a[3][3];
  for (auto &i : a) for (int &j : i) cin >> j;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    for (auto &j : a) for (int &k : j) if (k == b) k = 0;
  }
  for (int i = 0; i < 3; ++i) {
    if (!(a[i][0] || a[i][1] || a[i][2])) {
      puts("Yes");
      return 0;
    }
  }
  for (int i = 0; i < 3; ++i) {
    if (!(a[0][i] || a[1][i] || a[2][i])) {
      puts("Yes");
      return 0;
    }
  }
  puts(!(a[0][0] || a[1][1] || a[2][2]) || !(a[0][2] || a[1][1] || a[2][0]) ? "Yes" : "No");
}


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    X = int(input())

    if X % sum(list(map(int, list(str(X))))) == 0:
        print("Yes")
    else:
        print("No")


main()


Measured memory_bytes: 4628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
const string space=" ";
int main()
{

    ll n,t,sum=0,m,c,k;
    bool fg=0,mg=0;
    cin>>n>>m>>c>>k;
    if(k>=n)
        {sum+=n;
        k-=n;}
   else if(k<n)
        {sum+=k;
        k=0;}
        if(k>=m&&k>0)
        {
        k-=m;}
   else if(k<m&&k>0)
        {
        k=0;}
        if(k>=c&&k>0)

        {
            sum-=c;

        k-=c;}
   else if(k<c&&k>0)
        {
            sum-=k;
        k=0;}

    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> p(m);
	vector<string> s(m);
	vector<int> ac(m, 0);
	vector<int> wa(m, 0);
	vector<bool> ac_problem(n, false);
	vector<int> wa_p(n, 0);
	int ac_cnt=0, wa_cnt=0;
	for (int i=0; i<m; i++){
			cin >> p[i];
			cin >> s[i];
	}
	for (int i=0; i<m; i++) {
		if (s[i] == "AC" && ac_problem[p[i]] == false){
			ac_cnt++;
			wa_cnt += wa_p[p[i]];
			ac_problem[p[i]] = true;
		} else if (s[i] == "WA" && ac_problem[p[i]] == false) {
			wa_p[p[i]]++;
		}
	}
	cout << ac_cnt << " " << wa_cnt << endl;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <algorithm>
#include <complex>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <istream>
//-----------------------------------------------------define--------------------------------------------------------------------//
#define PB push_buck
#define MP make_pair
#define MAX 100000000
//-------------------------------------------------------typedef----------------------------------------------------------------//
typedef long long ll;

using namespace std;


//------------------------------------------------------------------------------------------------------------------------------//
int main() {
	int a;
	int b;
	char c;
	cin >> a >> c >> b;
	if (c == '+') {
		cout << a + b << endl;
	}
	else if (c == '-') {
		cout << a - b << endl;
	}
}

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


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                long A = scan.nextLong();
                long V = scan.nextLong();
                long B = scan.nextLong();
                long W = scan.nextLong();
                long T = scan.nextLong();
                
                long start = Math.abs(B-A);
                long maibyou = V-W;
                if(maibyou>0){
                    if( start-(maibyou*T)<=0){
                        System.out.println("YES");
                    }else{
                        System.out.println("NO");
                    }
                }else{
                    System.out.println("NO");
                }

        }
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

void inp()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
} 
ll min(ll a,ll b)
{
    if(a<b)
        return a;
    else
        return b;
}
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    else
        return b;
}
int main() {
    //inp();
    fio;
    ll n,k;
    cin>>n>>k;

    vector<int> nums(n);
    for(int i=0;i<n;i++)
    {
    	cin>>nums[i];
    }

    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
    	for(int j=1;j<=k && i-j>=0;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(nums[i]-nums[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

ll calc(ll a, ll x) {
    return a/x + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = calc(b, x) - calc(a, x);
    if (a%x == 0) ans++;
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    ll n, x;
    cin >> n >> x;
    ll ans = 0;
    vector <int> a(n);

    for (int i = 0; i < n; i++) cin >> a[i];
    
    int tmp;
    for (int i = 1; i <= n-1; i++) {
        if (a[i-1] + a[i] <= x) continue;
        tmp = a[i-1] + a[i] - x;
        ans += tmp;
        a[i] = max(a[i]-tmp, 0);
        //cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#define N 250

typedef struct{
  int key;
  int parent;
  int left;
  int right;
}node;



node Tree[N];
int main(){
  int i,n=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)Tree[i].parent=-1;
  
  for(i=0;i<n;i++){
    scanf("%d",&Tree[i].key);
  }

  for(i=0;i<n;i++){
    
    if(i!=0)Tree[i].parent=(i+1)/2-1;
    
    if(2*(i+1)-1<n)Tree[i].left=2*(i+1)-1;
    else Tree[i].left=-1;
    
    
    if(2*(i+1)<n)Tree[i].right=2*(i+1);
    else Tree[i].right=-1;
  }
  
  for(i=0;i<n;i++){

    printf("node %d: key = %d, ", i+1, Tree[i].key);
    
    if(Tree[i].parent!=-1) printf("parent key = %d, ",Tree[Tree[i].parent].key);
    
    if(Tree[i].left!=-1) printf("left key = %d, ",Tree[Tree[i].left].key);
    
    if(Tree[i].right!=-1) printf("right key = %d, ",Tree[Tree[i].right].key);
    
    printf("\n");
  }
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)   for(ll i=0;i<(b);i++)
#define f1(i,b)   for(ll i=1;i<=(b);i++)
#define f2(i,a,b) for(ll i=(a);i<=(b);i++)
#define f3(i,b,a) for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld\n",a)

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//char ch;
string S, T, U;
ll i, j, k, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    //scan(n);
    cin>>S;
    ll A[26]= {0};

    f0(i,4)
    {
        A[S[i]-'A']++;
    }
    f0(i,26)
    {
        if(A[i]==2)
        {
            cnt++;
        }
    }
    if(cnt==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >>s;
  string a ="Sunny",b="Cloudy",c="Rainy";
  if(s==a){
    cout << b << endl;
  }
  else if (s==c){
	cout << a << endl;
  }
  else{
  	cout << c << endl;
  }
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        
        if (N % 2 == 1) {
            System.out.println("No");
        } else {
            String t1 = S.substring(0, N / 2);
            String t2 = S.substring(N / 2, N);
            
            if (t1.equals(t2)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 21716
x1, y1, r1 = map(int, raw_input().split())
x2, y2, r2 = map(int, raw_input().split())

from math import sqrt

def solve(x1, y1, r1, x2, y2, r2):
    result = []
    xd = x2 - x1; yd = y2 - y1

    rr0 = xd**2 + yd**2
    r0 = sqrt(rr0)
    if (r1 - r2)**2 <= rr0:
        cv = r1 - r2
        if rr0 == (r1 - r2)**2:
            result.append((x1 + r1*cv*xd/rr0, y1 + r1*cv*yd/rr0))
        else:
            sv = sqrt(rr0 - cv**2)
            result.append((x1 + r1*(cv*xd - sv*yd)/rr0, y1 + r1*(sv*xd + cv*yd)/rr0))
            result.append((x1 + r1*(cv*xd + sv*yd)/rr0, y1 + r1*(-sv*xd + cv*yd)/rr0))
    if (r1 + r2)**2 <= rr0:
        cv = r1 + r2
        if rr0 == (r1 + r2)**2:
            result.append((x1 + r1*cv*xd/rr0, y1 + r1*cv*yd/rr0))
        else:
            sv = sqrt(rr0 - cv**2)
            result.append((x1 + r1*(cv*xd - sv*yd)/rr0, y1 + r1*(sv*xd + cv*yd)/rr0))
            result.append((x1 + r1*(cv*xd + sv*yd)/rr0, y1 + r1*(-sv*xd + cv*yd)/rr0))
    return result

result = sorted(solve(x1, y1, r1, x2, y2, r2))
if result:
    print "\n".join("%.08f %.08f" % p for p in result)

Measured memory_bytes: 6548
N, Q = map(int,input().split())
S = input()+"d"
#'AC'が見つかったらCのほうに+1
count = [0]*(N+1)
for i in range(N):
    if S[i] == "A":
        if S[i+1] == "C":
            count[i+1] += count[i] + 1
        else:
            count[i+1] = count[i]
    else:
        count[i+1] = count[i]
    
#print(count)

for _ in range(Q):
    l, r = map(int,input().split())
    print(count[r-1]-count[l-1])

Measured memory_bytes: 11488
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m, b[100008][2], ans[100008];

struct union_find {//1-origin
	vector<int> rnk, par, siz;
	union_find(int n) {
		rnk.resize(n+1);
		par.resize(n+1);
		siz.resize(n+1);
		for(int i = 1; i <= n; i++){
			par[i] = i;
			rnk[i] = 0;
			siz[i] = 1;
		}
	}
	
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
 
	ll unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return 0;
		ll r = siz[x]*siz[y];
		if (rnk[x] < rnk[y]) {
			par[x] = y;
			siz[y] += siz[x];
			return r;
		}
		else {
			par[y] = x;
			siz[x] += siz[y];
			if (rnk[x] == rnk[y])rnk[x]++;
			return r;
		}
	}
	
	bool same(int x, int y) {
		return (find(x) == find(y));
	}
};

int main(){
	cin >> n >> m;
	for(ll i = 1; i <= m; i++){cin >> b[i][0] >> b[i][1];}
	union_find island(n);
	
	ans[m] = n*(n-1)/2;
	for(ll i = m-1; i >= 1; i--){
		ans[i] = ans[i+1]-island.unite(b[i+1][0], b[i+1][1]);
	}
	
	for(ll i = 1; i <= m; i++){cout << ans[i] << endl;}
	return 0;
}

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

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

bool isPalindromicNumber(int x) {
  string s = to_string(x);
  bool flag = true;
  rep(i, s.size() / 2) { flag &= (s[i] == s[s.size() - i - 1]); }
  return flag;
}

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  for (int x = a; x <= b; x++) {
    if (isPalindromicNumber(x)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3776
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	n := nextInt()
	a := make([]int, n)

	fsum := 0
	a[0] = nextInt()
	top := a[0]
	for i := 1; i < n; i++ {
		a[i] = nextInt()

		if a[i] < a[i-1] {
			fsum += top - a[i]
		} else {
			if a[i] < top {
				fsum += top - a[i]
			} else {
				top = a[i]
			}
		}
	}

	fmt.Println(fsum)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

signed main(){
int a[150][2000]{};
a[0][0]=1;
for(int b=0;b<=100;b++){
	for(int c=1000;c>=b;c--){
		for(int d=10;d!=0;d--){
			a[d][c]+=a[d-1][c-b];
		}
	}
}
int x,y;
while(cin>>x>>y,x|y){
	printf("%lld\n",a[x][y]);
}
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == 5 && b == 7 && c == 5){
    cout << "YES" << endl;
  }else if(a == 5 && b == 5 && c == 7){
    cout << "YES" << endl;
  }else if(a == 7 && b == 5 && c == 5){
    cout << "YES" << endl;
  }else cout << "NO" << endl;
}



Measured memory_bytes: 256
N,T = map(int,input().split())
A = list(map(int,input().split()))

cummax = [A[-1]]
for a in reversed(A[:-1]):
    cummax.append(max(cummax[-1], a))
cummax.reverse()

maxgain = n = 0
for buy,sell in zip(A,cummax):
    gain = sell - buy
    if gain > maxgain:
        maxgain = gain
        n = 1
    elif gain == maxgain:
        n += 1
print(n)


Measured memory_bytes: 14680
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(a-b+1)*(a-c+1)<<endl;

  return 0;
}

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

#define M 1128979
#define S 20

char T[M][S];

void insert(long num ,char ch[]){
    int i;
    int h1 = num % M;
    int h2 = 1 + (num % (M-1));
    int h;

    i=0;
    while(i<M){
        h = (h1 + i * h2)%M;
        if(T[h][0]=='\0'){
            strcpy(T[h],ch);
            break;
        }
        i++;
    }
}

int find(long num,char ch[]){
    int i,f=0;
    int h1 = num % M;
    int h2 = 1 + num%(M-1);
    int h;

    i=0;
    while(i < M){
        h = (h1 + i * h2) % M;
        if(strcmp(T[h],ch) == 0) return 1;
        else if(strlen(T[h]) == 0) return 0;
        i++;
    }
    return 0;
}

int main(){
    int n,j,i;
    long num,p;
    char ch[12];
    char com[7];

    for(i=0; i<M; i++){
        for(j=0; j<S; j++){
            T[i][j]='\0';
        }
    }

    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%s",com);
        scanf("%s",ch);
        num = 0;
        p=1;
        for(j=0; j<strlen(ch); j++){
            if(ch[j] == 'A'){
                num += 1*p;
            }else if(ch[j] == 'C'){
                num += 2*p;
            }else if(ch[j] == 'G'){
                num += 3*p;
            }else if(ch[j] == 'T'){
                num += 4*p;
            }
            p *= 3;
        }

        if(!strcmp("insert",com)){
            insert(num,ch);
        }else if(!strcmp("find",com)){
            if(find(num,ch)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}




Measured memory_bytes: 23848
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, n;
  cin >> n;
  int cnt[100001];
  REP(i,100002)cnt[i]=0;
  REP(i,n){
      cin >> a;
      cnt[a]++;
  }
  int mx = 0;
  FOR(i,1,100001){
      mx = max(mx,cnt[i-1]+cnt[i]+cnt[i+1]);
  }
  cout << mx << endl;

}


Measured memory_bytes: 640
import scala.collection.mutable

object Main extends App {
  val  cache = mutable.HashMap.empty[Long, Long]
  def count(hp: Long): Long = if (hp <= 1) 1 else cache.getOrElseUpdate(hp, 1 + 2 * count(hp/2))
  val h = io.StdIn.readLong()
  println(count(h))
}


Measured memory_bytes: 27200
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))
ruiA=[]
ruiB=[]


#lst=set(P[1:])
count=1
for i in range(0,N)[::-1]:
    B[P[i]]-=count
    """for m in lst:
        B[m]-=1
    lst.add(P[i])"""
    count+=1

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))


Measured memory_bytes: 45080
a,b,c=map(int, input().split())
k=int(input())
mink=0
while a>=b:
    b*=2
    mink+=1
while b>=c:
    c*=2
    mink+=1
if mink<=k:
    print("Yes")
else:
    print("No")
#print(mink,a,b,c)

Measured memory_bytes: 9148
#include<stdio.h>
int main()
{
	long a,b,c,d,sum;
	scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
  if(a>=d){
    sum=d;
  }
  else if(a+b>=d){
    sum=a;
  }
  else{
    sum=a-(d-a-b);
  }
  printf("%ld",sum);
	return 0;
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s/100;
  s2 = (s - s1*100)/10;
  s3 = s - s1*100 - s2*10;
  cout << s1 + s2 + s3  << endl;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
    l[i+1]=l[i] 
  i=i+1
r=i
for b in range(r,n):
    d=d+(u-l[b])
print(d)


Measured memory_bytes: 32180
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};
// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

int lcs(const string& S, int i, int j, vector<vector<int>>& L) {
  if(i >= S.size() || j >= S.size()) return 0;
  if(L[i][j] >= 0) return L[i][j];
  int l;
  if(S[i] == S[j]) l = min(1 + lcs(S, i+1, j + 1, L), j - i);
  else l = 0;
  return L[i][j] = l;
}

void solve() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  vector<vector<int>> L(N, vector<int>(N, -1));
  rep(i, N) {
    rep2(j, i+1, N) {
      ans = max(ans, lcs(S, i, j, L));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 98432
# -*- coding: utf-8 -*-
H, W = [int(n) for n in input().split()]
N = int(input())
A = [int(n) for n in input().split()]

list_ = []
for i, num in enumerate(A):
    list_.extend([i+1]*num)

result = ""
for h in range(H):
    tmp = [str(n) for n in list_[h*W:(h+1)*W]]
    if h%2==0:
        result += " ".join(tmp) + "\n"
    else:
        result += " ".join(tmp[::-1]) + "\n"
print(result[:-1])

Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


class Tree:
    def __init__(self, crdinal, adjgrph, root):
        self.n = crdinal
        self.g = adjgrph
        self.root = root
        self.parent = [-1]*self.n
        self.depth = [-1]*self.n
        self.subsize = [1]*self.n
        self.result = [1]*self.n  # 0 : additive, 1 : multiplicative

        s = [self.root]
        while s:
            v = s.pop()
            if self.depth[v] == -1:
                if v == self.root:
                    self.depth[v] = 0
                else:
                    self.depth[v] = self.depth[self.parent[v]] + 1
                    s.append(v)
                for w in self.g[v]:
                    if self.depth[w] == -1:
                        self.parent[w] = v
                        s.append(w)
            else:
                self.subsize[self.parent[v]] += self.subsize[v]
                self.calc(v)

    def calc(self, v):
        # The following formula is calculated by bottom-up:
        self.result[self.parent[v]] *= self.result[v]+1
        self.result[self.parent[v]] %= m
        return None

    def wanted(self):
        # Edit the result you want using self.depth, self.subsize, etc..
        # Default : self.parent
        return self.parent

    def rerooting(self) -> list:
        cum1 = [[1] for i in range(n)]  # 0 : additive, 1 : multiplicative
        cum2 = [[1] for i in range(n)]  # 0 : additive, 1 : multiplicative
        FromParent = [0]*n

        ans = [0]*n
        ans[0] = self.result[0]

        s = [self.root]
        while s:
            v = s.pop()
            if v != self.root:
                ans[v] = (FromParent[v]+1)*self.result[v]
                ans[v] %= m

            for w in self.g[v]:
                if w != self.parent[v]:
                    cum1[v].append(cum1[v][-1]*(self.result[w]+1) % m)
                    s.append(w)
                else:
                    cum1[v].append(cum1[v][-1]*(FromParent[v]+1) % m)
            for w in self.g[v][::-1]:
                if w != self.parent[v]:
                    cum2[v].append(cum2[v][-1]*(self.result[w]+1) % m)
                else:
                    cum2[v].append(cum2[v][-1]*(FromParent[v]+1) % m)
            cum2[v] = cum2[v][::-1]

            for i, w in enumerate(self.g[v]):
                FromParent[w] = cum1[v][i]*cum2[v][i+1] % m
        return ans


n, m = map(int, input().split())
g = [[] for _ in range(n)]

for _ in range(n-1):
    x, y = map(int, input().split())
    g[x-1].append(y-1)
    g[y-1].append(x-1)


T1 = Tree(n, g, 0)

ans = T1.rerooting()


for x in T1.rerooting():
    print(x)


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

int main(){
  int a, p;
  cin >> a >> p;
  int hahen = 3*a + p;
  cout << hahen/2 << endl;
}


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


int main() {
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    vector<ll> b(n+1);
    b[0]=0;
    for (int i=0;i<n;i++) {
        b[i+1]=a[i]+b[i];
    }
    vector<ll> c(n);
    ll lx=0,rx=1e6;
    while (rx-lx>1) {
        ll mx=lx+(rx-lx)/2;
        ll sumc=0;
        for (int i=0;i<n;i++) {
            c[i]=n-(lower_bound(a.begin(),a.end(),mx-a[i])-a.begin());
            sumc+=c[i];
        }
        if (sumc>=m) lx=mx;
        else rx=mx;
    }
    ll sumc=0;
    for (int i=0;i<n;i++) {
        c[i]=n-(lower_bound(a.begin(),a.end(),lx-a[i])-a.begin());
        sumc+=c[i];
    }
    ll ans=lx*(m-sumc);
    for (int i=0;i<n;i++) ans+=c[i]*a[i]+(b[n]-b[n-c[i]]);
    cout << ans << endl;
}

Measured memory_bytes: 2560
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto a = readints;
    int x1 = a[0], y1 = a[1], x2 = a[2], y2 = a[3];

    int x = x2;
    int y = y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    for (int i = 0; i < 2; i++) {
        swap(dx, dy);
        dx *= -1;
        x += dx;
        y += dy;
        write(x, " ", y, " ");
    }
    writeln();
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
a=list(map(int,input().split()))
tans=0
for s in range(n):
    b=list(map(int,input().split()))
    ans=0
    for t in range(m):
        ans+=a[t]*b[t]
    if ans+c>0:
        tans+=1
print(tans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main()
{
    int a,s,b,c=1;
    scanf("%d %d",&a,&b);
    s=b;
while(b)
    {
        b=b/10;
        c=c*10;
    }
    a=a*c;
    a=a+s;
    b=(int)sqrt(a)*(int)sqrt(a);
    if(b==a)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    int x1, y1, x2, y2, x3, y3, x4, y4;

    cin >> x1 >> y1 >> x2 >> y2;

    int dx, dy;
    dy = y2 - y1;
    dx = x2 - x1;

    x3 = x2 - dy;
    y3 = y2 + dx;

    x4 = x3 - dx;
    y4 = y3 - dy;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}



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

int main() {
	int i, j;
	int n, m;
	int M, N, K;
	bool flag = false;
	cin >> N >> M >> K;
	for (n = 0; n <= M; n++)
		for (m = 0; m <= N; m++)
			if (n*N + m*M - 2*n*m == K)
				flag = true;
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	
	ll N, M, A, B;
	string S;

	
	ll H;
	cin >> H >> A;

	cout << (H / A) + bool(H%A != 0);




}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t dp[3000][3000];

int main(){
    int N, Q, A[3000];
    cin >> N >> Q;
    for(int i=0; i<N; i++) cin >> A[i];

    for(int i=0; i<N; i++) for(int j=0; j<N; j++) if(A[i] > A[j]) dp[i][j] = 1;
    int64_t inv2 = power_mod(2, MOD-2);

    for(int q=0; q<Q; q++){
        int x, y;
        cin >> x >> y;
        x--; y--;

        for(int i=0; i<N; i++) if(i!=x && i!=y){
            dp[x][i] = dp[y][i] = (dp[x][i] + dp[y][i]) * inv2 % MOD;
            dp[i][x] = dp[i][y] = (dp[i][x] + dp[i][y]) * inv2 % MOD;
        }
        dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) * inv2 % MOD;
    }

    int64_t ans = 0;
    for(int i=0; i<N; i++) for(int j=i+1; j<N; j++) add(ans, dp[i][j]);
    ans = ans * power_mod(2, Q) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70528
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self,n):
        fact=[1]*(n+1); invfact=[1]*(n+1)
        for i in range(1,n+1): fact[i]=i*fact[i-1]%MOD
        invfact[n]=pow(fact[n],MOD-2,MOD)
        for i in range(n-1,-1,-1): invfact[i]=invfact[i+1]*(i+1)%MOD
        self.__fact=fact; self.__invfact=invfact

    def inv(self,n):
        assert(n>0)
        return self.__fact[n-1]*self.__invfact[n]%MOD

    def fact(self,n):
        return self.__fact[n]

    def invfact(self,n):
        return self.__invfact[n]

    def comb(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[k]*self.__invfact[n-k]%MOD

    def perm(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[n-k]%MOD

def resolve():
    x,y=map(int,input().split())
    if((x+y)%3):
        print(0)
        return

    mf=modfact(x+y)
    z=(x+y)//3
    print(mf.comb(z,x-z))
resolve()

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    rep(ti,t){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(d < b){
            cout << "No" << endl;
            continue;
        }
        if(a < b){
            cout << "No" << endl;
            continue;
        }
        ++c;
        if(c >= b){
            cout << "Yes" << endl;
            continue;
        }
        a %= b;
        d %= b;
        ll g = gcd(d, b);
        a += (b - a - 1) / g * g;
        if(a < b && c <= a) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3488
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 2010
#define MOD 998244353
using namespace std;
typedef long long ll;
ll C[2*MAXN][2*MAXN],bits[2*MAXN];
int n,k;
ll count(int s,int tot){
    return C[s+tot-1][s-1]; 
}
ll solve(int i,int tot){
    int k2=min(k-i/2,(i-1)/2);
    int k1=k-k2*2-((i%2)==0);
    ll flag=1;
    ll res=0;
    for(int l=k2;l>=0;l--)
	{
        res+=count(l+k1,tot-l)*bits[l]%MOD*C[k2][l]%MOD;
        res%=MOD;
    }
    return (res+MOD)%MOD;
}
int main()
{
    SF("%d%d",&k,&n);
    int sum=0;
    bits[0]=1;
    for(int i=1;i<=4000;i++)
        bits[i]=bits[i-1]*2ll%MOD;
    C[0][0]=1;
    for(int i=1;i<=4000;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
    }
    ll ans=0;
    for(int i=2;i<=2*k;i++){
        if(i%2==0){
            ans=(solve(i,n)+solve(i,n-1))%MOD;
        }
        else{
            ans=solve(i,n);
        }
        PF("%lld\n",ans);
    }
}

Measured memory_bytes: 124288
package main

import (
  "fmt"
  "sort"
)

func min(a, b int) int {
  if a < b {
    return a
  }
  return b
}

func main() {
  var n, k int
  fmt.Scan(&n, &k)
  
  nums := make([]int, n)
  for i:=0; i<n; i++ {
    fmt.Scan(&nums[i])
  }
  
  sort.Sort(sort.IntSlice(nums))
  
  m := 1000000000
  for i:=0; i<n-k+1; i++ {
    var p int
    p = nums[i+k-1] - nums[i]
    m = min(m, p)
  }
  
  fmt.Println(m)
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// 参考 https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename T>
struct SegTree {
    using F = function<T(T,T)>;
    
    int size;
    vector<T> dat;

    const F f;
    const T INIT;
    
    SegTree(int n, const F func, const T &init) : f(func), INIT(init) {
        size = 1;
        while(size < n) size <<= 1;
        dat.assign(2*size, INIT);
    }

    void update(int k, const T &x) {
        k += size;
        dat[k] = x;
        while(k >>= 1) {
            dat[k] = f(dat[2*k],dat[2*k+1]);
        }
    }

    T query(int a,int b) {
        T l = INIT, r = INIT;
        for(a += size, b += size+1; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l,dat[a++]);
            if (b & 1) r = f(r,dat[--b]);
        }
        return f(l,r);
    }

    // 未使用機能
    private:
    void set(int k, const T &x) {
        dat[k+size] = x;
    }

    void build() {
        for(int k = size - 1; k > 0; k--) {
            dat[k] = f(dat[2*k],dat[2*k+1]);
        }
    }

    T operator[](const int &k) const {
        return dat[k+size];
    }

};


int main(void)
{
    IOS
    constexpr int C = 26;
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    using bs = bitset<C>;
    auto al = [](char c) {return c - 'a';};

    SegTree<bs> seg(N,[](bs a,bs b){return a | b;}, bs());

    REP(i,S.size()) {
        seg.update(i,bs(1 << al(S[i])));
    }

    REP(i,Q) {
        int q; cin >> q;
        if (q == 1) {
            int i; char c;
            cin >> i >> c;
            i--;
            seg.update(i,bs(1 << al(c)));
        } else {
            int l,r;
            cin >> l >> r;
            l--; r--;
            OUT(seg.query(l,r).count());
        }
    }

    return 0;
}

Measured memory_bytes: 9116
// https://atcoder.jp/contests/abc147/tasks/abc147_f
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n,m;
    std::cin >> n>>m;
    vector<ll> a(n);
    vector<ll> csum(n+1,0);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    sort(a.begin(),a.end());
    for (int i = 0; i < n; i++) {
        csum[i+1] = csum[i]+a[i];
    }
    
    ll r = 1e18; //ng
    ll l = 0; //ok
    
    ll res = 0;
    
    map<ll,pair<ll,ll>> nokori;

    while(r-l>1){
        ll tmp= 0;
        ll mid = (r+l)/2;
        ll rem = m;

        for (ll i = 0; i < n; i++) {
            ll index = distance(a.begin(),lower_bound(a.begin(),a.end(),mid-a[i]));
            
            if((n-index)<=rem){
                tmp += (csum[n]-csum[index])+a[i]*(n-index);
                rem -= (n-index);
            }else{
                tmp += (csum[index+rem]-csum[index])+a[i]*rem;
                rem=0;
                break;
            }
        }
        
        res = max(res,tmp);
        if(rem>0){
            r =mid;
        }else{
            l = mid;
        }
        nokori[mid] = {tmp,rem};
    }
    
    if(nokori[l+1].second>0){
        std::cout << nokori[l+1].first+nokori[l+1].second*l << std::endl;
    }else{
        std::cout << res << std::endl;
    }
    
    
}


Measured memory_bytes: 1920
import java.util.*; 
public class Main{
public static void main(String ... string){
Scanner sc = new Scanner(System.in); 
  int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt(); 
  if( a==b && b!=c) System.out.println("Yes"); 
 else if( a ==c && b != c ) System.out.println("Yes"); 
  else if( b == c && b!=a ) System.out.println("Yes"); 
  else System.out.println("No"); 
}
}


Measured memory_bytes: 21972
H,W = (int(i) for i in input().split())

a = [0 for i in range(H)]

for i in range(H):
    a[i] = list(input())

count = 0
check = []
n = 0
for i in range(H):
    for j in range(W):
        if a[i-n][j] == '#':
            count = 1
            break
    if count == 0:
        del a[i-n]
        n += 1
    count = 0

ck = []
n = 0
for i in range(W):
    for j in range(len(a)):
        if a[j][i] == '#':
            count = 1
            break
    if count == 0:
        ck.append(i)
    count = 0

for i in ck:
    for j in range(len(a)):
        del a[j][i-n]
    n += 1

ans = ''
for i in range(len(a)):
    for j in a[i]:
        ans += j
    print(ans)
    ans = ''

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;

 
ll binom(int n,int r){
  int s=1;
  for(int i=0; i<r; i++){
    (s*=n-i)/=(i+1);
  }
  return s;
}
 
int main(){
  int n; cin >>n;
  vector<pair<int,int>> vec(n);
  for(int i=0; i<n; i++){
    int a,b; cin >>a >>b;
    vec[i]={a,b};
  }
  double sum=0.0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      sum+=hypot(vec[i].first-vec[j].first,vec[i].second-vec[j].second);
    }
  }
  sum*=n-1;
  sum/=binom(n,2);
  printf("%.10lf\n",sum);
}

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

int main() {
	int n, a, b, sum, tmp, ans = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		sum = 0;
		tmp = i;
		while (tmp > 0)sum += tmp % 10, tmp /= 10;
		if (a <= sum && sum <= b)ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define eb emplace_back
#define ep emplace
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

main(){
    string s,t;
    cin>>s>>t;
    cout<<t+s;
}

Measured memory_bytes: 256