akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;

// Frog1
// int frog(int i, int n, vector<int> arr) {
// 	if (i >= n)
// 		return INT_MAX / 2;

// 	if (i == n - 1)
// 		return 0;

// 	int op1 = abs(arr[i] - arr[i + 1]) + frog(i + 1, n, arr);
// 	int op2 = abs(arr[i] - arr[i + 2]) + frog(i + 2, n, arr);
// 	return min(op1, op2);
// }


// int frog2(int i, int n, int k, vector<int> arr) {
// 	if (i >= n)
// 		return INT_MAX / 2;

// 	if (i == n - 1)
// 		return 0;

// 	int ans = abs(arr[i] - arr[i + 1]) + frog2(i + 1, n, k, arr);
// 	for (int j = 2; j <= k; j++) {
// 		if (i + j < n)
// 			ans = min(ans, abs(arr[i] - arr[i + j]) + frog2(i + j, n, k, arr));
// 	}
// 	return ans;
// }

int dp[1000000][3];
int Vac(int arr[][3], int i, int n, int last) {
	if (i >= n)
		return 0;

	if (last >= 0 && dp[i][last] != -1)
		return dp[i][last];

	int max_ele = INT_MIN;
	for (int j = 0; j < 3; j++) {
		if (j != last) {
			max_ele = max(arr[i][j] + Vac(arr, i + 1, n, j), max_ele);
		}
	}
	if (last >= 0)
		dp[i][last] = max_ele;
	return max_ele;
}


int main() {
	
	int n;
	cin >> n;
	// vector<int> arr(n);
	// for (int i = 0; i < n; i++)
	// 	cin >> arr[i];
	// dp.resize(n, vector<int>(3, -1));
	memset(dp, -1, sizeof(dp));
	// vector<vector<int>> arr(n, vector<int>(3));
	int arr[n][3];
	for (int i = 0; i < n; i++)
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];

	cout << Vac(arr, 0, n, -1);
	// vector<int> dp(n, INT_MAX);
	// dp[0] = 0;
	// for (int i = 0; i < n; i++) {
	// 	for (int j = 1; j <= k; j++) {
	// 		if (i + j < n) {
	// 			dp[i + j] = min(dp[i + j], abs(arr[i] - arr[i + j]) + dp[i]);
	// 		}
	// 	}
	// }
	// cout << dp[n - 1];
	// cout << frog2(0, n, k, arr);
	// cout << frog(0, n, arr);
	// vector<int> dp(n);
	// dp[0] = 0;
	// dp[1] = abs(arr[0] - arr[1]);
	// for (int i = 2; i < n; i++) {
	// 	int one = dp[i - 1] + abs(arr[i] - arr[i - 1]);
	// 	int two = dp[i - 2] + abs(arr[i] - arr[i - 2]);
	// 	dp[i] = min(one, two);
	// }
	// cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 25784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define For(i,n) for(ll int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(a,b,c) for(ll a=b;a<c;a++)
#define M 1000000007
/*
TOO MUCH TO LEARN
 	ostringstream str1;
    str1 << c;
    string x = str1.str();
 
    accumulate(a,b,sum)
*/
//............
//set
/*
set <ll> :: iterator itr;
if (b.find(a[i]) != b.end())
*/
//............
//queue
/*
void Print(queue<ll>& Queue)
{
    while (!Queue.empty()) {
        cout << Queue.front() << " ";
        Queue.pop();
    }
}
 
// Function to reverse the queue
void reverseQueue(queue<ll>& Queue)
{
    stack<ll> Stack;
    while (!Queue.empty()) {
        Stack.push(Queue.front());
        Queue.pop();
    }
    while (!Stack.empty()) {
        Queue.push(Stack.top());
        Stack.pop();
    }
}
*/
/*
ll power(ll x, ll y, ll m)
{
    ll res = 1;      // Initialize result
 
    x = x % m;  // Update x if it is more than or
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % m;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % m;
    }
    return res;
}
*/
 
// ll knapSack(ll W, ll wt[], ll val[], ll n) 
// { 
//    ll i, w; 
   
  
//    // Build table K[][] in bottom up manner 
//    for (i = 0; i <= n; i++) 
//    { 
//        for (w = 0; w <= W; w++) 
//        { 
//            if (i==0 || w==0) 
//                K[i][w] = 0; 
//            else if (wt[i-1] <= w) 
//                  K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
//            else
//                  K[i][w] = K[i-1][w]; 
//        } 
//    } 
  
//    return K[n][W]; 
// } 
int main()
{
	fast;
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    For(i,n)
    {
        cin>>w[i]>>v[i];
    }
    ll a[100005]={0};
    For(i,n)
    {
        for(ll j=W;j>=1;j--)
        {
            if(w[i]<=j)
            {
                a[j]=max(a[j],a[j-w[i]]+v[i]);
            }
        }
    }
    ll c=0;
    For(i,W+1)c=max(c,a[i]);
    cout<<c<<endl;
}


