akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

priority_queue<ll> que[4];
ll sum[4][101];
ll N, W, w0;
ll sz[4];

void solve() {
	cin >> N >> W;
	for (ll i = 0; i < N; i++) {
		ll w, v;
		cin >> w >> v;
		if (i == 0) w0 = w;
		que[w - w0].push(v);
	}

	for (ll i = 0; i < 4; i++) {
		sz[i] = que[i].size();
	}

	for (ll i = 1; i <= sz[0]; i++) {
		sum[0][i] += que[0].top() + sum[0][i-1];
		que[0].pop();
	}
	for (ll i = 1; i <= sz[1]; i++) {
		sum[1][i] += que[1].top() + sum[1][i - 1];
		que[1].pop();
	}
	for (ll i = 1; i <= sz[2]; i++) {
		sum[2][i] += que[2].top() + sum[2][i - 1];
		que[2].pop();
	}
	for (ll i = 1; i <= sz[3]; i++) {
		sum[3][i] += que[3].top() + sum[3][i - 1];
		que[3].pop();
	}

	ll ans = 0LL;

	for(ll i = 0; i <= sz[0]; i++)
		for (ll j = 0; j <= sz[1]; j++)
			for (ll k = 0; k <= sz[2]; k++)
				for (ll l = 0; l <= sz[3]; l++) 
					if (W >= i*w0 + j*(w0 + 1) + k*(w0 + 2) + l*(w0 + 3))
						ans = max(ans, (ll)sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]);
	
	cout << ans << endl;
				
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n;
int a[N];
int res[N];
int main() {
    ios::sync_with_stdio(false);
    cin>>n;
     for(int i=2;i<=n;++i){
         cin>>a[i];
         res[a[i]]++;
     }
     for(int i=1;i<=n;++i) printf("%d\n",res[i]);





    return 0;
}


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

int main() {
    int n;
    cin >> n;
    cout << "ai1333";
    REP(i,n/100) cout << "3";
    cout << endl;
    return 0;
}



Measured memory_bytes: 3100
from scipy import sparse
import numpy as np
from collections import Counter
import itertools
H,W = (int(x) for x in input().split())
b = []
wall = []
ans = 0
for i in range(10):
    b.append(list(map(int, input().split())))
c = np.array(b)
w = sparse.csgraph.floyd_warshall(c)
wall = [map(int, input().split()) for _ in range(H)]
count = Counter(list(itertools.chain.from_iterable(wall)))
for item in count.items():
    if item[0] == -1:
        continue
    else:
        ans += item[1] * w[item[0]][1]
print(int(ans))

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

char win_te(char src)
{
    char dst;
    if (src == 'r')
    {
        dst = 'p';
    }
    else if (src == 's')
    {
        dst = 'r';
    }
    else if (src == 'p')
    {
        dst = 's';
    }
    return dst;
}

