akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int c[1001],w[1001];
int sum[1001];
bool can[1001][1001];
int dp[1001];
int main() {
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		scanf("%d %d",&c[i],&w[i]);
		sum[i]=sum[i-1]+w[i];
	}
	for(int i=1;i<=N;i++) can[i][i]=1;
	for(int i=1;i<=N-1;i++) {
		for(int j=1;j+i<=N;j++) {
			can[j][i+j]|=(can[j+1][j+i] && (sum[j+i]-sum[j])<=c[j]);
			can[j][i+j]|=(can[j][j+i-1] && (sum[j+i-1]-sum[j-1])<=c[j+i]);
		}
	}
	fill(dp,dp+(N+1),1<<29);
	dp[0]=0;
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=i;j++) {
			if(can[j][i]) {
				dp[i]=min(dp[i],dp[j-1]+1);
			}
		}
	}
	printf("%d\n",dp[N]);
}

Measured memory_bytes: 2016
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 k = sc.nextInt();
		
		int count = 0;
		int p = Math.max(a, b);
		for(int i = Math.min(a, b); i > 0; i--) {
			if(a % i == 0 && b % i == 0) {
				count++;
			    p = Math.min(i, p);
			}
			if(count == k)
				break;
		}
		
		System.out.println(p);

	}

}


Measured memory_bytes: 21972
N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

cnt=0
if max(x)>=min(y):
    cnt=1
    print('War')
else:
    for i in range(X+1,Y+1,1):
        if max(x)<i and i<=min(y):
            print('No War')
            cnt=1
            break
        else:
            pass
if cnt==0:
    print('War')

Measured memory_bytes: 38492
#include<bits/stdc++.h>
using namespace std;
int main(){
  long double a;
  string b;
  cin >> a >> b;
  long double ans = 0;
  int n = b.length();
  for(int i = 0; i < n; ++i){
    if(b[i] == '.') continue;
    ans += a * ((long double)(b[i] - '0'));
    a /= (long double)10;
  }
  cout << (long long)ans << endl;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum > N) cout << -1 << endl;
    else cout << N-sum << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(new InputStreamReader(System.in));
		int a,b,s,l;
		a=sc.nextInt();
		b=sc.nextInt();
		sc.close();
		s=a*b;
		l=2*(a+b);
		System.out.println(s+" "+l);
	}
}

Measured memory_bytes: 26224
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


vi dots[MX];
int p[MX];
int sz[MX];

int get(int v) {
	if (p[v] == v)
		return v;
	return p[v] = get(p[v]);
}

void unite(int a, int b) {
	int pa = get(a);
	int pb = get(b);
	if (pa == pb)
		return;
	if (sz[pa] < sz[pb])
		swap(pa, pb);
	sz[pa] += sz[pb];
	p[pb] = pa;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    fi(0, n) {
    	int x, y;
    	cin >> x >> y;
    	dots[x].push_back(y);
    }
    fi(0, MX) {
    	sz[i] = 1;
    	p[i] = i;
    }
    fi(0, MX) {
    	if (dots[i].empty())
    		continue;
    	int v = dots[i].back();
    	fj(0, siz(dots[i]) - 1)
    		unite(dots[i][j], v);
    }
    int sum = -n;
    fi(0, MX) {
    	if (dots[i].empty())
    		continue;
    	sum += sz[get(dots[i][0])];
    }
    cout << sum << '\n';
}

Measured memory_bytes: 6016
a, b, c = map(int, input().split())
d = list(map(int, input().split()))
g = 0
for i in range(a):
    e = list(map(int, input().split()))
    f = 0
    for j in range(b):
        f += d[j] * e[j]
    if f + c > 0:
        g += 1
print(g)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;