Measured memory_bytes: 1024
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll maxa = 0;
    vll a(n); REP(i, n) {
        cin >> a[i];
        chmax(maxa, a[i]);
    }

    vll ans(n, 0);
    vll rem(n, 0);
    vll ac(n, 0);
    ll ret = 1;
    REP(i, n) {
        ac[a[i]]++;
        if (ac[a[i]] > 3 || (a[i] != 0 && ac[a[i] - 1] < ac[a[i]])) ret = 0;
        if (a[i] == 0) rem[0]++, ans[i] = 1;
        else {
            ans[i] = rem[a[i] - 1];
            rem[a[i] - 1]--;
            rem[a[i]]++;
        }
    }

    REP(i, n) (ret *= ans[i]) %= MOD;
    if (ac[0] == 1) (ret *= 3) %= MOD;
    else (ret *= 6) %= MOD;

    cout << ret << '\n';
    return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
#include<string.h>
int main(void)
{
    char a[200];
	int h,i,j,flg;
	scanf("%s",&a);
	h=strlen(a);
	while(1){
	    h--;
		j=0;
		flg=0;
		if(h%2==0){
		    for(i=0;i<h/2;i++){
			    if(a[i]!=a[h/2+j]){
				    flg=1;
				}
				j++;
			}
			if(flg==0) break;
		}
	}
	printf("%d\n",h);
	return 0;
}

Measured memory_bytes: 128
import queue


def bfs01(s: int, t: int, V: int, graph: list)->int:
    INF = float('inf')

    q = queue.deque([])
    qc = 0
    l = [INF] * V

    q.append(s)
    qc += 1
    l[s] = 0

    while qc > 0:
        u = q.popleft()
        qc -= 1
        for v, c in graph[u]:
            if l[u] + c < l[v]:
                l[v] = l[u] + c
                qc += 1
                if c == 0:
                    q.appendleft(v)
                else:
                    q.append(v)

    return l[t]


def small_multiple(K: int)->int:
    graph = []
    for k in range(K):
        graph.append([])
        v1 = k+1 if k+1 < K else 0
        v10 = (k*10) % K

        graph[k].append((v1, 1))
        if v10 != k:
            graph[k].append((v10, 0))

    return bfs01(1, 0, K, graph) + 1


if __name__ == "__main__":
    K = int(input())
    ans = small_multiple(K)
    print(ans)


Measured memory_bytes: 35816
fun main(args: Array<String>) {
    val (x, y, a, b, c) = readLine()!!.split(' ').map { it.toInt() }
    val p = readLine()!!.split(' ')
            .map { it.toLong() }
            .sortedDescending()
            .take(x)
    val q = readLine()!!.split(' ')
            .map { it.toLong() }
            .sortedDescending()
            .take(y)
    val r = readLine()!!.split(' ')
            .map { it.toLong() }
            .sortedDescending()

    val xs = (p + q).sorted().toLongArray()

    for (i in 0 until c) {
        if (r[i] > xs[i]) {
            xs[i] = r[i]
        } else {
            break
        }
    }

    println(xs.sum())
}


Measured memory_bytes: 108672
import java.util.*;

public class Main {

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

        if(a%2 == 0) {
            System.out.println(a/2);
        }else {
            System.out.println(a/2 + a%2);
        }

    }
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int a[100010];

int main() {
	cin >> N;
	rep(i, N) cin >> a[i];
	sort(a, a + N, greater<int>());

	int i = 0;
	while (i + 1 < N && a[i + 1] > i + 1) ++i;

	int p = a[i] - i;

	int j = i;
	while (j + 1 < N && a[j + 1] > i) ++j;

	int q = j - i + 1;

	if (p % 2 == 1 && q % 2 == 1) {
		puts("Second");
	} else {
		puts("First");
	}

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d %d %d %d" , &a,&b,&c,&d);
    char x;
    if(a+b-c-d<0)printf("Right");
        
    else if(a+b-c-d== 0)printf("Balanced");
    
    else printf("Left");

    return 0;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n in O(log(n)) time

const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;

/*********** variables ************/
string S;
/**********************************/


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    int n = 1;
    UP(i, 1, (int)S.size()-1) {
        if(S[i-1] != S[i]) n++;
    }
    cout << n-1 << endl;
}


