akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
#define ll long double  
#define pb push_back 
#define mp make_pair 
ll powr(int n ){
	int a = powr(n/2) ;
	if(n == 0)
		return 1 ;
	if(n % 2){
		return a*a*2 ;
	}
	return a*a ;
}
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	cout << fixed ;
	cout << setprecision(10) ;
	int n , k ;
	cin >> n >> k ;
	double ans = 0 ;
	for(int i = 1 ; i <= n ; i++){
		int kk = k ;
		if(i >= k){
			ans += 1/(ll)n ;
			continue ;
		}
		int cnt = 0 ;
		int ii = i ;
		while(ii < kk){
			ii*= 2;
			cnt++ ;
		}
		// cout << (1<<cnt) << endl ;
		ll b = 1/(ll)(1<<cnt) ;
		ans += ((1/(ll)n)*b);
		// cout << b << " " << ans << endl;
	}
	cout << ans ;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)1e6 + 9;

int vs[N];

int v2(int n, int k){
  return vs[n]-vs[k]-vs[n-k];
}

int solve(vector<int> t){
  int n = t.size();
  int r = 0;
  for(int i = 0 ; i < n; i ++ ){
    if(t[i] == 1){
      if(v2(n-1,i) == 0) r ^= 1;
    }
  }
  return r;
}

int main(){
  fastIO;
  vector<int> t;
  vector<int> mod;
  int n;
  cin >> n;
  int p;
  for(int i = 1 ; i <= n; i ++ ){
    p = i;
    while(p % 2 == 0){
      vs[i] ++ ;
      p /= 2;
    }
    vs[i] += vs[i - 1];
  }
  char y;
  int x;
  int has = 0;
  for(int i = 0 ; i < n;i  ++ ){
    cin >> y;
    x = y - '0';
    t.push_back(x-1);
    if(x == 2) has = 1;
    mod.push_back((x-1)%2);
  }
  int q = solve(mod);
  if(q == 1){
    cout << "1" << "\n";
  }
  else{
    if(has){
      cout << "0" << "\n";
    }
    else{
      for(auto &x : t){
        x /= 2;
      }
      if(solve(t)) cout << "2" << "\n";
      else cout << "0\n";
    }
  }
  return 0;
}

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

using namespace std;

int main(){
    int n;
    
    while(true){
        cin >> n;
        double mean = 0,var = 0;
        vector<double> scores_array;
        double score;

        if(n == 0) break;
        for(int i = 0;i < n;i++){
            cin >> score;
            scores_array.push_back(score);
            mean += scores_array[i];
        }
        mean /= n;
        for(int i = 0;i < n;i++){
            var += pow(scores_array[i] - mean,2);
        }
        double std = sqrt(var/n);
        printf("%f\n",std);
    }
    return 0;   
}



Measured memory_bytes: 3212
import java.util.Scanner;
     
    public class Main {
      public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int []a = new int[N];
        
        int migi = 0;
        int hidari = 0;
        for(int i=0; i<M; i++) {
        	 a[i] = sc.nextInt();
        	 	if(a[i]<X) {
        	 		hidari++;
        	 	}else {
        	 		migi++;
         	 }
        }
      System.out.println(Math.min(migi,hidari));
      }
    }

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k,a,b;
    cin>>k>>a>>b;
    if((a-1)/k!=b/k) cout<<"OK";
    else cout<<"NG";
    return 0;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  int res = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int j = 0; j < i; ++j) {
      auto s = to_string(a[i] * a[j]);
      bool valid = true;
      for (int t = 0; t < (int)s.size() - 1; ++t) {
        if (s[t + 1] - s[t] != 1) {
          valid = false;
          break;
        }
      }
      if (valid) {
        res = max(res, a[i] * a[j]);
      }
    }
  }
  cout << res << '\n';
}



