akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>

class Task {
public:
  bool read() {
    int n, m, k;
    if (scanf("%d%d%d", &n, &m, &k) != 3) {
      return false;
    }

    good.resize(n);
    bad.resize(n);
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      a--;
      b--;
      good[a].push_back(b);
      good[b].push_back(a);
    }
    for (int i = 0; i < k; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      a--;
      b--;
      bad[a].push_back(b);
      bad[b].push_back(a);
    }

    color.resize(n);
    color_count.resize(n + 1);
    int next_color = 1;
    for (int i = 0; i < n; i++) {
      if (color[i] != 0) {
        continue;
      }
      dfs(i, next_color);
      next_color++;
    }

    for (int i = 0; i < n; i++) {
      int res = color_count[color[i]] - 1 - (int)good[i].size();
      for (auto u : bad[i]) {
        if (color[i] == color[u]) {
          res--;
        }
      }
      printf("%d ", res);
    }
    printf("\n");

    return true;
  }

private:
  int n, m, k;
  std::vector<std::vector<int>> good;
  std::vector<std::vector<int>> bad;

  std::vector<int> color;
  std::vector<int> color_count;
  void dfs(int v, int c) {
    if (color[v] != 0) {
      return;
    }
    color_count[c]++;
    color[v] = c;
    for (auto u : good[v]) {
      dfs(u, c);
    }
  }
};

bool run() {
  Task task;
  if (!task.read()) {
    return false;
  }
  return true;
}
int main(void) {
  while (run()) {
  }
};


Measured memory_bytes: 12536
N = int(input())
TA = []
for i in range(N):
	TA.append(list(map(int, input().split())))
 
TA.reverse()
(voteA, voteB) = (1,1)
while TA:
	(Ti, Ai) = TA.pop()
	tmp = max((voteA + Ti -1) // Ti, (voteB + Ai -1) // Ai)
	voteA = Ti * tmp
	voteB = Ai * tmp
print(voteA + voteB)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

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

int main(){
  int a[3], m[3];
  while(true){
    int c[3] = {0};
    REP(i,3) scanf("%d%d",&a[i],&m[i]);
    if(a[0] == 0) return 0;

    REP(i,3){
      int x = 1;
      do{
	c[i]++;
	x = (a[i] * x) % m[i];
      }while(x!=1);
    }

    ll ans = (ll)c[0] * c[1] / gcd(c[0], c[1]);
    ans = ans * c[2] / gcd(ans, c[2]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
typedef long long ll;typedef pair<int,int> PII;const ll mod=1e9+7;const int N = 1e6+10;ll a[N];
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;}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	set<int> s;
	rep(i,0,n){
		cin>>a[0];
		s.insert(a[0]);
	}
	cout<<((int)s.size()==n?"YES":"NO");
  	return 0;
}



Measured memory_bytes: 9600
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n,k;
	cin >> n >> k ;
	cout << n - k + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
ll dp[400][400];
ll presum[401];
ll getsum(int l,int r){
	l++;r++;
	return presum[r]-presum[l-1];
}
int a[400];
ll min(ll a, ll b){
	return a < b ? a: b;
}
ll mincost(int l,int r){
	if(dp[l][r]!=0) return dp[l][r];
	if (r-l+1==2) return a[l]+a[r];
	if (l==r) return 0;
	
	ll mc = __LONG_LONG_MAX__;
	for(int i = l+1;i<=r;i++){
		ll L  =  mincost(l,i-1) ;
		ll R = mincost(i,r) ;
		mc = min(mc, L + R );
	}

	return dp[l][r] = mc + getsum(l,r);
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) presum[i] = presum[i-1] + a[i-1];
	printf("%lld",mincost(0,n-1) );
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;
    int n = s.size();

    string tmp, tmp2;
    tmp.push_back(s[0]);
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        tmp2.push_back(s[i]);
        if (tmp != tmp2) {
            cnt++;
            tmp = tmp2;
            tmp2.clear();
        }
    }

    cout << cnt + 1 << '\n';
    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
 
#define M_MAX 201
#define N_MAX 1001
 
int n, m;
int mx[M_MAX], my[M_MAX];
int nx[N_MAX], ny[N_MAX];
 
int main() {
  int i, j;
  int k;
   
  while (scanf("%d", &m),m) {
    for (i = 0; i < m; i++) {
      scanf("%d%d", mx+i, my+i);
    }
     
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
      scanf("%d%d", nx+i, ny+i);
    }
     
    for (i = 0; i < n; i++) {
      for (j = 1; j < m; j++) {
    int xd = nx[i] - mx[0] + mx[j];
    int yd = ny[i] - my[0] + my[j];
     
    for (k = 0; k < n; k++) {
      if (xd == nx[k] && yd == ny[k]) {
        break;
      }
    }
     
    if (k == n) {
      break;
    }
      }
      if (j == m) {
    printf("%d %d\n", nx[i] - mx[0], ny[i] - my[0]);
    break;
      }
    }
  }
   
  return 0;
}