Measured memory_bytes: 512
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mi d + 1, r
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
struct EE{int v, w, nx;}E[M * 2 + N * 2]; int hd[N], EN;
void init_edge(int num){EN = 0; memset(hd, -1, (num + 2) << 2);}
void add_edge(int u, int v, int w){
    E[EN].w = w; E[EN].v = v; E[EN].nx = hd[u]; hd[u] = EN++;
    E[EN].w = w; E[EN].v = u; E[EN].nx = hd[v]; hd[v] = EN++;
}
//const int dir[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
int n, a[N];
LL l[N], r[N];
int main(){
  //  IN;
    SC(n);
    FF(i, 1, n) II(a[i]);
    FF(i, 1, n) l[i] = l[i - 1] + a[i];
    RR(i, n, 1) r[i] = r[i + 1] + a[i];
    LL ans = INF;
    FF(i, 1, n - 1){
        LL tmp = l[i] - r[i + 1];
        if(tmp < 0) tmp = -tmp;
        if(tmp < ans) ans = tmp;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4352
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    inf=10**6
    n,m=MI()
    cc=LI()
    dp=[inf]*(n+1)
    dp[0]=0
    for c in cc:
        for i in range(n-c+1):
            if dp[i]==inf:continue
            if dp[i]+1<dp[i+c]:dp[i+c]=dp[i]+1
    print(dp[-1])

main()



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

#define INF 100000000
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i,N) cin >> A[i];
  ll cnt = 0;
  ll zero = 0;
  sort(A.begin(),A.end());
  ll sum;
  REP(i,N) sum+=abs(A[i]);
  REP(i,N){
    if(A[i] < 0){
      cnt++;
    }
    if(A[i] == 0){
      cout << sum << endl;
      return 0;
    }
  }
  ll minv = INF;
  REP(i,N){
      minv = min(minv,abs(A[i]));
  }

  if(cnt % 2 == 0) cout << sum << endl;
  else if(cnt % 2 == 1){
   cout << sum - minv*2 << endl;
  }
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
  long long int x,  year = 0, possession = 100;
  double interest = 1.01;

  scanf("%lld", &x);

  while (x > possession)
    {
      possession = (long long int)(possession * interest);
      year++;
    }

  printf("%lld", year);

  return 0;

}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int a[101][101],num[101],dis[101];
bool vis[101];
int n,u,k,x,t=1;
queue<int> q;
int main(){
	memset(a,0,sizeof(a));
	memset(vis,false,sizeof(vis));
	memset(dis,0x1f1f1f1f,sizeof(dis));
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>u>>k;
		num[u]=k;
		int j=0;
		while (k--){
			  cin>>x;
			  a[u][++j]=x;
		}
	}
	q.push(1);
	dis[1]=0;
	while (!q.empty()){
		  x=q.front(); q.pop(); vis[x]=true;
		  for (int i=1; i<=num[x]; i++){
		  	  if (!vis[a[x][i]]){
		  	     dis[a[x][i]]=min(dis[a[x][i]],dis[x]+1);
		  	     q.push(a[x][i]);
              }
		  }
	}
    for (int i=1; i<=n; i++){
    	cout<<i<<' ';
    	if (dis[i]==0x1f1f1f1f) dis[i]=-1;
		cout<<dis[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3332
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  vector<string> str;
  string s;
  int cnt=0;
  int pointer[1000]={};
  pair<int,string> pis;
  pis=make_pair(0,"");
  while(cin>>s){
    int flag=1;
    for(int i=0;i<str.size();i++){
      if(str[i]==s){
	pointer[i]++;
	flag=0;
	break;
      }
    }if(flag){
      str.push_back(s);
      pointer[str.size()-1]++;
      if(pis.first<s.size()){
	pis.first=s.size();
	pis.second=s;
      }
    }
  }
  pair<int,int> poin;
  poin=make_pair(0,0);
  for(int i=0;i<str.size();i++){
    if(poin.first<pointer[i]){
      poin.first=pointer[i];
      poin.second=i;
    }
  }
  cout<<str[poin.second]<<" "<<pis.second<<endl;
  return 0;
}

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

long digitCount(long x) {
  long ans = 0;
  do {
    x /= 10;
    ans++;
  } while (0 < x);
  return ans;
}

int main() {
  long N;
  cin >> N;
  long B, ans = digitCount(N), sN = ceil(sqrt(N));
  for (long A = 2; A <= sN; A++) {
    if (N % A != 0) {
      continue;
    }
    B = N / A;
    long tmp = digitCount(max(A, B));
    if (tmp < ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
     
            int n;
            cin>>n;
            vector <int > a(n,0),b(n,0),c(n,0);
            for(int i=0;i<n;i++){
                    cin>>a[i]>>b[i]>>c[i];
                    }
            vector <int> dp[3];
            dp[0].resize(n,0);
            dp[1].resize(n,0);
            dp[2].resize(n,0);
            dp[0][0]=a[0];
            dp[1][0]=b[0];
            dp[2][0]=c[0];
            // dp[0][1]=max(a[0],max(b[0],c[0]))+a[1];
            // dp[1][1]=max(a[0],max(b[0],c[0]))+b[1];
            // dp[2][1]=max(a[0],max(b[0],c[0]))+c[1];
            for(int i=1;i<n;i++){
                    dp[0][i] = max(dp[1][i-1],dp[2][i-1])+a[i];
                    // dp[0][i]= max(dp[0][i],max(dp[1][i-2],dp[2][i-2])+a[i-1]+a[i]);
     
                    dp[1][i] = max(dp[0][i-1],dp[2][i-1])+b[i];
                    // dp[1][i]= max(dp[1][i],max(dp[2][i-2],dp[0][i-2])+b[i-1]+b[i]);
     
                    dp[2][i] = max(dp[1][i-1],dp[0][i-1])+c[i];
                    // dp[2][i]= max(dp[2][i],max(dp[1][i-2],dp[0][i-2])+c[i-1]+c[i]);
     
            }
            cout<<max(dp[0][n-1],max(dp[2][n-1],dp[1][n-1]))<<endl;
            // for(auto x:dp[0]) cout<<x<<" ";
            // cout<<endl;
            // for(auto x:dp[1]) cout<<x<<" ";
            // cout<<endl;
            // for(auto x:dp[2]) cout<<x<<" ";
            // cout<<endl;
            return 0;
     
     
    }

Measured memory_bytes: 2560
S=list(map(str,input()))
N=len(S)

count=0
for i in range(N):
  if i %2==0:
    if S[i]=="L":
      count+=1
    else:
      count+=0
  if i %2==1:
    if S[i]=="R":
      count+=1
    else:
      count+=0
if count==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
while True:
    N,x=list(map(int,input().split()))
    if N==x==0:
        break
    num=0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            for k in range(j+1,N+1):
                if i+j+k==x:
                    num+=1

    print(num)



Measured memory_bytes: 5596
fun main(args:Array<String>){
    val (a,d)=readLine()!!.split(" ").map{it.toInt()}
    val b=readLine()!!
    val c="[0-9]{$a}-[0-9]{$d}".toRegex()
    if (c.matches(b)){
        println("Yes")
    }else{
        println("No")
    }
}

Measured memory_bytes: 37696
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

const int RED = 1;
const int BLUE = 2;

struct point{
    int x, y, color;
};

bool compare_points(point &l, point &r){
    return l.x < r.x;
}

int main(){
    int N;
    cin >> N;
    vector<point> ps(2*N);
    for(ll i=0;i<N;i++){
        cin >> ps[i].x >> ps[i].y;
        ps[i].color = RED;
    }
    for(ll i=0;i<N;i++){
        cin >> ps[i+N].x >> ps[i+N].y;
        ps[i+N].color = BLUE;
    }
    sort(ps.begin(), ps.end(), compare_points);

    ll ans = 0ll;
    vector<point> red;
    for(ll i=0;i<2*N;i++){
        if(ps[i].color == RED){
            red.push_back(ps[i]);
        }else{
            ll y_max = -1;
            ll k = -1;
            for(ll j=0;j<red.size();j++){
                if(red[j].y < ps[i].y && y_max < red[j].y){
                    y_max = red[j].y;
                    k = j;
                }
            }
            if(k!=-1){
                red.erase(red.begin() + k);
                ans++;
            }
        }
    }

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




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

int main(){
    int N;
    cin>>N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin>>v.at(i);
    }
    sort(v.begin(),v.end());
    
    double ans = v.at(0);
    
    for(int i=1;i<N;i++){
        ans = (ans+v.at(i))/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define triplell pair<pair<ll,ll> , ll>
#define triple pair<pair<int,int> , int>
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Forn(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define forba(i,a,b) for(int i=(int)b;i>=(int)a;i--)

int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};

const int MAXN = (int)1e5+9;

const int N = 100000;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */
    
    int i,j,k,l,m,n,p,q,r,tc,t;
    
    int h,w,h1,w1;
    
    cin>>h>>w;
    cin>>h1>>w1;
    
    h-=h1;
    w-=w1;
    cout<<h*w<<endl;
	
//	main();
    return 0;
}

Measured memory_bytes: 256
//input.c
#include <stdio.h>
 
int main(void)
{
  int N;
  int A;
  int B;
  scanf("%d %d %d",&N,&A,&B);
 
  int max_both_reader = ( A < B )?A:B;
  int min_both_reader = (max_both_reader-(N-((A<B)?B:A)));
  min_both_reader = (min_both_reader<0)?0:min_both_reader;
 
  printf("%d %d",max_both_reader,min_both_reader);
  return 0;
}

Measured memory_bytes: 128
#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;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;

    int n;
    cin>>n;
    int arr[n];
    int sum = 0;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    int b = arr[0];
    for(int i=0; i<n; i++) {
        sum += max(0ll , b-arr[i]);
        b = max(b , arr[i]);
    }
    cout<<sum<<"\n";
}



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

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

    vector<pair<int, int>> X(N);
    int A;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        X[i] = make_pair(A, i);
    }
    sort(X.begin(), X.end());

    for (pair<int, int> x : X)
    {
        cout << x.second + 1 << " ";
    }
    cout << endl;
}


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

int main(){
  int64_t n;
  cin >> n;
  std::vector<int64_t> a(3 * n, 0);
  for (int i = 0; i < 3 * n; ++i) {
    cin >> a[i];
  }

  sort(a.begin(), a.end(), std::greater<int64_t>());
  int64_t total = 0;
  for (int i = 0; i < n; ++i) {
    total += a[i * 2 + 1];
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 2560
N, M, C = gets.chomp.split(" ").map(&:to_i)
sources = []
correct = 0
B = gets.chomp.split(" ").map(&:to_i)
N.times do
  sources << gets.chomp.split(" ").map(&:to_i)
end
for i in 0...N
  point = 0
  for j in 0...M
    point += B[j] * sources[i][j]
    if j == M-1
      correct += 1 if point + C > 0
    end
  end
end
puts correct

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define INF 1<<15

int main(){
	int n,m;
	int s,t,d;
	int e[15][15];
	int dp[1<<15][15];
	
	scanf("%d %d",&n,&m);
	for(int i=0;i<15;i++) fill_n(e[i],15,INF);
	for(int i=0;i<m;i++){
		scanf("%d %d %d",&s,&t,&d);
		e[s][t]=d;
	}
	
	for(int i=0;i<(1<<n);i++) fill_n(dp[i],n,INF);
	dp[(1<<n)-1][0]=0;
	
	for(int i=(1<<n)-2;i>=0;i--){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(!((i>>k)&1))
				dp[i][j]=min(dp[i][j],dp[i|1<<k][k]+e[j][k]);
			}
		}
	}
	printf("%d\n",(dp[0][0]==INF ? -1 : dp[0][0]));
}


Measured memory_bytes: 5128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;


//constant
const int MOD = 1e9+7;
const int INF = 1e18;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};
const double pi = acos(-1);


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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n
//memset(obj,value,sizeof(obj));




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> A(n);
    
    int abssum = 0;
    int absmin = INF;
    int count  = 0;
    
    rep(i,n) {
        cin >> A[i];
        absmin = min(absmin,abs(A[i]));
        abssum += abs(A[i]);
        count += (A[i]<0)?1:0;
    }
    int ans;
    if(count%2){
        ans = abssum - absmin*2;
    }else{
        ans = abssum;
    }
    
    cout << ans << endl;
    
    
    
    

    
    
    
    
}





