akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define x           first
#define y           second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e5) + 7;
const int mod = int(1e9) + 7;

ll a[N], k, res;
vector<ll> v;
int t[N], n;

void Update(int x, int val) {for(; x < N; x += (x & -x)) t[x] += val;}
int Get(int x) {int res = 0; for(; x > 0; x -= (x & -x)) res += t[x]; return res;}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i]; a[i] -= k;
        a[i] += a[i - 1]; v.pb(a[i]);
    }
    v.pb(0); sort(v.begin(), v.end());
    Update(lower_bound(v.begin(), v.end(), 0) - v.begin() + 1, 1);
    for(int i = 1; i <= n; ++i) {
        a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
        res += Get(a[i]);
        Update(a[i], 1);
    }
    cout << res;
}


Measured memory_bytes: 4336
import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())

"""
i*2**t >= k
2**t >= k/i
tlog(2) >= log(k/i)
t >= log(k/i)/log(2)
"""

import math

ans = 0

for i in range(1,n+1):
    if i >= k:
        t = 0
    else:
        t = math.ceil(math.log(k/i)/math.log(2))
    ans += 1/pow(2, t)

ans /= n

print(ans)

Measured memory_bytes: 65920
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,k,a[200005],maxn;
int main()
{
    //IOS;
    cin>>k>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n-1;i++)
    {
        maxn=max(maxn,a[i+1]-a[i]);
    }
    maxn=max(maxn,k-a[n]);
    cout<<min(k-maxn,a[n]-a[1])<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 1792
[<EntryPoint>]
let main argv =
    let n = System.Console.ReadLine() |> int
    let a = System.Console.ReadLine().Split() |> Array.map int
    let b = System.Console.ReadLine().Split() |> Array.map int
    let c = System.Console.ReadLine().Split() |> Array.map int
    let ans =
        [0 .. n-1] |> List.map (fun i -> b.[i] + if i<>0 && a.[i-1]+1=a.[i] then c.[a.[i-1]-1] else 0) |> List.sum

    printfn "%d" ans
    0

Measured memory_bytes: 14044
n = int(input())
h = list(map(int, input().split()))
i = 0
li = []
while i < n:
    cnt = 0
    while i < n - 1 and h[i] >= h[i + 1]:
        i += 1
        cnt += 1
    li.append(cnt)
    i += 1