Measured memory_bytes: 2696
import sys

N = int(input().strip())
P = list(map(int, input().split()))

cnt = 0
for i in range(N):
    if P[i] != i + 1:
        if P[P[i] - 1] == i + 1:
            cnt += 1
        else:
            print("NO")
            sys.exit(0)

if cnt == 0 or cnt == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 9999999999999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	long long a, b, k[55], l[55], mon;
	cin >> a >> b;
	vector<long long> n, m;
	for (int i = 0; i < a; ++i) {
		cin >> k[i] >> l[i];
		n.push_back(k[i]);
		m.push_back(l[i]);
	}
	sort(n.begin(), n.end());
	sort(m.begin(), m.end());
	long long ans = (abs(n[a - 1] - n[0]))*(abs(m[a - 1] - m[0]));
	for (int i = 0; i < a; ++i) {
		for (int j = i + 1; j < a; ++j) {
			for (int kk = 0; kk < a; ++kk) {
				for (int ll = kk + 1; ll < a; ++ll) {
					mon = 0;
					for (int mm = 0; mm < a; ++mm) {
						if (n[i] <= k[mm] && k[mm] <= n[j] && m[kk] <= l[mm] && l[mm] <= m[ll]) { ++mon; }
					}
					if (mon >= b) { ans = min(ans, (abs(n[j] - n[i]))*(abs(m[ll] - m[kk]))); }
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		
		while(true){
			boolean flag = true;
			for(int j = 2; j < Math.sqrt(x); j++){
				if(x%j==0){
					flag = false;
					break;
				}
			}
			if(flag){
				System.out.println(x);
				return;
			}
			x++;
		}



	}

}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
 
int main(){
    
    int x, y, i;

    
    while (1){
            cin >> x >> y;
        if ( x == 0 && y == 0 ) break;
    
        if ( x < y ){
            cout << x << " " << y << endl;
}       else {
            cout << y << " " << x << endl;
    
}
}

    return 0;		 
}


Measured memory_bytes: 3104
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp;

fn main() {
    input!{
        a: i32, b: i32,
    }

    println!("{}", cmp::max(cmp::max(a + b,a - b), a * b));
}


Measured memory_bytes: 4352
//
// Created by Mahmoud Rashad on 11/27/19.
//

// Compiled with: g++ -Wall -std=c++14 -pthread

#include <bits/stdc++.h>

using namespace std;

typedef vector<pair<int, bool>> vii;

int main(){

    int n;
    cin >> n;
    vector<vii> data(n, vii());
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        while (a--) {
            int u;
            bool kind;
            cin >> u >> kind;
            data[i].push_back({--u, kind});
        }
    }


    int ans = 0;
    for(int mask = 0; mask < (1 << n); ++mask) {
        bool f = true;
        for (int i = 0; i < n; ++i) {
            if (!(mask & (1 << i)))
                continue;
            for (auto &p : data[i]) {
                int u = p.first;
                bool kind = p.second;
//                cout << mask << ' ' << u << ' ' << kind << endl;
                f &= ((bool)(mask & (1 << u)) == kind);
            }
        }
//        cout << mask << ' ' << f << endl;
        ans = max(ans, __builtin_popcount(mask) * f);
    }


    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define ull unsigned long long
std::unordered_map<ull,ull>mp;
inline ull hs(re ull l,re ull r,re ull l1,re ull r1)
{
	return r1|(l1<<20)|(r<<40)|(l<<50);
}
int a[110];
ull dfs(re int l,re int r,re int l1,re int r1)
{
	if(r<l)return 0;
	ull hh=hs(l,r,l1,r1);
	std::unordered_map<ull,ull>::iterator it=mp.find(hh);
	if(it!=mp.end())return it->second; 
	re ull ans=1llu<<60;
	for(re int i=l;i<=r;i++)
	{
		re ull num=dfs(l,i-1,l1,l1+r1)+dfs(i+1,r,l1+r1,r1)+(ull)a[i]*(l1+r1);
		if(num<ans)ans=num;
	}
	return mp[hh]=ans;
}
int main()
{
	re int n;
	scanf("%d",&n);
	for(re int i=1;i<=n;i++)scanf("%d",&a[i]);
	printf("%llu\n",dfs(2,n-1,1,1)+a[1]+a[n]);
}

Measured memory_bytes: 14408
#include<iostream>
#include<map>
using namespace std;
int N,Q;
map<int,int>mp;
main()
{
	cin>>N;
	long sum=0;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		sum+=A;
		mp[A]++;
	}
	cin>>Q;
	for(;Q--;)
	{
		long B,C;cin>>B>>C;
		sum+=(C-B)*mp[B];
		mp[C]+=mp[B];
		mp[B]=0;
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 7992
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 10000000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int dp[101010][3],n,m,s,t,vis[101010][3];
vi adj[101010];

void bfs( int s ){

   queue<int> q;
   for(int i=1;i<=n;i++){
      for(int j=0;j<3;j++){
         dp[i][j]=inf;
      }
   }

   dp[s][0]=0;
   vis[s][0]=1;
   q.push(s);

   while(!q.empty()){
      s = q.front();q.pop();
      //if( vis[s][0]&&vis[s][1]&&vis[s][2] )continue;
      //cout << s << endl;
      for(int i=0;i<3;i++){
         if( !vis[s][i] )continue;
         for(auto t:adj[s]){
            //cout << t << endl;
            if( vis[t][(i+1)%3] )continue;
            dp[t][(i+1)%3] = dp[s][i]+1;
            vis[t][(i+1)%3]=1;
            q.push(t);
         }
      }
   }

}

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

   cin >> n >> m;
   for(int i=1;i<=m;i++){
      int x,y;
      cin >> x >> y;
      adj[x].pb(y);
   }

   cin >> s >> t;

   bfs(s);



   if( vis[t][0] ){
      cout << dp[t][0]/3 << endl;
   }
   else {
      cout << -1 << endl;
   }

return 0;
}
///....


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;

    if(N == 3){
        cout << 2 << endl;
        cout << "1 3" << endl;
        cout << "2 3" << endl;
        return 0;
    }
    if(N == 4){
        cout << 4 << endl;
        cout << "1 2" << endl;
        cout << "1 3" << endl;
        cout << "4 2" << endl;
        cout << "4 3" << endl;
        return 0;
    }

    mat g;
    if(N % 2 == 1){
        g.pb(vec({N}));
        N--;
    }
    REP(i, N){
        int k = i + 1, l = N - i;
        if(k > l) break;
        g.pb(vec({k, l}));
    }
    g.pb(g[0]);

    mat ans;
    REP(i, SZ(g) - 1){
        for(int k: g[i]) for(int l: g[i + 1]) ans.pb(vec({k, l}));
    }
    cout << SZ(ans) << endl;
    REP(i, SZ(ans)){
        cout << ans[i][0] << " " << ans[i][1] << endl;
    }

    return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

string s;
int n;

map<pair<int, string>, int> res;

int solve(int i, string prev) {
    if(i == n) return 0;

    if(i == n-1) {
        if(prev == s.substr(i)) return 0;
        else return 1;
    }

    pair<int, string> cur = {i, prev};
    if(res.count(cur)) return res[cur];
    
    int ret = 0;
    if(s.substr(i, 1) != prev) {
        ret = max(ret, solve(i+1, s.substr(i, 1)));
    }
    if(s.substr(i, 2) != prev) {
        ret = max(ret, solve(i+2, s.substr(i, 2)));
    }

    res[cur] = ret+1;
    return ret + 1;
}

int32_t main() {

    cin >> s;
    n = s.length();

    int ans = solve(0, "0");

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


Measured memory_bytes: 86404
n = []
m = [[0 for i in range(3)] for j in range(2)]
for x in range(3):
    n.append(list(map(int, input().split())))

k =max(n)
kaisuu = max(k) + 1

def tansa(m):
    iti = 2
    for j in range(kaisuu):
        for k in range(kaisuu):
            if j + k == n[iti][iti]:
                m[0][iti] = j
                m[1][iti] = k
                for a in range(kaisuu):
                    for b in range(kaisuu):
                        if a + b == n[iti - 1][iti - 1] and a + m[1][iti] == n[iti - 1][iti]:
                            m[0][iti - 1] = a
                            m[1][iti - 1] = b
                            for c in range(kaisuu):
                                for d in range(kaisuu):
                                    if c + d == n[iti - 2][iti - 2] and c + m[1][iti - 1] == n[iti - 2][iti - 1] and c + m[1][iti] == n[iti - 2][iti]:
                                        m[0][iti-2] = c
                                        m[1][iti-2] = d
                                        if m[0][1] + m[1][0] == n[1][0] and m[0][2] + m[1][0] == n[2][0] and m[0][2] + \
                                                m[1][1] == n[2][1]:
                                            print("Yes")
                                            exit()

tansa(m)
print("No")


Measured memory_bytes: 40304
#include <iostream>
#include <vector>
using namespace std;
vector <int> a,b,c;
 
 
void shuffle(int kazu) {
   
  while(1) {
    int flg = 0;
     
    for(int i=0;i<kazu;i++) {
      if(a.size() == 0) {
    if(i == 0) flg++;
    break;
      }
      c.push_back(a[0]);
      a.erase(a.begin());
    }
 
    
    for(int i=0;i<kazu;i++) {
      if(b.size() == 0) {
    if(i == 0) flg++;
    break;
      }
      c.push_back(b[0]);
      b.erase(b.begin());
    }
  
 
    if(flg==2) break;
  }
 
 
}
 
 
int main() {
 
  int n,r;
 
  while(cin >> n >> r) {
    a.clear();
    b.clear();
    c.clear();
 
    for(int i=n/2;i<n;i++) a.push_back(i);
    for(int i=0;i<n/2;i++) b.push_back(i);
 
    for(int q=0;q<r;q++){
      int kazu;
      cin >> kazu;
      shuffle(kazu);
      a = c;
      for(int i=0;i<n/2;i++) {
    b.push_back(a[0]);
    a.erase(a.begin());
      }
      c.clear();
    }
    
    cout << a[n-1] <<endl; 
  }
 
  return 0;
}

Measured memory_bytes: 1224
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

x = int(input())
sum = 0
ans = 0
for i in range(0,x+1):
    sum = sum + i
    if sum >= x:
        ans = i
        break
print(ans)


Measured memory_bytes: 2940
//https://atcoder.jp/contests/dp/tasks/dp_m
//O(n*K*K) solution

#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX 1e9+7
#define lim 1e5
using namespace std;

const lld mod=MAX;


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

	int n,k;
	cin>>n>>k;

	std::vector<int> v(n);

	for(int i=1;i<=n;i++)
		cin>>v[i];

	int dp[n+1][k+1];

	memset(dp,0,sizeof(dp));

	for(int i=0;i<=n;i++)
		dp[i][0]=1;

	for(int i=1;i<=n;i++)
	{
		std::vector<int> prefsum(k+1);

		prefsum[0]=dp[i-1][0];

		for(int t=1;t<=k;t++)
		{
			prefsum[t] = (prefsum[t-1]+dp[i-1][t])%mod;
		}


		for(int j=1;j<=k;j++)
		{
			//dp[i][j] = (dp[i][j]%mod + dp[i-1][j-t]%mod)%mod;

			if(j-v[i]>0)
			{
				dp[i][j] = ((prefsum[j]-prefsum[j-v[i]-1])+mod)%mod;
			}

			else
				dp[i][j] = prefsum[j]%mod;
		}
	}


	cout<<dp[n][k]%mod<<endl;

}
//https://atcoder.jp/contests/dp/submissions/13269695

Measured memory_bytes: 40064
#include <iostream>
#include <string>
using namespace std;
int main(){

  int a,b;
  string s;
  cin>>a>>b>>s;
  if(s.size()==a+b+1){
    if(s[a]=='-'){
      int r=0;
      for(int i=0;i<(int)s.size();i++) if(s[i]=='-') r++;
      if(r==1){
        cout<<"Yes"<<endl;
        return 0;

      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(( abs(b-a) <= d && abs(c-b) <= d ) || abs(c-a)<=d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var line = System.Console.ReadLine();
        var n = int.Parse(line.Split(' ')[0]);
        var k = int.Parse(line.Split(' ')[1]);
        line = System.Console.ReadLine();
        var list = line.Split(' ');
        var pList = new List<int>();
        for (var i = 0; i < n; i++)
        {
            var p = int.Parse(list[i]);
            pList.Add(p);
        }
        var sum = pList.OrderBy(p => p)
            .Take(k)
            .Sum();
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 28540
program main
  implicit none
  character(len=1000) :: S,T
  integer :: len_S, len_T
  !
  integer :: i, j
  integer,allocatable :: counter(:)
  read(*,*) S
  read(*,*) T
  len_S = len(trim(S))
  len_T = len(trim(T))

  allocate(counter(len_S-len_T+1))
  counter = 0
  do i = 1, len_S-len_T+1
     do j  = 0,len_T-1
        if (S(i+j:i+j) == T(j+1:j+1)) counter(i) = counter(i) + 1
     end do
  end do
  write(*,'(i0)') len_T- maxval(counter)
  stop
end program main


Measured memory_bytes: 2928
#include<iostream>
#include<vector>

using namespace std;

int N;

int main() {
	cin >> N;
	vector<int> A(N), B(N), C(N - 1);
	for (int i = 0; i < N; i++) { cin >> A[i]; A[i]--; }
	for (int i = 0; i < N; i++) { cin >> B[i]; }
	for (int i = 0; i < N - 1; i++) { cin >> C[i]; }

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += B[A[i]];
		if (i > 0 && A[i] == A[i - 1] + 1) {
			ans += C[A[i] - 1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll ans=(n/500)*1000;
		ans+=((n%500)/5)*5;
		cout<<ans<<endl;
	}
}


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

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

long long MOD = 10000000000 + 7;

template<typename T>
map<T, int> prime_factorize(T x){
  map<T, int> res;

  while(x%2==0){
    x/=2;
    res[2]++;
  }

  for(int i=3;i*i<=x;i+=2){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

map<int,int> merge_map(map<int,int >m1, map<int,int> m2){
  map<int,int> m;
  for(auto x: m1){
    m[x.first] = 1;
  }
  for(auto x: m2){
    m[x.first] = 1;
  }
  return m;
}

template<typename T>
T gcd(T a, T b) {
  if(a < b) swap(a,b);
    
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<int> A;

  map<int, int> m;
  bool pairwise_flg = true;
  bool setwise_flg = true;
  int gcd_val;

  int one_count = 0;

  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    if(tmp == 1){
      one_count++;
    } else {
      A.push_back(tmp);
    }
  }

  if(one_count == N){
    cout << "pairwise coprime" << endl;
    return 0;
  }

  N = A.size();

  for(int i = 0; i < N; i++){
    if(i == 0){
      m = prime_factorize(A[i]);
    } else { 
      map<int,int> m_tmp1, m_tmp2; 
      m_tmp1 = prime_factorize(A[i]);
      int before = m.size();
      m.insert(m_tmp1.begin(), m_tmp1.end());
      if(m.size() == m_tmp1.size() + before){
        // OK
      } else {
        pairwise_flg = false;
        break;
      }
    }
  }

  for(int i = 0; i < N; i++){
    if(i == 0){
      gcd_val = A[i];
    } else {
      // cerr << i << " " << A[i] << " " << gcd_val << endl;
      gcd_val = gcd(gcd_val, A[i]);
    }
  }
  // cerr << "gcd_val: " << gcd_val << endl;

  setwise_flg = (gcd_val == 1);
  if(one_count > 0){
    setwise_flg = true;
  }

  if(pairwise_flg){
    cout << "pairwise coprime" << endl;
  } else if(setwise_flg){
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 7424
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W = map(int,readline().split())
floor = np.frombuffer(read(),dtype='S1').reshape(H,-1)[:,:W] == b'.'

score = np.zeros((H,W),np.int32)

x = np.zeros((H,W),np.int32)
for n in range(1,H):
    x[n] = (1+x[n-1])*floor[n-1]
score += x

x[:] = 0
for n in range(H-1,0,-1):
    x[n-1] = (1+x[n])*floor[n]
score += x

x[:] = 0
for n in range(1,W):
    x[:,n] = (1+x[:,n-1])*floor[:,n-1]
score += x

x[:] = 0
for n in range(W-1,0,-1):
    x[:,n-1] = (1+x[:,n])*floor[:,n]
score += x

score *= floor
answer = score.max() + 1
print(answer)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    unsigned int N, D, i, c = 0;
    cin >> N >> D; long long X, Y;
    for (i = 0; i < N; i++) {
        cin >> X >> Y;
        if (ceil(sqrt(X * X + Y * Y)) <= D)
            c++;
    }
    cout << c << "\n";
    return EXIT_SUCCESS;
}


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

int bingo[5][5];
bool result[5][5];
int b[20];

int main(){
  rep(i, 3)rep(j, 3)result[i][j] = false;
  rep(i, 3){
    rep(j, 3){
      cin >> bingo[i][j];
      //cerr << bingo[i][j];
    }
    //cerr << endl;
  }
  int n;
  cin >> n;
  rep(p, n){
    int b; cin >> b;
    rep(i, 3){
      rep(j, 3){
        if(bingo[i][j] == b){
          result[i][j] = true;
        }
      }
    }
  }
  rep(i, 3){ rep(j, 3) cerr << result[i][j]; cerr << endl; }
  string res = "No";
  rep(i, 3){
    if(result[i][0] && result[i][1] && result[i][2]){
      res = "Yes";
    }
    if(result[0][i] && result[1][i] && result[2][i]){
      res = "Yes";
    }
  }
  if(result[0][0] && result[1][1] && result[2][2]){
    res = "Yes";
  }if(result[0][2] && result[1][1] && result[2][0]){
    res = "Yes";
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


int main(){
  ll h, w; cin >> h >> w;
  if(w==1 || h==1){
    cout << 1 << endl; return 0;
  }
  ll ans = 0;
  ans+=(w*(h/2));
  if(h%2){
    ans+=((w+1)/2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main()
{
  ll A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  if(A > B) swap(A, B);
  ll x = A + V * T;
  ll y = B + W * T;
  if(x >= y) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

const int INF = 100000000;

typedef pair<int, int> P;

int H, W;
char A[1000][1000];

int d[1000][1000];

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

int bfs() {
  queue<P> que;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      d[i][j] = INF;
      if (A[i][j] == '#') {
        d[i][j] = 0;
        que.push(P(i, j));
      }
    }
  }
  int maxd = 0;
  while (que.size()) {
    P p = que.front(); que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (0 <= nx && nx < H && 0 <= ny && ny < W && d[nx][ny] == INF) {
        d[nx][ny] = d[p.first][p.second] + 1;
        maxd = max(maxd, d[nx][ny]);
        que.push(P(nx, ny));
      }
    }
  }
  return maxd;
}

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      cin >> A[i][j];
  cout << bfs() << endl;
  return 0;
}

Measured memory_bytes: 13328
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define MAXN 1005
#define inside(x,y) (x>0&&y>0&&x<=h&&y<=w)
#define encode(x,y) ((x-1)*w+y)
#define decodex(s) ((s-1)/w+1)
#define decodey(s) ((s-1)%w+1)
#define success(x,y) (x==gx&&y==gy)
const int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
int w,h,n;
char map[MAXN][MAXN];
int che[15][2];
int step[MAXN][MAXN];
int BFS(int sx,int sy,int gx,int gy)
{
	memset(step,0,sizeof step);
	step[sx][sy]=1;
	queue<int>Q;
	Q.push(encode(sx,sy));
	int s,x,y,tx,ty;
	while(!Q.empty())
	{
		s=Q.front();
		Q.pop();
		x=decodex(s);
		y=decodey(s);
		for(int d=0;d<4;d++)
		{
			tx=x+dir[d][0];
			ty=y+dir[d][1];
			if(!inside(tx,ty)||map[tx][ty]=='X'||step[tx][ty])
				continue;
			if(success(tx,ty))
				return step[x][y];
			step[tx][ty]=step[x][y]+1;
			Q.push(encode(tx,ty));
		}
	}
	return 0x7FFFFFFF;
}
int main()
{
	int sx,sy,gx,gy;
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=h;i++)
	{
		scanf("%s",map[i]+1);
		for(int j=1;j<=w;j++)
		{
			if(map[i][j]>='0'&&map[i][j]<='9')
				che[map[i][j]-'0'][0]=i,
				che[map[i][j]-'0'][1]=j;
			if(map[i][j]=='S')
				sx=i,sy=j;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		gx=che[i][0];
		gy=che[i][1];
		ans+=BFS(sx,sy,gx,gy);
		sx=gx;
		sy=gy;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7604
#include<bits/stdc++.h>
using namespace std;
//ai*log(ai);
//solve dynamic programming problems
//dp with bitmasks
vector< vector<int> > p;
int answer=0;
void permute(int s[],int l,int r,int n)
{
	if(l==r)
	{
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			ans+=p[i][s[i]];
		}
		answer=max(answer,ans);
	}
	else
	{
		for(int i=l;i<=r;i++)
		{
			swap(s[i],s[l]);
		permute(s,l+1,r,n);
		swap(s[i],s[l]);	
		}
	}
}
const int MOD=1e9+7;
int countbit(int mask)
{ int count=0;
	while(mask)
	{
		if(mask%2)count++;
		mask=mask/2;
	}
	return count;
}
const int inf =1e9+7;
signed main()
{
  int n,k;
  cin>>n>>k;
  int a[n+1]={0};
  for(int i=1;i<=n;i++)
  cin>>a[i];
  vector<int> dp;
  dp.resize(n+1);
  dp[0]=0;
  for(int i=1;i<=n;i++)
  { 
  int x=inf;
  	for(int j=i-1;j>=max(i-k,1);j--)
  	{
  	 x=min(x,dp[j]+abs(a[i]-a[j]));	
	}
	if(x!=inf)
	dp[i]=x;
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 4000
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=1e4;//1e9+7;
const int maxn=1e5+9;
const ll maxx=1e12+9;

int l,r,d;

int main()
{
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++)
        if(i%d==0) cnt++;
    cout<<cnt<<endl;
}


Measured memory_bytes: 3620
// inputに入力データ全体が入る
function Main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;
    
    console.log((a*b)%2==0?"Even":"Odd")
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 11468
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
bucket = [0 for _ in range(N)]
for i in range(M):
    a, b = map(int, sys.stdin.readline().rstrip().split())
    bucket[a-1] += 1
    bucket[b-1] += 1
for n in bucket:
    print(n)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args)throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader (is);
		int N = Integer.parseInt(br.readLine());
		int count = 0;
		int cardList[] = new int[N];
		long result = 0;
		while(br.ready()) {
			int card = Integer.parseInt(br.readLine());
			cardList[count] = card;
			if(count!=0) {
				if(cardList[count-1]>0 && cardList[count]>0) {
					if(cardList[count-1]%2 !=0) {
						cardList[count] -= 1;
						result += 1;
					}
				}
				result  += cardList[count-1]/2;
			}
			count++;
		}
		result += cardList[N-1]/2;
		System.out.println(result);
	}
}

Measured memory_bytes: 30560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws IOException 
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		sb.append(br.readLine());
		
		for(int i=0; i<sb.length(); i++)
		{
			char chk = sb.charAt(i);
			if(Character.isUpperCase(chk))
			{
				chk = Character.toLowerCase(chk);
				sb.setCharAt(i, chk);
			}
			else if(Character.isLowerCase(chk))
			{
				chk = Character.toUpperCase(chk);
				sb.setCharAt(i, chk);
			}
		}
		System.out.println(sb.toString());
	}
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, t, a;

void read() {
  cin >> n >> t >> a;
}

double Abs(double x) {
  if (x < 0)
    return -x;
  return x;
}

void solve() {
  double cmin = 100000.0;
  int sol = -1;
  for(int i = 0; i < n; ++i) {
    double x;
    cin >> x;
    double nr = 1.0 * a - (t - x * 0.006);
    if (cmin > Abs(1.0 * nr)) {
      cmin = Abs(1.0 * nr);
      sol = i + 1;
    }
  }
  cout << sol;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
//  cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


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

int main(){
    int a;

    cin >> a;

    if( a < 1200 ){
        cout << "ABC" << "\n";
    }
    else if( a < 2800 ){
        cout << "ARC" << "\n";
    }
    else{
        cout << "AGC" << "\n";
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");
		int v = Integer.parseInt(k[0]);// n
		int v2 = Integer.parseInt(k[1]);// m

		String[] n = new String[v];
		String[] m0 = new String[v2];
		int[] m = new int[v2];
		for (int i = 0; i < v; i++) {
			n[i] = sc.nextLine();// String??????n?????\??????????????¨???
		}
		for (int i = 0; i < v2; i++) {
			m0[i] = sc.nextLine();
			m[i] = Integer.parseInt(m0[i]);// int?????????????????????m?????\???
		}
		for (int i = 0; i < n.length; i++) {
			String[] gyou = n[i].split(" ");// ????????¨???n?????°??????
			int[] gyouv = new int[m.length];
			for (int j = 0; j < gyou.length; j++) {
				gyouv[j] = Integer.parseInt(gyou[j]);// 1????????°????????????
			}
			int sum = 0;
			for (int j = 0; j < gyouv.length; j++) {
				sum += gyouv[j] * m[j];

			}
			System.out.println(sum);

		}
	}

}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    int A,B;
    Scd3(N,A,B);

    printf ("%s\n", (B-A)%2 ? "Borys" : "Alice" );

    return 0;
}





Measured memory_bytes: 256
import numpy as np
# 差分の大きい値（移動距離が長い）は駒の数-1でショートカットできる
N, K = map(int, input().split())
X = np.array(list(map(int, input().split())))
X = np.sort(X)
X = np.diff(X)
X = np.sort(X)

ans = 0
if K-N >= 0:
  ans = sum(X[:K-N])
print(ans)  


Measured memory_bytes: 22992
H, W = list(map(int, input().split()))
dic = {}

for i in range(H):
    S = input()
    for j in range(W):
        dic[S[j]] = dic.get(S[j], 0) + 1

N = ((W + 1)//2) * ((H + 1) // 2)
needFour = (W // 2) * (H // 2)
needOne = (W % 2) * (H % 2)
needTwo = N - needFour - needOne

pare = [0, 0, 0]
for v in dic.values():
    pare[0] += v//4
    pare[1] += (v%4)//2
    pare[2] += v % 2

if pare[0] < needFour:
    print("No")
else:
    pare[1] += (pare[0] - needFour) * 2
    if pare[1] < needTwo:
        print("No")
    else:
        pare[2] += (pare[1] - needTwo) * 2
        if pare[2] < needOne:
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++){
        int t;
        cin >> t;
        if (t >= k)
            ans++;
    }
    cout << ans;
    return 0;
}  


Measured memory_bytes: 384
#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(){
   int n,k; cin>>n>>k;
   vector<int> a(n);
   rep(i,n) cin>>a[i];
   sort(a.rbegin(),a.rend());
   int cnt=0;
   rep(i,n){
      if (a[i]==a[0]) cnt++;
   }
   int ans=0;
   if((n-cnt)%(k-1)==0) ans= (n-cnt)/(k-1);
   else ans= (n-cnt)/(k-1)+1;
   cout<<ans<<endl;
   return 0;
}

   


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

int main(){
	int h, w;
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0) break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(i == 0 || i == h-1){
					putchar('#');
				}else{
					if(j == 0 || j == w-1){
						putchar('#');
					}else{
						putchar('.');
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[4096];
char t[4] = "BGR";
int cnt[90][4096] = {};

int main(){
	int n; scanf("%d%s", &n, s);
	REP(j, 3){
		REP(i, n){
			cnt[t[j]][i+1] = cnt[t[j]][i] + (s[i]==t[j] ? 1 : 0);
		}
	}
	ll ans = 0;
	do {
		REP(i, n){
			if(s[i] != t[1]) continue;
			ans += cnt[t[0]][i] * (cnt[t[2]][n] - cnt[t[2]][i]);
			REP(j, n){
				int k = i-j, l = i+j;
				if(k < 0 || l >= n) continue;
				if(s[k] == t[0] && s[l] == t[2]) ans--;
			}
		}
	} while(next_permutation(t, t+3));
	printf("%lld\n", ans);
}


Measured memory_bytes: 3884
x = input()
list = x.split()
[a, b] = list
a = int(a)
b = int(b)

d = a // b
r = a % b
f = float(a) / float(b)
f = round(f, 6)

d = str(d)
r = str(r)
f = str(f)
k = " "

ans = d + k + r + k + f
print(ans)


Measured memory_bytes: 5616
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

lcm = 1
for i in range(n):
  lcm = lcm * a[i] // gcd(lcm, a[i])
lcm %= mod

sum_b = 0
for i in range(n):
  sum_b = (sum_b + lcm * pow(a[i], mod - 2, mod)) % mod
print(sum_b)

Measured memory_bytes: 6112
n = int(input())
h = list(map(int, input().split()))

ans = 0
cnt = 0
prev = h[0]
for hi in h[1:]:
    if hi <= prev:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    prev = hi
print(max(ans, cnt))


Measured memory_bytes: 20600
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static class S {
        int num;
        int index;
        public S( int num , int index ){
            this.num = num;
            this.index = index;
        }
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        String[] params = in.nextLine().split(" ");
        S[] a = new S[n];
        for( int i = 0 ; i < n ; i++ ){
            a[i] = new S(Integer.parseInt(params[i]),i);
        }

        Arrays.sort(a, new Comparator<S>() {
            @Override
            public int compare(S o1, S o2) {
                return o1.num < o2.num ? -1 : 1;
            }
        });

        for( int i = 0 ; i < n ; i++ ){
            if( i != 0 ){
                System.out.print(" ");
            }
            System.out.print( a[i].index + 1);
        }
    }

}


Measured memory_bytes: 55188
import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println((Math.min(sc.nextInt(), Math.min(sc.nextInt(), sc.nextInt())))+Math.min(sc.nextInt(), sc.nextInt())-50);
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 == 0) {
        if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
            #pragma comment(linker, "/stack:200000000")
            #pragma GCC optimize("unroll-loops")
             
            #include <algorithm>
            #include <bitset>
            #include <cassert>
            #include <chrono>
            #include <cmath>
            #include <complex>
            #include <cstdio>
            #include <cstdlib>
            #include <cstring>
            #include <ctime>
            #include <deque>
            #include <functional>
            #include <iomanip>
            #include <iostream>
            #include <iterator>
            #include <limits>
            #include <climits>
            #include <list>
            #include <map>
            #include <numeric>
            #include <queue>
            #include <random>
            #include <ratio>
            #include <set>
            #include <sstream>
            #include <stack>
            #include <string>
            #include <unordered_map>
            #include <unordered_set>
            #include <utility>
            #include <vector>
            using namespace std;
             
            typedef long long ll;
            typedef long double ld;
            #define int ll
            #define double ld
            #define pb push_back
            #define mp make_pair
            #define REP(i,n) for (int i = 0; i < n; i++)
            #define loop(i,n) for (int i = 0; i < n; i++)
            #define FOR(i,a,b) for (int i = a; i < b; i++)
            #define REPD(i,n) for (int i = n-1; i >= 0; i--)
            #define FORD(i,a,b) for (int i = a; i >= b; i--)
            #define remax(a,b) a = max(a,b)
            #define remin(a,b) a = min(a,b)
            #define mem(a, b) memset(a, b, sizeof a)
            #define append push_back
            #define all(v) v.begin(),v.end()
            #define F first
            #define S second
            #define print(x) cout << (x) << endl
            #define PRECISION(x) cout << fixed << setprecision(x)
            #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
            #define N 300005
            const double PI=acos(-1);
            const int MOD = 1000000007;
            const int FMOD = 998244353;
            const double eps = 1e-9;
             
            mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
            
            signed main()
            {
            	string s,t;
            	cin>>s>>t;
            	loop(i,s.size())
            	{
            		if(s[i]!=t[i])
            		{
            			cout<<"No";
            			return 0;
					}
				}
				cout<<"Yes";
			}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define int long long
#define mod 1000000007

signed main() {
	int n;
	cin >> n;
	int f = 0, t = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0)f++;
		else if (a % 2 == 0)t++;
	}
	t /= 2;
	t *= 2;
	if ((n-t) / 2 <= f)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[10]={0,111,222,333,444,555,666,777,888,999},n;
	while(~scanf("%d",&n))
	{
		for(int i=0;i<9;i++)
		{
			if(a[i+1]>=n&&a[i]<n)
			printf("%d\n",a[i+1]);
		}
	}	
} 

Measured memory_bytes: 256