akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  	int H, W, K;
  	cin >> H >> W >> K;
  	char C[H][W];
  	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> C[i][j];
  	int res = 0;
  
  	for (int bit = 0; bit < (1 << H); bit++){
      	for (int bit2 = 0; bit2 < (1 << W); bit2++){
          	vector<int> S, S2;
          	for (int i = 0; i < H; i++){
              	if (bit & (1 << i)){
                  	S.push_back(i);
                }
            }
          	for (int i = 0; i < W; i++){
              	if (bit2 & (1 << i)){
                  	S2.push_back(i);
                }
            }
          	char c_[H][W];
          	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) c_[i][j] = C[i][j];
          	for (int i = 0; i < (int)S.size(); i++){
              	for (int j = 0; j < W; j++) c_[S[i]][j] = '.';
            }
          	for (int i = 0; i < (int)S2.size(); i++){
              	for (int j = 0; j < H; j++) c_[j][S2[i]] = '.';
            }
          	int count = 0;
          	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++){
              	if (c_[i][j] == '#') count++;
            }
          	if (count == K) res++;
        }
    }
  	cout << res << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int h, w;
  cin >> h >> w;
  char a;
  vector<vector<ll>> dp(h + 1, vector<ll>(w + 1, 0));
  dp[0][1] = 1;
  REP(i, h) {
    REP(j, w) {
      cin >> a;
      if (a == '.') {
        dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD;
      } else {
        dp[i + 1][j + 1] = 0;
      }
    }
  }
  cout << dp[h][w] << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