int color[12][12];
int ourx, enemyx;
void dfs() {

}

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

	ll a, b, x;
	cin >> a >> b >> x;
	if (a<=x&&a+b>=x)
		cout << "YES" << endl;
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	if n < 10 {
		fmt.Println("ABC00" + strconv.Itoa(n))
	} else if n < 100 {
		fmt.Println("ABC0" + strconv.Itoa(n))
	} else {
		fmt.Println("ABC" + strconv.Itoa(n))
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <tuple>
#include <chrono>
#include <bitset>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define debug false
#define ll long long

ll fabs(ll x) {
    return x >= 0LL ? x : -1LL * x;
}

ll fmax(ll x, ll y) {
    return x >= y ? x : y;
}

ll fmin(ll x, ll y) {
    return x >= y ? y : x;
}

bool is_even(ll x) {
    return x % 2 == 0;
}

bool is_odd(ll x) {
    return !is_even(x);
}

struct seq {
    ll x1, y1, x2, y2;
};

ll gcd(ll x, ll y) {
    return y == 0 ? x : gcd(y, x % y);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, x;
    cin >> n >> x;
    
    vector<ll> d(n);
    forn (i, n) cin >> d[i];
    
    sort(d.begin(), d.end());
    
    int count = 0;
    int i = 0;
    bool last_used = true;
    while (x > 0 && i < n) {
        if (x - d[i] >= 0) {
            x -= d[i];
            count++;
            i++;
        } else {
            last_used = false;
            break;
        }
    }
    
    if (x > 0 && i == n && last_used) {
        count--;
    }
    
    cout << count << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
 
#define NUMS 4
#define NUMR 13
 
int tonum(char ch){
  if('2' <= ch && ch <= '9') return ch - '0';
  else switch(ch){
    case 'T': return 10;
    case 'J': return 11;
    case 'Q': return 12;
    case 'K': return 13;
    case 'A': return 14;
    case 'C': return 4;
    case 'D': return 3;
    case 'H': return 2;
    case 'S': return 1;
    }
 
  return -1;
}
signed main(){
 
  while(true){
    char Trump, temp;
    int NS = 0, EW = 0, now = 0;
    string card[NUMS][NUMR];
     
    cin>>Trump;
 
    if(Trump == '#') break;
 
    for(int i = 0; i < NUMS; i++){
      for(int j = 0; j < NUMR; j++){
    cin>>card[i][j];
      }
    }
 
    for(int i = 0; i < NUMR; i++){
      int maxS = -1, maxH = -1, maxD = -1, maxC = -1, maxT = -1, maxO = -1;
      int maxSj = -1, maxHj = -1, maxDj = -1, maxCj = -1, maxTj = -1, maxOj = -1;
      temp = card[now][i][1];
      // cout<<"i = "<<i<<" now "<<now<<" "<<temp<<endl;
      for(int j = 0; j < NUMS; j++){
 
    if(card[j][i][1] == Trump && maxT < tonum(card[j][i][0])) maxT = tonum(card[j][i][0]), maxTj = j;
    else if(card[j][i][1] != Trump && card[j][i][1] == temp && maxO < tonum(card[j][i][0])) maxO = tonum(card[j][i][0]), maxOj = j;
    //else if(card[j][i][1] != Trump && maxO < tonum(card[j][i][0])) maxO = tonum(card[j][i][0]), maxOj = j;
    //  else if(card[j][i][1] != Trump && maxO == tonum(card[j][i][0]) && tonum(card[maxOj][i][1]) < tonum(card[j][i][1]))  maxO = tonum(card[j][i][0]), maxOj = j;
    switch(card[j][i][1]){
    case 'S': if(maxS < tonum(card[j][i][0])) maxS = tonum(card[j][i][0]), maxSj = j; break;
    case 'H': if(maxH < tonum(card[j][i][0])) maxH = tonum(card[j][i][0]), maxHj = j; break;
    case 'D': if(maxD < tonum(card[j][i][0])) maxD = tonum(card[j][i][0]), maxDj = j; break;
    case 'C': if(maxC < tonum(card[j][i][0])) maxC = tonum(card[j][i][0]), maxCj = j; break;
 
    }
      }
 
      if(maxT != -1){
     
    //  cout<<"i = "<<i<<" maxTj "<<maxTj<<endl;
    if(maxTj == 0 || maxTj == 2) {
      NS++;
    } else {
      EW++;
      //  cout<<"WE i = "<<i<<endl;
    }
    now = maxTj;
      } else {
     
    //  cout<<"i = "<<i<<" maxOj "<<maxOj<<endl;
     
    if(maxOj == 0 || maxOj == 2) NS++;
    else {
      EW++;
      // cout<<"WE i = "<<i<<endl;
    }
    now = maxOj;
    /*
    if(maxCj == 0 || maxCj == 2){
      NS++;
    } else if(maxCj == 1 || maxCj == 3){
      EW++; cout<<"cWE i = "<<i<<" "<<maxC<<endl;
    } else  if(maxDj == 0 || maxDj == 2){
      NS++;
    } else if(maxDj == 1 || maxDj == 3){
      EW++; cout<<"dWE i = "<<i<<endl;
    } else  if(maxHj == 0 || maxHj == 2){
      NS++;
    } else if(maxHj == 1 || maxHj == 3){
      EW++; cout<<"hWE i = "<<i<<endl;
    } else  if(maxSj == 0 || maxSj == 2){
      NS++;
    } else if(maxSj == 1 || maxSj == 3){
      EW++; cout<<"sWE i = "<<i<<endl;
    }
    */
      }
    }
 
    cout<<((NS>EW)?"NS " + to_string(NS-6) : "EW " + to_string(EW-6))<<endl;
  }
 
  return 0;
}


Measured memory_bytes: 3228
import java.util.*;
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 = sc.nextInt();


        if(a+b<c){
          System.out.println("NO");
          System.exit(0);
        }
        if(a<=c){
          System.out.println("YES");
          System.exit(0);
        }
        if(a>c){
          System.out.println("NO");
          System.exit(0);
        }
  }
}

