akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void solve(vector<int>& v, int i)
{
    vector<int> x(2);
    x[0] = 0;
    x[1] = 1 << i;

    int n = v.size();
    vector<int> ans(2*n);
    for(int i=0; i<2*n; ++i){
        ans[i] = v[i/2];
        ans[i] |= x[(i+1)/2%2];
    }
    v = move(ans);
}

void solve(vector<int>& v, int i, int j)
{
    vector<int> x(4);
    x[0] = 0;
    x[1] = 1 << i;
    x[2] = (1 << i) ^ (1 << j);
    x[3] = 1 << j;

    int n = v.size();
    vector<int> ans(4*n);
    for(int i=0; i<4*n; ++i){
        ans[i] = v[i/4];
        if(i / 4 % 2 == 0)
            ans[i] |= x[i%4];
        else
            ans[i] |= x[3-i%4];
    }
    swap(ans[4*n-1], ans[4*n-3]);
    v = move(ans);
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    b ^= a;
    if(bitset<32>(b).count() % 2 == 0){
        cout << "NO" << endl;
        return 0;
    }

    vector<int> diff, same;
    for(int i=0; i<n; ++i){
        if(b & (1 << i))
            diff.push_back(i);
        else
            same.push_back(i);
    }

    vector<int> ans(1, 0);
    solve(ans, diff[0]);
    for(unsigned i=1; i<diff.size(); i+=2)
        solve(ans, diff[i], diff[i+1]);
    for(unsigned i=0; i<same.size(); ++i)
        solve(ans, same[i]);

    for(int i=0; i<(1<<n); ++i)
        ans[i] ^= a;

    cout << "YES" << endl << ans[0];
    for(int i=1; i<(1<<n); ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 1656
# 引数nが持つ正の約数の数を調べる
def divisor_count(n:int) -> int:
  count = 0
  for x in range(1, n+1):
    if n % x == 0:
      count += 1
  
  return count

def solve(n: int) -> int:
  # [1..N]内で奇数かつ約数をちょうど8個持つ数字の数
  result = 0
  for x in range(1, n+1):
    if x&1 and divisor_count(x) == 8:
      result += 1
  return result
  
N = int(input())
print(solve(N))

Measured memory_bytes: 9120
// c lib
#include <cstdio>
#include <cstdlib>
#include <cmath>

// container
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <array>

// Convenience
#include <algorithm>
#include <functional>

// IO
#include <iostream>

using namespace std;

using llong = long long;
struct Node {
    llong p, l, r;
};

void print_tree_rec(Node* tree, llong idx)
{
    if (tree[idx].l != 0ll) print_tree_rec(tree, tree[idx].l);
    if (tree[idx].r != 0ll) print_tree_rec(tree, tree[idx].r);
    cout << idx << " ";
}

void print_tree_pos(Node* tree)
{
    auto idx = tree->l;
    if (tree[idx].l != 0ll) print_tree_rec(tree, tree[idx].l);
    if (tree[idx].r != 0ll) print_tree_rec(tree, tree[idx].r);
    cout << idx << endl;
}

int main()
{
    auto n = 0ll;
    cin >> n;

    auto pre = new llong[n];
    for (auto i = 0ll; i < n; i++)
    {
        cin >> pre[i];
    }

    auto in = new llong[n];
    for (auto i = 0ll; i < n; i++)
    {
        cin >> in[i];
    }

    auto tree = new Node[n + 1];
    for (auto i = 0ll; i < n + 1ll; i++)
    {
        tree[i].p = 0ll;
        tree[i].l = 0ll;
        tree[i].r = 0ll;
    }

    auto pre_visit_idx = 0ll;
    auto pre_pre_index = -1ll;
    for (auto i = 0ll; i < n; i++)
    {
        auto pre_idx = 0ll;
        for (; pre[pre_idx] != in[i]; pre_idx++) {}
        auto pre_visit_idx_fst = pre_visit_idx;
        for (auto j = pre_visit_idx; j <= pre_idx; j++, pre_visit_idx++)
        {
            if (j != pre_visit_idx_fst) 
            {
                tree[pre[j]].p = pre[j - 1];
                tree[pre[j - 1]].l = pre[j];
            }
            else if (j != 0ll)
            {
                tree[pre[j]].p = pre[pre_pre_index];
                tree[pre[pre_pre_index]].r = pre[j];
            }
            else
            {
                tree[0].l = pre[j];
            }
        }
        pre_pre_index = pre_idx;
    }

    print_tree_pos(tree);
}


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

using namespace std;

int main()
{
    double  n, p, q, c=0, y;
    double x, d, z;
    cin>>n>>d;
    while(n--)
    {
        cin>>p>>q;
        y=(p*p+q*q);
        z=y;
        x=sqrt(z);
        if(x<=d) c++;
        //cout<<y<<endl;
        //printf("%.4lf",x);
    }
    cout<<c<<endl;
    return 0;

}


Measured memory_bytes: 3864
// 問題URL
// https://atcoder.jp/contests/abc130/tasks/abc130_a

import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        Integer a = Integer.parseInt(scanner.next());

        if (x < a) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }

    }
}