int main()
{
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    vector<pair<int, char>> point(3);
    point[0] = make_pair(R, 'r');
    point[1] = make_pair(S, 's');
    point[2] = make_pair(P, 'p');
    sort(point.rbegin(), point.rend());
    string A;

    rep(i, N)
    {
        A += win_te(T[i]);
    }

    rep(i, N - K)
    {
        if (A[i] == A[i + K])
            A[i + K] = 'x';
    }

    long long ans = 0;
    rep(i, N)
    {
        rep(j, 3)
        {
            if (A[i] == point[j].second)
                ans += point[j].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rrep(i, a, b) for(ll i = b-1; i >= a; i--)
#define  pii pair<ll,ll>
typedef long long ll;

int main(){
    ll N, T; cin >> N >> T;
    vector<pii> P(N);
    rep(i, 0, N) cin >> P[i].first >> P[i].second;
    
    vector<pii> dp(3010, make_pair(0,0));
    rep(i, 0, N){
        rrep(j, 0, T + 1){
            if(j - P[i].first >= 0){
                if(dp[j].first < dp[j-P[i].first].first + P[i].second){
                    dp[j] = make_pair(dp[j-P[i].first].first + P[i].second, dp[j-P[i].first].second);
                }else if(dp[j].first == dp[j-P[i].first].first + P[i].second){
                    dp[j].second = max(P[i].second,dp[j].second);
                    dp[j].second = max(P[i].second,dp[j-P[i].first].second);
                }
                else{
                    if(dp[j].second < P[i].second){
                        dp[j].second = P[i].second;
                    }
                }
                //dp[j] = max(dp[j-P[i].first] + P[i].second, dp[j]);
            }else{
                if(dp[j].second < P[i].second){
                    dp[j].second = P[i].second;
                }
            }
        }
    }
    ll ans = 0;
    /* rep(i, 0, T){
        ans = max(ans, dp[i].first + dp[i].second);
    } */
    // ans = max(ans, dp[T].first);
    //rep(i, 0, T + 1) cout << i << " " << dp[i].first << " " << dp[i].second << " " << dp[i].first + dp[i].second << endl; 
    cout << dp[T-1].first + dp[T-1].second << endl;

}

Measured memory_bytes: 384
mod = 10**9 + 7
MAX=10**6
fac,finv,inv=[0]*MAX,[0]*MAX,[0]*MAX

def nCkinit(mod):
    fac[0]=finv[0]=1
    fac[1]=finv[1]=inv[1]=1
    for i in range(2,MAX):
        fac[i]=fac[i-1]*i % mod
        inv[i]=mod-inv[mod%i] *(mod//i) %mod
        finv[i]=finv[i-1]*inv[i] % mod
        
def modnCk(n,k,mod):
    if n<k:return 0
    if n<0 or k<0:return 0
    else:
        return fac[n]*(finv[n-k]*finv[k]% mod) % mod
    
nCkinit(mod)

###
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
s1=s2=0
for i in range(N-K+1):
    s1+=(A[i]*modnCk(N-(i+1),K-1,mod))%mod
    s2+=(A[N-(i+1)]*modnCk(N-(i+1),K-1,mod))%mod
print((s1-s2)%mod)

Measured memory_bytes: 132824
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N;
    vector<string> s(N);
    rep(i,N) cin >> s[i];
    cin >> M;
    vector<string> t(M);
    rep(i,M) cin >> t[i];

    int max = 0;
    rep(i,N) {
        int ans = 1;
        for(int j = i+1; j < N; j++) {
            if(s[i] == s[j]) ans++;
        } 
        rep(k,M) {
            if(s[i] == t[k]) ans--;
        } 
        if(max < ans) max = ans;    
    } 
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
import           Control.Monad
import           Data.Bool
import           Data.List
import qualified Data.Vector   as V

readInt = readLn :: IO Int

readInts = map read . words <$> getLine :: IO [Int]

readNInts = flip replicateM readInts

main :: IO ()
main = do
  ae <- replicateM 5 readLn :: IO [Int]
  let sorted = sortOn (`mod` 10) ae
      a = f sorted
      as = del a sorted
  print $ a + sum (map roundInt as)

roundInt :: Int -> Int
roundInt n
  | n `mod` 10 == 0 = n
  | otherwise = (* 10) . (+ 1) $ n `div` 10

f [x] = x
f (x:xs)
  | x `mod` 10 == 0 = f xs
  | otherwise = x

del :: Int -> [Int] -> [Int]
del n [] = []
del n (x:xs)
  | n == x = xs
  | otherwise = x : del n xs

Measured memory_bytes: 508
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

while true
  s=get_nsp
  break if s[0]=="-"
  m=gets.to_i
  m.times do|i|
    s_=s.shift(gets.to_i)
    s.push(s_)
    s.flatten!
  end
  puts s.join("")
end


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

int main() {
  int x, y;
  cin >> x >> y;
  string ans = "No";
  for(int i = 0;i < x+1;++i) {
    int b;
    b = x - i;
    if((2*i)+(4*b) == y) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    rep(i, H) cin >> field[i];

    vector<bool> use_h(H, true), use_w(W, true);

    rep(h, H) {
        bool ok = true;
        rep(w, W) {
            if (field[h][w] == '#') {
                ok = false;
                break;
            }
        }
        if (ok) {
            use_h[h] = false;
        }
    }

    rep(w, W) {
        bool ok = true;
        rep(h, H) {
            if (field[h][w] == '#') {
                ok = false;
                break;
            }
        }
        if (ok) {
            use_w[w] = false;
        }
    }

    rep(h, H) {
        rep(w, W) {
            if (use_h[h] && use_w[w]) cout << field[h][w];
        }
        if (use_h[h]) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	// Cを買うならA,Bを買ったほうがいい
	if (A + B <= 2 * C) {
		cout << A * X + B * Y;
		return 0;
	}

	//　A,Bを買うならCを買ったほうがいい
	else if (A >= 2 * C && X>=Y) {
		cout << C * 2 * X;
		return 0;
	}
	else if (B >= 2 * C && Y >= X) {
		cout << C * 2 * Y;
	}

	//　ミックス
	else {
		cout << C * 2 * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y));
		return 0;
	}









}	


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int studen = int.Parse(input[0]);
        int checkp = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        if(2*checkp-studen-c == 0){
            WriteLine("YES");
        }else{
            WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11092
use proconio::{fastout, input};

use proconio::marker::Chars;
use std::cmp::{max, min};

#[fastout]
fn main() {
    const M: usize = 998244353;
    input! {
        s: Chars, k: usize,
    }
    let n = s.len();
    let k = min(k, s.len());
    let mut a = vec![0];
    for c in s {
        if c == '0' {
            a.push(0);
        }
        if c == '1' {
            if let Some(last) = a.last_mut() {
                *last += 1;
            }
        }
    }
    let mut h = vec![vec![vec![None; k + 1]; n]; a.len() + 1];
    fn f(
        i: usize,
        j: usize,
        k: usize,
        a: &Vec<usize>,
        h: &mut Vec<Vec<Vec<Option<usize>>>>,
    ) -> usize {
        if i == 0 {
            return 1;
        }
        if let Some(v) = h[i][j][k] {
            return v;
        }
        let mut s = 0;
        for l in 0..=min(k, a[i]) {
            s += f(i - 1, j + l, k - l, a, h);
            s %= M;
        }
        for l in 1..=j {
            s += f(i - 1, j - l, k, a, h);
            s %= M;
        }
        h[i][j][k] = Some(s);
        s
    }
    let ans = f(a.len() - 1, 0, k, &a, &mut h);
    println!("{}", ans);
}


Measured memory_bytes: 216844
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let N = get!(usize);
    let (A, B): (Vec<_>, Vec<_>) = get!(i64, i64; N).into_iter().unzip();
    let mut m = 0;
    let mut j: usize = 0;
    for (i, a) in A.into_iter().enumerate() {
        if m < a {
            j = i;
            m = a;
        }
    }
    let ans = (m as usize) + (B[j] as usize);
    println!("{}", ans);
}

Measured memory_bytes: 8444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    string ss;
    cin>>ss;
    int n=0,w=0,s=0,e=0;
    int m=ss.size();
    rep(i,m){
        if(ss[i]=='N') n++;
        if(ss[i]=='W') w++;
        if(ss[i]=='S') s++;
        if(ss[i]=='E') e++;
    }
    if(n>0&&w>0&&s>0&&e>0) cout<<"Yes";
    else{
        if(n>0&&s>0&&w==0&&e==0) cout<<"Yes";
        else if(n==0&&s==0&&w>0&&e>0) cout<<"Yes";
        else cout<<"No";
    }
    cout<<endl;
}

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

int main() {
    int n;
    string s,t;
    //n = 8;
    //s = "hmhmnknk";
    //t = "uuuuuuuu";
    cin >> n;
    cin >> s >> t;
    string str = s + t;
    for (int i = 0; i < n; i++) {
        str[2 * i] = s[i];
    }
    for (int j = 0; j < n; j++) {
        str[2 * j + 1] = t[j];
    }
    cout << str << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    val h = readLine()!!.split(" ")
    var count = 0
    var bo : Boolean

    for(i in 0 .. (n-1)){
        bo = false
        for(j in 0 .. (i-1)){
            if(h[j].toInt() > h[i].toInt()) bo = true
        }
        if(!bo)count++
    }
    println(count)
}


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

int main(){
    int n;

    while(scanf("%d",&n)==1){
        int data[n];

        for(int i=0; i<n; i++)
            scanf("%d",&data[i]);

        sort(data, data+n);

        int alice=0, bob=0;

        for(int i=n-1;i>=0; i-=2)
            alice+=data[i];

        for(int i=n-2;i>=0; i-=2)
            bob+=data[i];

        printf("%d\n",alice-bob);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,i,j,k;
	cin>>a;
	i=a/100%10;
	j=a/10%10;
	k=a/1%10;
	if(i==7||j==7||k==7){
		cout<<"Yes";
	} else{
		cout<<"No";
	}
	return 0;
} 

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// From AtCoder Library.
// Returns the sum of (a * i + b) / m over 0 <= i < n.
int64 FloorSum(int64 n, int64 m, int64 a, int64 b) {
    int64 ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    int64 y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += FloorSum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

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

  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int64 n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << FloorSum(n, m, a, b) << "\n";
  }
}


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

using namespace std;

typedef long long int lli;

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

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

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

    int r = a[0];
    for (int i=1; i<n-1; i++) {
        r = (abs(2*a[i]-a[n-1]) < abs(2*r-a[n-1])) ? a[i] : r;
    }

    cout << a[n-1] << " " << r << endl;

    return 0;
}


Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <stdio.h>
#include<math.h>

int main(void)
{
	int a, b, C;
	double c;
	double S, L, h;
	double z;
	scanf("%d %d %d", &a, &b, &C);
	
	z=C*M_PI / 180;
	S = (a*b*sin(z))/2;
	c = (a*a) + (b*b) - 2 * a*b*cos(z);
	L = (double)a + (double)b + sqrt(c);
	h = 2 * S / a;
	printf("%f\n%f\n%f\n", S, L, h);

	return 0;
}

Measured memory_bytes: 636
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    dict = defaultdict(int)
    dict['AC'] = 0
    dict['WA'] = 0
    dict['TLE'] = 0
    dict['RE'] = 0

    for n in range(N):
        S = iss()
        dict[S] += 1

    print('AC x', dict['AC'])
    print('WA x', dict['WA'])
    print('TLE x', dict['TLE'])
    print('RE x', dict['RE'])


if __name__ == '__main__':
    main()


Measured memory_bytes: 10188
#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;

int main(){
	char ch;
	int cnt[26] = {};
	
	while (cin >> ch){
		ch = tolower(ch);
		if (isalpha(ch)) {
			cnt[ch-'a']++;
		}
	}
	for (int i=0;i<26;i++){
		printf("%c : %d\n",i+'a',cnt[i]); 
	}
	return 0;
}

Measured memory_bytes: 1124
def feed_runrun(burger_dimension, appetite):
    if appetite == 0:
        return 0

    burger_size = 2 ** (burger_dimension + 2) - 3
    amount_of_p = 2 ** (burger_dimension + 1) - 1

    if appetite == burger_size:
        return amount_of_p
    if appetite < burger_size:
        return feed_runrun(burger_dimension - 1, appetite - 1)
    if appetite > burger_size:
        return amount_of_p + 1 \
               + feed_runrun(burger_dimension, appetite - burger_size - 1)


n, x = map(int, input().split())
print(feed_runrun(n, x))

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

int main(){
	int q;
	scanf("%d", &q);
	vector<long> vec;
	for(int i = 0; i < q; i++) {
		int id;
		scanf("%d", &id);
		if(id == 0) {
			long x;
			scanf("%ld", &x);
			vec.push_back(x);
		}
		if(id == 1) {
			int p;
			scanf("%d", &p);
			printf("%ld\n", vec[p]);
		}
		if(id == 2) {
			vec.pop_back();
		}
	}
}



Measured memory_bytes: 4952
while True:
    n = int(input())
    if n == 0:break
    p = [tuple(map(int, input().split())) for _ in range(n)]
    p.sort()
    p.sort(key = lambda x:x[3])
    p.sort(key = lambda x:x[2], reverse = True)
    s = 0
    sg = {}
    for i in p:
        if s < 10:
            try:
                if sg[i[1]] < 3:
                    print(i[0])
                    s += 1
                    sg[i[1]] += 1
            except:
                sg[i[1]] = 1
                print(i[0])
                s += 1
        elif s < 20:
            try:
                if sg[i[1]] < 2:
                    print(i[0])
                    s += 1
                    sg[i[1]] += 1
            except:
                sg[i[1]] = 1
                print(i[0])
                s += 1
        elif s < 26:
            if i[1] not in sg:
                sg[i[1]] = 1
                print(i[0])
                s += 1


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int n;
    cin >> n;
    int a;
    set<int> st;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if(st.count(a) == 1) {
            st.erase(a);
            ans--;
        } else {
            st.insert(a);
            ans++;
        }
    }

    cout << ans << endl;  

}

Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define LL long long
#define ULL unsigned long long
#define P 1000000007
#define H 10007
#define mod(a,b) a-a/b*b
#define debug(x) cerr<<#x<<"="<<x<<endl
using namespace std;