Measured memory_bytes: 23764
n = int(input())

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
for i in range(n):
    pat, rank = input().split()
    rank = int(rank)
    cards[pattern.index(pat)][rank-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)


Measured memory_bytes: 5604
N = int(input())
A = list(map(int,input().split()))
A.sort()
d = {}
n = A[-1]
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    i = 0
    for j in A:
        if i == j:
            isPrime[i] = False
            continue
        i = j
        if isPrime[i]:
            for j in range(i * 2, n + 1, i):
                isPrime[j] = False
    return isPrime
P = makePrimeChecker(n)
i = 0
ans = 0
for j in A:
    if i == j:
        continue
    else:
        i = j
        if P[i]:
            ans += 1
print(ans)

Measured memory_bytes: 32376
candy = input().rstrip().split(' ')

max = 0
sum = 0

for i in range(3):

    if i == 0:
        max = int(candy[i])
    else:
        if int(candy[i]) > max:
            sum = sum + max
            max = int(candy[i])
        else:
            sum = sum + int(candy[i])


if max == sum:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 int H, W;
 int seen[10000][10000];
  char S[10000][10000];
vector<pair<ll, ll>> prime_factorize(ll n) { //素因数分解と各素数の個数
    vector<pair<ll, ll>> res;

    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i != 0)
        {
            continue;
        }
        int num = 0;
        
        while (n % i == 0)
        {
            ++num;
            n /= i;
        }
        res.push_back(make_pair(i, num));
       
    }
     if (n != 1) 
        {
            res.push_back(make_pair(n, 1));
        }
        return res;
        
} 
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
const int MAX = 510000;
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;
}

void dfs(int st, int fi) {
  //  cout << st << " " << fi <<  endl;
    if (st < 0 || fi < 0 || st >= H || fi >= W)
    {
        return ;
    }
    if (S[st][fi] == '#')
    {
        return ;
    }

    if (seen[st][fi] == 1)
    {
        return ;
    }
    
    
    if (S[st][fi] == '.')
    {
        seen[st][fi] = 1;
    }
    

    dfs(st + 1, fi);
    dfs(st, fi + 1);
    dfs(st, fi - 1);
    dfs(st - 1, fi);
    
}
int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N), b(N);
    vector<pair<ll, ll>> pa;
    for(ll i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        pa.push_back(make_pair(a[i], b[i]));
    }

    map<ll, ll> p;

   /* for(auto i : pa) {
        cout << i.first << " " << i.second << endl;
    }*/
    for(ll i = 0; i < N; i++) {
        p[a[i]] += b[i];
    }

    
    ll sum = 0;
    ll ans = 0;
    sort(pa.begin(), pa.end());
    for(ll i = 0; i < N; i++) {
        sum += pa[i].second;
       // cout << sum << endl;
        if(sum >= K) { ans = pa[i].first; cout << ans << endl; return 0; }
        
    }

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