void print_vector2(vector<vector<ll> >v){
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

void print_vector1(vector<ll> v){
    for(ll i=0; i<v.size();i++){
        cout<<v[i]<<" ";
    }cout<<"\n";
}

ll gcd(ll a, ll b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;
    if (a == b)
        return a;
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}

int main(){
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k;
    }
    else{
        if(k<=a+b){
            cout<<a;
        }
        else{
            cout<<a - (k - a - b);
        }
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll h,w;
  cin>>h>>w;
  ll ans=h*w,tmp=h*w;
  for(int p=0;p<2;p++){
    for(int i=1;i<=h;i++){
      ll s1,s2,s3;
      s1=i*w;
      s2=w*((h-i)/2);
      s3=h*w-s1-s2;
      tmp=min(tmp,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
      s1=i*w;
      s2=(h-i)*(w/2);
      s3=h*w-s1-s2;
      tmp=min(tmp,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
    }
    ans=min(ans,tmp);
    swap(h,w);
  }
  cout<<ans<<endl;
  return 0;
}


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

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

  int c[100007];

  int h[100007];
  
  for(int i=1;i<=n;i++){
      cin >> h[i];
  }

  c[1] = 0;
  c[2] = abs(h[2]-h[1]);

  for(int i=3;i<=n;i++){
      c[i] = min((c[i-2] + abs(h[i]-h[i-2])),c[i-1] + abs(h[i]-h[i-1]));
  }

  cout << c[n] << endl;
  
  



}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

map<long long int, int>mp;
int getans(const long long int n) {
	if (n < 0)assert(false);
	if (mp.find(n) != mp.end())return mp[n];
	else {
		int ans = n==1?0:n % 2 ? (1 + getans(3 * n + 1)) : (1 + getans(n / 2));
		return mp[n] = ans;
	}
}

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int ansid = 0;
		ld minn = 1e8;
		while (N--) {

			int p;
			ld h, w; cin >> p >> h >> w;
			ld bmi = w / (h*h / 10000);
			ld sa = abs(22 - bmi);
			if (minn > sa) {
				minn = sa;
				ansid = p;
			}
		}
		cout << ansid << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	string s,t;
	bool flag;
	cin>>s;
	for(int i=s.length();i>0;i--)
	{
		for(int j=0;j<=s.length()-i;j++)
		{
			t=s.substr(j,i);
			flag=true;
			for(int k=0;k<i;k++)
			{
				if(t[k]!='A'&&t[k]!='C'&&t[k]!='G'&&t[k]!='T')flag=false;
			}
			if(flag)
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
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) { return b?gcd(b,a%b):a;}

int dp[3010][3010];
int main() {
    string s,t;
    cin >> s >> t;
    int sl = s.size();
    int tl = t.size();

    for(int i = 1; i <= sl; i++){
        for(int j = 1; j <= tl; j++){
            if(s.at(i-1) == t.at(j-1)){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }


    string ans;

    while(sl > 0 && tl > 0){
        if(dp[sl][tl] == dp[sl-1][tl]){
            sl--;
            continue;
        }
        if(dp[sl][tl] == dp[sl][tl-1]){
            tl--;
            continue;
        }
        ans += s.at(sl-1);
        sl--;
        tl--;

    }
    for(int i = ans.size()-1; i >= 0; i--){
        cout << ans.at(i);
    }
    cout << endl;


}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 305;
int n, mem[45][2][2][2][2], lim = 50;
ll a[MX], acu, res;

int dp (int i, int x, int y, int val, int nc) {
	if (i > 42) return !x && !y && nc;

	int &res = mem[i][x][y][val][nc];
	if (res != -1) return res;
	res = 0;

	int f = bool(a[0] & (1ll << i)) ^ x;
	int g = bool(a[1] & (1ll << i)) ^ y;
	
	if (!(f ^ g ^ bool(acu & (1ll << i)) ^ bool(a[0] & (1ll << i)) ^ bool(a[1] & (1ll << i)))) {
		int nx = x && !(a[0] & (1ll << i));
		int ny = bool(a[1] & (1ll << i)) && y;

		if (dp(i + 1, nx, ny, val, nc || bool(a[0] & (1ll << i))) ) return res = 1;
	}

	f = 1 - f;
	g = 1 - g;

	if (i < lim && !(f ^ g ^ bool(acu & (1ll << i)) ^ bool(a[0] & (1ll << i)) ^ bool(a[1] & (1ll << i)))) {
		int nx = x || !(a[0] & (1ll << i));
		int ny = bool(a[1] & (1ll << i)) || y;

		if (dp(i + 1, nx, ny, 1, nc || !bool(a[0] & (1ll << i))) ) return res = 1;
	}

	return res = 0;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(mem, -1, sizeof(mem));

	cin >> n;
	forn (i, n) {
		cin >> a[i];
		acu ^= a[i];
	}

	int val = 0, nc = 0;

	if (!dp(0, 0, 0, 0, 0)) {
		cout << -1 << endl;
		return 0;
	}

	for (int i = 40; i >= 0; i--) {
		lim = i;
		memset(mem, -1, sizeof(mem));

		if (dp(0, 0, 0, val, nc || bool(a[0] & (1ll << i))) ) {
			nc |= bool(a[0] & (1ll << i));
			continue;
		}

		val = 1;
		nc |= !bool(a[0] & (1ll << i));
		
		acu ^= a[0];
		acu ^= a[1];
		a[0] -= (1ll << i);
		a[1] += (1ll << i);
		res |= (1ll << i);
		acu ^= a[0];
		acu ^= a[1];
	}

	assert(!acu);
	cout << res << endl;

	return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++)
  {
    cin >> X.at(i);
  }
  int min=1000000;
  int chk=0;
  for(int i=1; i<=100; i++)
  {
    for(int j=0; j<N; j++)
    {
      chk+=(X.at(j)-i)*(X.at(j)-i);
      if(j==N-1)
      {
        if(min>chk)
        {
          min=chk;
        }
        chk=0;
      }
    }
  }
  cout << min << endl;
}

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

#define MAX 1000000

int main()
{
	int i, j, k;
	int a, b;
	vector<int> h(MAX+1);
	for (i = 1; i <= MAX; i *= 2) {
		h[i] = 1;
		for (j = 1; i*j <= MAX; j *= 3) {
			h[i*j] = 1;
			for (k = 5; i*j*k <= MAX; k *= 5) {
				h[i*j*k] = 1;
			}
		}
	}

	while (cin>>a>>b, a) {
		k = 0;
		for (i = a; i <= b; i++)
			if (h[i]) k++;
		cout<<k<<endl;
	}
	return 0;
}

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

void solve(long long D, long long G, std::vector<long long> p, std::vector<long long> c){
    ll minimum_solved = accumulate(p.begin(),p.end(),0LL);
    for (ll i=0;i< 1<<(D+1)-1;i++){
        long long current_score= 0;
        ll current_solved = 0;
        for (int j=0;j<D;j++){
            ll mask = 1 << j;
            if (mask & i){
                current_score+= p[j] * 100 *(j+1) + c[j]; 
                current_solved +=p[j];
            }
        }
        if (current_score < G){
            for (int j=D-1;j>=0;j--){
                ll mask = 1 << j;
                ll score = (j+1)*100;
                if ( (mask & i) == 0){
                    ll a = (G -current_score ) / score;
                    if ((G-current_score)%score !=0) a+=1;//あまりが出てたら足す
                    if (a <= (p[j] -1 )){//使い切ってなかったらOK
                        current_solved+= a;
                        current_score += (j+1)*100 * a;
                    }else{
                        current_solved+= p[j]-1  ;//そうでなければ貪欲に
                        current_score+=  (j+1)*100 * (p[j]-1);
                    }
                }
                if (current_score>=G) break;
            }
        }
        if (current_score>=G){
                minimum_solved = min(minimum_solved,current_solved);
        }
    }
    printf("%lld\n",minimum_solved);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    long long G;
    scanf("%lld",&G);
    std::vector<long long> p(D);
    std::vector<long long> c(D);
    for(int i = 0 ; i < D ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&c[i]);
    }
    solve(D, G, std::move(p), std::move(c));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  fast;
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // 要素の個数
		int[] num = new int[n]; // 個数のリスト
		int[] S = new int[n];
		int s = 0; // 要素の合計
		for (int i = 0; i < n; i++) {
			num[i] = scan.nextInt();
			s += num[i];
		}

		int q = scan.nextInt(); // つくりたい個数
		int[] num_q = new int[q]; // つくりたいリスト
		for (int j = 0; j < q; j++) {
			num_q[j] = scan.nextInt();
			if (solve(0, num_q[j], n, num)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}

		}
		scan.close();

	}

	private static boolean solve(int i, int m, int n, int[] A) { // i番目以降の要素でmがつくれるか
																	// true:作れる
																	// false:作れない
		boolean res;
		if (m == 0) { // 0だったら作れる
			return true;
		}
		if (i >= n) {
			return false;
		}
		res = solve(i + 1, m, n, A) || solve(i + 1, m - A[i], n, A);
		return res;
	}

}



Measured memory_bytes: 26800
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
typedef pair<int,int> P;

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int f(int n){
	if(n<=1)return 1;
	else return n*f(n-1);
}

int main(){
	int n;
	int c[8][8];
	cin>>n;
	REP(i,n)REP(j,n)cin>>c[i][j];
	vector<int> seq(n);
	REP(i,n)seq[i] = i;
	map<vector<int>, int> vtoi;
	map<int, vector<int> > itov;
	for(int i = 0; i<f(n); i++,next_permutation(seq.begin(), seq.end())){
		vtoi[seq] = i;
		itov[i] = seq;
	}
	priority_queue<P, vector<P>, greater<P> > que;
	int dist[50000];
	fill(dist, dist + 50000, INF);
	int ans = 0;
	que.push(P(0,0));
	while(!que.empty()){
		P p = que.top(); que.pop();
		if(dist[p.second] <= p.first) continue;
		dist[p.second] = p.first;
		ans = max(ans, dist[p.second]);
		vector<int> v = itov[p.second];
		REP(i,v.size())FOR(j,i+1,v.size()){
			swap(v[i],v[j]);
			int next = vtoi[v];
			if(dist[next] > c[i][j] + p.first){
				que.push(P(c[i][j]+p.first ,next));
			}
			swap(v[i],v[j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	lint x,t;
	cin>>x>>t;
	cout<<(x-t<0?0:x-t)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000000000007LL
#define int long long
using namespace std;
vector<int> pat[1140];
int isr[1140][1140];
int dist[1140];
signed main(){
	int n,m;
	cin>>n>>m;
	vector<int> a,b,c;
	for(int i=0;i<m;i++){
		int ta,tb,tc;
		cin>>ta>>tb>>tc;
		ta--;tb--;
		a.pb(ta);b.pb(tb);c.pb(tc);
		pat[ta].pb(tb);
	}
	for(int i=0;i<n;i++){
		queue<int> que;
		que.push(i);
		isr[i][i]=1;
		while(!que.empty()){
			int ci = que.front(); que.pop();
			for(int j=0;j<pat[ci].size();j++){
				int cd = pat[ci][j];
				if(isr[i][cd]==0){
					isr[i][cd]=1;
					que.push(cd);
				}
			}
		}
	}
	vector<int> na,nb,nc;
	for(int i=0;i<m;i++){
		if(isr[0][ a[i] ] == 1 && isr[ b[i] ][n-1] == 1){
			na.pb(a[i]);nb.pb(b[i]);nc.pb(-c[i]);
		}
	}
	int mm = na.size();
	for(int i=1;i<n;i++){
		dist[i]=inf;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<mm;j++){
			if(dist[ nb[j] ] > dist[ na[j] ] + nc[j]){
				dist[ nb[j] ] = dist[ na[j] ] + nc[j];
				if( i == n-1){
					cout<<"inf"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<-dist[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<int> p(3);
    vector<int> j(2);
    for(int i = 0;i < 3;i++){
        cin >> p[i]; 
    }
    for(int i = 0;i < 2;i++){
        cin >> j[i]; 
    }
    sort(p.begin(),p.end());
    sort(j.begin(),j.end());
    cout << p[0] + j[0] - 50 << endl;
}


Measured memory_bytes: 3116
n = int(input())
a = list(map(int,input().split()))

b = list()
for i in range(100000):
    b.append(0)

for i in range(n):
    b[a[i]] += 1
    
c = list()    
for i in range(100000):
    if(i==0):
        if(b[i]):
            c.append(b[i+1]+b[i])
    elif(i==99999):
        if(b[i]):
            c.append(b[i-1]+b[i])
    else:
        if(b[i]):
            c.append(b[i-1]+b[i+1]+b[i])
        
print(max(c))

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; string s; cin >> n >> s;
    int maxi=0;
    rep(i,1,n){
        set<char> a,b;
        int cnt=0;
        rep(j,0,i){
            a.insert(s[j]);
        }
        rep(j,i,n){
            b.insert(s[j]);
        }
        int al=0,bl=0;
        for(char c='a';c<='z';c++){
            if(a.find(c)!=a.end() && b.find(c) != b.end()) cnt++;
        }
        maxi = max(maxi,cnt);
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define MIN(a,b)  (a<b?a:b)
#define MAX(a,b)  (a>b?a:b)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230

using namespace std;

int main(int argc, char* argv[])
{
	string S, T;
   cin >> S;
   cin    >> T;
   int count =0;
   if(S==T)
   {
	   cout << 0;
	   return 0;
   }
   for (int i = 0; i < S.size(); ++i)
	   if(S[i]!=T[i])
		   ++count;
	cout << count;   
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    ll h, w;
    cin >> h >> w;

    if (w == 1 or h == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    ll ans = 0;

    ans += ((h + 1) / 2) * ((w + 1) / 2);
    ans += (h / 2) * (w / 2);

    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
import heapq
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
N, M = map(int, input().split())

jobs = defaultdict(list)

for i in range(N):
    A, B = map(int, input().split())
    jobs[A].append(B)

res = 0
q = []

for i in range(1, M+1):
    for b in jobs[i]:
        heapq.heappush(q, -b)
    if len(q) > 0:
        res += -heapq.heappop(q)

print(res)


Measured memory_bytes: 36544
X = int(input())

lst = [ [400, 599, 8], [600, 799, 7], [800, 999, 6], [1000, 1199, 5], [1200, 1399, 4], [1400, 1599, 3], [1600, 1799, 2], [1800, 1999, 1] ]

def Kyu(X):
   
   for i in lst:
      if i[0] <= X <= i[1]:
         result = i[2]
         break
   print(result)

Kyu(X)

Measured memory_bytes: 9192
n = gets.chomp.to_i
v = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)

sum = 0

for i in 1..n do
    dif = v[i-1] - c[i-1]
    if dif > 0 
        sum += dif
    end
end

p sum

Measured memory_bytes: 1788
import java.util.Scanner;


public class Main {

	static Scanner sc = new Scanner(System.in);
	static int b,r,g,c,s,t;
	public static void main(String[] args) {
		while(read())	solve();

	}

	private static void solve() {
		int dec = 2 * (b * 5 + r * 3) + (t - (b * 5 + r * 3)) * 3;
		int gain = g * 7 + c * 2 + s * 3 + (b * 5 + r * 3) * 15 + (b+r) * 15;
		System.out.println(gain+100-dec);

	}

	private static boolean read() {
		b = sc.nextInt();
		r = sc.nextInt();
		g = sc.nextInt();
		c = sc.nextInt();
		s = sc.nextInt();
		t = sc.nextInt();
		if (b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0) {
			return false;
		} else {
			return true;
		}
	}

}

Measured memory_bytes: 20812
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sec = sc.nextInt();
        int bisc = sc.nextInt();
        int limit = sc.nextInt();

        int ans = (int)(limit / sec) * bisc;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
 
using namespace std;
set <int> q[26];
int n,op,x,l,r,t,len,cnt;
char s[500001]; 
char c;
 
 
int main(){
	int n;
	cin >> n;
	cin>>s;
	len=strlen(s);
	for (int i=0;i<len;i++) q[s[i]-97].insert(i);
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>op;
		if (op==1){
			cin>>x>>c;
			x--;
			q[s[x]-97].erase(x);
			s[x]=c;
			q[c-97].insert(x);
		}
		if (op==2){
			cin>>l>>r;
			l--;r--;
			cnt=0;
			for (int j=0;j<=25;j++) if (*q[j].lower_bound(l)<=r&&q[j].lower_bound(l)!=q[j].end()) cnt++;
			cout<<cnt<<endl;
		}
	}
}

Measured memory_bytes: 24192
#include<iostream>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;


const int ASCII_S = 's';
const int ASCII_W = 'w';
const int EMPTY = -1;



int main() {

	while (true){
		int w, q;
		cin >> w >> q;

		if (w == 0 && q == 0){
			return 0;
		}

		vector<int> cat_map;
		for (int i = 0; i < w; ++i){
			cat_map.push_back(EMPTY);
		}

		char a;
		int  b, c;
		for (int k = 0; k < q; ++k){
			cin >> a >> b;

			switch ((int)a)
			{
			case ASCII_S:
				cin >> c;
				// look for a vacant space
				for (int i = 0; i < cat_map.size(); ++i){
					if (cat_map[i] == EMPTY){
						bool isVacant = true;
						for (int j = 0; j < c; ++j){
							if (!((i + j) < cat_map.size()) || cat_map[i + j] != EMPTY){
								isVacant = false;
							}
						}
						if (isVacant){
							cout << i <<endl;
							for (int j = 0; j < c && (i + j) < cat_map.size(); ++j){
								cat_map[i + j] = b;
							}
						}
					}
					vector<int>::iterator cIter = find(cat_map.begin(), cat_map.end(), b);
					if (cIter != cat_map.end()){
						i = cat_map.size();
					}

				}
			{
				vector<int>::iterator cIter = find(cat_map.begin(), cat_map.end(), b);
				if (cIter == cat_map.end()){
					cout << "impossible" << endl;
				}
			}


			break;
			case ASCII_W:
				for (int i = 0; i < cat_map.size(); ++i){
					if (cat_map[i] == b){
						cat_map[i] = EMPTY;
					}
				}

				break;
			}

		}
		cout << "END" << endl;
	}
	

}

Measured memory_bytes: 1220
#include<iostream>
using namespace std;
#define MAX 10000

int A[2000000], B[2000000];
int C[MAX] = {0};

void CountingSort(int A[], int B[], int k){
    for(int i = 0; i < k; i++) C[A[i]]++;
    
    for(int i = 1; i <= MAX; i++) C[i] = C[i] + C[i - 1];
    
    for(int i = 0; i < k; i++){
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }
}

int main(){
    int n;
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    
    CountingSort(A, B, n);
    
    for(int i = 1; i <= n; i++){
        if(i > 1) cout << " ";
        cout << B[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 18776
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    
    scanf("%d%d", &a, &b);
    
    if (a+b>=10) {
        printf("error");
    } else {
        printf("%d", a+b);
    }
    
    return 0;
}



Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
char s[105];
int main(){
	LL k;
	scanf("%s", s+1);
	scanf("%lld", &k);
	int n = strlen(s+1);
	for(int i=1;i<=n;i++){
		if(i == k) return !printf("%c\n", s[i]);
		if(s[i] == '1') continue;
		else return !printf("%c\n", s[i]);
	}
}

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

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

    int x;
    int i = 0;

    bool flag = true;
    while (i < N)
    {
        cin >> A;
        i++;

        if (A % 2 != 0)
        {
            continue;
        }

        else if (A % 3 != 0 && A % 5 != 0)
        {
            flag = false;
        }
    }
    if (flag) {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define endl              "\n"
        #define int               long long
        #define mem1(x)           memset(x, -1, sizeof (x))
        #define M                 1000000007
        #define MM                998244353
        #define ff                first
        #define pb                push_back
        #define pii               pair<int,int>
        #define rep(i,a,b)        for(long long i=a;i<b;i++)
        #define ss                second
        #define mii               map<int,int>
        #define psi               pair<string,int>
        #define pis               pair<int,string>
        #define GCD(x,y)          (__gcd((x), (y)))
        #define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
        #define mem0(x)           memset(x, 0, sizeof (x))
        #define all(x)            (x).begin(),(x).end()
        #define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
        int powmod(int a, int l, int md) {int res = 1; while (l) {if (l & 1)res = res * a % md; l /= 2; a = a * a % md;} return res;}
         
         
        void solve()
        {
            int input;
            

     string v;
     cin>>v;          
         


            if(v[0]=='7'||v[1]=='7'||v[2]=='7')
            {
            	cout<<"Yes"<<endl;

            }
            else
            {
            	cout<<"No"<<endl;
            }












           
        }
         
        signed main() {
            IOS;
        
            //sieve();
            int t = 1;
            //cin >> t;
            while (t--) solve();
            return 0;
        }

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

string g[101];
short dp[101][101][101][101];
short px[101][101],py[101][101];

void update(short& x,short y){
	x=max(x,y);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>g[i];
	for(int i=1;i<=n;i++)
		g[i].insert(0," ");
	int sx,sy;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(g[i][j]=='E'){
				sx=i,sy=j;
			}
			if(g[i][j]=='o'){
				px[i][j]=py[i][j]=1;
			}
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			px[i][j]+=px[i-1][j];
			py[i][j]+=py[i][j-1];
		}
	for(int i=sx;i>=1;i--)
		for(int j=sy;j>=1;j--)
			for(int ii=sx;ii<=n;ii++)
				for(int jj=sy;jj<=m;jj++){
					if(i>1){
						update(dp[i-1][j][ii][jj],dp[i][j][ii][jj]);
						int z=max(jj-sy+1,j),zz=min(m-sy+j,jj);
						if(ii-sx+1<i&&z<=zz)
							update(dp[i-1][j][ii][jj],dp[i][j][ii][jj]+py[i-1][zz]-py[i-1][z-1]);
					}
					if(ii<n){
						update(dp[i][j][ii+1][jj],dp[i][j][ii][jj]);
						int z=max(jj-sy+1,j),zz=min(m-sy+j,jj);
						if(n-sx+i>ii&&z<=zz)
							update(dp[i][j][ii+1][jj],dp[i][j][ii][jj]+py[ii+1][zz]-py[ii+1][z-1]);
					}
					if(j>1){
						update(dp[i][j-1][ii][jj],dp[i][j][ii][jj]);
						int z=max(ii-sx+1,i),zz=min(n-sx+i,ii);
						if(jj-sy+1<j&&z<=zz)
							update(dp[i][j-1][ii][jj],dp[i][j][ii][jj]+px[zz][j-1]-px[z-1][j-1]);
					}
					if(jj<m){
						update(dp[i][j][ii][jj+1],dp[i][j][ii][jj]);
						int z=max(ii-sx+1,i),zz=min(n-sx+i,ii);
						if(m-sy+j>jj&&z<=zz)
							update(dp[i][j][ii][jj+1],dp[i][j][ii][jj]+px[zz][jj+1]-px[z-1][jj+1]);

					}
				}
	cout<<dp[1][1][n][m]<<endl;
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  vector<ll>b(n+1);
  rep(i,0,n)b[i+1]=b[i]+a[i];
  auto dp=vec(n,n,0LL);
  rep(i,1,n){
    rep(j,0,n-i){
      ll minbuf=INF;
      rep(o,0,i){
        chmin(minbuf,dp[o][j]+dp[i-o-1][j+o+1]+b[i+j+1]-b[j]);
      }
      dp[i][j]=minbuf;
    }
  }
  cout<<dp[n-1][0]<<endl;
  return 0;
}

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

///cygdrive/c/users/charis/onedrive/c/problem/itp1

int  main(){
	
	string W, T;
	
	cin >> W ;
	for (int i=0; i<W.size(); i++){
		if (isupper(W[i])) W[i]=tolower(W[i]);			
	}	
	
	int x=0;
	while (1){
		cin >> T ;
		if (T=="END_OF_TEXT") break;
		for (int i=0; i<T.size(); i++){
			if (isupper(T[i])) T[i]=tolower(T[i]);			
		}
		if (T==W) x++;
	}
	cout << x << endl;
	
	return 0;
}

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

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

	int sub = b - a, ans = -a;
	rep(i, 0, sub) ans += i;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
INF = int(1e9 + 7)


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = i * FCT % INF
    return FCT


def main():
    N, M = map(int, input().split())
    if N == M:
        print(2 * factorial(min(N, M)) ** 2 % INF)
    elif abs(N - M) <= 1:
        print(factorial(min(N, M)) ** 2 * max(N, M) % INF)
    else:
        print(0)

    return


main()


Measured memory_bytes: 3060
N = int(input())

a = N / 1.08

a = int(a)
if int(a*1.08) == N:
    print(a)
elif int((a+1)*1.08)==N:
    print(a+1)
elif int((a-1) * 1.08 ) == N:
    print(a-1)
else:
    print(':(')


Measured memory_bytes: 3064
def main():
    n, k = map(int, input().split())
    
    ans = 0
    for j in range(1, n+1):
        i = 0
        while True:
            if j*(2 ** i) >= k:
                ans += 1/  (n * (2 ** i))
                break
            else:
                i += 1
            
    print(ans)

    
if __name__ == '__main__':
    main()

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

using namespace std;

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

int main() {
	int x;
	scanf("%d", &x);
	if (x < 1200) {
		printf("ABC\n");
	} else {
		printf("ARC\n");
	}
	
	
	
	return 0;
}

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



int main(){

    int N,M;
    long K;
    cin >> N >> M >> K;

    vector<int> A(N,0);
    vector<int> B(M,0);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<M;i++) cin >> B[i];

    // 累積和データを保存しておく
    vector<long> sumA(N+1,0);
    sumA[0] = 0;
    sumA[1] = sumA[0] + A[0];
    for(int i=2;i<=N;i++){
        sumA[i] = sumA[i-1]+A[i-1]; // i冊目まで読んだときの合計時間
        // Kが10^9以下なのでオーバーフロー考慮しなくて良い
        if(sumA[i]>K){ // 上限超えとなるので i冊目は存在しないこととする
            N = i-1;
            break;
        }
    }
    vector<long> sumB(M+1,0);
    sumB[0] = 0;
    sumB[1] = sumB[0] + B[0];
    for(int i=2;i<=M;i++){
        sumB[i] = sumB[i-1]+B[i-1]; // i冊目まで読んだときの合計時間
        // Kが10^9以下なのでオーバーフロー考慮しなくて良い
        if(sumB[i]>K){ // 上限超えとなるので i冊目は存在しないこととする
            M = i-1;
            break;
        }
    }
    // sumA, sumB の要素は 10^9 以下であるから足し合わせてもオーバーフローしない

    // 読める数最大値
    int maxv = 0;
    pair<int,int> hoge={0,0};

    for(int i=0;i<=N;i++){
        // Aをi冊読んだらK以上となる
        if(sumA[i]>K) break;
        long dst = K-sumA[i];

        if(sumA[i]+sumB[M]<=K){
            if(maxv < i+M){
                maxv = i+M;
                hoge = {i,M};
            }
            continue;
        }

        // にぶたん

        int L=0, R=M;
        if(L>=R)continue;

        while(R-L!=1){
            int mid=(L+R)/2;
            long tmp = sumB[mid];
            if(tmp<dst){
                L = mid;
            }else if(tmp==dst){
                L = mid;
            }else{ // tmp > dst
                R = mid;
            }
        }

        if(maxv < i+L){
            maxv = i+L;
            hoge = {i,L};
        }

    }

    // 検算

    //cout << hoge.first << ' ' << hoge.second << endl;
    cout << maxv << endl;


    
    return 0;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    string A,B; cin >> A >> B;
    B = B.substr(0,1)+B.substr(2,2);
    ll C = stol(A), D = stol(B);
    C *= D;
    C /= 100;
    cout << C << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define int128 __int128_t
#define Android ios::sync_with_stdio(false), cin.tie(NULL)
#define redirect_input freopen("./input.txt", "r", stdin);
#define redirect_output freopen("./output.txt", "w", stdout);
#define debug(s, r) std::cerr << #s << ": " << (s) << (r==0?' ':'\n')
#define pii pair<ll, ll>  
#define sqr(x) ((x)*(x))

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

const int maxn = 1e5 + 100;
const ll mod = 1e9 + 7;

ll n, nfac = 1;
ll a[maxn], presum[maxn];

ll inv(ll base){
    ll t = mod - 2, ret = 1;
    for(; t; t>>=1){
        if(t & 1) ret = ret * base % mod;
        base = base * base % mod;
    }
    return ret;
}

void init(){
    for(int i=2; i<=n; i++) nfac = nfac * i % mod;
    for(int i=2; i<=n; i++){
        presum[i] = (presum[i-1] + nfac * inv(i) % mod) % mod;
    }
}

void solve(){
    cin >> n;
    init();
    ll suma = 0, ans = 0;
    for(int i=1; i<=n; i++) cin >> a[i], suma = (suma + a[i]) % mod;
    for(int i=1; i<=n; i++){
        ans = (ans + (presum[i] + presum[n - i + 1]) % mod * a[i]) % mod;
    }
    ans = (ans + suma * nfac % mod) % mod;
    cout << ans << '\n';
}

signed main(){
    Android;
    solve();
}


Measured memory_bytes: 5204
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    REP(i,5){
        if (in() == 0){
            cout << i + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
ll n,k,a[200001];
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> k >> n;
  rep(i,n) cin >> a[i];
  int max_distance = (k - a[n-1]) + a[0];
  rep(i,n-1) max_distance = (max_distance < a[i+1]-a[i])? a[i+1]-a[i]: max_distance;

  int ans = k-max_distance;
  cout << ans<< endl;
}


Measured memory_bytes: 1792
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
for b in B:
    for y in range(3):
        for x in range(3):
            if A[y][x] == b:
                A[y][x] = -1
for y in range(3):
    if sum(A[y]) == -3:
        print("Yes")
        exit()
for x in range(3):
    if A[0][x] == A[1][x] == A[2][x] == -1:
        print("Yes")
        exit()
if A[0][0] == A[1][1] == A[2][2] == -1 or A[2][0] == A[1][1] == A[0][2] == -1:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 9092
//youtube解説のままです。
#include<stdio.h>
#include<stdlib.h>

int MIN(int a, int b){return a>b?b:a;}

int main(void){
    int n,k;
    scanf("%d%d", &n, &k);
    int x[n];
    for(int i = 0; i < n; i++){scanf("%d", &x[i]);}

    int l,r;
    int ans = 2000000001;
    int sum;
    for(int i = 0; i <= n-k; i++){
        sum = 0;
        l = i;
        r = i+k-1;
        sum += ( MIN(abs(x[l]), abs(x[r])) + x[r] - x[l]);
        ans = MIN(sum, ans);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 200010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int n, m, k, ans, a[MAXN], b[MAXN];
long long suma[MAXN], sumb[MAXN];

signed main() {
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		suma[i] = suma[i - 1] + a[i];
	}
	for (int i = 1; i <= m; ++i) {
		scanf("%d", &b[i]);
		sumb[i] = sumb[i - 1] + b[i];
	}
	for (int i = 0; i <= n; ++i) {
		int temp = k - suma[i];
		if (temp == 0) ans = max(ans, i);
		if(temp < 0) break;
		int pos = upper_bound(sumb + 1, sumb + m +1, temp) - sumb;
		ans = max(ans, i + pos - 1);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long int
int minn(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x;
    cin>>n;
    int a[n];
    int max=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>max)
            max=a[i];
    }
    sort(a,a+n);
    int pre[max+1];
    for(int i=0;i<=max;i++)
        pre[i]=1;
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(i<n-1&&a[i]==a[i+1])
            pre[a[i]]=0;
        count+=pre[a[i]];
        //if(pre[a[i]])
            //cout<<a[i]<<" ";
        int x=a[i];
        while(x<=max)
        {
            pre[x]=0;
            x+=a[i];
        }
    }
    cout<<count<<"\n";


}


Measured memory_bytes: 8332
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
i64 dp[100001][2];
int main() {
  cin >> n;
  read_n(a, n);
  i64 d = 0;
  dp[0][0] = dp[0][1] = 1;
  for (i64 i = 1; i < n; ++i) {
    dp[i][0] = min(
        dp[i - 1][0] + (a[i - 1] <= a[i] ? 0 : 1),
        dp[i - 1][1] + 1
    );
    dp[i][1] = min(
        dp[i - 1][0] + 1,
        dp[i - 1][1] + (a[i - 1] >= a[i] ? 0 : 1)
    );
  }
  cout << min(dp[n - 1][0], dp[n - 1][1]) << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>

using namespace std;

int main(){
    int n,d;
    cin>>n>>d;
    if (n%(2*d+1)==0 && n/2*(d+1)>=0) {
        cout<<n/(2*d+1)<<endl;
    }else if(n%(2*d+1)!=0 && n/2*(d+1)>=0){
        cout<<n/(2*d+1)+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 10
using namespace std;

int num, ans = 0;
int ary[MAX] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int sum, int count) 
{
	if (count == 4 || sum == num) {
		if (sum == num) ans++;
	}else {
		for (int j = 0; j < MAX; j++) {
			dfs(sum+ary[j], count+1);
		}
	}
}

int main(void)
{
	while (cin >> num) {
		ans = 0;
		dfs(0, 0);
		cout << ans << endl;
	}
	
	return 0;
}

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

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

	ll z = 2;
	map<ll, ll> m;
	while (z * z <= n) {
		if (n % z == 0) {
			m[z]++;
			n /= z;
		} else
			z++;
	}
	if (n != 1)
		m[n]++;

	ll count = 0;
	for (auto p : m) {
		for (ll i = 1; i <= p.second; i++) {
			count++;
			p.second -= i;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3632
# include <cstdio>
using namespace std;
int c[2005][2005];
long long C(int n, int m)
{
	if(n < m)
	{
		return 0;
	}
	return c[n][m];
}
int p = 1e9 + 7;
int main()
{
	int ans;
	int n;
	int k;
	scanf("%d%d", &n, &k);
	for(int i = 0; i <= n; i++)
	{
		c[i][0] = 1;
		c[i][i] = 1;
 	}
 	for(int i = 1; i <= n; i++)
 	{
 		for(int j = 1; j <= i - 1; j++)
 		{
 			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;
		 }
	 }
	for(int i = 1; i <= k; i++)
	{
		printf("%d\n", C(n - k + 1, i) * C(k - 1, i - 1) % p);
	}
	return 0;
 } 

Measured memory_bytes: 14976
while True :
    n = int(input())
    
    if n == 0 :
        break
    else :
        cnt = 0
        
        while True:
            if n == 1 :
                print(cnt)
                break
            
            elif n % 2 == 0 :
                n /= 2
                cnt += 1
                
            else :
                n *= 3
                n += 1
                cnt += 1
        



Measured memory_bytes: 5592
import sys
if __name__ == "__main__":
    N=6
    in_lst=[]
    for _ in range(N):
        in_lst.append(int(input()))
    for i in in_lst[:-1]:
        for j in in_lst[:-1]:
            if j-i>in_lst[-1]:
                print(':(')
                sys.exit()
    print('Yay!')


Measured memory_bytes: 2940
from sys import stdin
import string
s = (stdin.readline().rstrip())
K = int(stdin.readline().rstrip())

alp = string.ascii_lowercase*3
ans = ""
for i in s:
    ind = alp.index(i)
    cnt = 0
    if i == "a":
        ans += "a"
        continue
    for j in alp[ind+1:]:
        cnt += 1
        if K - cnt < 0:
            ans += i
            cnt = 0
            break
        if j == "a":
            ans += "a"
            K = K - cnt
            cnt = 0
            break
if K != 0:
    ind = (K % 26) + alp.index(ans[-1])
    ans = ans[:-1]+alp[ind]
print(ans)

Measured memory_bytes: 4088
import numpy as np

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

N = int(input())

card = np.zeros((3, 3))
for i in range(N):
    t = int(input())
    if t in A1:
        card[0][A1.index(t)] = 1
    if t in A2:
        card[1][A2.index(t)] = 1
    if t in A3:
        card[2][A3.index(t)] = 1
f = False
s = np.sum(card, axis=0)
if s[0] == 3 or s[1] == 3 or s[2] == 3:
    f = True

if card[0][0] + card[1][1] + card[2][2] == 3 or card[0][2] + card[1][1] + card[2][0] == 3:
    f = True
s = np.sum(card, axis=1)
if s[0] == 3 or s[1] == 3 or s[2] == 3:
    f = True

if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12504