akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, in;
	cin >> n;
	queue<pii> q;
	vi v;
	vector<bool> b(n, true);
	rep(i, n) {
		cin >> in;
		v.push_back(in - 1);
	}
	q.push({ v[0],1 });
	while (!q.empty()) {
		int btn = q.front().fs;
		int lev = q.front().sc;
		b[btn] = false;
		q.pop();
		if (btn == 1) {
			cout << lev << endl;
			return 0;
		}
		else if (b[v[btn]] )q.push({ v[btn], lev + 1 });
	}
	cout << -1 << endl;
}

Measured memory_bytes: 892
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


w = C(input())
for cnt in w.values():
    if cnt % 2 == 1:
        print("No")
        exit()
print("Yes")

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

using namespace std;

//[0] for P
//[1] for D
int dp[200005][2];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    string T;
    cin>>T;

    for(int i=1;i<=T.length();i++){
        int cur =i-1;
        if(T[cur]=='P'){
            dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
        }
        else if(T[cur]=='D'){
            dp[i][1] = max(dp[i-1][0]+2,dp[i-1][1]+1);
        }
        else{
            dp[i][0] = max(dp[i-1][0], dp[i-1][1]);
            dp[i][1] = max(dp[i-1][0]+2, dp[i-1][1]+1);

        }
    }
    int n = T.size();
    char ch = '*';
    //cout<<max(dp[n][0], dp[n][1])<<"\n";
    for(int i=n;i>=1;i--){
        int cur = i-1;
        if(T[cur]!='?'){
            ch='*';
            continue;

        }
        if(ch!='*'){
            if(ch=='P'){
                T[cur]='P';
                if(dp[i-1][0]>dp[i-1][1]){
                    ch='P';
                }
                else{
                    ch='D';
                }
            }
            else if (ch=='D'){
                T[cur]='D';
                if(dp[i-1][0]+2>dp[i-1][1]+1){
                    ch='P';
                }
                else{
                    ch='D';
                }
            }
        }
        if(dp[i][0]>dp[i][1]){
            T[cur]='P';
            if(dp[i-1][0]>dp[i-1][1]){
                ch='P';
            }
            else{
                ch='D';
            }
        }
        else{
            T[cur]='D';
            if(dp[i-1][0]+2>dp[i-1][1]+1){
                ch='P';
            }
            else{
                ch='D';
            }
        }
    }
    cout<<T<<"\n";
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int i, j;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  vector<int> b(m);
  vector<int> c(m);
  for(i = 0; i < m; i++)
  {
    cin >> b.at(i) >> c.at(i);
  }
  sort(a.begin(), a.end());
  vector<pair<int, int> > pairs(m);
  for(i = 0; i < m; i++)
  {
    pairs.at(i) = make_pair(c.at(i), b.at(i));
  }
  sort(pairs.begin(), pairs.end());
  reverse(pairs.begin(), pairs.end());
  vector<int> chan(n, 0);
  j = 0;
  for(i = 0; i < n; i++)
  {
    chan.at(i) = pairs.at(j).first;
    pairs.at(j).second--;
    if(pairs.at(j).second == 0)
    {
      j++;
    }
    if(j >= m) break;
  }
  for(i = 0; i < n; i++)
  {
    if(a.at(i) < chan.at(i))
    {
      a.at(i) = chan.at(i);
    }
    else break;
  }
  long long ans = 0;
  for(i = 0; i < n; i++)
  {
    ans += a.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

ll N, M;
vector<ll> A, B;
void solve(){
  ll ans = 1;
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  A.pb(-1);
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  rep(i, N-1)if(A[i] == A[i+1]) ans = 0;
  rep(i, M-1)if(B[i] == B[i+1]) ans = 0;
  B.pb(-1);
  ll a = 0, b = 0;
  for(ll i = N * M; i >= 1; i--){
    if(A[a] == i && B[b] == i){
      ans *= 1;
      a++, b++;
    }else if(A[a] == i){
      ans *= b;
      a++;
    }else if(B[b] == i){
      ans *= a;
      b++;
    }else{
      ans *= a * b - (N*M-i);
    }
    ans %= MOD;
  }
  cout << ans << endl;
}
int main(){
  cin >> N >> M;
  A.resize(N);
  B.resize(M);
  rep(i, N) cin >> A[i];

  rep(i, M) cin >> B[i];

  solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = a + b;
    if(c % 2 == 0){
      System.out.println(c / 2);
    }else{
      System.out.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 24020
package main

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

func main() {
	var n int
	var t string
	s := wordScanner(100)
	scanInts(s, &n)
	l := make(map[string]int, n)
	for i := 0; i < n; i++ {
		scanStrings(s, &t)
		l[sorted(t)]++
	}

	var c int
	for _, val := range l {
		for i := 1; i < val; i++ {
			c += i
		}
	}

	fmt.Println(c)
}

type RuneSlice []rune

func (p RuneSlice) Len() int           { return len(p) }
func (p RuneSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p RuneSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

func sorted(s string) string {
	runes := []rune(s)
	sort.Sort(RuneSlice(runes))
	return string(runes)
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}

func scanStrings(s *bufio.Scanner, vals ...*string) {
	for i := range vals {
		s.Scan()
		*vals[i] = s.Text()
	}
}


Measured memory_bytes: 9344
N,x=map(int,input().split())
a=[int(i) for i in input().split()]
ans=sum([max(a[i]-x,0) for i in range(N)])
a=[min(a[i],x) for i in range(N)]
for i in range(N-1):
    if a[i]+a[i+1]>=x:
        ans+=a[i]+a[i+1]-x
        a[i+1]=x-a[i]
print(ans)

Measured memory_bytes: 14540
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        String S = sc.next();
        int A = Integer.parseInt(S.substring(0, 1));
        int B = Integer.parseInt(S.substring(1, 2));
        int C = Integer.parseInt(S.substring(2, 3));
        int D = Integer.parseInt(S.substring(3));
        int suma = A;
        int sumb;
        int sumc;
        int sumd;
        String x;
        String y;
        String z;
        
        for(int i=0; i<2; i++){
            sumb = suma;
            if(i==0){
                sumb += B;
                x = "+";
            }
            else{
                sumb -= B;
                x = "-";
            }
            for(int j=0; j<2; j++){
                sumc = sumb;
                if(j==0){
                    sumc += C;
                    y = "+";
                }
                else{
                    sumc -= C;
                    y = "-";
                }
                for(int k=0; k<2; k++){
                    sumd = sumc;
                    if(k==0){
                        sumd += D;
                        z = "+";
                    }
                    else{
                        sumd -= D;
                        z = "-";
                    }
                    if(sumd==7){
                        System.out.println(A + x + B + y + C + z + D + "=7" );
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 23636
#include<stdio.h>

int main(void)
{
   int a,b,c,n=3,i,temp;
   scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<n-1;i++){
		if(b<a){
			temp=a;
			a=b;
			b=temp;
		}
		if(c<b){
			temp=b;
			b=c;
			c=temp;
		}
	}
	printf("%d %d %d\n",a,b,c);
			
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n,k;cin>>n>>k;
    vl a(n);rep(i,n)cin>>a[i];

    ll ans=LINF;
    rep(i,1<<n){
        if(__builtin_popcount(i)<k)continue;
        ll nowh=0;
        ll sum=0;
        rep(j,n){
            if((i>>j&1)==1&&nowh>=a[j]){
                sum+=nowh+1-a[j];
                nowh++;
            }else{
                chmax(nowh,a[j]);
            }
        }
        chmin(ans,sum);
    }
    cout<<ans<<endl;
}

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


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

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

int k, cnt;
ll res;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> k;
    vector<ll> arr = {1,2,3,4,5,6,7,8,9};
    priority_queue<ll, vector<ll>, greater<ll>> pq(arr.begin(), arr.end());

    while (cnt++ < k) {
      res = pq.top();
      pq.pop();
      int lb = res % 10;
      pq.push(res * 10 + lb);
      if (lb > 0) {
        pq.push(res * 10 + lb - 1);
      }
      if (lb < 9) {
        pq.push(res * 10 + lb + 1);
      }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3700
from operator import itemgetter
n=int(input())
s=[""]*n
t=[""]*n
for i in range(n):
    x,l=map(int,input().split())
    s[i]=x-l
    t[i]=x+l
st=sorted([(s[i],t[i]) for i in range(n)], key=itemgetter(1))
ans=0
last=0
last=-float("inf")
for i in range(n):
    if last<=st[i][0]:
        ans+=1
        last=st[i][1]
print(ans)


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

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

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

	int tmp = 1;
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (tmp == a[i]) tmp++;
		else cnt++;
	}
	if (tmp == 1)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << cnt << endl;
	}
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


long long int value(long long int x, long long int A, long long int B) {
	return floor(A * x / B) - A * floor(x / B);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);

	int N, K;
	cin >> N >> K;
	vi flag(N);
	rep(i, N) {
		flag.at(i) = 1;
	}
	rep(i, K) {
		int d;
		cin >> d;
		vi A(d);
		rep(j, d) {
			cin >> A.at(j);
			flag.at(A.at(j)-1) = 0;
		}
	}
	cout << accumulate(all(flag), 0);
	return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int P=1e9+7;

int f[3010][3010][2];

inline void add(int &x,int y){ (x+=y)%=P; }

int main(){
	int n,m;
	cin>>n>>m;
	f[0][0][1]=1;
	for(int i=1;i<=n;i++) f[0][i][0]=1;
	for(int i=0;i<m;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=1;k++){
				if(j) add(f[i+1][j-1][k|!(j-1)],f[i][j][k]);
				if(n-j) add(f[i+1][j+1][k],f[i][j][k]);
				if(j) add(f[i+1][j][k|(j==1)],f[i][j][k]);
				if(n-j) add(f[i+1][j][k],f[i][j][k]);
			}
	int ans=0;
	for(int i=0;i<=n;i++) add(ans,f[m][i][1]);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pi;

#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void solve() {
    int n, k;
    cin>>n>>k;
    vl p(n);
    vl c(n);

    loop(n) cin>>p[i];
    loop(n) cin>>c[i];

    vvi moves(n);
    vl tot_score(n);
    //vector <pair<int,int>> mxscore(n,{INT_MIN,-1});
    //mscore[i][j] -> is max score at ith posn in jth turn
    //int mscore[n][n] {INT_MIN};
    vvl mscore(n, vl (n,INT_MIN));
    //memset(mscore, INT_MIN, sizeof(mscore));
    loop(n) {
        int in=i+1;
        int tr = p[in-1];
        moves[i].pb(tr);
        int turn = 1;
        tot_score[i] += c[tr-1];
        //mxscore[i] = {c[tr-1], turn};
        mscore[i][turn-1] = max(mscore[i][turn-1], (ll)tot_score[i]);
        while(tr!=in) {
            turn++;
            tr = p[tr-1];
            moves[i].pb(tr);
            tot_score[i] += c[tr-1];
            // if(mxscore[i].f < tot_score[i]) {
            //     mxscore[i] = {tot_score[i],turn};
            // }
            mscore[i][turn-1] = max(mscore[i][turn-2], (ll)tot_score[i]);
        }
    }
    int ans=INT_MIN;
    loop(n) {
        int mvs = moves[i].size();
        int a1=INT_MIN, a2=INT_MIN, a3=INT_MIN, a4=INT_MIN;
        if(k > mvs) {
            a4 = mscore[i][mvs-1];
            if(tot_score[i] > 0) {
                a1 = (k/mvs)*tot_score[i];
                int k1 = k%mvs;
                if(k1!=0) {
                    a1 += mscore[i][k1-1];
                }
                else {
                    a1 -= tot_score[i];
                    a1 += mscore[i][mvs-1];
                }
            }
            else {
                a1 = mscore[i][mvs-1];
            }
        }
        else {
                a3 = mscore[i][k-1];
        }
        //cout<<"mvs:\n"<<mvs<<"\n***\n"<<a1<<" "<<a3<<" "<<a4<<"\n***";
        a1 = max(a1,a4);
        a2 = max(a1,a3);
        ans = max(a2,ans);
    }
    cout<<ans<<"\n";
    return;
}
int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 316780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    string s,t;
    cin>>s>>t;
    ll int i,j;
    ll int n=s.size(),m=t.size();
    ll int dp[n][m];//cout<<s<<" "<<t<<endl;
    for(i=0;i<n;i++)
    {
    	for(j=0;j<m;j++)
    	{
    		if(i==0 && j==0)
    		{
    			if(s[i]==t[j])
    				dp[i][j]=1;
    			else
    				dp[i][j]=0;
    		}
    		else if(i==0 && s[i]==t[j])
    			dp[i][j]=1;
    		else if(i==0)
    			dp[i][j]=max(dp[i][j-1],(ll int)0);
    		else if(j==0)
    		{
    			if(s[i]==t[j])
    				dp[i][j]=1;
    			else
    				dp[i][j]=0;
    		}
    		else if(s[i]==t[j])
    		{
    			dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
    	}
    }
/*    for(i=0;i<n;i++)
    	{for(j=0;j<m;j++)
    		cout<<dp[i][j]<<" ";
    	cout<<endl;}*/
    ll int z=dp[n-1][m-1];
    if(z==0)
    	exit(0);
    i=n-1;j=m-1;
    deque<char> q;
    while(z!=0)
    {
    	if(s[i]==t[j])
    	{
    		q.PB(s[i]);
    		z--;
    		i=i-1;j=j-1;continue;
    	}
    	if(i==0)
    		j--;
		else if(j==0)
			i--;
	   	else if(dp[i-1][j]>=dp[i][j-1])
    		i=i-1;
    	else
    		j=j-1;
    }
    while(q.empty()!=true)
    {
    	cout<<q.back();
    	q.pop_back();
    }
}


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



int main()
{
    int n;
    cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    int dp[n+1]={0};
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    cout<<dp[n]<<endl;
    return 0;
    
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

typedef long long ll;
const int mod = 1000000007;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

vector<int> inv(200001), two(200001);
vector<int> v[200000], child[200000];
int n;

int dfs(int x, int p){
    for(int j : v[x]){
        if(j == p)  continue;
        child[x].push_back(dfs(j, x));
    }
    int sum = 1;
    for(int j : child[x])   sum += j;
    return sum;
}

int main(){
    cin >> n;
    inv[0] = 1;
    two[0] = 1;
    ll tinv = modpow(2, mod-2, mod);
    for(int i = 1; i <= n; i++) inv[i] = inv[i-1]*tinv%mod, two[i] = two[i-1]*2%mod;

    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0, -1);

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(child[i].empty() || child[i][0] == n-1)  continue;
        ll sub = 1;
        int res = n-1;
        for(int j : child[i]){
            res -= j;
            sub += (two[j]-1+mod)%mod;
            sub %= mod;
        }
        if(res) (sub += (two[res]-1+mod)%mod) %= mod;
        sub = (two[n-1]-sub+mod)%mod;
        (sub *= inv[n-1]) %= mod;
        (ans += sub*inv[1]%mod) %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36480
#include<iostream>
#include<vector>

using namespace std;

int main(void){

    int n, count = 0;

    cin >> n;

    vector<int> p(n);

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

    for(int i = 0;i < n-2;i++){
        if((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2])){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    ans = [1]*n
    for i in range(m):
        a,b = map(int,input().split())
        if h[a-1] < h[b-1]:
            ans[a-1] = 0
        elif h[a-1] > h[b-1]:
            ans[b-1] = 0
        elif h[a-1] == h[b-1]:
            ans[a-1] = 0
            ans[b-1] = 0
    print(ans.count(1))


    
    
if __name__ == "__main__":
    main()


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

int main(){
  int n;
  cin >> n;
  int p[n];
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int ans=0;
  for(int i=0;i<n-2;i++){
    if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2]))ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MOD = 1000*1000*1000+7;
int n;
LL k;

struct Matrix {
    LL m[50][50];
    Matrix operator * (const Matrix&a) const {
        Matrix tmp;
        for(int i=0; i<n;i++) {
            for(int j=0; j<n;j++) {
                tmp.m[i][j] = 0;
                for(int k=0; k<n;k++) {
                    tmp.m[i][j]=(tmp.m[i][j]+(m[i][k]*a.m[k][j])%MOD)%MOD;
                }
            }
        }
        return tmp;
    }
};

Matrix G;
Matrix ans;
LL res=0;

void fastPow() {
    while(k>0) {
        if(k&1) {
            ans=ans*G;
        }
        G=G*G;
        k/=2;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    for(int i=0; i<n;i++) {
        for(int j=0; j<n;j++) {
            cin>>G.m[i][j];
            if(i==j) {
                ans.m[i][j]=1;
            }
        }
    }
    fastPow();
    for(int i=0; i<n;i++) {
        for(int j=0; j<n;j++) {
            res=(res+ans.m[i][j])%MOD;
        }
    }
    cout<<res;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void) {
	int i,count=0,L, R, d;
	scanf("%d", &L);
	scanf("%d", &R);
	scanf("%d", &d);
	for (i = L; i <= R; i++) {
		if (i % d == 0) {
			count++;
		}
	}
	printf("%d", count);

	return 0;
}

Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();

		boolean[] flg = new boolean[n * m + 1];
		for (int i = 0; i < flg.length; i++) {
			flg[i] = false;
		}

		for (int i = 0; i <= m; i ++) {
			if (m - 2 * i == 0) {
				flg[i * n] = true;
			} else if (m - 2 * i > 0) {
				for (int j = 0; i * n + j < n * m -i * n; j += (m - 2 * i)) {
					flg[i * n + j] = true;
				}
			} else {
				for (int j = 0; i * n + j >= n * m - i * n; j += (m - 2 * i)) {
					flg[i * n + j] = true;
				}
			}
		}

		if (flg[k] == true) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 24020
#include <stdio.h>
const int N=3e2+10;
int main(){
    char c[N][N],a[N][N];
    bool f;
    int n,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%s",c[i]);
    for(int i=0;i<n;i++){
        f=true;
        for(int j=0;j<n&&f;j++)for(int k=0;k<n&&f;k++){
            a[j][k]=c[(j+i)%n][k];
        }//if(c[(j+i)%n][k]!=c[k][(j+i)%n])f=false;
        for(int j=0;j<n;j++)for(int k=0;k<n;k++)if(a[k][j]!=a[j][k])f=false;
        if(f)ans+=n;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 384
def read_input():
    x = int(input())
    return x

def sumup(y):
    return y*(y+1)/2

def submit():
    x = read_input()

    for i in range(1, x + 1):
        if x <= sumup(i):
            print(i)
            break


if __name__ == '__main__':
    submit()


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = 0; i < (ty - sy); i++) {
    cout << 'U';
  }
  for (int i = 0; i < (tx - sx); i++) {
    cout << 'R';
  }
  for (int i = 0; i < (ty - sy); i++) {
    cout << 'D';
  }
  for (int i = 0; i < (tx - sx); i++) {
    cout << 'L';
  }
  cout << 'L';
  for (int i = 0; i < (ty - sy + 1); i++) {
    cout << 'U';
  }
  for (int i = 0; i < (tx - sx + 1); i++) {
    cout << 'R';
  }
  cout << "DR";
  for (int i = 0; i < (ty - sy + 1); i++) {
    cout << 'D';
  }
  for (int i = 0; i < (tx - sx + 1); i++) {
    cout << 'L';
  }
  cout << 'U' << endl;
}


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

#define int long long


signed main() {
    
    string S;
    cin >> S;
    int N = S.length();
    int ans=0;
    for(int i=0; i<N;){
        int j = i;
        if((S[j] == 'A' || S[j]=='C' || S[j]== 'G' || S[j]=='T')){
            while(j<N && (S[j] == 'A' || S[j]=='C' || S[j]== 'G' || S[j]=='T')){ j++;}
            ans = max(ans, j-i);
            i=j;
        }else
            i++;
    }
    cout << ans << endl;
    return 0;
}


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

ll N, K;

int main(){
  cin >> N;
  ll ans = 0;
  K = 2;
  ll tmp = N;
  while(K <= sqrt(tmp)){
    N = tmp;
    while(true){
      if(N%K != 0) break;
      N = N / K;
    }
    if(N%K == 1){
      ans++;
    }
    K++;
  }
  ll i = 1;
  N = tmp;
  while(true){
    if((N-1)/i < sqrt(N)) break;
    if((N-1) % i == 0){
      ans++;
    }
    i++;
  }
  cout << ans + 1 <<endl;
}

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

// x^nのmod(10^9 + 7)を求める関数
long at_pow(long x, long n) {
  long MOD = 1000000007;
  long ans = 1;
  while(n > 1) {
    if(n % 2 == 1) ans = ans*x % MOD;
    x = x*x % MOD;
    n /= 2;
  }
  ans = ans*x % MOD;
  return ans;
}

// x!のmod(10^9 + 7)を求める関数
long at_factorial(long x) {
  long MOD = 1000000007;
  long ans = 1;
  for(int i = 1; i <= x; i++) {
    ans = ans*i % MOD;
  }
  return ans;
}

// nCkの組み合わせ計算のmod(10^9 + 7)を求める関数 (n >= k)
long at_combination(long n, long k) {
  long MOD = 1000000007;
  long a, b, c, ans;
  a = at_factorial(n);
  b = at_pow(at_factorial(k), MOD - 2);
  c = at_pow(at_factorial(n - k), MOD - 2);
  ans = a*b % MOD;
  ans = ans*c % MOD;
  return ans;
}


int main() {
  int N, K;
  cin >> N >> K;
  long MOD = 1000000007;
  long ans;
  for(int i = 1; i <= K; i++) {
    // (N - K + 1)Ci*(K - 1)C(i - 1)
    if(N - K + 1 >= i) {
      ans = at_combination(N - K + 1, i)*at_combination(K - 1, i - 1) % MOD;
      cout << ans << endl;
    } else {
      cout << 0 << endl;
    }
  }
}


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

int main()
{
  int n;
  cin >> n;
  double v[n];
  
  
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];

  }
  
  for (int i = 0; i < n-1; i++)
  {
    sort(v,v+n);
    v[i+1]=(v[i]+v[i+1])/2;
    v[i]=0;
    // for (int i = 0; i < n; i++)
    // {
    //   cout << v[i] << ":";
    // }
    // cout << "\n";
  }

  cout << v[n-1] << "\n";
  
  return 0;
}

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

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

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n;cin>>n;
    cout<<(n-1)/2<<endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
long long int mod= 1000000007,modd=998244353;
int32_t main()
{  lli i,j,k,c,n;
   cin>>n;
   lli a[n+1];
   lli s[4];
   for(i=1;i<=n;i++) cin>>a[i];
   if(n<3)
    cout<<0;
   else
   { c=0;
     for(i=1;i<=n;i++)
     { for(j=1;j<=n;j++)
        { for(k=1;k<=n;k++)
           { if(i!=j && i!=k && j!=k && a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k])
               {  s[1]=a[i]; s[2]=a[j]; s[3]=a[k];
                  sort(s+1,s+4);
                  if(s[1]+s[2] >s[3])
                  {  //debug(a[i]); debug(a[j]); debug(a[k]);
                     c++;
                  }
               }
           }//for k
        }//for j
     }//for i
     cout<<c/6;
   }
   return 0;
}//main


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




string S; int w;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S >> w;

    int i = 0;
    while (i < S.length()) {
        printf("%c", S[i]);
        i += w;
    }
    printf("\n");
}

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

struct Node{
	unsigned int key;
	struct Node *next;
	struct Node *prev;
};

typedef struct Node * node;

node nil;

node listSearch(int key);
void init();
void printList();
void deleteNode(node t);
void deleteFirst();
void deleteLast();
void delete(int key);
void insert(int key);

int main(void)
{
	int key, n, i;
	int size = 0;
	char com[20];
	int np =0, nd =0;
	
	scanf("%d", &n);
	init();
	
	for(i =0; i<n; i++){
		scanf("%s%d", com, &key);
		if(com[0] == 'i'){
			insert(key);
			np++;
			size++;
		}
		else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F'){
					deleteFirst();
				}
				else if(com[6] == 'L'){
					deleteLast();
				}
			}
			else{
					delete(key);
					nd++;
				}
			size--;
		}
	}
	
	printList();
	
	return 0;
}

node listSearch(int key)
{
	node cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init()
{
	nil = malloc(sizeof(struct Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList()
{
	node cur = nil->next;
	int isf=1;
	while(1){
		if(cur == nil){
			break;
		}
		if(isf == 0){
			printf(" ");
		}
		printf("%d", cur->key);
		cur = cur->next;
		isf =0;
	}
	printf("\n");
}

void deleteNode(node t)
{
	if(t == nil){
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst()
{
	node t = nil->next;
	if(t == nil){
		return;
	}
	deleteNode(t);
}

void deleteLast()
{
	node t = nil->prev;
	if(t == nil){
		return;
	}
	deleteNode(t);
}

void delete(int key)
{
	deleteNode(listSearch(key));
}

void insert(int key)
{
	node x;
	x = malloc(sizeof(struct Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}




Measured memory_bytes: 33024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int f[50][50], c[50][50];
char  l[50][51];
int w, h, dx[] = {0,-1,0,1}, dy[] = {-1,0,1,0};

// black 1 white 2
int dfs(int y, int x){
  if(l[y][x] == 'B') return 1;
  if(l[y][x] == 'W') return 2;

  int ret = 0;
  rep(d, 4){
    int ny = y+dy[d], nx = x+dx[d];
    if(ny < 0 || nx < 0 || ny >= h || nx >= w || f[ny][nx]) continue;
    f[ny][nx] = 1;
    ret |= dfs(ny, nx);
  }
  return ret;
}

int main(){
  while(scanf("%d%d", &w, &h) && w+h){
    rep(i, h) scanf("%s", l[i]);
    memset(c, 0, sizeof(c));

    rep(i, h) rep(j, w){
      if(l[i][j] == 'B' || l[i][j] == 'W' || c[i][j]) continue;
      //      printf("%d %d\n", i, j);
      memset(f, 0, sizeof(f));
      f[i][j] = 1;
      int flag = dfs(i, j);
      //      printf("%d\n", flag);
      rep(k, h) rep(m, w) if(f[k][m] != 0 && l[k][m] == '.') c[k][m] = flag;
    }

    int black = 0, white = 0;
    rep(i, h) rep(j, w){
      if(c[i][j] == 1) black++;
      else if(c[i][j] == 2) white++;
    }

    printf("%d %d\n", black, white);
  }
  return 0;
}

Measured memory_bytes: 1332
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){var r=Number(e[0]),t=e[1].split(" ").map(function(e){return Number(e)});t.sort(function(e,r){return e-r});for(var n=t[r-1]/2,o=9999999999,u=0,i=0;i<r-1;i++){var f=Math.abs(t[i]-n);f<=o&&(o=f,u=i)}console.log(`${t[r-1]} ${t[u]}`)}},function(e,r){e.exports=require("fs")}]);

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

int main() {

  int N, K;
  cin >> N >> K;
  int B = 1;
  for (int i = 0; i < N; i++) {
    if (B < K){
     B *= 2 ;
    }
    else{
      B += K;
  }
   
    
  }
 cout << B << endl;
}


Measured memory_bytes: 256
a=list(input())
b=list(input())
c=list(input())
t=a.pop(0)
while(1):
    if t=='a':
        if len(a)==0:
            print('A')
            break
        t=a.pop(0)
    elif t=='b':
        if len(b)==0:
            print('B')
            break
        t=b.pop(0)
    else:
        if len(c)==0:
            print('C')
            break
        t=c.pop(0)

Measured memory_bytes: 3064
n = int(input())
arr = list(map(int, input().split()))
ans = []
flag = False
for _ in range(n):
  for i in range(len(arr)-1,-1,-1):
    if arr[i] == i+1:
      ans.append(arr[i])
      arr = arr[:i]+arr[i+1:]
      break
  else:
    flag = True
    break
if flag:
  print(-1)
else:
  ans = ans[::-1]
  for i in range(n):
    print(ans[i])


Measured memory_bytes: 3064
/*
	Auther:_Destiny
	time:2020.5.3
*/
#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;
string a;

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int main() {
	cin >> a;
	if (a == "ABC") puts("ARC");
	else puts("ABC");
}

Measured memory_bytes: 3616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ANot solver = new ANot();
        solver.solve(1, in, out);
        out.close();
    }

    static class ANot {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int ans = 0;

            if (a == 0) ans = 1;
            else ans = 0;
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35636
N = int(input())

AC_count = 0
WA_count = 0
TLE_count = 0
RE_count = 0

S = []
for i in range(N):
    S.append(input())
    if S[i] == 'AC':
        AC_count += 1
    elif S[i] == 'WA':
        WA_count += 1
    elif S[i] == 'TLE':
        TLE_count += 1
    elif S[i] == 'RE':
        RE_count += 1

print('AC x ' + str(AC_count))
print('WA x ' + str(WA_count))
print('TLE x ' + str(TLE_count))
print('RE x ' + str(RE_count))

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

int main(){
  int N, Y;
  cin >> N >> Y;
  
  for(int m = 0; true; m++){
    if(m > Y) break;
    for(int g = 0; true; g++){
      int s = N - m - g;
      if(s < 0)  break;
      if(s * 1000 + g * 5000 + m * 10000 == Y)
      {
        cout << m << " " << g << " " << s << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  COMinit();
  long long N,K;cin>>N>>K;
  vector<long>A(N);for(int i=0;i<N;i++)cin>>A[i];
  
  //min
  sort(A.begin(),A.end());
  long long x=0;
  for(int i=0;i<=N-K;i++){
    x=(x+COM(N-i-1,K-1)*((A[i]+MOD)%MOD)%MOD)%MOD;
  }
  
  //max
  reverse(A.begin(),A.end());
  long long y=0;
  for(int i=0;i<=N-K;i++){
    y=(y+COM(N-i-1,K-1)*((A[i]+MOD)%MOD)%MOD)%MOD;
  }
  long long z=y-x;
  while(z<0)z+=MOD;
  cout<<z;
  //cout<<(y-x+2*MOD)%MOD;
  assert(z>=0);
}




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

int main(){
  map< string , vector<int> > mp;
  
  string str;
  int num;
  
  while( cin>>str>>num ){
    mp[ str ].push_back( num );
  }

  //for( pair<string,vector<int> > p : mp)
  for( auto  p : mp){
    string name=p.first;
    vector<int> v=p.second;
    sort(v.begin(),v.end());
    
    cout<<name<<endl;

    for(int i=0;i<(int)v.size();i++){
      if(i>0)cout<<' ';
      cout<<v[i];
    }
    cout<<endl;
  }
  
  return 0;
}

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

using namespace std;


int main()
{
    int n;
    int t_even, t_old, count, t, t1, t2;
    map<int, int> even, odd;
    pair<int, int> p;
    vector<pair<int, int>> vec_even, vec_odd;
    
    cin >> n;


    for (int i = 0; i < n/2; i++) {
        cin >> t_old >> t_even;
        even[t_even]++;
        odd[t_old]++;
    }
/*
    auto x = std::max_element(even.begin(), even.end(),
    [](const pair<int, int>& p1, const pair<int, int>& p2) {
        return p1.second < p2.second; });

    auto y = std::max_element(odd.begin(), odd.end(),
    [](const pair<int, int>& p1, const pair<int, int>& p2) {
        return p1.second < p2.second; });
*/
/*
    for (const auto& [key, value] : even) {
        p.first = value;
        p.second = key;
        vec_even.push_back(p);
    }

    for (const auto& [key, value] : odd) {
        p.first = value;
        p.second = key;
        vec_odd.push_back(p);
    }
*/
    for (auto itr = even.begin(); itr != even.end(); itr++) {
        p.first = itr->second;
        p.second = itr->first;
        vec_even.push_back(p);
    }
    for (auto itr = odd.begin(); itr != odd.end(); itr++) {
        p.first = itr->second;
        p.second = itr->first;
        vec_odd.push_back(p);
    }
    
    
    sort(vec_even.begin(), vec_even.end(), greater<pair<int, int>>());
    sort(vec_odd.begin(), vec_odd.end(), greater<pair<int, int>>());

    if (vec_even[0].second != vec_odd[0].second) {
        count = n - vec_even[0].first - vec_odd[0].first;
    } else {
        if (vec_even.size() == 1 && vec_odd.size() == 1) {
            t = vec_even[0].first;
        } else if (vec_even.size() == 1) {
            t = vec_even[0].first + vec_odd[1].first;
        } else if (vec_odd.size() == 1) {
            t = vec_even[1].first+ vec_odd[0].first;
        } else {
            t1 = vec_even[0].first + vec_odd[1].first;
            t2 = vec_even[1].first+ vec_odd[0].first;
            t = t1 > t2 ? t1 : t2;
        }
        count = n - t;
    }

    cout << count << endl;

    return 0;   
}

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



int main() {
    int n,m;
    cin>>n>>m;
    
    vector<vector<int>> matrix(n,vector<int>(m));
    
    rep(i,n){
        rep(j,m){
            cin>>matrix[i][j];
        }
    }
    vector<int> vec(m);
    rep(i,m)  cin>>vec[i];
    int sum=0;
    rep(i,n){
        sum=0;
        rep(j,m){
            sum+=matrix[i][j]*vec[j];
            
        }
        cout<<sum<<endl;
    }
  
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,m,k;
	long long s;
	cin>>n>>m>>k;
	for(int i=0;i<n+1;i++){
		for(int j=0;j<m+1;j++){
			s=i*(m-j)+(n-i)*j;
			if(s==k){
				//cout<<i<<" "<<j<<endl;
				//cout<<endl;
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

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

int main(){
	int a=0,b,n;
	cin>>n;
	for(int i=0; i<n; i++){
		int c,d;
		cin>>c>>d;
		if(a<c){
			a=c;
			b=d;
		}
	}
	cout<<a+b<<endl;
}

Measured memory_bytes: 256