signed main() {
    solve();
    return 0;
}




Measured memory_bytes: 1024
#!/usr/bin/env python3
# coding=utf-8

import sys

import numpy as np

num_max = 100000
primes = np.asarray([True for _ in range(num_max + 1)])
for i in range(num_max + 1):
    if i == 0 or i == 1:
        primes[i] = False
    elif primes[i]:
        primes[i * 2::i] = False
primes = set(np.arange(num_max + 1)[primes])
like2017 = [1 if i in primes and (i + 1) // 2 in primes else 0 for i in range(num_max + 1)]
cumsum = np.cumsum(like2017)

q = int(sys.stdin.readline().strip())
for _ in range(q):
    l, r = sys.stdin.readline().strip().split(" ")
    l = int(l)
    r = int(r)
    print(cumsum[r] - cumsum[l - 1])


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

int main() {
  int a,b;
  cin >> a >> b;
  if (a>0){
  cout << "Positive" << endl;  
  }
  else if (a<=0 && b>=0){
  cout << "Zero" << endl;
  }
  else {
  int c=0;
  c=b-a;
  if (c%2==0){
  cout << "Negative" << endl;
  }
  else {
  cout << "Positive" << endl;
  }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main (void) {

    do {
        int a, l;
        cin >> a >> l;
        if (a == 0 && l ==0) { break; }

        vector<int> log_a;
        log_a.push_back(a);
        bool isEnd = false;
        int loop_cnt = 1;

        do {
            int as[l];
            for (int i=0; i<l; i++) {
                as[i] = (a == 0) ? 0 : a % 10;
                a = a / 10;
            }

            sort(as, as+l);
            int maxa=0, mina=0, newa;
            for (int j=0; j<l; j++) {
                mina += as[j] * pow(10.0, (l-1-j));
                maxa += as[j] * pow(10.0, j);
            }

            a = maxa - mina;

            for (int i=0; i<loop_cnt; i++) {
                if (log_a[i] == a) {
                    isEnd = true;
                    log_a.push_back(a);
                    cout << i << ' ' << log_a[loop_cnt] << ' ' << loop_cnt-i << endl;
                    break;
                }
            }

            log_a.push_back(a);
            loop_cnt++;
        } while (!isEnd);



    } while (true);

    return 0;
}

Measured memory_bytes: 1260
def find_the_remainder(p)
  length = p.length
  output = []
  minv = p[0]
  for i in 1..(length-1)
    # p "minv = #{minv}"
      if minv > p[i]
        minv = p[i]
      else
      result = (p[i]) - (minv)
        output.push(result)
      end
      if output == []
        output.push(p[1]-p[0])
      end
  end
  return output
end

# def find_the_remainder(p)
#   length = p.length
#   maxv = 20000000000001
#   minv = -2000000000001
#   for i in 0..(length-1)
#     if maxv <
# end
n = gets.chomp.to_i
input_values = []
n.times do
  input_value = gets.chomp.to_i
  input_values.push(input_value)
end

puts find_the_remainder(input_values).uniq.max

Measured memory_bytes: 25880
#include <string>
#include <iostream>
using namespace std;
int N, M, K;
int main() {
	cin >> N >> M >> K;
	bool ret = false;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (i * (M - j) + j * (N - i) == K) ret = true;
		}
	}
	cout << (ret ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	pii a[n + 1];
	for(int i = 1; i <= n; i++) {
		cin >> a[i].fi;
		a[i].se = i;
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int dp[n + 2][n + 2];
	memset(dp, 0, sizeof(dp));
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < i; j++) {
			dp[j + 1][n - i + j + 2] = max(dp[j + 1][n - i + j + 2], dp[j][n - i + j + 2] + a[i].fi * abs(a[i].se - (j + 1)));
			dp[j][n - i + j + 1] = max(dp[j][n - i + j + 1], dp[j][n - i + j + 2] + a[i].fi * abs(a[i].se - (n - i + j + 1)));
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; i++) {
		ans = max(ans, dp[i][i + 1]);
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 34996
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    int n;
    cin >> n;

    vector<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    ll ans = 1;
    ll tmp = v[0];
    for(int i = 0; i < n; i++){
        if( tmp > v[i] ){
            tmp = v[i];
            ans ++;
        }
    }
    cout << ans << endl;

}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(ll i=0; (i)<(n); ++(i))

ll n;

bool judge(vector<ll> &a, ll m, ll i = 0){
  if(m == 0) return true;
  if(i >= n) return false;
  return judge(a, m, i+1) || judge(a, m-a[i], i+1);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll q; cin >> q;
  ll m;
  REP(i,q){
    cin >> m;
    if(judge(a, m)) cout << "yes" << "\n";
    else cout << "no" << "\n";
  }
  return 0;
}


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

ll solve() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll a1 = min(A,B);
    ll a2 = max(A+B-N,0LL);
    cout << a1 << " " << a2 << "\n";
    return 0;
}

int main() {
    auto ans = solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        
        String S = scanner.next();
        String T = scanner.next();
        int count = 0;
        
        for(int i=0; i<S.length(); i++){
            if(S.charAt(i)!=T.charAt(i)){
                count++;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 41628
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    A = LI()
    print("bust" if sum(A) >= 22 else "win")

if __name__ == '__main__':
    main()

Measured memory_bytes: 76752
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int a[4];
 string t;
 cin>>t;
 for(int i=0;i<4;i++){
   a[i]=t[i]-'0';
 }
 for(int s=0;s<(1<<3);s++){
   int sum=a[0];
   string S;
   S+=(char)('0'+a[0]);
   for(int i=0;i<3;i++){
     if(s>>i&1){
       sum+=a[i+1];
       S+='+';
       S+=(char)('0'+a[i+1]);
       }
     else{
       sum-=a[i+1];
       S+='-';
       S+=(char)('0'+a[i+1]);
       }
     }
     if(sum==7){
       cout<<S<<"=7"<<endl;
       return 0;
     }
   }
 return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n,k;
int a[maxn];
int place[maxn],att[maxn];

int32_t main()
{
    IOS
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>a[i];

    int now=1,cnt=1;
    place[1]=1,att[1]=1;
    k++;
    while (1)
    {
        now=a[now];
        if (place[now]) break;
        place[now]=++cnt;
        att[place[now]]=now;

        if (place[now]==k)
        {
            cout<<now<<endl;
            return 0;
        }
    }
    //cout<<(k-cnt-1)%(cnt-place[now]+1)+place[now]<<endl;
    cout<<att[(k-cnt-1)%(cnt-place[now]+1)+place[now]]<<endl;
}



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

int main(){
    int n;cin>>n;
    int a[200010];
    rep1(i,n)cin>>a[i];
    int index = 1;
    int cnt=0;
    rep1(i,n){
        if(a[i]==index)index++;
        else{cnt++;}
    }
    co((index==1)?(-1):(cnt));
}

Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readStrLines :: IO [BC.ByteString]
readStrLines = BC.lines <$> BC.getContents

countUp :: [BC.ByteString] -> [Int] ->  [Int]
countUp [] march = march
countUp (s:ss) [m, a, r, c, h]
  | BC.head s == 'M' = countUp ss [m + 1, a, r, c, h]
  | BC.head s == 'A' = countUp ss [m, a + 1, r, c, h]
  | BC.head s == 'R' = countUp ss [m, a, r + 1, c, h]
  | BC.head s == 'C' = countUp ss [m, a, r, c + 1, h]
  | BC.head s == 'H' = countUp ss [m, a, r, c, h + 1]
  | otherwise = countUp ss [m, a, r, c, h]

comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

main :: IO ()
main = do
  getLine
  ss <- readStrLines
  print . sum . map product . comb 3 $ countUp ss [0, 0, 0, 0, 0]


Measured memory_bytes: 2556
#include<cstdio>
#include<algorithm>
#define mo 1000000007
#define x first
#define y second
using namespace std;
using LL=long long;

pair<int,int> P[3005];
int h,w,n,ind[3005],dp[3005],fac[200005];

int quick_power(int a, int b)
{
	int res=1,base=a;
	while(b)
	{
		if(b&1)
			res=(LL)res*base%mo;
		base=(LL)base*base%mo;
		b>>=1;
	}
	return res;
}

int get_C(int a, int b)
{
	return (LL)fac[a]*quick_power(fac[b],mo-2)%mo*quick_power(fac[a-b],mo-2)%mo;
}

int main()
{
	scanf("%d%d%d",&h,&w,&n);
	fac[0]=1;
	for(int i=1;i<=h+w;i++)
		fac[i]=(LL)fac[i-1]*i%mo;
	P[n+1]={h,w};
	for(int i=1;i<=n;i++)
		scanf("%d%d",&P[i].x,&P[i].y);
	n++;
	sort(P+1,P+n+1);
	for(int i=1;i<=n;i++)
		dp[i]=get_C(P[i].x+P[i].y-2,P[i].x-1);
	for(int u=1;u<n;u++)
		for(int j=u+1;j<=n;j++)
			if(P[j].y>=P[u].y)
				dp[j]=(dp[j]-(LL)dp[u]*get_C(P[j].x+P[j].y-P[u].x-P[u].y,P[j].x-P[u].x)%mo+mo)%mo;
	printf("%d",dp[n]);
	return 0;
}

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

int main(){
  string S;
  cin >> S;

  int yyyy = atoi(S.substr(0, 4).c_str());
  int mm = atoi(S.substr(5, 2).c_str());
  int dd = atoi(S.substr(8, 2).c_str());

  if (yyyy < 2019) {
	cout << "Heisei" << endl;
  } else if (yyyy > 2019) {
	cout << "TBD" << endl;
  } else{
	if (mm > 4) {
	  cout << "TBD" << endl;
	} else {
	  cout << "Heisei" << endl;
	}
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
struct edge
{
	int next,to,sum;
	edge(){}
	edge(int x,int y,int z):next(x),to(y),sum(z){}
}e[maxn*2];
int h[maxn],cnt;
void build(int x,int y,int z)
{
	e[++cnt]=edge(h[x],y,z);
	h[x]=cnt;
}
int n,ans[maxn];
void dfs(int x,int fa)
{
	int y;
	for(int i=h[x];i;i=e[i].next)
	{
		y=e[i].to;
		if(y==fa)continue;
		if(e[i].sum&1)ans[y]=ans[x]^1;
		else ans[y]=ans[x];
		dfs(y,x);
	}
}
int main()
{
	int x,y,z;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d %d %d",&x,&y,&z);
		build(x,y,z),build(y,x,z);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}

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

using namespace std;

int main() {
    int n, a; cin >> n;
    vector<int> nums;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        nums.push_back(a);
    }
    auto res = 0ll;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            res += nums[i] * nums[j];
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <cmath>
#include <utility>

int brCif(int x)
{
    int br=0;
    while (x)
    {
        x/=10;
        br++;
    }
    return br;
}

std::map<std::pair<int,int>,int> mapa;

int main()
{
    int n;
    std::cin>>n;
    int sum1=0,sum2=0;
    for (int i=1; i<=n; i++)
    {
        int prva=i/pow(10,brCif(i)-1),zadnja=i%10;
        if (prva==zadnja)
            sum1++;;
        sum2+=mapa[std::make_pair(zadnja,prva)];
        mapa[std::make_pair(prva,zadnja)]++;
    }
    std::cout<<sum1+sum2*2;
    return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
const int maxn=1e5+5;
int sz[maxn],par[maxn],n,m,ans;
pair<int,int>arr[maxn];
vector<int>vec;
void init()
{
	for(int i=0;i<=n;i++)
		par[i]=i,sz[i]=1;
}
int root(int i)
{
	while(par[i]!=i)
	{
		par[i]=par[par[i]];
		i=par[i];
	}
	return i;
}
void merge(int x,int y)
{
	x=root(x);
	y=root(y);
	if(x==y)return;
	ans-=sz[x]*sz[y];
	if(sz[y]>sz[x])swap(x,y);
	par[y]=x;
	sz[x]+=sz[y];
}
signed main()
{
	cin>>n>>m;
	init();
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		arr[i]={a,b};
	}
	ans=(n*(n-1))/2;
	for(int i=m-1;i>=0;i--)
	{
		vec.emplace_back(ans);
		merge(arr[i].first,arr[i].second);
	}
	reverse(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;
	return 0;
}

Measured memory_bytes: 5364
#include <iostream>

using namespace std;

int main(void) {
  int l;
  int a, b;
  int c, d;
  int i;

  cin >> l >> a >> b >> c >> d;

  for(i = 1; ; i++) {
    a -= c;
    b -= d;
    if(a <= 0 && b <= 0) break;
  }

  cout << l - i << endl;

  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if(a < b){
          System.out.println("a < b");
        }else if(a > b){
          System.out.println("a > b");
        }else if(a == b){
          System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 26292
N,Y=map(int,input().split())
A=[]
for i in range(Y//10000+1):
    for j in range((Y-i*10000)//5000+1):
        c1=(Y-10000*i-5000*j)//1000
        c2=N-i-j
        if c1==c2:
            A=[i,j,c1]
            break
        if c1!=c2:
            continue
if len(A)==0:
    print("-1 -1 -1")
else:
    A[2]=int(A[2])
    #intは整数、floatは少数
    print(str(A[0])+" "+str(A[1])+" "+str(A[2]))


Measured memory_bytes: 3064
import sys
S=input()
N=len(S)
#L=['B','D','E','F','G','H','I','J','K','L','N','M','O','P','Q','R','S','T','U','V','W','X','Y','Z']
if S[0]!='A':
    print('WA')
    sys.exit()
ans=0
for i in range(2,N-1) :
    if S[i]=='C':
        ans+=1
if ans!=1:
    print('WA')
    sys.exit()
num=0
for i in range(N) :
    if S[i]>='A' and S[i]<='Z':
        num+=1
if num!=2:
    print('WA')
    sys.exit()
print('AC')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define vpli vector<pair<long long,int>>
#define deb(x) cout<<x<<endl;
ll MOD = 1e9+7;
void solve()
{
 int n;
 cin>>n;
 vi a(n);
 int res = 0;
 for(int &x : a)
 {
     cin>>x;
     res = res^x;
 }
 for(int &x : a)
 {
     cout<<(res^x)<<" ";
 }
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 4028
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int N, K;
int main(int argc, char const *argv[]) {
  cin >> N >> K;
  vector<int> l(N);
  for (size_t i = 0; i < l.size(); i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  reverse(l.begin(),l.end());
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum+=l[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace Contest
{
    

    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ");
            var a = decimal.Parse(input[0]);
            var b = decimal.Parse(input[1]);

            Console.WriteLine(Decimal.Floor(a * b));
            
        }
    }
}




Measured memory_bytes: 27584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

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


int n, k;
int a[101];
int dp[101][100005];

int solve(int ind, int left) {
	if (left == 0) return 1;
	if (ind == 0 or left < 0) return 0;

	int &ans = dp[ind][left];

	if (ans != -1) return ans;

	ans = solve(ind, left - 1);
	ans = (ans + solve(ind - 1, left)) % mod;
	ans = (ans - solve(ind - 1, left - a[ind - 1] - 1) + mod) % mod;
	return ans;
}

signed main() {

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

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n >> k;
	for0(i, n) cin >> a[i];

	memset(dp, -1, sizeof(dp));

	cout << solve(n, k) << endl;

	return 0;
}

Measured memory_bytes: 90264
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int n = str.length();
		boolean flag = true;
		for(int i = 0; i < n/2; i++) {
			if(str.charAt(i)!=str.charAt(n-1-i)) {
				flag = false;
			}
		}

		String fstr = str.substring(0,(n-1)/2);
		for(int i = 0; i < fstr.length()/2; i++) {
			if(fstr.charAt(i)!=fstr.charAt(fstr.length()-1-i)) {
				flag = false;
			}
		}

		String lstr = str.substring((n+3)/2-1,n);
		for(int i = 0; i <lstr.length()/2; i++) {
			if(lstr.charAt(i)!=lstr.charAt(lstr.length()-1-i)) {
				flag = false;
			}
		}
		if(flag) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844