Measured memory_bytes: 21332
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    int n;
    cin>>s;
    n=s.size()-2;
    cout<<s[0]<<n<<s[n+1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	double n; cin >> n;
	if((int)n % 2) cout << (n + 1) / (2 * n) << endl;
	else cout << 0.5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll red=0;
	for(char c: s){
		
		if(c=='R') red++;
	}
	ll white=n-red,op=0;
	for(ll i=0;i<red;i++){
		if(s[i]!='R')	op++;
	}
	cout<<op<<endl;
	return 0;
}

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

int main() {
  double a, b, c, d, e, f;

  while(cin >> a >> b >> c >> d >> e >> f) {
    double x, y;
    double tmp_b = b, tmp_c = c;
    b *= d;
    c *= d;
    e *= a;
    f *= a;

    b -= e;
    c -= f;
    y = c / b;
    x = (tmp_c - tmp_b * y) / a;

    cout << fixed << setprecision(3) << x << ' '  << y << endl;
  }
  return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    int n, d, ans = 0, k = 0;
    cin >> n >> d;
    int x[n][d];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            for(int l = 0; l < d; l++)
            {
                k=k+abs(x[i][l]-x[j][l])*abs(x[i][l]-x[j][l]);
			}
			if(sqrt(k)-int(sqrt(k))==0){
				ans++;
			}
			k=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
H,W=map(int,input().split())

board=[]
for i in range(H):
  board_=list(input())
  board.append(board_)

for i in range(H):
  if all([board[i][j]  == '*' or board[i][j]  == '.' for j in range(W)]):
    board[i]=['*']*W

for j in range(W):
  if all([board[i][j] =='*' or board[i][j] =='.' for i in range(H) ]):
    for k in range(H):
      board[k][j]='*'

Board=[[] for i in range(H)]
for i in range(H):
  for j in range(W):
    if board[i][j]!='*':
      Board[i].append(board[i][j])

for i in range(H):
  if Board[i]!=[]:
    print(''.join(Board[i]))
    
  else:
    continue

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    Vl h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    ll mn = L_INF;

    for (int i = 0; i < N - K + 1; i++) {
        mn = min(mn, h[i + K - 1] - h[i]);
    }

    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    
    string s,t,u;
    int a,b;
    
    cin>>s>>t>>a>>b>>u;
    
    if(s==u){
        if(a>0){
            --a;
        }
    }else if(t==u){
        if(b>0){
            --b;
        }
    }
    
    cout<<a<<" "<<b;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int n,nC;
vi adj[200001];
map<pii,int> mp;

void dfs(int cur,int par,int last){
    
    int k=1,left;
    for(int ch:adj[cur]){
        if(ch==par)continue;
        if(k==last)left=k,k++;
        if(k>nC)k=left;
        mp[{ch,cur}]=k;
        mp[{cur,ch}]=k;
        dfs(ch,cur,k);
        k++;
    }
}

signed main(){
    FASTER;
    cin>>n;
    vii v;
    for(int i=1;i<n;i++){
        int a,b;cin>>a>>b;
        v.push_back({a,b});
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int st=-1;
    for(int i=1;i<=n;i++){
        if(nC<adj[i].size()){
            nC=adj[i].size();
            st=i;
        }
    }
    dfs(st,-1,-1);
    cout<<nC<<"\n";
    for(pii i:v){
        cout<<mp[{i.first,i.second}]<<"\n";
    }
}


Measured memory_bytes: 26892
S = input().strip()

answer = 0

for n in range(2**(len(S)-1)):
    A = [0]
    for d in range(9):
        if n & (1 << d):
            A.append(d+1)
    T = []
    #print("A", A)
    for l, r in zip(A, A[1:]):
        T.append(int("".join(S[l:r])))
    T.append(int("".join(S[A[-1]:])))
    answer += sum(T)

print(answer)


Measured memory_bytes: 3064
int main(void)
{
    char st[1200];
    int c = 0,i;
     
    while(1){
        scanf("%c",&st[c]);
        if(st[c] == '\n')break;
        if((int)st[c] >= 97&&(int)st[c] <= 122)st[c] = (int)st[c] - 32;
        else
        if((int)st[c] >= 65&&(int)st[c] <= 90)st[c] = (int)st[c] + 32;
        c++;
    }
     
    for(i = 0;i < c;i++){
        printf("%c",st[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int a,b,n,i;
    cin>>n;
    for(i=1;i<10;i++)
    {
        if(n%i==0 && (n/i)<10)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


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

int main() {
	int a;
	int n;
	while(true){
		int sum=0;
		int minimum=1000,maximum=0;
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin >> a;
			sum+=a;
			maximum=max(maximum,a);
			minimum=min(minimum,a);
		}
		cout << (sum-maximum-minimum)/(n-2) << endl;
	}	
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

class Main {
public static Integer judge(String w, int wlen ,String target){

String wafter = w.replace(target,"");
int wlenafter = wafter.length();
if((wlen - wlenafter) % 2 == 0){
return 0;
}else{
return 1;
}

}


public static void main(String[] args){

int ugly = 0;
Scanner sc = new Scanner(System.in);
String w = sc.next();
int wlen = w.length();
ugly += judge(w, wlen, "a"); ugly += judge(w, wlen, "b"); ugly += judge(w, wlen, "c"); ugly += judge(w, wlen, "d");
ugly += judge(w, wlen, "e"); ugly += judge(w, wlen, "f"); ugly += judge(w, wlen, "g"); ugly += judge(w, wlen, "h");
ugly += judge(w, wlen, "i"); ugly += judge(w, wlen, "j"); ugly += judge(w, wlen, "k"); ugly += judge(w, wlen, "l");
ugly += judge(w, wlen, "m"); ugly += judge(w, wlen, "n"); ugly += judge(w, wlen, "o"); ugly += judge(w, wlen, "p");
ugly += judge(w, wlen, "q"); ugly += judge(w, wlen, "r"); ugly += judge(w, wlen, "s"); ugly += judge(w, wlen, "t");
ugly += judge(w, wlen, "u"); ugly += judge(w, wlen, "v"); ugly += judge(w, wlen, "w"); ugly += judge(w, wlen, "x");
ugly += judge(w, wlen, "y"); ugly += judge(w, wlen, "z");
if(ugly == 0){
System.out.println("Yes");
}else{
System.out.println("No");
}

}
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;

int main()
{
    FLASH
    int l,r,d;
    cin >> l >> r >> d;
    int cnt = 0;
    for(int i = l; i <= r; i++){
    	if(i % d == 0)
    		cnt++;
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
int main()
{
	ll mx, my;
	int num;
	scanf("%lld%lld%d", &mx, &my, &num);
	map<pii, int>ma;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		for (int i = -2; i <= 0; i++)
		{
			for (int j = -2; j <= 0; j++)
			{
				if (za + i > 0 && zb + j > 0 && za + i <= mx - 2 && zb + j <= my - 2)
				{
					ma[make_pair(za + i, zb + j)]++;
				}
			}
		}
	}
	ll ans[10];
	fill(ans, ans + 10, 0);
	ans[0] = (mx - 2)*(my - 2);
	map<pii, int>::iterator it = ma.begin();
	for (;;)
	{
		if (it == ma.end())break;
		ans[(*it).second]++;
		it++;
		ans[0]--;
	}
	for (int i = 0; i < 10; i++)printf("%lld\n", ans[i]);
}

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

int main() {
  int A,B,C,D;
  cin >> A>>B>>C>>D;
  
  if (A+B>C+D) {
    cout << "Left" << endl;
  }
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  if (A+B < C+D) {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#以下、入力編
n,m,l=map(int,input().split())
A = [[0] for j in range(n)]
B = [[0] for j in range(m)]
for i in range(n):
	a = list(map(int,input().split()))
	A[i] = a
for i in range(m):
	b = list(map(int,input().split()))
	B[i] = b
C = [[0 for i in range(l)] for j in range(n)]
#以上、入力編

#以下、計算編
for i in range(n):
	for j in range(l):
		for k in range(m):
			C[i][j]+=A[i][k]*B[k][j]
#以上、計算編
#以下、出力編
for c in C:
	print(*c)


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

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


void solve() {
    int p,q,r;
    cin >> p >> q >> r;

    int ans = p + q;
    ans = min(ans, q + r);
    ans = min(ans, r + p);

    cout << ans << "\n";
}


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

    solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = []
for i in range(N):
    si = input()
    s.append(si)
M = int(input())
t = []
for i in range(M):
    ti = input()
    t.append(ti)

dicts = {}
for i in range(N):
    if(s[i] in dicts):
        dicts[s[i]] += 1
    else:
        dicts[s[i]] = 1
dictt = {}
for i in range(M):
    if(t[i] in dictt):
        dictt[t[i]] += 1
    else:
        dictt[t[i]] = 1

ans = 0
for i in range(N):
    if(s[i] in dictt):
        ans = max(dicts[s[i]] - dictt[s[i]], ans)
    else:
        ans = max(dicts[s[i]], ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int n,r;
int x[100005];
int dp[1<<16];

int f(int m){
	int& r=dp[m];
	if(r>=0)return r;
	r=1<<30;
	fore(i,1,16)if(m&(1<<i))fore(j,1,16)if(j!=i&&(m&(1<<j))){
		int k=i^j;
		int nm=m^(1<<i)^(1<<j);
		int a=1;
		if(k){
			if(nm&(1<<k))a++;
			nm^=1<<k;
		}
		r=min(r,a+f(nm));
	}
	return r;
}

int main(){
	scanf("%d",&n);
	fore(_,1,n){
		int i,j,a;
		scanf("%d%d%d",&i,&j,&a);
		x[i]^=a;x[j]^=a;
	}
	int m=0;
	fore(i,0,n){
		if(!x[i])continue;
		if(m&(1<<x[i]))r++;
		m^=1<<x[i];
	}
	memset(dp,-1,sizeof(dp));dp[0]=0;
	printf("%d\n",r+f(m));
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 100000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

char s[50][50];
int h, w;

int main()
{
    int n, m, k, i, j;
    cin >> n >>k;

    ll ans = 0;
    rep(i,n) {
        if (i == 0)
            ans = (ll)k;
        else
            ans *= (ll)(k-1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#   AtCoder abc064 a
#   ストレッチ課題

#   入力
r, g, b = map(int, input().split())

#   処理
answer = r * 100 + g *10 + b

#   判定
if (answer % 4) == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 8856
# coding: utf-8

# https://atcoder.jp/contests/abc083/tasks/arc088_a
# 17:19-


def main():
    X, Y = map(int, input().split())

    ans = 0
    x = X
    while True:
        if x > Y:
            return ans

        ans += 1
        x *= 2


print(main())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << s[k - 1] << '\n';
  
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,a[106],b[106],ans=0,cnt;
char s[106];
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		cnt=0;
		for(int j=0;j<=i;j++)
			a[s[j]-'a']=1;
		for(int j=i+1;j<n;j++)
			b[s[j]-'a']=1;
		for(int j=0;j<26;j++)
			if(a[j]==b[j] && a[j]==1) cnt++;
		ans=max(ans,cnt);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define fread_siz 1024

inline int get_c(void)
{
	static char buf[fread_siz];
	static char *head = buf + fread_siz;
	static char *tail = buf + fread_siz;

	if (head == tail)
		fread(head = buf, 1, fread_siz, stdin);

	return *head++;
}

inline int get_i(void)
{
	register int ret = 0;
	register int neg = false;
	register int bit = get_c();

	for (; bit < 48; bit = get_c())
		if (bit == '-')neg ^= true;

	for (; bit > 47; bit = get_c())
		ret = ret * 10 + bit - 48;

	return neg ? -ret : ret;
}

template <class T>
inline T min(T a, T b)
{
	return a < b ? a : b;
}

const int inf = 2e9;
const int maxn = 2005;

int n, m;
int s, t;
int flow;

int edges;
int hd[maxn];
int nt[maxn];
int to[maxn];
int vl[maxn];
int fl[maxn];

inline void add(int u, int v, int f, int w)
{
	nt[edges] = hd[u]; to[edges] = v; fl[edges] = f; vl[edges] = +w; hd[u] = edges++;
	nt[edges] = hd[v]; to[edges] = u; fl[edges] = 0; vl[edges] = -w; hd[v] = edges++;
}

int dis[maxn];
int pre[maxn];

inline bool spfa(void)
{
	static int que[maxn];
	static int inq[maxn];
	static int head, tail;
	
	memset(dis, 0x3f, sizeof(dis));
	head = 0, tail = 0;
	que[tail++] = s;
	pre[s] = -1;
	inq[s] = 1;
	dis[s] = 0;
	
	while (head != tail)
	{
		int u = que[head++], v; inq[u] = 0;
		
		for (int i = hd[u]; ~i; i = nt[i])
			if (dis[v = to[i]] > dis[u] + vl[i] && fl[i])
			{
				dis[v] = dis[u] + vl[i];
				pre[v] = i ^ 1;
				if (!inq[v])
					inq[v] = 1, que[tail++] = v;
			}
	}
	
	return dis[t] < 0x3f3f3f3f;
}

inline int expend(void)
{
	int newFlow = inf;
	
	for (int i = pre[t]; ~i; i = pre[to[i]])
		newFlow = min(newFlow, fl[i ^ 1]);
		
	for (int i = pre[t]; ~i; i = pre[to[i]])
		fl[i] += newFlow, fl[i^1] -= newFlow;
		
	return flow -= newFlow, newFlow * dis[t];
}

inline int mcmf(void)
{
	int ret = 0;
	
	while (spfa())
		ret += expend();
		
	return flow ? -1 : ret;
}

signed main(void)
{
	n = get_i();
	m = get_i();
	
	flow = get_i();
	
	memset(hd, -1, sizeof(hd));
	
	for (int i = 1; i <= m; ++i)
	{
		int u = get_i();
		int v = get_i();
		int f = get_i();
		int w = get_i();
		add(u, v, f, w);
	}
	
	s = n, t = n - 1;
	
	add(s, 0, flow, 0);
	
	printf("%d\n", mcmf());
}

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

using namespace std;

long long inf=1000000007;

int main(){
	int h,w;
	cin>>h>>w;
	vector<string> grid(h);
	for(int i=0;i<h;i++) cin>>grid.at(i);

	struct m{
		int u=0;
		int d=0;
		int l=0;
		int r=0;
	};

	vector<vector<m>> dp(h+2,vector<m>(w+2));

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(grid.at(i-1).at(j-1)=='.'){
				dp.at(i).at(j).u=dp.at(i-1).at(j).u+1;
				dp.at(i).at(j).l=dp.at(i).at(j-1).l+1;
			}
		}
	}

	for(int i=h;i>0;i--){
		for(int j=w;j>0;j--){
			if(grid.at(i-1).at(j-1)=='.'){
				dp.at(i).at(j).d=dp.at(i+1).at(j).d+1;
				dp.at(i).at(j).r=dp.at(i).at(j+1).r+1;
			}
		}
	}

	int ans=0;

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			int pre=0;

			pre+=dp.at(i).at(j).u+dp.at(i).at(j).d-1;
			pre+=dp.at(i).at(j).l+dp.at(i).at(j).r-2;

			ans=max(ans,pre);
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 67072
def is_yymm(fmt):
    _, month = fmt[:2], fmt[2:]
    if 1 <= int(month) <= 12:
        return True
    else:
        return False


def is_mmyy(fmt):
    month, _ = fmt[:2], fmt[2:]
    if 1 <= int(month) <= 12:
        return True
    else:
        return False


s = input()
if is_mmyy(s) and is_yymm(s):
    print('AMBIGUOUS')
elif is_mmyy(s):
    print('MMYY')
elif is_yymm(s):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#define MAX 100030
using namespace std;
typedef long long lld;
typedef pair<int,int> pii;
//priority_queue<pii> bean,bbean;
vector<int> conn[MAX];
//vector<pii> weight[MAX];
int n,par[MAX],ogn=-1;
void build(int x,int y){
    par[x]=y;
    for(int i=0;i<conn[x].size();i++) if(conn[x][i]!=y) build(conn[x][i],x);
}
int getnum(int x){
    int num=0,num_min=0,t;
    for(int i=0;i<conn[x].size();i++) if(conn[x][i]!=par[x]) {
        t=getnum(conn[x][i]);
        num+=t,num_min+=(t==0);
    }
    num+=max(num_min-1,0);
    return num;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        conn[t1].push_back(t2);
        conn[t2].push_back(t1);
    }
    for(int i=0;i<n;i++) if(conn[i].size()>=3) ogn=i;
    if(ogn==-1){
        printf("1\n");
        return 0;
    }
    build(ogn,-1);
    printf("%d\n",getnum(ogn));

}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int l,num=1,m,nl;
void jb(int x,int y,int z){
	cout<<x<<' '<<y<<' '<<z<<endl;
}
int main(){
	cin>>l;
	l--;nl=l;
	while (nl){
		if (nl%2==0){nl--;m++;}
		m+=2;nl/=2;
		num++;
	}
	cout<<num<<' '<<m<<endl;
	while (l){
		if (l%2==0){jb(1,num,l);l--;}
		jb(num-1,num,(l+1)/2);jb(num-1,num,0);l/=2;
		num--;
	}
	return 0;
}

Measured memory_bytes: 256
K=int(input())
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(A[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    string s;cin>>s;
    char c=s[0];
    if(c=='S'){
        puts("Cloudy");
    }else if(c=='C'){
        puts("Rainy");
    }else{
        puts("Sunny");
    }
}

Measured memory_bytes: 764
fun main(arr: Array<String>) {
    println(solve())
}

fun solve():Long {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    val inner = (0 until a.lastIndex).map { idx-> (idx+1 until n).count { a[idx] > a[it] } }.sum()
    val outer = a.indices.map { idx -> a.indices.count { a[idx] > a[it] } }.sum()
    val mod = 1000000000 + 7
    var ans = k.toLong()*inner%mod
    ans += (k.toLong() * (k.toLong()-1) / 2) % mod * outer
    ans %= mod
    return ans
}



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

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;
const ll maxsize = 3e5;
ll h, w, a, b, modInv[maxsize], fact[maxsize], factInv[maxsize];

ll nCm(ll n, ll m){
    return (n - m >= 0 && m >= 0) ? fact[n] * factInv[m] % mod * factInv[n - m] % mod : 0;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1; fact[1] = 1;
    for(int i = 2; i < maxsize; ++i){
        fact[i] = fact[i - 1] * i % mod;
    }
    modInv[1] = 1;
    for(int i = 2; i < maxsize; ++i){
        modInv[i] = modInv[mod % i] * (mod - mod / i) % mod;
    }
    factInv[0] = 1;
    for(int i = 1; i < maxsize; ++i){
        factInv[i] = factInv[i - 1] * modInv[i] % mod;
    }
    cin >> h >> w >> a >> b;
    ll sum = 0;
    for(int i = 0; i < h - a; ++i){
        sum += nCm(b + i - 1, b - 1) * nCm(w - b - 1 + h - 1 - i, w - b - 1);
        sum %= mod;
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a,b,k;
	vector<int>v;
	cin>>a>>b>>k;
	for(int i=1;i<=max(a,b);i++)
	{
		if(a%i==0&&b%i==0)v.push_back(i);
	}
	cout<<v[v.size()-k]<<endl;
}

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

int main(){

  int M,D;
  int ans=0;
  cin >> M >> D;

  for(int i=22; i<=D; i++){
    int ten, one;
    ten = (i/10)%10;
    one = i%10;
    if(one<2) continue;
    else if(ten*one<=M) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

n = gets.to_i
a = gets.split.map(&:to_i).sort
INF = 10 ** 18
sum = 1
a.each do |i|
  sum *= i
  if sum > INF
    sum = -1
    break
  end
end

puts sum


Measured memory_bytes: 23156
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

signed main() {
  int n;
  cin >> n;
  int a = n / 1000;
  int b = n / 100 % 10;
  int c = n / 10 % 10;
  int d = n % 10;
  for (size_t i = 0; i < (1 << 3); i++) {
    int op1 = (i >> 2) & 1;
    int op2 = (i >> 1) & 1;
    int op3 = (i) & 1;
    int ov1 = op1 * 2 - 1;
    int ov2 = op2 * 2 - 1;
    int ov3 = op3 * 2 - 1;
    if (a + ov1 * b + ov2 * c + ov3 * d == 7) {
      cout << a;
      cout << (op1 ? "+" : "-");
      cout << b;
      cout << (op2 ? "+" : "-");
      cout << c;
      cout << (op3 ? "+" : "-");
      cout << d;
      cout << "=7" << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
U=list(str(input()))
if "N" in U:
  if "S" not in U:
    print("No")
    exit()
if "S" in U:
  if "N" not in U:
    print("No")
    exit()
if "E" in U:
  if "W" not in U:
    print("No")
    exit()
if "W" in U:
  if "E" not in U:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 9108
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, As):
    all_xor = 0
    for A in As:
        all_xor ^= A
    ans = ''
    for A in As:
        ans += str(A ^ all_xor) + ' '
    print(ans[:-1])


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, As)


Measured memory_bytes: 31388
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e15
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N;
  cin >> N;
  vector<int> A(N);
  ll sum = 0;
  REP(i, N){
    cin >> A[i];
    A[i]-=i;
    sum+=A[i];
  }
  sort(ALL(A));

  ll cnt = 0;
  REP(i,N){
    cnt+=abs(A[i]-A[N/2]);
  }

  cout << cnt << endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int k, t;  cin >> k >> t;
    vector<int> a(t);
    rep(i, t) cin >> a[i];
    sort(a.begin(), a.end());
    cout << max(a[t-1]-1-(k-a[t-1]), 0) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> pi;
bool check(string&a){
	bool three = false;
	bool five = false;
	bool seven = false;
	
	for(int i=0; a[i]; i++){
		if(a[i]=='3') three = true;
		if(a[i]=='5') five = true;
		if(a[i]=='7') seven = true;
	}
	if(three && five && seven) return true;
	return false; 
}
bool comp(string&a, int n){
	long long number = 0;
	long long unit = 1;
	for(int i=a.length()-1; i>=0; i--){
		long long num = (int)(a[i]-'0');
		number+=num*unit;
		unit*=10;
	}
	if(number<=n) return true;
	else return false; 
}
int main(){
	int n;
	cin>>n;
	int t = n;
	int len = 0;
	while(t){
		len++;
		t/=10;
	}
	queue<pi>q;
	string s = "3";
	q.push(pi(s,1));
	s = "5";
	q.push(pi(s,1));
	s = "7";
	q.push(pi(s,1));
	int ret = 0;
	while(!q.empty()){
		string curr = q.front().first;
		int d = q.front().second;
		q.pop();
		if(d>len) continue;
		if(check(curr) && comp(curr,n)){
			ret++;
		}
		curr.push_back('3');
		q.push(pi(curr,d+1));
		curr.erase(curr.length()-1,1);
		
		curr.push_back('5');
		q.push(pi(curr,d+1));
		curr.erase(curr.length()-1,1);
		
		curr.push_back('7');
		q.push(pi(curr,d+1));
	}
	cout<<ret;
}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int t1,t2,a1,a2,b1,b2;cin>>t1>>t2>>a1>>a2>>b1>>b2;
  a1-=b1;a2-=b2;
  if(a1>0)a1*=-1,a2*=-1;
  int A=t1*a1+t2*a2,B=-t1*a1;
  if(A<0)fin(0);
  if(A==0)fin("infinity");
  int ans=B/A*2+1;
  if(B%A==0)ans--;
  cout<<ans<<endl;
}
/*
あまりがある時　(B/A*2+1)
あまりがない時　(B/A*2)
*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main()
{
    int M;  cin >> M;
    cout << 48-M << endl;
    return 0;
}

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

int main() {
  int a,b,c,ans;
  cin >> a >> b >> c;
  if(a==b&&b==c) ans=1;
  else if(a==b||b==c||c==a) ans=2;
  else ans=3;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<vector<int>> solve(int n) {
	vector<vector<int>> ans(n, vector<int>(n));
	if (n == 3) {
		ans = { {1,1,2},{4,0,2},{4,3,3} };
	}
	if (n == 4) {
		ans = { {1,4,5,5},{1,4,6,6},{2,2,7,8},{3,3,7,8} };
	}
	if (n == 5) {
		ans = { {1,4,4,6,0},{1,0,0,6,7},{2,5,5,0,7},{2,0,8,9,9},{3,3,8,10,10} };
	}
	if (n == 6) {
		ans = { { 1,4,4,7,0,0 }, { 1,0,3,7,0,0 }, { 2,2,3,0,8,8 }, { 5,0,0,9,12,12 }, { 5,0,0,9,0,11 }, { 0,6,6,10,10,11 } };
	}
	if (n == 7) {
		ans = { { 1,1,0,5,7,7,0 }, { 2,2,0,5,0,8,8 }, { 3,0,6,6,0,0,11 }, { 3,0,9,0,0,0,11 }, { 0,4,9,0,13,13,0 }, { 0,4,0,0,12,0,14 }, { 0,0,10,10,12,0,14 } };
	}
	return ans;
}


int main() {
	int n;
	cin >> n;
	if (n == 2) {
		cout << -1 << endl;
		return 0;
	}
	if (n == 3) {
		cout << "aab" << endl;
		cout << "d.b" << endl;
		cout << "dcc" << endl;
		return 0;
	}
	int k = n % 4 + 4;
	vector<vector<int>> anss(k, vector<int>(k));
	anss = solve(k);
	vector<vector<int>> ans(n, vector<int>(n));
	vector<vector<int>> s4(4, vector<int>(4));
	s4 = solve(4);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i < k&&j < k) ans[i][j] = anss[i][j];
			else if (i >= k && j >= k && (i - k) / 4 == (j - k) / 4) {
				ans[i][j] = s4[(i - k) % 4][(j - k) % 4];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (ans[i][j] == 0) cout << '.';
			else {
				ans[i][j] %= 26;
				char c = 'a' + ans[i][j];
				cout << c;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 5120
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{   
    int n, k;
    scn(n); scn(k);

    ll res = 0;

    for(ll i=n+1; i>=k; i--) {
        res += (n+1-i)*i%mod;
        res += 1;
        res %= mod;
    }

    lprin(res);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct SPLAY
{
	static const int N=200005;
	int ch[N][2],fa[N],size[N],cnt[N],val[N],sz,root;
	int newnode(int v,int f)
	{
		sz++;
		ch[sz][0]=ch[sz][1]=0;
		fa[sz]=f;
		size[sz]=cnt[sz]=1;
		val[sz]=v;
		return sz;
	}
	void pushup(int k)
	{
		size[k]=cnt[k]+size[ch[k][0]]+size[ch[k][1]];
	}
	void rotate(int x)
	{
		int f=fa[x],d=ch[f][0]==x?1:0;
		fa[x]=fa[f];
		fa[f]=x,fa[ch[x][d]]=f;
		ch[f][d^1]=ch[x][d],ch[x][d]=f;
		if(fa[x]) ch[fa[x]][ch[fa[x]][0]==f?0:1]=x;
		pushup(f),pushup(x);
	}
	void splay(int x,int k=0)
	{
		while(fa[x]!=k)
		{
			int f=fa[x],g=fa[f];
			if(g!=k)
				rotate((ch[f][0]==x)==(ch[g][0]==f)?f:x);
			rotate(x);
		}
		if(k==0)
			root=x;
	}
	void insert(int v)
	{
		int now=root,f=0;
		while(now&&val[now]!=v)
			f=now,now=ch[now][v>val[now]];
		if(now)
			cnt[now]++;
		else
		{
			now=newnode(v,f);
			if(f)
				ch[f][v>val[f]]=now;
		}
		splay(now);
	}
	int rank(int v)
	{
		int now=root,ans=1;
		while(now)
		{
			if(val[now]>v)
				now=ch[now][0];
			else
			{
				ans+=size[ch[now][0]];
				if(val[now]==v)
				{
					splay(now);
					return ans;
				}
				ans+=cnt[now];
				now=ch[now][1];
			}
		}
		return ans;
	}
	int kth(int k)
	{
		int now=root;
		while(now)
		{
			if(k<=size[ch[now][0]])
				now=ch[now][0];
			else
			{
				k-=size[ch[now][0]]+cnt[now];
				if(k<=0)
					return val[now];
				now=ch[now][1]; 
			}
		}
	}
	int pre(int v,int fl=0)
	{
		int ans=-1e18,id=0,now=root;
		while(now)
		{
			if(val[now]>=v)
				now=ch[now][0];
			else
			{
				if(val[now]>ans)
					ans=val[now],id=now;
				now=ch[now][1];
			}
		}
		return fl?id:ans;
	}
	int suc(int v,int fl=0)
	{
		int ans=1e18,id=0,now=root;
		while(now)
		{
			if(val[now]<=v)
				now=ch[now][1];
			else
			{
				if(val[now]<ans)
					ans=val[now],id=now;
				now=ch[now][0];
			}
		}
		return fl?id:ans;
	}
	void remove(int v)
	{
		rank(v);
		if(cnt[root]>1)
			cnt[root]--;
		else if(!ch[root][0]&&!ch[root][1])
			root=0;
		else if(!ch[root][0]||!ch[root][1])
			root=ch[root][0]?ch[root][0]:ch[root][1],fa[root]=0;
		else
		{
			int p=pre(v,1),o=root;
			splay(p);
			fa[ch[o][1]]=p;
			ch[p][1]=ch[o][1];
			pushup(p);
		}
	}
}s;
const int N=200005;
int a[N],sum[N],n,k,ans;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	s.insert(0);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]-=k;
		sum[i]=sum[i-1]+a[i];
		ans+=s.rank(s.suc(sum[i]))-1;
		s.insert(sum[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12800
//07:27~
#include <bits/stdc++.h>
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int64_t n, k;
    static int64_t a[100000], b[100000], c[100000];
    cin >> n >> k;
    int64_t kmax = (n + 1) / 2;
    if(k > kmax){ cout << -1 << endl; return 0; }
    if(n & 1){
        for(int64_t i=0;i<=n/2;++i){ a[i] = kmax + 2*i; b[i] = 2*kmax+n-1 - i; c[i] = kmax + 2*n + i; }
        for(int64_t i=0;n/2+1+i<n;++i){ a[n/2+1+i] = kmax + 2*i + 1; b[n/2+1+i] = kmax + 2*n - 1 - i; c[n/2+1+i] = kmax + 2*n + n/2+1+i; }
    }else{
        for(int64_t i=0;i<n/2;++i){ a[i] = kmax + 2*i; b[i] = 2*kmax+n-1 - i; c[i] = kmax + 2*n + i; }
        for(int64_t i=0;n/2+i<n;++i){ a[n/2+i] = kmax + 2*i + 1; b[n/2+i] = kmax + 2*n - 1 - i; c[n/2+i] = kmax + 2*n + n/2+i; }
    }
    for(int64_t i=0;i<n;++i){
        cout << a[i] - (kmax - k) << " " << b[i] - (kmax - k) << " " << c[i] - (kmax - k) << endl;
    }
    
    return 0;
}

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

main(){
	string t[21] , tmp ;
	int p[21] , tmp2 ;
	int n , a , b , c ;
	bool r = false ;
	
	while( cin >> n , n ){
		if( r ) cout << endl ;
		r = true ;
		
		map<string,int> x ;
		for( int i=0 ; i<n ; i++ ){
			cin >> t[i] >> a >> b >> c ;
			p[i] = a*3 + c ;
			x[t[i]] = i ;
		}
		
		for( int i=0 ; i<n ; i++ ){
			for( int j=i+1 ; j<n ; j++ ){
				if( p[i] < p[j] || p[i] == p[j] && x[t[i]] > x[t[j]] ){
					tmp = t[i] ;
					t[i] = t[j] ;
					t[j] = tmp ;
					
					tmp2 = p[i] ;
					p[i] = p[j] ;
					p[j] = tmp2 ;
				}
			}
		}
		
		for( int i=0 ; i<n ; i++ ) cout << t[i] << ',' << p[i] << endl ;
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	int n,m; cin >> n >> m;
	map<long long,long long> A;
	map<long long,long long> B;
	for (long long i=1;i<=n;i++){
		long long a; cin >> a;
		A[i]=a;
		B[i]=1;
	}
	for (long long i=0;i<m;i++){
		long long s,d; cin >> s >> d;
		if (A[s]>A[d]) B[d]=0;
		else if (A[s]<A[d]) B[s]=0;
		else {
			B[d]=0;
			B[s]=0;
		}
	}
	long long ans=0;
	for (auto val : B){
		if (val.second!=0) ans++;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, K;
    cin >> N >> K;
    vi a(N), b(N);
    vi ab(100050, 0);
    vi arr;
    rep(i, N) {
        cin >> a[i] >> b[i];
        if(ab[a[i]]==0) arr.pb(a[i]);
        ab[a[i]] += b[i];
    }

    SORT(arr);
    int tcnt = 0;
    rep(i, arr.size()) {
        tcnt += ab[arr[i]];
        if(tcnt >= K) {
            cout << arr[i] << endl;
            break;
        }
    }

    
    return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

struct Cake{
	int w, d, s;
	Cake(){}
	Cake(int w, int d, int s) :w(w), d(d), s(s){}
	bool operator < (Cake c) const{
		return s < c.s;
	}
};

int n, w, d, p, s;
vector<Cake> cake;

void solve(){
	int a = cake[p - 1].w;
	int b = cake[p - 1].d;
	cake.erase(cake.begin() + p - 1);
	int len = s % (2 * (a + b));
	if (0 < len && len < a){
		if (len*b < (a - len)*b){
			cake.push_back(Cake(len, b, len*b));
			cake.push_back(Cake(a - len, b, (a - len)*b));
		}
		else{
			cake.push_back(Cake(a - len, b, (a - len)*b));
			cake.push_back(Cake(len, b, len*b));
		}
		return;
	}
	else len -= a;
	if (0 < len && len < b){
		if (a*len < a*(b - len)){
			cake.push_back(Cake(a, len, a*len));
			cake.push_back(Cake(a, b - len, a*(b - len)));
		}
		else{
			cake.push_back(Cake(a, b - len, a*(b - len)));
			cake.push_back(Cake(a, len, a*len));
		}
		return;
	}
	else len -= b;
	if (0 < len && len < a){
		if (len*b < (a - len)*b){
			cake.push_back(Cake(len, b, len*b));
			cake.push_back(Cake(a - len, b, (a - len)*b));
		}
		else{
			cake.push_back(Cake(a - len, b, (a - len)*b));
			cake.push_back(Cake(len, b, len*b));
		}
		return;
	}
	else len -= a;
	if (0 < len && len < b){
		if (a*len < a*(b - len)){
			cake.push_back(Cake(a, len, a*len));
			cake.push_back(Cake(a, b - len, a*(b - len)));
		}
		else{
			cake.push_back(Cake(a, b - len, a*(b - len)));
			cake.push_back(Cake(a, len, a*len));
		}
		return;
	}
	else len -= b;
}


int main(){
	while (cin >> n >> w >> d, (n | w | d)){
		cake.clear();
		cake.push_back(Cake(w, d, w*d));

		for (int i = 0; i < n; i++){
			cin >> p >> s;
			solve();
		}

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

		for (int i = 0; i < cake.size(); i++){
			if (i + 1 != cake.size())cout << cake[i].s << " ";
			else cout << cake[i].s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
'use strict'
function main(input) {
    const tmp = input.split(' ');
    const X = parseInt(tmp[0], 10);
    const A = parseInt(tmp[1], 10);

    if (X < A) {
        console.log("0");
    } else {
        console.log("10");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
l = [input() for _ in range(int(input()))]
f,r = True,''
for _ in range(int(input())):
    s = input()
    if s in l:
        if f: r = 'Opened by '+s
        else: r = 'Closed by '+s
        f = not(f)
    else: r = 'Unknown '+s
    print(r)

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    rep(0, 21) {
        if (b <= i * a - (i - 1)) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define ll long long
const int MAXN=1e5+10; 
int N,K;
vector<int> G[MAXN];
const int M=1e9+7;
int addedge(int x,int y)
{
	G[x].push_back(y);
	G[y].push_back(x);
}
ll ans;
ll dfs(int u,int fa,int dep)
{
	int temp=K-min(2,dep);
	for(int i=0;i<(int )G[u].size();i++)
	{
		int v=G[u][i];
		if(v==fa)
		continue;
		if(dfs(v,u,dep+1)==0)
		return 0;
		ans=(ans*(temp))%M;
		temp--;
	}
	return ans;
}
int main(){
cin>>N>>K;
int x,y;
for(int i=1;i<=N-1;i++)
{
	cin>>x>>y;
	addedge(x,y);
}
ans=K;
dfs(1,-1,1);
cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 11520