int a,b,c;

int main()
{
	cin>>a>>b>>c;
	if(a<=c && c<=b)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
s = input().strip()
n = len(s)
ans = [1] * n
odd = 0
even = 0
for i in range(n):
    if s[i - 1] == 'R' and s[i] == 'R':
        if i & 1:
            odd += 1
        else:
            even += 1
        ans[i - 1] -= 1
    if s[i - 1] == 'R' and s[i] == 'L':
        if i & 1:
            ans[i] += even
            ans[i - 1] += odd
        else:
            ans[i] += odd
            ans[i - 1] += even
        odd = 0
        even = 0
for i in range(n - 1, -1, -1):
    if s[i - 1] == 'L' and s[i] == 'L':
        if i & 1:
            odd += 1
        else:
            even += 1
        ans[i] -= 1
    if s[i - 1] == 'R' and s[i] == 'L':
        if i & 1:
            ans[i] += odd
            ans[i - 1] += even
        else:
            ans[i] += even
            ans[i - 1] += odd
        odd = 0
        even = 0
print(*ans)


Measured memory_bytes: 49852
#include <bits/stdc++.h>
typedef long long ll;
#define loop(x) for(int i = 1;i<=(x);i++)
using namespace std;

int main(){
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    ll n,count = 0;
    cin>>n;
    loop(n){
        if(i%5!=0&&i%3!=0)count+=i;
    }
    cout<<count<<endl;
    return 0;
}




Measured memory_bytes: 3636
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

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

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n;scanf("%d",&n);
	int k=1,s=1;
	while (s<n)
	{
		k++;s+=k;
	}
	for (int i=k;i;i--)
		if (n>=i) {printf("%d\n",i);n-=i;}
	return 0;
}