print(max(li))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int d[N];
    rep(i, N) cin >> d[i];
    sort(d, d+N, greater<int>());
    int ans = 0;
    rep(i, N-1) {

        if (d[i] == d[i+1]) continue;
        else ans++;
    }
    cout << ans+1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, k, q;
    cin >> n >> k >> q;
    int pointUp[n];
    for (int i=0; i<n; i++) {
        pointUp[i] = 0;
    }
    for (int i=0; i<q; i++) {
        int a;
        cin >> a;
        pointUp[a-1]++;
    }
    for (int i=0; i<n; i++) {
        if (k-q+pointUp[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int N, t;
	double asumikana = 0;
	int i;
	if (scanf("%d%d", &N, &t) != 2) return 1;
	for (i = 0; i < N; i++) {
		int x, h;
		double aoisyouta;
		if (scanf("%d%d", &x, &h) != 2) return 1;
		aoisyouta = (double)h / x;
		if (aoisyouta > asumikana) asumikana = aoisyouta;
	}
	printf("%.15f\n", asumikana * t);
	return 0;
}



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



int main(){
    string s;
    cin>>s;
    if(s.length()%2!=0){
        cout<<"No"<<endl;
            return 0;
    }
    rep(i,s.length()){
        if(i%2==0){
            if(s[i]!='h'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            if(s[i]!='i'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#pragma gcc optimize ("O2")
#pragma gcc optimize ("unroll-loops")

#include <bits/stdc++.h>


#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 1e5 + 10;
const ll MOD = 1e9 + 7;

int n, k;
ll cnt[N];
vector<int> fac[N];

ll fpow(ll a, ll b){
    ll ret = 1;
    while (b){
        if (b & 1){
            ret = ret * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

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

    cin >> n >> k;
    for (int i=1;i<=k;i++){
        for (int j=i + i;j<=k;j+=i){
            fac[j].pb(i);
        }
    }
    ll ans = 0;
    for (int i=k;i>=1;i--){
        ll bag = k / i;
        ll temp = fpow(bag, n);
        cnt[i] = (cnt[i] + temp + MOD) % MOD;
        ans = (ans + cnt[i] * i) % MOD;

        for (auto x : fac[i]){
            cnt[x] = (cnt[x] - cnt[i] + MOD) % MOD;
        }
    }
    cout << ans << el;

    return 0;
}

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

int main()
{
    int n,k,ans=0;
    set<int>s;
    cin>>n;
    while(1)
    {
        ++ans;
        if(s.count(n)==0)
        s.insert(n);
        else
            break;
        if(n%2==0)
        {
            n=n/2;
        }
        else
        {
            n=3*n+1;
        }
    }
    cout<<ans;
    return 0;
}



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

int main() {
	int n,l=0,m=0,p1=0,p2=0,p3=0,a;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		if(a==l){
			if(m<p1+p2+p3){
				m=p1+p2+p3;
			}
			p1=p2;
			p2=p3;
			p3=1;
		}else{
			p3++;
		}
		l=a;
	}
	if(m<p1+p2+p3){
		m=p1+p2+p3;
	}
	cout << m <<endl;
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            while(a[i] % 2 == 0) {
                a[i] /= 2;
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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


int main(void)
{
 int m, i, j;
 char x[201], y[101];
 scanf("%s %s", x, y);
 
 m = strlen(x);
 
 for(i=0;i<m;i++) x[i+m] = x[i];

 if(strstr(x, y) != NULL)
   printf("Yes\n");
 else
   printf("No\n");


 return 0;

 }

Measured memory_bytes: 524
while True:
    S = raw_input()
    if S == '0':
        break
    m = [0 for i in range(11)]
    m[0] = 1
    diff = 0
    even = True
    S = reversed(S)
    ans = 0
    for c in S:
        num = int(c)
        if even:
            diff += num
        else:
            diff -= num
        diff %= 11
        if num != 0:
            ans += m[diff]
        m[diff] += 1
        even = (not even)
    
    print ans


Measured memory_bytes: 4696
open System

let getMaxLen input =
    let isACGT char = List.contains char ['A'; 'C'; 'G'; 'T']

    let rec inner = function
    | hd :: tl when isACGT hd -> 1 + (inner tl) 
    | _ :: _ -> 0
    | [] -> 0

    let rec outer = function 
    | hd :: tl -> max (inner <| hd :: tl) (outer tl)
    | [] -> 0

    outer <| Seq.toList input

let input = Console.ReadLine()
printfn "%i" <| getMaxLen input


Measured memory_bytes: 14812
N = int(input())
S = input()
left = 1 if S[0] == 'W' else 0
right = S[1:].count('E')
MIN =  right 
for i in range(1,N):
  if S[i] == 'W':
    MIN = min(MIN,left+right)
    left += 1
  else:
    MIN = min(MIN,left+right)
    right -= 1
  
  if i==N-1:
    MIN = min(MIN,S[:i].count('W'))

print(MIN)

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	int N,M,L,R,lower,higher;
	cin>>N>>M;

	lower=1; higher=N;
	REP(i,M){
		cin>>L>>R;
		chmax(lower,L);
		chmin(higher,R);
	}

	print(max(higher-lower+1,0));

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int a[92][92],b[92][92];
int f(int x,int y){
  int mx=1;
  if(a[x][y]&&b[x][y]){
    b[x][y]=0;
    mx=max(mx,f(x-1,y)+1);
    mx=max(mx,f(x,y-1)+1);
    mx=max(mx,f(x+1,y)+1);
    mx=max(mx,f(x,y+1)+1);
    b[x][y]=-1;
  }else
    mx=0;
  return mx;
}
int main(){
  int i,j;
  int w,h;
  int mx;
  memset(b,-1,sizeof(b));
  while(cin>>w&&w){
    cin>>h;
    memset(a,0,sizeof(a));
    for(i=1;i<h+1;i++)
      for(j=1;j<w+1;j++)
	cin>>a[j][i];
    mx=0;
    for(i=1;i<h+1;i++)
      for(j=1;j<w+1;j++)
	mx=max(mx,f(j,i));
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

string s;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;

  int a = inf, z = inf;
  for (int i = 0; i < s.length(); i++) {
    if (a == inf && s[i] == 'A') {
      a = i;
    }
    if (s[i] == 'Z') {
      z = i;
    }
  }
  cout << (z - a) + 1 << endl;

  return 0;
}


Measured memory_bytes: 720
#include <stdio.h>

int main(void)
{
    //??´??°x?????£?¨?
	int x;
	int i=1;
	
    scanf("%d",&x);	
	//????????????
	while(x >= 1){
		printf("Case %d: %d\n",i,x);
	    i++;
		scanf("%d",&x);
	}
		
	return 0;
}

Measured memory_bytes: 2744
N, X = [int(_) for _ in input().split()]

def solve(n, x):

    if n == 0:
        return 1

    left = 1
    if x == left:
        return 0

    right = 2 ** (n + 2) - 3
    pivot = right // 2 + 1

    if x == right:
        return 1 + 2 * solve(n - 1, pivot - 2)

    if x < pivot:
        return solve(n - 1, x - 1)

    elif x == pivot:
        return 1 + solve(n - 1, pivot - 2)

    else:
        return solve(n - 1, pivot - 2) + 1 + solve(n - 1, x - pivot)




print(solve(N, X))

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>

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

	while( std::cin>>a>>b>>c>>d>>e>>f )
	{
		double y = ( a * f - c * d ) / ( a * e - b * d );
		double x = ( c - b * y ) / a;

		std::cout << std::fixed << std::setprecision( 3 ) << x << " " << y << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1280
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b = (int(_) for _ in input().split())
    if a%3 == 0 or b%3 ==0 or (a+b) % 3 ==0:
        print('Possible')
    else:
        print('Impossible')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <stdio.h>

int main() {

  int n,m;
  int i,t,j,k;
  int p[1001] = {0};
  int sum;

  while(1) {
    sum = 0;
    scanf("%d %d",&n,&m);

    if(n == 0 && m == 0) break;

    for(i=0;i<n;i++) {
      scanf("%d",&p[i]);
      sum = sum + p[i];
    }


    for(i=0;i<n;i++) {
      for(j=i;j<n;j++) {
	if(p[i] < p[j]) {
	  t = p[j];
	  p[j] = p[i];
	  p[i] = t;
	}
      }
    }
    
    /*    for(i=0;i<n;i++) {
	printf("%d ",p[i]);
      }
    printf("\n");
    */ 


    for(i=m-1;i<n;i=i+m) {
      sum -= p[i];
    }


    printf("%d\n",sum);

  }

  return 0;
}

Measured memory_bytes: 600
import sys
from itertools import combinations

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    S = input()
    
    acc = [[0] * 3 for _ in range(N + 1)]
    for i in range(1, N + 1):
        acc[i] = acc[i - 1][:]
        if S[i - 1] == 'R':
            acc[i][0] += 1
        elif S[i - 1] == 'G':
            acc[i][1] += 1
        else:
            acc[i][2] += 1
    
    ans = 0
    for i, j in combinations(range(N - 1), 2):
        si, sj = S[i], S[j]
        if si == sj:
            continue
        if 'R' not in [si, sj]:
            ans += acc[N][0] - acc[j][0]
            t = j + j - i
            if t < N:
                ans -= S[t] == 'R'
        elif 'G' not in [si, sj]:
            ans += acc[N][1] - acc[j][1]
            t = j + j - i
            if t < N:
                ans -= S[t] == 'G'
        else:
            ans += acc[N][2] - acc[j][2]
            t = j + j - i
            if t < N:
                ans -= S[t] == 'B'
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 69176
#include <iostream>

using namespace std;

int main(){
    long int a,b,c,k;
    cin>>a>>b>>c>>k;

    long int a1=a*1;
    long int b1=b*0;
    long int c1=c*(-1);
    
    long int count=0;
    long int sum=0;
    while(1){
        if(count==a||k==count) break;
        sum++;
        count++;
    }
    while(1){
        if(count==a+b||k==count) break;
        sum+=0;
        count++;
    }
    while(1){
        if(count==a+b+c||k==count) break;
        sum--;
        count++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    string s;
    cin >> s;
    map<char, int> mp;
    forn(i, sz(s)) mp[s[i]]++;
    bool ok = 1;
    for (auto x : mp) {
        if (x.S % 2) {
            ok = 0;
            break;
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int p[200][3],s[200],i,j,k,m,n;

  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    s[i]=0;
    scanf("%d %d %d\n",&p[i][0],&p[i][1],&p[i][2]);
  }
  for(i=0;i<3;i++){
    for(j=0;j<n;j++){
      m=p[j][i];
      for(k=0;k<n;k++){
        if(j!=k && p[j][i]==p[k][i]) m=0;
      }
      s[j]+=m;
    }
  }
  for(i=0;i<n;i++){
    printf("%d\n",s[i]);
  }
  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>

long int gcd (long a,long b);

int main(void){
  long a, b, i;
  while(scanf("%ld %ld", &a,&b)!=EOF){

    if(a<b){
      i=a;a=b;b=i;
    }
    i=gcd(a,b);
    printf("%ld %ld\n",i, (a*b)/i);
  }
  return 0;
}

long gcd(long a,long b){
  long s;
  s=a%b;
  if(s!=0)
    gcd(b,s);
  else
    return b;
}

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

struct MT
{
    int number;
    long long size;
};

int main()
{
    int N;
    long long tmp;
    
    cin >> N;
    vector<MT> a(N);
    vector<long long> ans(N);
    
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a[i] = {i+1, tmp};
    }
    
    sort(a.begin(), a.end(),
         [](MT x, MT y) -> int 
         {
            if (x.size != y.size)
            {
                return x.size > y.size;
            }
            else
            {
                return x.number > y.number;
            }
         });
    
    int j = 0;
    long long sum = a[0].size;
    for (int i = 1; i < N; i++)
    {
        if (a[i].size < a[j].size && a[i].number < a[j].number)
        {
            ans[a[j].number - 1] = sum - a[i].size * i;
            sum = a[i].size * (i + 1);
            j = i;
        }
        else
        {
            if (a[i].size == a[j].size && a[i].number < a[j].number)
            {
                j = i;
            }
            sum += a[i].size;
        }
    }
    ans[0] = sum;
    
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3456
/* created   : 2019-08-13 20:19:33
 * accepted  : 2019-08-14 09:39:16
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(m);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (x <= m) {
      a[m - x].push_back(y);
    }
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    for (auto t : a[i]) {
      q.push(t);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << "\n";
}

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


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

int main() {
    string s;
    for (int i = 0; i < 3; i++) {
        cin >> s;
        s.at(0) += 'A' - 'a';
        cout << s.at(0);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <memory.h>
#include <random>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <bitset>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/

const int MAXN = 2e5 + 10;
LL nums[MAXN], dp[MAXN];

pll solve(int i, int j) {
    if (i+1 == j) {
        LL ma, mi;
        ma = max(nums[i], nums[j]);
        mi = min(nums[i], nums[j]);
        return {mi, ma};
    }
    else {
        LL avg = (dp[j] - dp[i-1]) / 2;
        int p = lower_bound(dp+i, dp+j+1, avg+dp[i-1]) - dp;
        p--;
        p = max(p, i);
        LL a = dp[p] - dp[i-1];
        LL b = dp[j] - dp[p];
        p++;
        while (p < j) {
            LL tmpa = dp[p] - dp[i-1];
            LL tmpb = dp[j] - dp[p];
            if (abs(a-b) > abs(tmpa-tmpb)) {
                a = tmpa;
                b = tmpb;
            }
            if (tmpa > avg+1) break;
            p++;
        }
        if (a > b) swap(a, b);
        return {a, b};
    }
}



/*-------------------------------------coding area end------------------------------------------*/
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
    #ifdef LOCAL
        freopen("../test.txt", "r", stdin);
//        freopen("../output.txt", "w", stdout);
    #endif
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/

    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> nums[i];
        dp[i] = dp[i-1] + nums[i];
    }
    LL ret = LLONG_MAX;
    for (int i = 3; i+1 <= n; i++) {
        auto a = solve(1, i-1);
        auto b = solve(i, n);
        ret = min(ret, max(a.second,b.second) - min(a.first, b.first));
    }
    cout << ret << endl;



/*-------------------------------------coding area end------------------------------------------*/

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
    #endif
    return 0;
}
/* author:  txingml */


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int tmpmin=1e9;
int main(int argc,char const* argv[])
{
  string s;
  cin >> s;
  int ans=10000;
  for(int i=0;i<int(s.size())-2;i++)
    {
      string t=s.substr(i,3);
      ans=min(ans,abs(stoi(t)-753));
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import permutations
n = int(input())
a = list(map(int, input().split()))
b = list(permutations(range(1, n+1)))
for i in range(len(b)):
  if b[i]==tuple(a):
    if i==0:
      pass
    else:
      print(" ".join(map(str, b[i-1])))
    print(" ".join(map(str, a)))
    if i==len(b)-1:
      pass
    else:
      print(" ".join(map(str, b[i+1])))
    break


Measured memory_bytes: 52360
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
signed main()
{
    fast;
    int a,b,c;
    cin>>a>>b>>c;
    int ans = a+b+c;
    if(ans>=22)
        cout<<"bust";
    else cout<<"win";
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define push push
#define all(v) v.begin(),v.end()
#define rep(i,l,r) for(int i = (int)(l) ; i < (int)(r) ; i++)
#define clr(a,x) memset(a,x,sizeof(a));
#define rr(v) for(auto &val:v)
#define print(v) for(const auto itr:v){ cout << itr << ' ';} cout << endl;
#define init(v,x) for(auto &itr:v){ itr = x; }
#define minpq(x) x,vector<x>,greater<x>
#define ln length()
#define sz size()
#define infinity 1e18;
#define elif else if

void addEdge(vector<pi> adj[],int u,int v,int wt) {
    adj[u].pub(mkp(v,wt));
    adj[v].pub(mkp(u,wt));
}


int32_t main(){
    fastIO
    int n,k;
    int ans = 0;
    
    cin >> n >> k;
    
    vector<int> p(n);
    
    rep(i,0,n)
        cin >> p[i];
        
    sort(all(p));
    
    rep(i,0,k) {
        ans += p[i];   
    }
        
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3608
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")\
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mod = 1e9+7;
const int MAX = 2100000;
const int N = 21;

int mat[N][N];
int n;

ll DP[N][MAX];

ll add(ll a ,ll b){
    ll rta = a+b;
    return rta >= mod ? rta - mod : rta;
}

ll dp(int m, int i){
    if(i==n) return 1;
    if(DP[i][m]!=-1) return DP[i][m];
    ll rta = 0;
    for(int j = 0; j<n; ++j){
        if(mat[i][j] && ! (m&(1<<j)) ){
            //cout<<"holi"<<"\n";
            int d = dp(m | 1<<j, i+1);
            rta=add(rta, d);
        }
    }
    return DP[i][m] = rta;
}

int main(){

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

    memset(DP, -1, sizeof(DP));
    cout<<dp(0,0)<<"\n";


}



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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[100], t;

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	bool f = true;
	while (f) {
		f = false;
		for (int i = n-1; i >= 1; --i) {
			if (a[i]<a[i-1]) swap(a[i],a[i-1]), f = true, t++;
		}
	}
	rep(i,n) cout << a[i] << (i==n-1 ? '\n' : ' ');
	cout << t << ln;
}


Measured memory_bytes: 3216
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

//ll INF = 1e16;
//int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        if (A[i] == 0) {
            print(0);
            return 0;
        }
    }

    long double inf = 1e18;
    ll ans = 1;
    REP(i, N) {
        if (ans > inf / A[i]) {
            print(-1);
            return 0;
        }

        ans *= A[i];
    }

    print(ans);
}


Measured memory_bytes: 3992
class UnionFind:
  def __init__(self, n):
    self.n = [-1]*n
    self.r = [0]*n
    self.co = n

  def find(self, x):
    if self.n[x] < 0:
      return x
    else:
      self.n[x] = self.find(self.n[x])
      return self.n[x]

  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    elif self.r[x] > self.r[y]:
      self.n[x] += self.n[y]
      self.n[y] = x
    else:
      self.n[y] += self.n[x]
      self.n[x] = y
      if self.r[x] == self.r[y]:
        self.r[y] += 1
    self.co -= 1

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def size(self, x):
    return -self.n[self.find(x)]

  def set_count(self):
    return self.co

n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
  a, b = map(int, input().split())
  uf.unite(a-1, b-1)
print(uf.set_count()-1)


Measured memory_bytes: 11600
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}
int main(){
   int n;
   cin >> n;
    vector<ll> vec1(n+1) ,vec2(n+1),vec(n+1);
   map<ll,ll> mp;
   ll x;
   REP(i,n){
       cin >> x;
        vec[i] = x;
       mp[x] ++;
   }
    ll all = 0;
    for(auto x:mp){
        vec1[x.first] = nCr(x.second,2);
        all += vec1[x.first];
        
    }

    REP(i,n){
        ll ans = all;

        ans -= mp[vec[i]]-1;
        cout << ans << endl;
    }
}





Measured memory_bytes: 15488
"""#################################################################
【ABC112】
B_Time_Limit_Exceeded
#################################################################"""

#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N, T = ISI()
min = 999999
for i in range(N):
    c, t = ISI()
    if t <= T:
        if min > c:
            min = c
if min == 999999:
    print("TLE")
else:
    print(min)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
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) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A = getint();
	int B = getint();
	A -= B;
	int H[100000], M[100000] = {};
	ll D[100000] = {};
	rep(i, N) H[i] = getint();
	pakuri_sort(N, H);
	rep(i, N) {
		D[i + 1] = H[i] / A + D[i];
		M[i] = H[i] % A;
	}

	int L = 0;
	int R = (1000000000 + B - 1) / B;

	while (L + 1 != R) {
		int mid = (L + R) / 2;
		int damage = B * mid;
		ll cnt = 0;
		auto k = upper_bound(H, H + N, damage) - H;
		ll d = damage / A;
		int m = damage % A;
		cnt += D[N] - D[k] - d * (N - k);
		for (; k != N; k++) {
			cnt += (M[k] > m);
		}
		if (cnt > mid) L = mid;
		else R = mid;
	}

	printf("%lld", R);

	Would you please return 0;
}

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

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

  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  for (int i = 0; i < (n + 1) / 2; i++) {
    cnt += s[i] != s[n-1-i];
  }
  cout << cnt << '\n';
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

struct Block {
    int w, s, v;
};

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    Block block[n];
    int maxS = 0;
    FOR(i,0,n-1){
        int w, s, v; cin >> w >> s >> v;
        block[i] = {w, s, v};
        maxS = max(maxS, s);
    }

    sort(block, block+n, [](Block a, Block b) {
            return a.s + a.w < b.s + b.w;
            });

    //for (auto b : block) {
    //    cout << b.w << " " << b.s << " " << b.v << endl;
    //}

    ll dp[n+1][maxS+1];
    memset(dp[n], 0, sizeof dp[n]);
    RFOR(i,n-1,0) FOR(x,0,maxS) {
        dp[i][x] = dp[i+1][x];
        if (block[i].s >= x) {
            int y = x+block[i].w;
            dp[i][x] = max(dp[i][x], (y <= maxS ? dp[i+1][y] : 0) + block[i].v);
        }
        //cout << i << " " << x << " :: " << dp[i][x] << endl;
    }
    cout << dp[0][0] << '\n';
}



Measured memory_bytes: 78464
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  string s; cin >> s;
  if(s=="Sunny"){
    cout << "Cloudy" << endl;
  }
  if(s=="Cloudy"){
    cout << "Rainy" << endl;
  }
  if(s=="Rainy"){
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 3664
#include<stdio.h>
int main()
{
  int n,x,t,sum=0,time=0,i=1;
  scanf("%d %d %d",&n,&x,&t);
  while(sum<n)
  {
    sum=sum+x;
    time=t*i;
    i++;
      
  }
  printf("%d",time);
}

Measured memory_bytes: 1732
import itertools
import numpy as np

N = int(input())
stl = []
for i in range(N):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        stl.append((i, x-1, y))
dl = np.array(list(itertools.product([0, 1], repeat=N)), np.bool)
for i, x, y in stl:
    bl = (dl[:, i] == False) | (dl[:, x] == bool(y))
    dl = dl[bl]
res = dl.sum(axis=1).max()
print(res)


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

#define int long long
using namespace std;

signed main(){
//    freopen("in", "r", stdin);
    ios::sync_with_stdio(false);
    int n, m, t; cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> t;
        n -= t;
    }
    if (n < 0) n = -1;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3648
S = input()

i = 0

a = ["dreameraser", "dreamerase", "dreamer", "eraser", "dream", "erase"]
while i < len(S):
    f = False
    for j in a:
        l = len(j)
        if S[i:i + l] == j:
            f = True
            i += l
            break

    if not f:
        print("NO")
        exit(0)

print("YES")


Measured memory_bytes: 3188
N = gets.to_i
a = gets.split.map(&:to_i)
a.sort!

while a.size > 1 do
    int = a[0]
    b = a.map{|x| x % int}
    a.clear
    a << int
    a = a + b[1..-1]
    a.reject!{|x| x == 0}
    a.sort!
end

puts a

Measured memory_bytes: 10852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

//t以下で最小の2^x-1となるxを返す
int notover2(int t){
    double tt = (double) t+1;
    return floor(log2(tt));
}
//t以下で最小の2^xとなるxを返す
int notover(int t){
    double tt = (double) t;
    return floor(log2(tt));
}
//t以下で最小の2^x-1となる2^x-1を返す
int no2(int t){
    double tt = (double) t+1;
    return pow(2,floor(log2(tt)))-1;
}
//t以下で最小の2^xとなる2^xを返す
int no(int t){
    double tt = (double) t;
    return pow(2,floor(log2(tt)));
}

struct edge{
    int a;
    int b;
    int c;
};

void solve(){
    int l;
    cin >> l;

    int x;
    x = notover(l);
    int n=x+1;
    vector<edge> v;
    int numedge=0;
    
    for(int i=1; i<n; i++){
        //cout << i << " " << i+1 << " " << pow(2,n-i-1) << endl;
        int tm = pow(2,n-i-1);
        v.emplace_back(edge{i,i+1,tm});
        //cout << i << " " << i+1 << " " << 0 << endl;
        v.emplace_back(edge{i,i+1,0});
        numedge += 2;
    }
    int tmp = l - pow(2,n-1);
    int i=0;
    int pointer = pow(2,n-1);
    while(tmp>0){
        int y = tmp%2;
        if(y==1){
            int p = pow(2,n-1);
            int d = pow(2,i);
            v.emplace_back(edge{1,n-i,pointer});
            pointer += d;
            numedge++;
        }
        tmp /= 2;
        i++;
    }

    cout << n << " " << numedge << endl;
    for(auto i:v){
        cout << i.a << " " << i.b << " " << i.c << endl;
    }
}

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


Measured memory_bytes: 512
x,y,a,b,c = (int(x) for x in input().split())
p = sorted((int(x) for x in input().split()), reverse=True)
q = sorted((int(x) for x in input().split()), reverse=True)
r = sorted((int(x) for x in input().split()), reverse=True)
ans = sum(p[:x]) + sum(q[:y])
cnt = 0
cnt_a = 0
cnt_b = 0
for cnt in range(c):
    if (x-1-cnt_a) < 0 and  y-1-cnt_b < 0:
        break
    pa = max(0, x-1-cnt_a)
    pb = max(0, y-1-cnt_b)
    if r[cnt] < p[pa] and r[cnt] < q[pb]:
        break
    if p[pa] > q[pb]:
        ans  = ans - q[pb] + r[cnt]
        cnt_b += 1
        q[pb] = r[cnt]
    elif p[pa] < q[pb]:
        ans = ans - p[pa] + r[cnt]
        cnt_a += 1
        p[pa] = r[cnt]
    else:
        j = 0
        while p[pa-j] == q[pb-j] and pa - j > -1 and pb - j > -1:
            j += 1
        if p[pa-j] > q[pb-j]:
            ans  = ans - q[pb] + r[cnt]
            cnt_b += 1
            q[pb] = r[cnt]
        elif p[pa-j] < q[pb-j]:
            ans = ans - p[pa] + r[cnt]
            cnt_a += 1
            p[pa] = r[cnt]
        elif x > y and x-1-cnt_a >= 0:
            ans = ans - p[pa] + r[cnt]
            cnt_a += 1
            p[pa] = r[cnt]
        elif y-1-cnt_b >= 0:
            ans  = ans - q[pb] + r[cnt]
            cnt_b += 1
            q[pb] = r[cnt]
        elif x-1-cnt_a >= 0:
            ans = ans - p[pa] + r[cnt]
            cnt_a += 1
            p[pa] = r[cnt]
        else:
            break
    
print(ans)

Measured memory_bytes: 105188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if(n == 0) break;
			while(n-- > 0){
				int c = sc.nextInt();
				int b = sc.nextInt();
				int a = sc.nextInt();
				int ave = (a + b + c) / 3;
				if(a == 100 || b == 100 || c == 100){
					System.out.println("A");
				}
				else if((b + c) / 2 >= 90){
					System.out.println("A");
				}
				else if(ave >= 80){
					System.out.println("A");
				}
				else if(ave >= 70){
					System.out.println("B");
				}
				else if(ave >= 50 && (b >= 80 || c >= 80)){
					System.out.println("B");
				}
				else{
					System.out.println("C");
				}
			}
		}
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 28424
#include<stdio.h>

int main(){
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		if(a<1868||a==1868&&(b<9||(b==9&&c<8)))printf("pre-meiji\n");
		else if(a<1912||a==1912&&(b<7||(b==7&&c<30)))printf("meiji %d %d %d\n",a-1867,b,c);
		else if(a<1926||a==1926&&(b<12||(b==12&&c<25)))printf("taisho %d %d %d\n",a-1911,b,c);
		else if(a<1989||a==1989&&(b<1||(b==1&&c<8)))printf("showa %d %d %d\n",a-1925,b,c);
		else printf("heisei %d %d %d\n",a-1988,b,c);
	}
}

Measured memory_bytes: 0