Measured memory_bytes: 10240
N,Q = map(int,input().split())
parents = {1:0}
for _ in range(N-1):
    a,b = map(int,input().split())
    key,val = max(a,b), min(a,b)
    parents[key] = val
counts = [0]*(N+1)
for _ in range(Q):
    p,x = map(int,input().split())
    counts[p] += x
results = [0]*(N+2)
for i in range(1,N+1):
    results[i] = counts[i]+results[parents[i]]
    print(results[i], end=' ')

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> road(n);
    vector<int> A(m),B(m);

    rep(i,m){
        cin >> A.at(i) >> B.at(i) ;
    }

    rep(i,m){
        road.at(A.at(i)-1) += 1;
        road.at(B.at(i)-1) += 1;
    }
    rep(i,n){
        cout << road.at(i) << endl;
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = int(M**0.5)
ans = []
for i in range(1, a + 1):
    if M % i == 0:
        if N * i <= M:
            ans.append(i)
        if N <= i:
            ans.append(int(M / i))
print(max(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
		using namespace std;
		#define ll long long
		#define endl "\n"
		void solve();
		int main()
		{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);

		/*#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
		#endif*/
		
			int t=1;
			//cin>>t;
			while(t--){
			solve();
			cout << endl;
			}

			cerr << "time taken : "	<< (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
			return 0;		
		}
		void solve(){
			int num;
			for (int i = 1; i <= 5; ++i)
			{
				cin>>num;
				if(num==0){
					cout<<i;
				}
			}
		}
	

Measured memory_bytes: 3772
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,m,p,q,a[300000],b[300000];
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	scanf("%d",&m);
	for (int i=1;i<=m;i++) scanf("%d",&b[i]);
	sort(a+1,a+n+1); sort(b+1,b+m+1);
	p=1; q=1;
	while (q<=m) {
		while (a[p]<b[q]) p++;
		if (p>n||a[p]!=b[q]) {
			printf("NO");
			return 0;
		}
		p++; q++;
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 1792
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数
//if(cin.eof()) break; 入力数が決まってないとき
//ifstream  whilwee(ifs>>data)

// 浮動小数点
// cout << fixed; 以下と組fみ合わせで小数点以下n桁
// cout << setprecision(n) << 値; n桁表記
// defaultfloat
int main (){
    int n;
    cin >> n;
    vei a(n);
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n-1){
            cout << a[i] << " ";
    }
    cout << a[n-1];
    cout << '\n';

    for(int i=1;i<n;i++){
        int v = a[i];
        int j = i-1;
        while(j>=0 && a[j]>v){
            a[j+1] = a[j];
            j--;
            a[j+1]=v;
        }
        REP(i,n-1){
            cout << a[i] << " ";
        }
        cout << a[n-1];
        cout << '\n';
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, cnt = 0, ans = 0;
    cin >> n;

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

    int min_p = p[0];

    for(int i = 0; i < n; i++){
        min_p = min(min_p, p[i]);
        if(min_p == p[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>

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


using namespace std;
const int NIL = -1;

node tree[10000];
int D[10000];
int H[10000];

// Calculate depth of nodes
void depth(int u, int p)
{
	D[u] = p;
	if (tree[u].right != NIL)
		depth(tree[u].right, p + 1);
	if (tree[u].left != NIL)
		depth(tree[u].left, p + 1);
}

// Calculate height of nodes
int height(int u)
{
	int h1, h2;
	h1 = h2 = 0;
	if (tree[u].left != NIL)
		h1 = height(tree[u].left) + 1;
	if (tree[u].right != NIL)
		h2 = height(tree[u].right) + 1;
	return H[u] = max(h1, h2);
}

// Preorder traversal
void preorder(int u)
{
	cout << " " << u;
	if (tree[u].left != NIL)
		preorder(tree[u].left);
	if (tree[u].right != NIL)
		preorder(tree[u].right);
}

// Inorder traversal
void inorder(int u)
{
	if (tree[u].left != NIL)
		inorder(tree[u].left);
	cout << " " << u;
	if (tree[u].right != NIL)
		inorder(tree[u].right);
}

// Postorder traversal
void postorder(int u)
{
	if (tree[u].left != NIL)
		postorder(tree[u].left);
	if (tree[u].right != NIL)
		postorder(tree[u].right);
	cout << " " << u;
}

// MAIN FUNCTION
int main(int argc, char** argv)
{
	// Input
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		tree[i].left = tree[i].parent = tree[i].right = NIL;
	}
	int degree;
	int v;
	int s;
	int pre;
	int l, r;
	for (int i = 0; i < n; i++) {
		cin >> v >> l >> r;
		tree[v].left = l;
		tree[v].right = r;
		tree[l].parent = v;
		tree[r].parent = v;
	}
	
	// Find root
	int root = 0;;
	while (tree[root].parent != NIL) {
		root = tree[root].parent;
	}
	
	// Preorder traversal
	cout << "Preorder" << endl;
	preorder(root);
	cout << endl;

	// Inorder traversal
	cout << "Inorder" << endl;
	inorder(root);
	cout << endl;

	// Postorder traversal
	cout << "Postorder" << endl;
	postorder(root);
        cout << endl;
	
	// Calculate depth
	//depth(root, 0);
	// Calculate height
	//height(root);

	//// Output
	//for (int i = 0; i < n; i++) {
	//	cout << "node " << i << ":" << " parent = " << tree[i].parent << ", ";
	//	// Out put sibling
	//	cout << "sibling = ";
	//	if (tree[i].parent == NIL)
	//		cout << -1;
	//	else if (tree[tree[i].parent].left != i)
	//		cout << tree[tree[i].parent].left;
	//	else
	//		cout << tree[tree[i].parent].right;
	//	// Output degree
	//	cout << ", degree = ";
	//	if (tree[i].left != NIL && tree[i].right != NIL)
	//		cout << 2;
	//	else if (tree[i].left == NIL && tree[i].right == NIL)
	//		cout << 0;
	//	else
	//		cout << 1;
	//	// Output depth
	//	cout << ", depth = " << D[i];
	//	// Output height
	//	cout << ", height = " << H[i];
	//	// Output type of node
	//	cout << ", ";
	//	if (tree[i].parent == NIL)
	//		cout << "root";
	//	else if (tree[i].left == NIL && tree[i].right == NIL)
	//		cout << "leaf";
	//	else
	//		cout << "internal node";
	//	cout << endl;
	//}

	return 0;
}

Measured memory_bytes: 3100
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    if n <= 3 {
        return "0".to_string();
    }

    let mut count_r = 0;
    let mut count_g = 0;
    let mut count_b = 0;
    for &c in &s {
        if c == 'R' {
            count_r += 1;
        } else if c == 'G' {
            count_g += 1;
        } else {
            count_b += 1;
        }
    }

    let mut ans: usize = count_r * count_g * count_b;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            let k = j + (j - i);
            if k >= n {
                break;
            }
            if s[i] != s[j] && s[j] != s[k] && s[k] != s[i] {
                ans -= 1;
            }
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

double v[3000];
double dp[3000][3000];
int n;

signed main(){
    FASTER;
    //dp[i][j] prob of exactly i heads with j coins
    cin>>n;
    for(int i=0;i<n;i++)cin>>v[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        dp[0][i]=(1-v[i-1])*dp[0][i-1];
        for(int heads=1;heads<=n && i!=0;heads++){
            dp[heads][i]=v[i-1]*dp[heads-1][i-1]+(1-v[i-1])*dp[heads][i-1];
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++)ans+=dp[i][n];
    cout<<fixed<<setprecision(10)<<ans;//sum it
}


Measured memory_bytes: 140928
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            
            for(int i = 1 ; i <= W ; i++){
                System.out.print("#");
            }
            System.out.println();
            
            for(int i = 2 ; i <= H-1 ; i++ ){
                for(int j = 1 ; j <= W ; j++){
                    if(j == 1){
                        System.out.print("#");
                    } else if (j == W){
                        System.out.println("#");
                    } else {
                        System.out.print(".");
                    }
                }
            }
            
            for(int i = 1 ; i <= W ; i++){
                System.out.print("#");
            }
            System.out.println();
            System.out.println();
        }
    }
}


Measured memory_bytes: 37516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    FOR(i, 0, s.length())cout << 'x';
    cout << "\n";
}

Measured memory_bytes: 256
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 100100;

int n;
ll c, k, p[MAXN];
int sol;

int main() {
  scanf("%d %lld %lld",&n,&c,&k);
  REP(i, n) scanf("%lld",&p[i]);
  sort(p, p + n);
  ll tajm = -1, tmp = 0;
  REP(i, n) {
    if (tmp == c) {
      tajm = -1;
      tmp = 0;
    }
    if (tajm >= p[i]) {
      tmp++;
      continue;
    }
    sol++;
    tajm = p[i] + k;
    tmp = 1;
  }
  printf("%d\n",sol);
  return 0;
}
    



Measured memory_bytes: 1024
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from math import ceil

n, k = na()
print(min(n % k, k - n % k))

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

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

long long N,K;
bool KK[101];

int main() {

	cin >> N;

	long long R = 1;

	for(long long i=1;i*i<=N;i++)
	{
		if (N%i == 0)R = i;
	}

	long long ans = (R - 1) + (N / R - 1);
	cout << ans << endl;


	
}

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

/**
 * StructuredProgramming
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();
        boolean flg = false;

        for (int i = 3; i <= n; i++) {
            if (i % 3 == 0 || Integer.toString(i).indexOf("3") != -1) {
                System.out.print(" ");
                System.out.print(i);
                flg = true;
            }
        }

        System.out.println("");
    }
}


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

int main(){
  int a,b,k,j=0;cin>>a>>b>>k;
  for(int i=min(a,b);i>=1;i--) if((!(a%i))&&(!(b%i))){
    j++;
    if(j==k) cout<<i;
  }
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

s = input()
a,b = s[:2], s[2:]
if 1 <= int(a) <= 12:
    if 1 <= int(b) <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if 1 <= int(b) <= 12:
        ans =   "YYMM"
    else:
        ans = "NA"

print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        string[] num = Console.ReadLine().Split(' ');
        int A = int.Parse(num[0]);
        int B = int.Parse(num[1]);
        int C = int.Parse(num[2]);
        int D = int.Parse(num[3]);


        while (true)
        {
            C -= B;
            if (C <= 0)
            {
                Console.WriteLine("Yes");
                break;
            }

            A -= D;
            if (A <= 0)
            {
                Console.WriteLine("No");
                break;
            }
        }

    }
}




Measured memory_bytes: 27524
#include <stdio.h>
int main(void)
{
	int  a,b,c,d,e,f;
	scanf("%d", &a);
	scanf("%d", &b);
	c = b - a;
	d = 0;
	for (e = 1; e <= c; e++) {
		d = d + e;
		}
	f = d - b;
	printf("%d", f);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int x,y;
    cin >> x >> y;
    
    int A[7]={1,3,5,7,8,10,12},B[7]={4,6,9,11,11,11,11};
    
    int a=0,b=0;
    for(int i=0;i<7;i++){
        if(x == A[i] || y == A[i]){
            a++;
        }else if(x == B[i] || y == B[i]){
            b++;
        }
    }
    if(a == 2 || b == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
#その値より左の数字を比較して、一番小さいやつが当てはまる。


Ans = 0
min = N

for i in range(N):
    if min >= P[i]:
        min = P[i]
        Ans = Ans +1
        #print("そうやで")
    #else:
        #print("ちがうやで")

print(Ans)

Measured memory_bytes: 24744
n = int(input())
s = input()
sum = 0
if n < 4:print(0);exit()
r = 0;g = 0; b = 0;
for i in range(len(s)):
    if s[i] == "R":
        r += 1
    if s[i] == "G":
        g += 1
    if s[i] == "B":
        b += 1
sum = r*g*b
for i in range(n):
    for j in range(i+1,n):
        dis = j - i
        k = j + dis
        if k >= n:break
#        print(i,j,k)
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i] :
            sum -= 1
print(sum)


Measured memory_bytes: 68108
#include <iostream>
#include <cstdio>
#include <cstdint>

using namespace std;

typedef uint64_t u64;
typedef uint32_t u32;
typedef int64_t s64;
typedef int32_t s32;

#define rep(i, N) for(int i; i < N; ++i)
#define MAX(a, b) (((a) > (b)) ? (a) : (b))

#define N 100000

u64 n;

int main()
{
    scanf("%ld", &n);

    if (n & 1)
    {
        printf("%lu\n", (n - 1) / 2 * n);
    }
    else
    {
        printf("%lu\n", n / 2 * (n - 1));
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int r;
  cin>>r;

  Int ans = r * r;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
from collections import OrderedDict
from sys import stdin
N = int(stdin.readline().rstrip())
SP = {} 
_P = []
for i in range(N):
    s, p = stdin.readline().rstrip().split()
    _P.append(int(p))
    if s in SP:
        SP[s].append(int(p))
    else:
        SP[s] = [int(p)]
for v in SP.values():
    v.sort(reverse=True)
SP = OrderedDict(sorted(SP.items()))
for k, V in SP.items():
    for v in V:
        print(_P.index(v)+1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    int n, k;
    cin >> n >> k;
    int ans = 0;
    int e;
    while (n--) {
        cin >> e;
        ans += (e >= k);
    }
    
    cout << ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 1e9 + 7;
const int maxn = 2e6 + 5;

ll f[maxn];

ll mod_exp(ll a, ll b){
	if(b == 0)
		return 1ll;
	if(b % 2 == 0){
		ll t = mod_exp(a, b / 2) % mod;
		return t * t % mod;
	}
	return a * mod_exp(a, b - 1) % mod;
}

ll inv(ll x){
	return mod_exp(x, mod - 2) % mod;
}

ll n_k(ll n, ll k){
	if(k > n)
		return 0;
	ll num = f[n];
	ll den = f[k] * f[n - k] % mod;
	den = inv(den);
	return num * den % mod;
}

ll get(ll n, ll k){
	return n_k(n + 1, k + 1);
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	f[0] = 1ll;
	for(int i = 1; i < maxn; i++)
		f[i] = 1ll * i * f[i - 1] % mod;
	
	ll a, b, c, d;
	cin >> a >> c >> b >> d;
	
	ll ans = 0;
	
	for(ll i = a; i <= b; i++){
		ll hi = get(i + d, i);
		ll lo = get(i + c - 1, i);
		ll x = (hi + mod - lo) % mod;
		ans = (ans + x) % mod;
	}
	
	cout << ans << endl;

	return 0;
}


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

int main() {
  int R;
  cin >> R;
  string answer;
  if (R < 1200) {
    answer = "ABC";
  }
  else if (2800 <= R) {
    answer = "AGC";
  }
  else {
    answer = "ARC";
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class DChatInACircle {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin>>n;
        int a[n];
        for (int i=0;i<n;i++)
            cin>>a[i];
        ll sum=0;
        sort(a,a+n);
        sum+=a[n-1];
        int b[n]={0},j=1;
        for (int i=n-2;;i--){
            if (i-j<0)
                break;
            else{
                b[i-j]=a[i];
                b[i-j-1]=a[i];
                j++;
            }
        }
        for (int i=0;i<n-2;i++)
            sum+=(ll)b[i];
        cout<<sum;
	}
};


int main() {
	DChatInACircle solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5212
N,W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())
    
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if w[i] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
            
print(dp[N][W])

Measured memory_bytes: 120300
x = input().split(" ")
store = int(x[0])
need = int(x[1])
ans = 0
price = {}

for i in range(store):
    y = input().split(" ")
    pri = int(y[0])
    bottles = int(y[1])
    if pri in price.keys():
        price[pri] += bottles
    else:
        price[pri] = bottles
#print(price)
price_sort = sorted(price.items(), key=lambda x: x[0]) #安い順に並び変え
#print(price_sort)
for price_bottles in price_sort: #price_bottles=(価格、本数)になる
    if need == price_bottles[1]:
        ans += price_bottles[1] * int(price_bottles[0])
        break
    elif need > price_bottles[1]:
        ans += price_bottles[1] * int(price_bottles[0])
        need -= price_bottles[1]
    else:
        ans += need * int(price_bottles[0])
        break


print(ans)

Measured memory_bytes: 24128
import java.util.*;
 
public class Main{
 
	public static void main(String[] args){
 		
		Scanner sc = new Scanner(System.in);       
        int n = sc.nextInt();
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	
      	if(Math.abs(a-b) % 2 == 0) System.out.println("Alice");
      	else System.out.println("Borys");
        
       
    }
}

Measured memory_bytes: 35656
from collections import deque

if __name__ == "__main__":
    N = int(input())

    num_list = deque([])
    for i in range(N):
        command = input()
        if "insert" in command:
            key = command.split()[1]
            num_list.appendleft(key)
        else:
            if "First" in command:
                num_list.popleft()
            elif "Last" in command:
                num_list.pop()
            else:
                key = command.split()[1]
                if (key in num_list):
                    num_list.remove(key)

    print(" ".join(list(num_list)))



Measured memory_bytes: 69736
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let mut l: Vec<usize> = read_as_vec();

    l.sort();

    let mut ans: usize = 0;
    for i in 0..n {
        for j in i + 1..n {
            for k in j + 1..n {
                if l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k] && l[i] != l[k] {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <cstdio>
#include <iostream>
#include <cstdlib>
using namespace std;
int f[105][20], p[105][20], n;

int main() {
    int ans = -(int)1e9;
    cin >> n;
    for(int i = 1; i <= n; i++) 
        for(int j = 0; j < 10; j++)
            cin >> f[i][j];
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= 10; j++)
            cin >> p[i][j];    
    for(int b = 1; b < (1 << 10); b++) {
        int sum = 0;
        for(int i = 1; i <= n; i++) {
            int cnt = 0;
            for(int j = 0; j < 10; j++) 
                if(((b >> j) & 1) && f[i][j])
                    cnt ++;
            sum += p[i][cnt];
        }
        if(sum > ans) ans = sum;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int P, Q, R,min=1000;
	scanf("%d%d%d", &P, &Q, &R);
	min = P + R;
	if (min > P + Q) {
		min = P + Q;
	}
	if (min > R + Q) {
		min = R + Q;
	}
	printf("%d", min);
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var N, r, g, b int
	var S string
	fmt.Scan(&N, &S)
	for i := 0; i < len(S); i++ {
		switch S[i] {
		case 'R':
			r++
		case 'G':
			g++
		case 'B':
			b++
		}
	}
	bad := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if S[i] == S[j] {
				continue
			}
			// S[i] != S[j]
			k := 2*j - i
			if k < N && S[k] != S[j] && S[i] != S[k] {
				bad++
			}
		}
	}
	fmt.Println(r*g*b - bad)
}


Measured memory_bytes: 1808
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int x;
  cin >> x;
  for (int i = x; i < INF; i++) {
    int flag = 1;
    for (int p = 2; p * p < i; p++) {
      if (i % p == 0) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      P(i);
      return 0;
    }
  }

  return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var nk = CRL().ArrayLongs();
        var n = nk[0];
        var k = nk[1];
        var dds = CRL().ArrayLongs();
        var val = n;
        while (true)
        {
            var flag = true;
            for (int i = 0; i < k; i++)
            {
                if (val.ToString().Contains(dds[i].ToString()))
                {
                    flag = false;
                    break;
                }
            }

            if (flag)
            {
                CWL(val);
                return;
            }

            val++;
        }
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array)
    {
        var list = array.ToList();
        list.Sort();
        return list.ToArray();
    }
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    //テンプレここまで
}


Measured memory_bytes: 15436