Measured memory_bytes: 256
def examC():
    def bfs(n, e, fordfs):
        # 点の数、スタートの点、有向グラフ
        W = [-1] * n
        # 各点の状態量、最短距離とか,見たかどうかとか
        W[e] = 0
        que = deque()
        que.append(e)
        while que:
            now = que.popleft()
            nowW = W[now]
            for ne in fordfs[now]:
                if W[ne] == -1:
                    W[ne] = nowW + 1
                    que.append(ne)
        return W
    N, M = LI()
    V = [[]for _ in range(N)]
    for i in range(M):
        a, b = LI()
        a -= 1
        b -= 1
        V[a].append(b)
        V[b].append(a)
    L = bfs(N,0,V)
    if L[N-1]==2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    return

def examD():
    K = I()
    N = 50
    A = [i for i in range(N)]
    for i in range(N):
        A[-1-i] +=((K-i+49)//N)
    print(N); print(" ".join(map(str,A)))
    return

def examE():
    N = I()
    A = LI()
    ans = 0
    while(True):
        cur = 0
        for i in range(N):
            cur += A[i]//N
        for i in range(N):
            A[i] = A[i]%N + cur-A[i]//N
        ans += cur
        if cur==0:
            break
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 53080
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	int a = N + 1;
	int b;
	for (int i = 1; i <= sqrt(N); i++)
	{
		if (N % i == 0)
		{
			if (a == N + 1)
			{
				a = i + N / i;
				b = abs(i - N / i);
			}
			else
			{
				a = i + N / i;
				b = min(b, abs(i - N / i));
			}
		}
	}
	cout << a - 2;
}

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