Measured memory_bytes: 3300
import java.io.*;
import java.util.StringTokenizer;

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    String s = in.next();
    int res = 0;
    char[] arr = s.toCharArray();
    for (int i = 0; i < arr.length; i++) {
      if (arr[i] == '+') {
        res++;
      } else {
        res--;
      }
    }
    out.println(res);
  }


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

  private void run() {
    try (
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {

    }
  }

}

Measured memory_bytes: 21076
package main
import (
  "fmt"
)
func main() {
  var s string
  fmt.Scan(&s)
  f, l := -1, -1
  var secondPrevChar, prevChar rune
  for i, char := range s {
    if i == 0 {
      prevChar = char
      continue
    }
    if i == 1 {
      if char == prevChar {
        f = 1
        l = 2
        break
      }
      secondPrevChar = prevChar
      prevChar = char
      continue
    }
    if char == prevChar {
      f = i
      l = i+1
      break
    }
    if char == secondPrevChar {
      f = i-1
      l = i+1
      break
    }
    secondPrevChar = prevChar
    prevChar = char
  }
  fmt.Println(f, l)
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String S = in.next();
			int a = Integer.parseInt(S.substring(0, 2));
			int b = Integer.parseInt(S.substring(2, 4));
			String ans = "NA";
			if ((0 <= a && a <= 99 && 1 <= b && b <= 12) && (1 <= a && a <= 12 && 0 <= b && b <= 99)) {
				ans = "AMBIGUOUS";
			} else if (0 <= a && a <= 99 && 1 <= b && b <= 12) {
				ans = "YYMM";
			} else if (1 <= a && a <= 12 && 0 <= b && b <= 99) {
				ans = "MMYY";
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 21460
import Data.List

main = do
  s <- getLine
  putStrLn . showF $ f s
  
showF :: Bool -> String
showF True  = "YES"
showF False = "NO"
  
f :: String -> Bool
f [] = True
f s
  | "dream" `isPrefixOf` s && "dreamer" `isPrefixOf` s = f (drop 5 s) || f (drop 7 s)
  | "dream" `isPrefixOf` s = f (drop 5 s)
  | "dreamer" `isPrefixOf` s = f (drop 7 s)
  | "erase" `isPrefixOf` s && "eraser" `isPrefixOf` s = f (drop 5 s) || f (drop 6 s)
  | "erase" `isPrefixOf` s = f (drop 5 s)
  | "eraser" `isPrefixOf` s = f (drop 6 s)
  | otherwise = False

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){
  
  string s;
  cin >> s;
  int now = s.size()-1,firstsize = s.size();
  bool flag = true;
  if(now == 0)flag = false;
  while(flag){
    if(s[now] != s[now-1]){
      s.erase(s.begin()+now-1,s.begin()+now+1);
      now = s.size()-1;
    }else{
      now--;
    }
    if(now <= 0)flag = false;
  }
  cout << firstsize - s.size() << endl;



  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;

int main(void){

	int a[4],b[4];
	int hf,bf,hc,bc;

	while(scanf("%d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
		hc=0,bc=0;
		for(int i=0;i<4;i++){
			hf=0,bf=0;
			for(int j=0;j<4;j++){
				if(a[i]==b[j]){
					bf=1;
					if(i==j){
						hf=1;
					}
				}
			}
			if(hf==1){
				hc++;
			}
			else if(bf==1){
				bc++;
			}
		}
		printf("%d %d\n",hc,bc);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int h , w ;
    cin >> h >> w ;
    char arr [105];
    for ( int i = 0; i < h; ++i){
        cin >> arr;
        cout << arr <<"\n"<< arr << "\n";
    }
}



Measured memory_bytes: 256
s = list(input())
comp = ["0" if i % 2 == 0 else "1" for i in range(len(s))]

a = 0
b = 0
for i in range(len(s)):
    if s[i] != comp[i]:
        a += 1
    else:
        b += 1

print(min(a, b))

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

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


int main() {
int a,b;cin >> a >>b;

if(a<=b)cout << a << endl;
else cout << a-1 << endl;

        return 0;
}


Measured memory_bytes: 256
from math import ceil
n, h = map(int, input().split())
cut = set()
throw = []

for _ in range(n):
    a, b = map(int, input().split())
    cut.add(a)
    throw.append(b)

throw.sort(reverse=True)
ans = 0
m_cut = max(cut)

for t in throw:
    if t > m_cut:
        ans += 1
        h -= t
    if h <= 0:
        break

if h > 0:
    ans += ceil(h / m_cut)

print(ans)

Measured memory_bytes: 8304
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

//#define int long long
#define oset tree < int , null_type , less<> , rb_tree_tag , tree_order_statistics_node_update >
const int mod = 998244353;
//const int inf = 1e18;
const int MAX = 1e6 + 10;

//    auto random_address = [] {
//        char *p = new char;
//        delete p;
//        return (uint64_t) p;
//    };
//    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1ull));


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int x, y;
    cin >> x >> y;
    if (y % 2) {
        cout << "No" << endl;
        return 0;
    }
    y /= 2;
    int a = y - x;
    int b = x - a;
    if (a >= 0 and b >= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

    string s;
    cin>>s;
    int n=s.size();
    ll arr[n+5]={0};
    for(int i=0;i<n;i++)
    {
        if(s[i]=='<')
        {
            arr[i+1]=arr[i]+1;
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='>')
        {
            arr[i]=max(arr[i+1]+1,arr[i]);
        }
    }
    ll ans=0;
    for(int i=0;i<n+1;i++)
    {
        ans+=arr[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7704
n, k = map(int, input().split())
a_l = list(map(int, input().split()))
a_m = dict()
tmp = list()  # startまでの距離を計測用

f = 1

while True:
    if f in a_m:
        # すでにfrom-toが登録済みであればループのstartを登録終了
        start = f
        pre = tmp.index(f)
        break
    tmp.append(f)
    t = a_l[f-1]  # to
    a_m[f] = t  # from-toを登録
    f = t

if k > pre:
    cycle_len = len(a_m) - pre
    k_mod = (k - pre) % cycle_len

    result = start

else:
    result = 1
    k_mod = k

for _ in range(k_mod):
    result = a_m[result]

print(result)


Measured memory_bytes: 124452
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
minus=0
ans=0
for i in range(N):
    if a[i]<=0:
        minus+=1
for i in range(N):
    b[i]=abs(a[i])
c=sorted(b)

if minus%2==1:
    for i in range(N-1):
        ans= ans+c[N-i-1]
    ans=ans-c[0]
else:
    for i in range(N):
        ans= ans+c[N-i-1]
print(ans)



Measured memory_bytes: 14464
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int i,q,a,b,r,len;
        String str,com,p,sa,sb,sc;
        str=scan.next();
        q=scan.nextInt();
        for(i=0;i<q;i++) {
        	com=scan.next();
        	switch(com) {
        		case ("print"):
        			a=scan.nextInt();
        			b=scan.nextInt();
        			sa=str.substring(a,b+1);
        			System.out.println(sa);
        			break;
        		case ("reverse"):
        			a=scan.nextInt();
        			b=scan.nextInt();
        			sa=str.substring(0,a);
    				sb=str.substring(a,b+1);
    				sc=str.substring(b+1);
    				len=sb.length();
    				for(r=len-1;r>=0;r--) {
    					sa+=sb.substring(r,r+1);
    				}
    				str=sa+sc;
    				break;
        		case ("replace"):
        			a=scan.nextInt();
    				b=scan.nextInt();
    				p=scan.next();
    				sa=str.substring(0,a);
    				sb=str.substring(a,b+1);
    				sc=str.substring(b+1);
    				str=sa+p+sc;
        			break;
        		default :
        			break;
        	}
        }
    }
}


Measured memory_bytes: 61260
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI 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)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int n,m;
    cin >> n >> m;
    VI p(m);
    VS s(m);

    rep(i,m)  {
      cin >> p[i] >> s[i];
      p[i]--;
    }

    LL AC = 0;
    LL WA = 0;
    VB t(n);
    VI e(n);
    rep(i,n) t[i] = true;


    rep(i,m) {
      if(t[p[i]]) {
        if(s[i] == "WA") {
          e[p[i]]++;
        } 
        if(s[i] == "AC") {
          WA += e[p[i]];
          AC++;
          t[p[i]] = false;
        }
      }
    }
    cout << AC << " " << WA << endl;    
}

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

int main() {
  string s; cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
int n,ans=0;
string s;
signed main(){
    cin>>n>>s;
    rep(i,n-1){
        string x=s.substr(0,i);
        string y=s.substr(i);
        set<int>st;
        rep(j,i){
            rep(k,n-i){
                if(x[j]==y[k])st.insert(x[j]);
            }
        }
        int siz=st.size();
        ans=max(ans,siz);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
const ll MOD = 1e9 + 7;

template<typename T>
T pomod(T x, T y, T mod) {
    T res = 1;
    x = x % mod;

    while (y > 0) {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll inv(ll x) {
    return pomod(x, MOD - 2, MOD);
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    v fact, invfact;
    fact = v(n + 1);
    invfact = v(n + 1);
    fact[0] = invfact[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = i * fact[i - 1];
        fact[i] %= MOD;
        invfact[i] = inv(fact[i]);
    }

    vv ncr(n + 1, v(n + 1, 0));
    for (ll x = 1; x <= n; x++) {
        ncr[x][0] = 1;
        for (ll y = 1; y <= x; y++) {
            ncr[x][y] = ((ncr[x][y - 1] * (x - y + 1)) % MOD) * inv(y);
            ncr[x][y] %= MOD;
        }
    }

    vector<vv> combi(n + 1, vv(n + 1));
    for (ll sum = 1; sum <= n; sum++) {
        for (ll groupSize = 1; groupSize <= n; groupSize++) {
            ll curr = 1, left = sum;

            for (ll use = 1; use <= n; use++) {
                if (groupSize * use > sum)break;
                curr *= ncr[left][groupSize];
                curr %= MOD;
                left -= groupSize;

                ll ans = curr * invfact[use];
                ans %= MOD;
                combi[sum][groupSize].push_back(ans);
            }
        }
    }

    vv dp(n + 2, v(n + 2, 0));
    dp[0][b] = 1;
    for (ll i = c; i <= d; i++) {
        if (i * b > n)break;
        dp[i * b][b] = combi[i * b][b][i - 1];
    }

    for (ll groupSize = b - 1; groupSize >= a; groupSize--) {
        for (ll usage = c; usage <= d; usage++) {
            ll sum = groupSize * usage;

            for (ll s = sum; s <= n; s++) {
                ll add = combi[s][groupSize][usage - 1] * dp[s - sum][groupSize + 1];
                add %= MOD;
                dp[s][groupSize] += add;
                dp[s][groupSize] %= MOD;
            }
        }
        for (ll s = 0; s <= n; s++) {
            dp[s][groupSize] += dp[s][groupSize + 1];
            dp[s][groupSize] %= MOD;
        }
    }

    cout << dp[n][a] << endl;
    return 0;
}

Measured memory_bytes: 83456
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N,u,v,i;
	cin >> N >> u >> v;
	u--;
	v--;
	vector < vector <ll> > G(N);
	ll a,b;
	for(i=0;i<N-1;i++){
		cin >> a >> b;
		G[a-1].push_back(b-1);
		G[b-1].push_back(a-1);
	}
	ll distA[N];
	ll distT[N];
	for(i=0;i<N;i++){
		distA[i]=-1;
		distT[i]=-1;
	}
	distA[v]=0;
	distT[u]=0;
	queue <ll> que;
	que.push(u);
	ll p;
	while(!que.empty()){
		p=que.front();
		que.pop();
		for(auto itr=G[p].begin();itr!=G[p].end();++itr){
			i = *itr;
			if(distT[i]==-1){
				distT[i]=distT[p]+1;
				que.push(i);
			}
		}
	}
	que.push(v);
	while(!que.empty()){
		p=que.front();
		que.pop();
		for(auto itr=G[p].begin();itr!=G[p].end();++itr){
			i = *itr;
			if(distA[i]==-1){
				distA[i]=distA[p]+1;
				que.push(i);
			}
		}
	}
	ll mx=0;
	for(i=0;i<N;i++){
		if(distT[i]<distA[i])mx=max(mx,distA[i]-1);
	}
	cout << mx <<endl;
    return 0;
}


Measured memory_bytes: 8064
a = [int(input()) for _ in range(5)]
ans = 1000


def solve(l, t):
    global ans
    if len(l) == 0:
        if ans > t:
            ans = t
        return
    if t % 10 > 0:
        t = t+10-t % 10
    for i, v in enumerate(l):
        solve(l[:i]+l[i+1:], t+l[i])


solve(a, 0)
print(ans)


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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  Bint a, b;
  cin >> a >> b;
  cout << a - b << endl;

  return 0;
}



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

int main() {
	ll n, k; cin >> n >> k;

	ll c = 0;
	if (k % 2 == 1) {
		rep(i, 0, n + 1) if ((i * 2 >= k) && (i % k == 0)) c++;
		cout << c * c * c << endl;
	}
	else {
		ll b = 0;
		rep(i, 0, n + 1) {
			if (i * 2 >= k) {
				if (i % k == 0) b++;
				else if (i % k == k / 2) c++;
			}
		}
		cout << (c* c* c) + (b* b* b) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 public class Main{
   public static void main(String[]args){
     Scanner s = new Scanner(System.in);
     int n = s.nextInt();
	 int k = s.nextInt();
     int a = 0;
     for(int i=0; i<n; i++){
       int h = s.nextInt();
       if(h>=k){
        a=a+1;}
     }
       System.out.println(a);
   }
 }

Measured memory_bytes: 47236
#include<iostream>
#include<string>
using namespace std;
int main()
{
	//int a;
	//cin >> a;
	//if (a >= 400 && a <= 599)cout << 8;
	//else if (a >= 600 && a <= 799)cout << 7;
	//else if (a >= 800 && a <= 999)cout << 6;
	//else if (a >= 1000 && a <= 1199)cout << 5;
	//else if (a >= 1200 && a<= 1399)cout << 4;
	//else if (a >= 1400 && a <= 1599)cout << 3;
	//else if (a >= 1600 && a <= 1799)cout << 2;
	//else if (a >= 1800 && a <= 1999)cout << 1;


	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (a >= b)
	{
		b = b << 1;
		k -= 1;
		//cout << b << endl;
		if (k < 0)
		{
			cout << "No";
			exit(0);
		}
	}
	while (b >= c)
	{
		c = c << 1;
		k -= 1;
		//cout << c << " " << k << endl;
		if (k < 0)
		{
			cout << "No";
			exit(0);
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, m) = [int(e) for e in lines[0].split(' ')]

    return (n, m)


def solve(n, m):
    
    
    result = (n + m) * (n + m - 1) // 2 - n * m
    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define V vector<pair<pair<int,int>,int> >
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    V code;
    code.push_back(make_pair(make_pair(0,1000000000),-1));
    for(int i=0; i<n; i++){
      string s;
      int a,b;
      cin >>s>>a;
      if(s == "W"){
	cin >>b;
	for(int i=0; i<code.size(); i++){
	  if(code[i].second == -1){
	    int start = code[i].first.first;
	    int size = code[i].first.second-start+1;
	    if(size>b){
	      code[i].first.first = start+b;
	      code.push_back(make_pair(make_pair(start,start+b-1),a));
	      sort(code.begin(),code.end());
	      break;
	    }
	    else{
	      code[i].second = a;
	      b-=size;
	      if(b == 0) break;
	    }
	  }
	}
      }
      if(s == "D") for(int i=0; i<code.size(); i++) if(code[i].second == a) code[i].second = -1;
      if(s == "R") for(int i=0; i<code.size(); i++) if(code[i].first.first<=a && code[i].first.second>=a){cout <<code[i].second<<endl;}
    }
    cout <<endl;
  }
  return 0;
}

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

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main(){
    int n,d;
    cin>>n>>d;
    
    int val=2*d+1;

    int ans=ceil((float)n/(float)val);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
imput = sys.stdin.readline
def main():
    N, W = map(int, input().split())
    dp = [[0]*(W+1) for _ in range(N+2)]
    for i in range(1, N+1):
        w, v = map(int, input().split())
        for j in range(1, W+1):
            if j<w:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v)
    print(int(dp[i][j]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 120176
#include<iostream>
using namespace std;
int main(){
	int a[120], n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = n-1; i >= 0; i--){
		if (i != n-1){
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3096
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var p = (long)Math.Pow(10, 9) + 7;
            var result = 0L;
            for (var digit = 0; digit < 60; digit++)
            {
                var x = 0L;
                foreach (var a in ai) if ((a >> digit & 1) == 1) x++;
                var xy = x * (ai.Length - x) % p;
                for (var i = 0; i < digit; i++) xy = xy * 2 % p;
                result += (xy % p);
            }
            Console.WriteLine(result % p);
        }
    }
}


Measured memory_bytes: 61072
/*
*@Author  Chand Vachhani
*/

#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define mii         map<int,int>
#define pb          push_back
#define pf          push_front
#define mp(a,b)          make_pair((a),(b))
#define vpii        vector<pair<int,int>>
#define fo(i,l,n)   for(int i{l}; i<n; i++)
#define rf(s)       for(auto &c : s)
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define PI          3.141592653589
#define sz(x)       (int)x.size()
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007  

using namespace std;

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

signed main(){
    tezz
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    fo(i,0,s.length()){
        cout << (char)(((s[i]-'A'+n)%26)+'A');
    }
    
    return 0;
}   






















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

typedef long long ll;
 
int main(){
  int h, w;
  cin >> h >> w;
  int m[h][w] = {};
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      char s;
      cin >> s;
      if(s=='#'){
        m[i][j] = -1;
        for(int k=-1; k<=1; k++){
          for(int l=-1; l<=1; l++){
            if(i+k<0 || i+k>=h || j+l<0 || j+l>=w) continue;
            if(k==0 && l==0) continue;
            if(m[i+k][j+l] == -1) continue;
            m[i+k][j+l]++;
          }
        }
      }
    }
  }
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(m[i][j]==-1){
        cout << "#";
        continue;
      }
      cout << m[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

class Progaram
{
    static Int32 H;
    static Int32 W;
    static Int32 N;

    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        H = l[0];
        W = l[1];
        N = Int32.Parse(Console.ReadLine());
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var retu1 = new List<Int32>();
        for (var i = 0; line.Length > i; i++)
        {
            for (var j = 0; line[i] > j; j++)
            {
                retu1.Add(i + 1);
            }
        }

        var table = new Int32[H][];
        for (var i = 0; H > i; i++)
        {
            var tas = new Int32[W];
            for (var j = 0; W > j; j++)
            {
                tas[j] = retu1[0];
                retu1.RemoveAt(0);
            }
            if (i % 2 == 1)
            {
                Array.Reverse(tas);
            }
            table[i] = tas;
        }
     
        for (var i = 0; H > i; i++)
        {
            for (var j = 0; W > j; j++)
            {
                Console.Write(table[i][j]);
                Console.Write(' ');
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13396
N, mod = int(input()), 10**9+7
memo = [{} for i in range(N+1)]
# memo = [{},{},{},...]

def ok(last4):
  for i in range(4):
    l = list(last4)
    if l[1]=='A' and l[2]=='G' and l[3]=='C':
      return False
    if l[1]=='A' and l[2]=='C' and l[3]=='G':
      return False
    if l[1]=='G' and l[2]=='A' and l[3]=='C':
      return False
    if l[0]=='A' and l[2]=='G' and l[3]=='C':
      return False
    if l[0]=='A' and l[1]=='G' and l[3]=='C':
      return False
    else:return True
    
def func(num, last3):
  if last3 in memo[num]:
    return memo[num][last3]
  if num == N:
    return 1
  ans = 0
  for i in 'ACGT':
    if ok(last3 + i):
      ans = (ans + func(num+1, last3[1:] + i)) % mod
  memo[num][last3] = ans
  return ans
    
      
print(func(0,'TTT'))
# 72

Measured memory_bytes: 3796
while 1:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
    except EOFError:
        break
    Points = [(x1, y1), (x2, y2), (x3, y3)]
    for i in xrange(3):
        A = Points[i]
        B = Points[(i + 1) % 3]
        C = Points[(i + 2) % 3]
        if A[0] - B[0] == 0:
            mark1 = C[0] - A[0]
            mark2 = xp - A[0]
        else:
            a = (A[1] - B[1]) / (A[0] - B[0])
            b = A[1] - a * A[0]
            mark1 = C[1] - (a * C[0] + b)
            mark2 = yp - (a * xp + b)
        if not ((mark1 >= 0 and mark2 >= 0) or (mark1 <= 0 and mark2 <= 0)):
            print "NO"
            break
    else:
        print "YES"

Measured memory_bytes: 4284
def merge(A, left, mid, right):
    L = A[left:mid] + [int(1e9)]
    R = A[mid:right] + [int(1e9)]
    i,j = 0,0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global count
    count += (right - left)

def merge_sort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


if __name__=='__main__':
    n = int(input())
    A = list(map(int, input().strip().split()))
    count = 0
    merge_sort(A, 0, n)
    print(" ".join(map(str, A)))
    print(count)

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N;
  cin >> N;
  vector< int64 > dp(4, -infll);

  {
    int x;
    cin >> x;
    dp[0] = x;
  }

  for(int i = 0; i + 1 < N; i++) {
    char op;
    int x;
    cin >> op >> x;

    vector< int64 > dp2(dp);
    for(int j = 0; j < 3; j++) {
      chmax(dp2[j], dp2[j + 1]);
    }
    for(int j = 0; j < 4; j++) {
      if(op == '+') {
        if(j & 1) dp2[j] -= x;
        else dp2[j] += x;
      } else {
        if(j & 1) dp2[j] += x;
        else dp2[j] -= x;
      }
    }
    if(op == '-') {
      for(int j = 3; j > 0; j--) {
        chmax(dp2[j], dp2[j - 1]);
      }
    }
    dp.swap(dp2);
  }
  for(int j = 2; j >= 0; j--) {
    chmax(dp[j], dp[j + 1]);
  }
  cout << dp[0] << endl;
}






Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

s = s()
if s[:4] == "YAKI":
    print("Yes")
else:
    print("No")


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

int n;
int a[100][100] = {0};
int k[100] = {0};
int d[100];

int kansu( int i, int t ){
	if ( d[i] != -1 && d[i] <= t ) return 0;
	d[i] = t;
	t++;
	for ( int j = 0; j < k[i]; j++ ) {
		kansu( a[i][j], t );
	}
	return 0;
}

int main(){
	cin >> n;
	int s;
	for ( int i = 0; i < n; i++ ) {
		cin >> s;
		cin >> k[i];
		for ( int j = 0; j < k[i]; j++ ) {
			cin >> s;
			a[i][j] = s-1;
		}
	}
	for ( int i = 0; i < n; i++ ) {
		d[i] = -1;
	}
	kansu(0,0);
	for ( int i = 0; i < n; i++ ) {
		cout << i+1 << " " << d[i] << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a[N];
  
  for(int i = 0; i<N; i++){
    cin >> a[i];
  }
  
    sort(a, a+N);
    reverse(a, a+N);
    int A=0, B=0;
    for(int i = 0; i<N; i++){
      if(i%2==0){
        A += a[i];
      }else{
        B += a[i];
      }
    }
  
    cout << abs(A-B) << endl;
  }

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int n;
    int c=9;
    int count=0;
    string s;
    cin>>n;
    while(n>=400){
        n-=200;
        count++;
    }
    
    cout<<c-count;
}


Measured memory_bytes: 3720
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int h,w;
int main(void){
	scanf("%d%d",&h,&w);
	rep(y,h){
		rep(x,w){
			char s[100];
			scanf("%s",s);
			if(strcmp(s,"snuke")==0){
				printf("%c%d\n",x+'A',y+1);
			}
		}
	}
	
	return 0;
}






Measured memory_bytes: 256
N=int(input())
L = [int(i) for i in input().split()]
L.sort(reverse=True)
ans = 0
for a_index,a in enumerate(L):
    if a_index == N-1:break
    for b_index in range(a_index+1,N):
        b = L[b_index]
        min_c = a - b #min_cより大きい
        U = N #つねにmin_c以下
        D = -1 #つねにmin_cより大きい
        if b<=min_c:continue
        while U-D > 1:
            X = (U+D)//2
            if L[X]<=min_c:
                U = X
            else:
                D = X
        c_index_max = D
        ans += c_index_max - b_index
print(ans)

Measured memory_bytes: 45068
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

// const ll max_size = 200010;
ll H, W, A, B;
ll *fact, *ifact;

void init(ll size) {
    fact = new ll[size+1];
    ifact = new ll[size+1];
    fact[0] = 1;
    FOR(i, 1, size)
        fact[i] = i*fact[i-1]%MOD;
    ifact[size] = modpow(fact[size], MOD-2);
    DOWN(i, size-1, 0)
        ifact[i] = ifact[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll k) {
    ll res = fact[n]*ifact[k]%MOD;
    return res*ifact[n-k]%MOD;
}

int main() {
    cin >> H >> W >> A >> B;
    init(H+W);
    ll ans = 0;
    ll a = H-A-1;
    ll c = A-1;
    REP(i, W-B) {
        ll b = B+i;
        ll d = W-B-1-i;
        ll t = comb(a+b,a)*comb(c+d,c)%MOD;
        ans = (ans + t)%MOD;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, s, x, y, z, ans=0;
  cin >> k >> s;
  for(int i=0; i<=k; i++)
    for(int j=0; j<=k; j++)
      if(0<=s-i-j && s-i-j<=k)
        ans++;
  cout << ans;
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define ll   long long int  
#define pb push_back
const int M=1e9 + 7;
using namespace std;
int N=1000000+1;
int main() {
   
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int** a=new int*[3+1];
    for(int i=1;i<=3;i++)
    {
    	a[i]=new int[n+1];
	}
    int** dp=new int*[4];
    for(int i=1;i<=3;i++)
    {
    	dp[i]=new int[n+1];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>a[1][i]>>a[2][i]>>a[3][i];
	}
	dp[1][1]=a[1][1];
	dp[2][1]=a[2][1];
	dp[3][1]=a[3][1];
	for(int i=2;i<=n;i++)
	{
		dp[1][i]=max(dp[2][i-1]+a[1][i],dp[3][i-1]+a[1][i]);
		dp[2][i]=max(dp[1][i-1]+a[2][i],dp[3][i-1]+a[2][i]);
		dp[3][i]=max(dp[2][i-1]+a[3][i],dp[1][i-1]+a[3][i]);
	}
  	int ans=max(dp[1][n],max(dp[2][n],dp[3][n]));
  	cout<<ans<<endl;
	return 0;
}










Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():

    N = INT()
    print((1000 - N % 1000) % 1000)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
# Sports Festival
from collections import Counter
N, M = map(int, input().split())
data = [list(map(int, input().split())) for i in range(N)]
ans = N
for i in range(M):
    K = []
    for j in range(N):
        K.append(data[j][0])
    index, weight = Counter(K).most_common()[0]
    ans = min(ans, weight)
    for k in range(N):
        data[k].remove(index)
print(ans)

Measured memory_bytes: 45276