int main() {
  int N = 0;
  int A = 0;
  
  cin >> N >> A;
  
  if ((N % 500) <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[][][] room = new int[4][3][10];
		
		int n = scanner.nextInt();
		
		for (int i = 0; i < n; i++) {
			int b = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();
			int v = scanner.nextInt();
			room[b - 1][f - 1][r - 1] += v;
		}

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 10; k++) {
					System.out.print(" " + room[i][j][k]);
				}
				System.out.println();
			}
			if (i < 3)
				System.out.println("####################");
		}
	}

}



Measured memory_bytes: 29736
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

vector<bool> get_prime(int n){
    vector<bool> prime(static_cast<unsigned int>(n + 1), true);
    if(n >= 0) prime[0] = false;
    if(n >= 1) prime[1] = false;

    for(int i = 2; i * i <= n; i++){
        if(prime[i]){
            for(int j = i + i; j <= n; j += i) prime[j] = false;
        }
    }

    return(prime);
}
int main() {
    auto prime_list = get_prime(100001);
    vector<int> d(100001, 0);
    int k = 0;
    for (int i = 0; i <= 100000; ++i) {
        if(prime_list[i] && prime_list[(i+1)/2]) k++;
        d[i] = k;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int l, r;
        scanf("%d %d", &l, &r);
        cout << d[r]-d[l-1] << "\n";
    }
    return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S, T;
    cin >> S >> T;
   
    string U = S+S;
    bool ans = false;
    for (int i = 0; i < U.length(); i++) {
        bool ok = true;
        for (int j = 0; j < T.length(); j++) {
            if (U[j+i] != T[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = true;
        }
    }
    if (ans) {
        print("Yes");
    } else {
        print("No");
    }

}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int n, a[100000],c=0;

    cin>>n;

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

    for(int i=0;i<n-1;i++){
        int x=0;
        for(;i<n-1;i++){
            if(a[i+1]>a[i])
                {
                    break;
                }
            else
                {
                    x++;
                }
        }
        if(x>c)
            c=x;

    }
    cout<<c;
}



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

int main() {
    long n, ans = 0;
    cin >> n;
    vector<long> a(n), b(n), c(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);
    rep(i, n) cin >> c.at(i);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    rep(i, n) {
        auto itr = lower_bound(a.begin(), a.end(), b.at(i));
        long t = itr - a.begin();
        itr = upper_bound(c.begin(), c.end(), b.at(i));
        long s = c.end() - itr;
        ans += t * s;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXN = 5 + 100000;
const int MOD = 1000000000 + 7;

int memo[MAXN][2], p[MAXN], N;
vector<int> t[MAXN];

int dp(int u, bool f) { /// f = true -> u es negro,  f = false -> u es blanco
    int& ans = memo[u][f];
    if(ans == -1) {
        if(f) { /// u es negro, todos los hijos deben ser blancos
            ans = 1;
            for(const int& v : t[u]) {
                ans = (1LL * ans * dp(v, false)) % MOD;
            }
        } else { /// u es blanco, todos los hijos pueden ser blancos o negros, da igual
            int last = 1;
            for(const int& v : t[u]) {
                int res = (dp(v,0) + dp(v,1));
                if(res >= MOD) res -= MOD;
                res = (1LL * res * last) % MOD;
                last = res;
            }
            ans = last;
        }
    }
    return ans;
}

void dfs(int u) {
    for(const int& v : t[u]) {
        if(v == p[u]) continue;
        p[v] = u;
        dfs(v);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N;
    foi(i,0,N-1) {
        int u,v; cin >> u >> v;
        t[--u].emplace_back(--v);
        t[v].emplace_back(u);
    }
    p[0] = -1;
    dfs(0);
    foi(i,1,N) {
        assert(find(t[i].begin(), t[i].end(), p[i]) != t[i].end());
        t[i].erase(find(t[i].begin(), t[i].end(), p[i]));
        assert(find(t[i].begin(), t[i].end(), p[i]) == t[i].end());
    }
    memset(memo, -1, sizeof memo);
    int ans = dp(0,0) + dp(0,1);
    if(ans >= MOD) ans -= MOD;
    cout << ans << '\n';
    return 0;
}


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

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

using namespace std;

const int inf = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	int max = 0;
	int min = inf;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(a>max)max=a;
		if(a<min)min=a;
	}
	cout << max - min << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
template <class T, typename U> void assign(T& container, int N, initializer_list<U> list) {
	for (auto e: list) {
		container[N] = e;
		N++;
	}
}

//------------------8<------------------------------------8<--------------------

signed main() {
	int N;
  cin >> N;
  vector<int> A(N);
  cin >> A;
  
  int minuscnt=0;
  int absmine=10e9, abse, sum=0;
  for (auto e: A) {
    if (e >= 0) {
      abse = e;
    } else {
      abse = -e;
      minuscnt++;
    }
    if (absmine > abse) {
      sum += absmine;
      absmine = abse;
    } else {
      sum += abse;
    }
  }
  sum -= 10e9;
  if (absmine == 0 || minuscnt % 2 == 0) {
    sum += absmine;
  } else {
    sum -= absmine;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	out(N/3);
	
	return 0;
}


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

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);

            int ans = 0;
            for(int i = A; i <= B; i++)
            {
                string s = i.ToString();
                if (s[0] == s[4] && s[1] == s[3]) ans++;
            }

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13140
N=int(input())
A=list(map(int, input().split()))
even = [A[i] for i in range(0, N, 2)]
odd = [A[i] for i in range(1, N, 2)]
if N%2==0:
    ans = odd[::-1] + even
else:
    ans = even[::-1] + odd
print(*ans)

Measured memory_bytes: 116396
#include <iostream>
#include <algorithm>

#define INF 1000000

using namespace std;

int H, W;

int main() {
  int ans;

  cin >> H >> W;
  ans = INF;

  if (H % 3 == 0 || W % 3 == 0) {
    ans = 0;
  }

  if (H >= 3) ans = min(ans, W);
  if (W >= 3) ans = min(ans, H);

  if (H % 2 == 0) {
    ans = min(ans, H / 2);
  } else {
    int h = H / 2;
    int w = W / 3;
    if (W % 3 == 0) {
      ans = min(ans, w * 2);
    } else if (W % 3 == 1) {
      ans = min(ans, max(w * 2, h * 2 + w + 1));
      ans = min(ans, max(w * 2 + 1, h + w + 1));
    } else {
      ans = min(ans, max(w * 2 + 1, h + w + 1));
    }
  }

  if (W % 2 == 0) {
    ans = min(ans, W / 2);
  } else {
    int h = H / 3;
    int w = W / 2;
    if (H % 3 == 0) {
      ans = min(ans, h * 2);
    } else if (W % 3 == 1) {
      ans = min(ans, max(h * 2, w * 2 + h + 1));
      ans = min(ans, max(h * 2 + 1, h + w + 1));
    } else {
      ans = min(ans, max(h * 2 + 1, h + w + 1));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
k, a, b = gets.chomp.split(' ').map(&:to_i)

ans = 0

if (b - a) <= 2
  ans =  k + 1
else
  ans += a
  if (k - a + 1) % 2 == 0
    ans += ((b - a) * (k - a + 1)) / 2
  else
    ans += (((b - a) * (k - a)) / 2) + 1
  end
end

puts ans

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

int main(){
  int N;
  cin >> N;
  //vector<bool> people(N, true);
  vector<int> num_state(N);//i番目の人の証言の個数
  vector<vector<int>> x(N, vector<int>()), y(N, vector<int>());
  int tmp_x, tmp_y;
  for(int i=0; i<N; i++){
    cin >> num_state.at(i);
    for(int j=0; j<num_state.at(i); j++){
      cin >> tmp_x >> tmp_y;
      tmp_x--; // 番号1~15を 0~14に変換
      x.at(i).push_back(tmp_x); y.at(i).push_back(tmp_y);
    }
  }
  
  /*
  //ちゃんと取得できているか確認
  for(int i=0; i<N; i++){
    cout << i << "番目の証言数: " << num_state.at(i) << endl;
    for(int j=0; j<num_state.at(i); j++){
      cout << " x_" << i << j << ": " << x.at(i).at(j) << " y_" << i<< j<< ": " << y.at(i).at(j) << endl;
    }
  }*/
  
  
  //以下bit全探索する
  //cout << " (7 & 4): " << (7 & 4) << " (7 & (1<<2)): " << (7 & (1<<2)) << endl;//試しに出力させてみる
  //cout << " (3 & 4): " << (3 & 4) << " (3 & (1<<2)): " << (3 & (1<<2)) << endl;//試しに出力させてみる
  int ans = 0;
  for(int i=0; i< (1<<N); i++){//bit全探索で0~2^N通りを全部試す)
    
    //パターンiのときの people全員の 正直か不親切かを　割り当てる
    vector<bool> people(N, false);//とりあえず全員が不親切
    for(int j=0; j<N; j++){//0~N-1までループ
      if(i & (1<<j)){//iを2進数にしたときに右からj番目が1ならば...
        people.at(j) = true;
      }
    }//ここまでで，people全員の　正直か不親切かを　割り当てが完了
    
    /*
    //ちゃんと割り当てられているかを確認
    //for(int j=0; j<N; j++) cout << people.at(j) << " ";
    for(int j=N-1; j>=0; j--) cout << people.at(j) << " ";
    cout << endl;*/
    
    //矛盾がないか確認
    bool is_OK = true;
    for(int a=0; a<N; a++){//N人の証言を全部確認
      if(people.at(a) == false) continue;//不親切だと思われる人の証言はどうでもよい!!
      for(int b=0; b<num_state.at(a); b++){//a番目の人の証言の個数分だけループ
        if( people.at(x.at(a).at(b)) != y.at(a).at(b) ){
          is_OK = false;//矛盾が生じているので　次のbitパターンへ 
          //cout << " 矛盾!!! " << a << "番目の" << b << "個目の証言: " <<  x.at(a).at(b) << "番目の人は " << y.at(a).at(b) << endl;
          break;//bのfor文を抜ける
        }
      }
      if(is_OK == false) break;//aのfor文を抜ける
    }
    if(is_OK == false) continue;//矛盾があったようなので，次のbitパターンへ
    
    
    //矛盾がないので，正直者の人数を数える
    int num_honest = 0;
    for(int j=0; j<N; j++){
      if(people.at(j)) num_honest++;
    }
    //cout << " 矛盾なし!!! ans:" << ans << " num_honest: " << num_honest << endl;
    ans = max(ans, num_honest);//正直者の人数がなるべく多いのが答え
    
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
require 'set'
T,U={},{};S=Set.new
while true
  a,b=gets.split(',').map &:to_i
  break if a==0&&b==0
  T[a]=b;S.add(b)
end
T.each{|k,v|U[k]=S.count{|a|a>v}+1}
$<.map{|l|p U[l.to_i]}

Measured memory_bytes: 8772
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;
ll dp[203][100003];

int main() {
	int N, X; cin >> N >> X;
	vector<int> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	sort(s.rbegin(), s.rend());
	dp[0][X] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= X; j++) {
			dp[i + 1][j%s[i]] += dp[i][j];
			dp[i + 1][j%s[i]] %= mod;
			if (i + 1 != N) {
				dp[i + 1][j] += dp[i][j] * (N - i - 1) % mod;
				dp[i + 1][j] %= mod;
			}
		}
	}
	ll ans = 0;
	for (ll j = 1; j <= X; j++) ans += j*dp[N][j], ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 157184
unittest
{
	assert( [ "4 4", "1 2", "2 4", "1 3", "3 4" ].parse.expand.solve == "YES" );
	assert( [ "5 5", "1 2", "3 5", "5 1", "3 4", "2 3" ].parse.expand.solve == "NO" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	return tuple( nm[ 0 ], abs );
}

auto solve( long n, long[ 2 ][] abs )
{
	auto cs = new long[ n ];
	foreach( ab; abs )
	{
		cs[ ab[ 0 ] ]++;
		cs[ ab[ 1 ] ]++;
	}
	return cs.count!( ( x ) => x % 2 == 1 ) ? "NO" : "YES";
}


Measured memory_bytes: 5244
#include <stdio.h>

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

int n,m;
double t[100][100],dp[100][100];

double solve(int rem,int idx){
	int i;
	double tmp,res = 0;

	if(rem == 0) return 1;
	if(dp[rem][idx] != -1) return dp[rem][idx];

	rep(i,n){
		tmp = t[idx][i] * solve(rem-1,i);
		if(res < tmp) res = tmp;
	}

	return dp[rem][idx] = res;
}

int main(void){
	int i,j;
	double tmp,max;

	while(scanf("%d%d",&n,&m) && (n||m)){
		rep(i,100) rep(j,100) dp[i][j] = -1;
		rep(i,n) rep(j,n) scanf("%lf",&t[i][j]);

		max = 0;
		rep(i,n){
			tmp = solve(m-1,i);
			if(max < tmp) max = tmp;
		}
		printf("%.2lf\n",max);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
    int n, card, c[201] = {0}, ba, t, i, x, cnt;
    cin >> n;
    while(n != 0){
        for(i = 1; i <= n * 2; i++){
            c[i] = 0;
        }
        ba = 0;
        t = 0;
        cnt = 0;
        for(i = 1; i <= n; i++){
            cin >> card;
            c[card] = 1;
        }
        while(1){
            if(ba == 0){
                for(i = 1; i <= n * 2; i++){
                    if(c[i] == (t + 1) % 2){
                        ba = i;
                        c[i] = 2;
                        break;
                    }
                }
            }
            else{
                x = 0;
                for(i = 1; i <= n * 2; i++){
                    if(c[i] == ((t + 1) % 2) && (ba < i)){
                        x = 1;
                        ba = i;
                        c[i] = 2;
                        break;
                    }
                }
                if(x == 0){
                    ba = 0;
                }
            }
            x = 0;
            for(i = 1; i <= n * 2; i++){
                if(c[i] == 1){
                    x = 2;
                }
            }
            if(x == 0){
                break;
            }
            x = 1;
            for(i = 1; i <= n * 2; i++){
                if(c[i] == 0){
                    x = 2;
                }
            }
            if(x == 1){
                break;
            }
            t++;
        }
        if(x == 0){
            for(i = 1; i <= n * 2; i++){
                if(c[i] == x){
                    cnt++;
                }
            }
            cout << cnt << endl << 0 << endl;
        }
        else{
            for(i = 1; i <= n * 2; i++){
                if(c[i] == x){
                    cnt++;
                }
            }
            cout << 0 << endl << cnt << endl;
        }
            cin >> n;
    }
    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    vector<Int> v(n);
    for(Int i=0;i<n;i++) cin>>v[i];

    if(*max_element(v.begin(),v.end())<=1){
      cout<<"NA"<<endl;
      continue;
    }

    Int ans=1;
    for(Int i=0;i<n;i++) ans+=!!v[i];
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3192
gets
arr = gets.split.map(&:to_i)

arr[0] -= 1
flag = true
(1..(arr.count-1)).each do |i|
  last_num = arr[i - 1]
  now_num = arr[i]
  if last_num == now_num
    next
  end
  if last_num < now_num
    arr[i] -= 1
  else
    flag = false
    break
  end
end

if flag
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 8580
#include<bits/stdc++.h>
#define fastio   ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll        long long
#define yes       printf("YES\n")
#define no        printf("NO\n")
#define pb        push_back
#define srtd(x)   sort(x.begin(),x.end())
#define rvsd(x)   reverse(x.begin(),x.end())
#define scn(n)    scanf("%lld",&n)
#define scab(a,b) scanf("%lld %lld",&a,&b)
#define pn(n)     printf("%lld",n)
#define pab(a,b)  printf(%lld %lld",a,b)
#define nl        cout<<endl
#define MAX       1000005
#define PI        acos(-1.0)
#define mmst(a,b) memset(a,b,sizeof(a));
#define FOR(i,n)  for(ll i=1;i<=n;i++)
#define LOP(i,n)  for(ll i=0;i<n;i++)
//Emama_Nahid//
using namespace std;
int main()
{
    ll a,b,i;
    scab(a,b);
    if(a<6)
        i=0;
    else if(a<13)
        i=b/2;
    else i=b;
    pn(i);
    nl;


    return 0;

}





Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
   int a,b,c;
   string input;
   scanf("%d %d %d", &a, &b, &c);
   
   if (c >= a && c <= b)
   {
        printf("Yes");
   }
   else
   {
       printf("No");
   }
   return 0;
}

Measured memory_bytes: 256
N, W = gets.split.map(&:to_i)

max_v = N * 1000
goods = N.times.map { gets.split.map(&:to_i) }

dp = Array.new(max_v + 1, Float::INFINITY)
dp[0] = 0

goods.each do |w, v|
  (max_v).downto(0) do |i|
    next if dp[i] > W

    nw = dp[i] + w
    next if nw > W

    nv = i + v
    dp[nv] = nw if dp[nv] > nw
  end
end

puts dp.rindex { |w| w <= W }


Measured memory_bytes: 2556