akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] lns = in.readLine().split(" ");
      int n = Integer.parseInt(lns[0]);
      int m = Integer.parseInt(lns[1]);
      // int cityP[] = new int[m];
      // int cityY[] = new int[m];
      City[] city = new City[m];
      int[] p = new int[n+1];

      int maxP = 0;
      int x,y;
      for(int i=0; i<m; i++) {
        lns = in.readLine().split(" ");
        x = Integer.parseInt(lns[0]);
        y = Integer.parseInt(lns[1]);
        city[i] = new City(x, y);
        city[i].s = i;
      }

      Arrays.parallelSort(city, new Comparator<City>() {
        public int compare(City a, City b) {
          if(a.y == b.y) return 0;
          return a.y > b.y ? 1 : -1;
        }
      });

      Arrays.fill(p, 1);
      String no;
      for(int i=0; i<m; i++) {
        city[i].no = p[city[i].p]++;
      }

      Arrays.parallelSort(city, new Comparator<City>() {
        public int compare(City a, City b) {
          return a.s - b.s;
        }
      });
      
      for(int i=0; i<m; i++) {
        no = String.format("%06d%06d", city[i].p,city[i].no);
        out.println(no);
      }
      out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  class City {
    int s;
    int p;
    int y;
    int no;

    public City(int p, int y) {
      this.p = p;
      this.y = y;
    }
  }
}

Measured memory_bytes: 104200
/*

        শুভ নববর্ষ ।
        ঘরে থাকুন , সুস্থ থাকুন ।
    wan-_-s
*/

#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
const ll N = 200007 ;
map<ll,ll> mp ;
void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=1 ;i<n;i++) { scanf("%lld",&v[i]) ;mp[v[i]]++ ; } }
vector<ll> adj[N] ;
ll vis[N] , lvl[N] ,lvl1[N],vis1[N] ;
void edge (ll u , ll v) {
    adj[u].pb(v) ;
    adj[v].pb(u) ;
}
ll mod = 1000000007 ;

int main() {

   ll n , k ;
   cin >> n >> k ;

   ll ans = 1 ;
   for(ll i = n ;i>=k;i--) {

        ll z = (n*(n+1)) / 2 ;
        ll z1 = (n-i) ;
        z1 = (z1*(z1+1))/2 ;
        z-=z1 ;
        ll y = i-1 ;
        ll x = (y*(y+1)) / 2 ;
        ll tmp = (z-x) ;
        tmp = (tmp+mod)%mod ;
        ans+=tmp+1 ;
        ans%=mod ;
      //  cout <<z<< ' ' << x << ' ' << ans << endl ;
   }

   cout << ans%mod << endl ;

    stay_home_stay_safe ;
}






Measured memory_bytes: 8328
#include"bits/stdc++.h"
using namespace std;

int main() {
	long long H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		puts("1");
	}
	else {
		cout << (H % 2 == 0 ? H / 2 * W : H / 2 * W + (W + 1) / 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        String ans = "Good";

        for (int i = 1; i < 4; i++) {
            if (n.charAt(i) == n.charAt(i-1)) {
                ans = "Bad";
                break;
            }
        }

        System.out.println(ans);
    }
}



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

#define M_PI       3.14159265358979323846   // pi

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

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)


const ll mod = 1000000007;

int main(void)
{
	ll s;
	cin >> s;
	const ll div = (ll)1e9;
	ll m = s % div;
	if (m == 0) {
		vector<P> v;
		v.emplace_back(0, 0);
		v.emplace_back(s/div, 0);
		v.emplace_back(0, 1e9);
		for (auto e : v) {
			cout << e.first << " " << e.second << " ";
		}
		cout << endl;
		return 0;
	}
	else {
		ll y3 = s / div + 1LL;
		ll x3 = -(m - 1e9);
		vector<P> v;
		v.emplace_back(0, 0);
		v.emplace_back(1e9, 1);
		v.emplace_back(x3, y3);
		for (auto e : v) {
			cout << e.first << " " << e.second << " ";
		}
		cout << endl;

	}

}


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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;
    
    int n;
    cin >> n;

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

    int q;
    cin >> q;

    vector<int> m(q);
    for(int i=0; i<q; i++){
        cin >> m[i];
    }

    vector<bool> a_sum(2001);
    for(int i=0; i<2001; i++){
        a_sum[i] = false;
    }
    a_sum[0] = true;

    for(int i=0; i<n; i++){
        bool a_sum_temp[2001] = {false};
        for(int j=0; j<2001; j++){
            if(j + a[i] < 2001){
                a_sum_temp[j+a[i]] = a_sum[j];
            }
        }

        for(int j=0; j<2001; j++){
            a_sum[j] = a_sum[j] || a_sum_temp[j];
        }
    }

    for(int i=0; i<q; i++){
        if(a_sum[m[i]]){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;
long long sum,a,N,ans;

int main()
{
    map<long long,long long>ms;
    ms[0]++;
    long long i;
    sum=0;
    ans=0;
    scanf("%lld",&N);
    for(i=0;i<N;i++){
            scanf("%lld",&a);
        sum=sum+a;
        ans=ans+ms[sum];
        ms[sum]++;
    }
    printf("%lld\n",ans);
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll D, G;
    cin >> D >> G;
    vector<ll> p(D), c(D);
    REP(i, D)
    {
        cin >> p[i] >> c[i];
    }

    ll ans = LONG_MAX;
    for (int i = 0; i < (1 << D); i++)
    {
        ll score = 0;
        ll count = 0;
        ll maxNum = -1;
        REP(j, D)
        {
            if ((i >> j) & 1)
            {
                score += 100 * (j + 1) * p[j];
                score += c[j];
                count += p[j];
            }
            else
            {
                maxNum = max(maxNum, (ll)j);
            }
        }
        if (G - score > 0)
        {
            if (maxNum != -1 && (100 * (maxNum + 1)) * (p[maxNum] - 1) >= G - score)
            {
                count += (G - score) > 100 * (maxNum + 1) ? (G - score) / (100 * (maxNum + 1)) : 1;
            }
            else
            {
                continue;
            }
        }
        ans = min(ans, count);
    }

    cout << ans << endl;
}


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

int main(){
  int N,M,islocked=1,found=0;
  char U[256][11],T[11];

  cin >> N;

  for (int i=0;i<N;i++) cin >> U[i];

  cin >> M;

  for (int i=0;i<M;i++){
    cin >> T;
    found=0;
    for (int j=0;j<N;j++)
      if (strcmp(T,U[j])==0)found=1;
    if (found){
      if (islocked) cout << "Opened by " << T << endl;
      else cout << "Closed by " << T << endl;
      islocked = !islocked;
    } else cout << "Unknown " << T << endl;
  }
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int h = Integer.parseInt(strlist[0]);
		int w = Integer.parseInt(strlist[1]);
		String[][] list = new String[h][w];

		for(int i=0; i<h; i++){
			str = input.readLine();
			list[i] = str.split("");
		}

		StringBuffer buf = new StringBuffer();
		for(int i=0; i<w+2; i++){
			buf.append("#");
		}

		System.out.println(buf.toString());

		for(int i=0; i<h; i++){
			System.out.print("#");
			for(int j=0; j<w; j++){
				System.out.print(list[i][j]);
			}
			System.out.println("#");
		}

		System.out.println(buf.toString());
	}


}


Measured memory_bytes: 23636
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n,m;
	cin>>n>>m;
	cout<<(n*500>=m?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
for (let i = 0; i < input.length; i++) {
    let [a, x, b] = input[i].split(/\s/);
    switch (x) {
        case '+':
            console.log(Number(a) + Number(b));
            break;
        case '-':
            console.log(Number(a) - Number(b));
            break;
        case '*':
            console.log(Number(a) * Number(b));
            break;
        case '/':
            console.log(Math.floor(Number(a) / Number(b)));
            break;
        case '?':
            break;
    }
}


Measured memory_bytes: 15464
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ll N;
  cin >> N;
  vector<Pll> A(N, Pll(0LL, 0LL));
  for(ll i = 0; i < N; i++){
    cin >> A.at(i).first;
    A.at(i).second = i;
  }
  sort(ALL(A), greater<Pll>());
  vvll dp(N+1, vll(N+1, 0));
  ll ans = 0;
  for(int ij = 1; ij <= N; ij++){ //合計i人
    for(int i = 0; i <= ij; i++){ //左がi人
      int j = ij - i;
      if(i-1 >= 0) chmax(dp.at(i).at(j), dp.at(i-1).at(j) + A.at(ij-1).first * (A.at(ij-1).second - (i-1))); //左からi番目にij人目
      if(j-1 >= 0) chmax(dp.at(i).at(j), dp.at(i).at(j-1) + A.at(ij-1).first * (N-j - A.at(ij-1).second)); //右にij人目
      if(ij == N) chmax(ans, dp.at(i).at(j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 34684
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100001][2];
ll mod = 1e9+7;
vector<ll>v[100001];
ll add(ll x , ll y)
{
    x += y;
    if(x >= mod)
    x -= mod;

    return x;
}
void dfs(ll x , ll p)
{
    ll mult2 = 1  , mult1 = 1;
    for(ll i = 0 ; i < (ll)v[x].size() ; i++)
    {
        if(v[x][i] == p)
        continue;

        dfs(v[x][i] , x);
        ll num2 = add(dp[v[x][i]][1] , dp[v[x][i]][0]);
        mult2 = (mult2*num2)%mod;
        mult1 = (mult1 * dp[v[x][i]][1])%mod;
    }

    dp[x][0] = add(dp[x][0] , mult1);
    dp[x][1] = add(dp[x][1] , mult2);
}


int main() { 
    ll n;
    cin >> n;
    for(ll i =0 ; i < n-1 ; i++)
    {
        ll x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1, 1);
    ll ans = add(dp[1][1] , dp[1][0]);
    cout << ans;
}


Measured memory_bytes: 17500
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    int i=0;
    bool flag;
    if(s.size()>=t.size()) {
        flag=false;
        while(i<t.size()) {
            if(s[i]==t[i]) {
                i++;
            } else if(s[i]<t[i]) {
                flag = true;
                break;
            } else {
                break;
            }
        }
    } else if(s.size()<t.size()) {
        flag=true;
        while(i<s.size()) {
            if(s[i]==t[i]) {
                i++;
            } else if(s[i]<t[i]) {
                break;
            } else {
                flag = false;
                break;
            }
        }
    }
    
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int top=0;
int stack[100];
int pop(void);

int main(){
  int y,a;
  char x,s[100];

  while(1){
    scanf("%s",s);

    if(s[0] =='+'){
      a = pop() + pop();
      stack[top] = a;
      top++;
      if(getchar() == '\n')break;
    }
    else if(s[0] == '-'){
      a = pop() - pop();//aaaaaaaaaa
      stack[top] = a * -1;
      top++;
      if(getchar() == '\n')break;
    }
    else if(s[0] == '*'){
      a = pop() * pop();
      stack[top] = a;
      top++;
      if(getchar() == '\n')break;
    }
    else{
      a = atoi(s);
      stack[top] = a;
      top++;
    }
  }

  printf("%d\n",stack[0]);

  return 0;
}

int pop(void){
  top --;
  return stack[top];
}



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

int main() {
	int n;
	while (cin >> n) {
		int cnt = 0;
		rep(i, 10)rep(j, 10)rep(k, 10)rep(l, 10)if (i + j + k + l == n)cnt++;
		cout << cnt << endl;
	}
	return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

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

    REP(i, n+1) {
        REP(j, n+1-i) {
            int k = n - i - j;
            if(i*10000 + j * 5000 + k*1000 == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}
 

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repfrom(i, from, n) for (ll i = (from); i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

ll N;
vector<ll> prime_list;
//unordered_set<ll> primes;

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    
    return true;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    
    repfrom(i, 2, 55556) {
        if (is_prime(i)) {
            prime_list.push_back(i);
        }
    }
    
    vector<ll> ans;
    for (auto p : prime_list) {
        if (p % 10 == 1) {
            ans.push_back(p);
            if (ans.size() == N) {
                break;
            }
        }
    }
    
    for (auto a : ans) {
        cout << a << " ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

  int n,k;
  cin>>n>>k;
  vector<ll> x(n);
  rep(i,n)cin>>x[i];
  ll ans = 400000000;
  //rep(i,n)cout<<x[i];
  if(x[n-1]<=0){
    cout<<abs(x[n-k])<<endl;
    //cout<<x[n-k];
    return 0;
  }
  auto i0 = lower_bound(x.begin(),x.end(),0)-x.begin();
  if(i0==0){
    cout<<x[k-1]<<endl;
    //cout<<222;
    return 0;
  }
  for(int i=i0;i<n;i++){
    if(i>=k+i0-1)break;
    if(i-k+1>=0){
    //printf("l %d r %d\n",x[i-k+1],x[i]);
    ll mn=min(2*abs(x[i])+abs(x[i-k+1]),2*abs(x[i-k+1])+abs(x[i]));
    ans = min(ans,mn);
    //cout<<ans<<endl;
    }
  }
  if(i0-k>=0)ans = min(ans,abs(x[i0-k]));
  if(i0+k-1<n)ans = min(ans,x[i0+k-1]);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=2e5+10;
const int mod=1e9+7;
int n,m,a[100];
set<int> w;
int main()
{
	sf(n);
	rep(i,1,9){
		rep(j,1,9)a[i*j]=1;
	}
	if(a[n])cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        cs: chars,
    }
    println!("{}", cs.into_iter().filter(|&c| c == '1').count());
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	int cnt = 0;

	REP(in, n)
	{
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2)
		{
			cnt++;
			if (3 <= cnt)
			{
				cout << "Yes";
				return 0;
			}
		}
		else
		{
			cnt = 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) b.rbegin(),v.rend()
typedef long long ll;
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  rep(i,n){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  int count = 0;
  rep(i,n){
    if(4*m*a.at(i)>=sum){
      count++;
    }
  }
  if(count>=m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int k, a, b;
  cin >> k >> a >> b;;
  int m = b - (b % k);
  string ans = "NG";
  if(m >= a) {
    ans = "OK";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N = II()
    A, B, C = sorted(list(MI())), sorted(list(MI())), sorted(list(MI()))

    s = [i for i in range(1, N + 1)]
    ia = N-1
    ns = [None] * N
    for ib in range(N-1, -1, -1):
        while ia >= 0 and A[ia] >= B[ib]:
            ia -= 1
        if ia >= 0:
            ns[ib] = s[ia]
        else:
            ns[ib] = 0
    for i in range(1, N):
        ns[i] += ns[i-1]

    s = ns
    ib = N-1
    ns = [None] * N
    for ic in range(N-1, -1, -1):
        while ib >= 0 and B[ib] >= C[ic]:
            ib -= 1
        if ib >= 0:
            ns[ic] = s[ib]
        else:
            ns[ic] = 0
    return sum(ns)


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 23988
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;long long ans=1,t;
	cin>>n;
	while(n--){
		cin>>t;
		long long a=t,b=ans;
		while(true){
			if(a<b)swap(a,b);
			a%=b;
			if(a==0)break;
		}
		ans=ans/b*t;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int reverse(int l){
  int ans = 0;
  while(l > 0){
	ans = ans*10 + (l%10);
   l = l/10;
  }
  return ans;
}
pi firlst(int l){
  string str = to_string(l);
	return {str[0] -'0' , str[str.length() - 1] - '0'};
}
bool reverse(int l ,int n){
 string str = to_string(l);
 reverse(str.begin() , str.end());
 string ultimate = to_string(n);
 if(str <= ultimate){
  return true;
 }
 return false;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
map<pi , int> m;
for(int i = 1 ; i <= n ;i++){
    pi val = firlst(i);
    m[val]++;
}
int ans = 0;
for(int i = 1 ; i <= 9 ; i++){
 for(int j = 1 ; j <= 9 ; j++){
	  pi val = {i , j};
	  pi val2 = {j , i};
      if(i == j){
	      ans += m[val]*m[val2];
	  }
	  else{
	     ans += m[val]*m[val2];
	  }
 }
}
cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll x;
    cin>>x;
    
    ll a=x/11;
    if(x%11==0)cout<<2*a<<endl;
    else if(x%11<=6)cout<<2*a+1<<endl;
    else cout<<2*a+2<<endl;
    
    return 0;
}


Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/abc165/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    
    // 2. 解説通り.
    if(M & 1){
        rep(i, M / 2)     printf("%d %d\n", i + 1, M - i);
        rep(i, M / 2 + 1) printf("%d %d\n", M + 1 + i, 2 * M + 1 - i);
    }else{
        rep(i, M / 2) printf("%d %d\n", i + 1, M + 1 - i);
        rep(i, M / 2) printf("%d %d\n", M + 2 + i, 2 * M + 1 - i);
    }
    return 0;
    
}

Measured memory_bytes: 3828
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <random>

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

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<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(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() {
	int N; cin >> N;
	V<ll> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	ll ans = A[0] - 1, P = 2;
	A[0] = 1;
	for (int i = 1; i < N; ++i) {
		if (P > A[i]) continue;
		if (P == A[i]) {
			P++;
			continue;
		}
		A[i] -= P;
		ans += A[i] / P;
		if(A[i]%P != 0) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
n = gets.chomp.to_i
s = gets.chomp.split('').map(&:to_i)
cnt = 0
for i in 0..999
    c = [i/100,(i/10)%10,i%10]
    j = f = 0
    while j<n && f<3
        f+=1 if s[j] == c[f]
        cnt+=1 if f==3
        j+=1
    end
end
puts cnt

Measured memory_bytes: 5500
#include <stdio.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i < n; ++i)

class dice {
  private:
    int f[6];
  public:
    dice(int *a){
      int i;
      rep(i, 6) f[i] = a[i];
    }
    dice(){}
    void set(int *a) {
      int i; 
      rep(i, 6) f[i] = a[i];
    }
    void n(){
      int t;
      t = f[0];
      f[0] = f[1];
      f[1] = f[5];
      f[5] = f[4];
      f[4] = t;
    }
    void s() {
      int t;
      t = f[0];
      f[0] = f[4];
      f[4] = f[5];
      f[5] = f[1];
      f[1] = t;
    }
    void w() {
      int t;
      t = f[0];
      f[0] = f[2];
      f[2] = f[5];
      f[5] = f[3];
      f[3] = t;
    }
    void e() {
      int t;
      t = f[0];
      f[0] = f[3];
      f[3] = f[5];
      f[5] = f[2];
      f[2] = t;
    }
    void r() {
      int t;
      t = f[1];
      f[1] = f[2];
      f[2] = f[4];
      f[4] = f[3];
      f[3] = t;
    }
    void l() {
      int t;
      t = f[1];
      f[1] = f[3];
      f[3] = f[4];
      f[4] = f[2];
      f[2] = t;
    }
    int print(int num) {
      return f[num];
    }
};

int main(void) {
  int a[6], n, i, j, k, l;
  scanf("%d", &n);
  dice d[n];
  rep(i, n) {
    rep(j, 6) scanf("%d", &a[j]);
    d[i].set(a);
  }
  /*rep(i, n) {
   rep(k, 6) printf("%d ", d[i].print(k));
   printf("\n");
  }*/
  int s = 0;
  rep(i, n) for(j = i + 1; j < n; ++j) {
    rep(l, 30) {
    if(d[i].print(1) == d[j].print(0)) d[j].s();
    else if(d[i].print(2) == d[j].print(0)) d[j].e();
    else if(d[i].print(3) == d[j].print(0)) d[j].e();
    else if(d[i].print(4) == d[j].print(0)) d[j].n();
    else if(d[i].print(5) == d[j].print(0)) d[j].n(), d[j].n();
    if(d[i].print(3) == d[j].print(1)) d[j].r();
    else if(d[i].print(2) == d[j].print(1)) d[j].l();
    else if(d[i].print(4) == d[j].print(1)) d[j].r(), d[j].r();
    /*printf("%d %d:\n", i, j);
    rep(k, 6) printf("%d %d\n", d[i].print(k), d[j].print(k));*/
    int s = 0;
    rep(k, 6) if(d[i].print(k) != d[j].print(k)) s = 1;
    if(!s) {
     /* printf("%d %d:\n", i, j);
      rep(k, 6) printf("%d %d\n", d[i].print(k), d[j].print(k));*/
      printf("No\n");
      return 0;
    }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 2616
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


def solve(L: int):

    if L == 1:
        print(3)
        return

    strL = str(L)

    lesser_count = 1
    over_count = 2
    for i, c in enumerate(strL[1:]):
        lesser_count *= 3
        lesser_count %= MOD
        if c == "1":
            lesser_count += over_count
            lesser_count %= MOD
            over_count *= 2
            over_count %= MOD
    print((lesser_count + over_count) % MOD)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)


if __name__ == '__main__':
    main()


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

int sum[110];

int main() {

	string st;
	int ans = 0;
	cin >> st;
	int len = st.length();
	for (int i = 0; i < len; ++i) 
		sum[i + 1] = sum[i] + st[i] - '0';
	for (int i = 1; i < len; ++i)
		ans = max(ans, sum[i] - 1 + 9 * (len - i));
	printf("%d", max(ans, sum[len]));

	return 0;
}


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

int main(void)
{
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 1;i--){
        if(a%i==0&&b%i==0){
            --k;
        if(k==0){
            cout << i << endl;
        }
    }
    }
}


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

typedef long long ll;

int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;

int n;
int a[N];

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  
  cin >> n;
  for(int i = 0; i < n; ++i)
    cin >> a[i];

  int cnt = 0;

  for(int i = 0, j = 0; i < n; i = j) {
    int x = i+1;
    int y = i+1;

    while(x < n && a[x-1] <= a[x])
      x++;

    while(y < n && a[y-1] >= a[y])
      y++;

    j = max(x, y);
    cnt++;
  }

  cout << cnt;

  cout << flush;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

void Main() {
  //自動整形防止用コメント
  ll n;
  std::cin >> n;
  std::vector<ll> t(n);
  for (auto &x : t) {
    std::cin >> x;
  }

  priority_queue<ll, vector<ll>, greater<ll>> p;
  for (auto &x : t) {
    p.push(x);
  }

  ll gcdnum = p.top();
  while (p.size() != 1) {
    ll tmp = p.top();
    p.pop();
    gcdnum = (tmp / gcd(tmp, p.top())) * p.top();
    p.pop();
    p.push(gcdnum);
  }

  std::cout << gcdnum << '\n';

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
import sys
import os

MOD = 10 ** 9 + 7


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

    x = int(sys.stdin.buffer.readline().rstrip())
    print('ABC' if x < 1200 else 'ARC')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    double a,b,h,m;
    cin >> a >> b >> h >> m;
    h += m / 60;

    double arg = (h * 30 - m * 6) * pi / 180;

    cout << fixed << setprecision(11) <<  sqrt(a*a + b*b - 2*a*b*cos(arg)) << endl;

    return 0;
}


Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define ldb long double
#define clr(x) memset(x,0,sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
const int size1 = 1e5+7;
const int size2 = 1e4;
const ll mod = 1e9+7;
 
// ll fact[size1];
 
// ll pw(ll x,ll y,ll md)
// {
//     if(y==0)return 1;
//     ll p =pw(x,y/2,md);
//     p = (p*p)%md;
//     if(y%2==1)p = (p*x)%md;
//     return p;
// }
// ll gcd(ll a,ll b)
// {
//  if(b==0)return a;
//  a = a%b;
//  return gcd(b,a);
// }
// ll inverse(ll x,ll mod)
// {
//     return pw(x,mod-2,mod);
// }
// ll ncr(ll n,ll r,ll mod)
// {
//     ll num = fact[n];
//     ll den = (fact[r] * fact[n-r])%mod;
//     den = inverse(den,mod);
 
//     ll ans = (num*den)%mod;
//     return ans;
// }
// vector<ll> adj1[size1];
// vector<ll> adj[size1];
// ll d[size1];
// ll n,m;
// void dikstra(ll s)
// {
//     for(ll i=1;i<=n;i++)d[i]=1e9;
//     d[s] = 0;
//     priority_queue<pll, vector<pll>, greater<pll>> q;
//     q.push({0, s});
//     while(!q.empty())
//     {
//         ll v = q.top().ss;
//         ll d_v = q.top().ff;
//         q.pop();
//         if(d_v!=d[v])continue;
//         for(auto to:adj1[v])
//         {
//             ll len = 1;
//             if(d[v] + len < d[to])
//             {
//                 d[to] = d[v]+len;
//                 q.push({d[to],to});
//             }
//         }
//     }
// }
 
// ll smallestPrimeFactor[size1];
 
// void seive(){
//     clr(smallestPrimeFactor);
 
//     for(ll i=2;i<size1;i++){
//         if(smallestPrimeFactor[i]!=0)continue;
//         smallestPrimeFactor[i] = i;
//         for(ll j=2*i;j<size1;j+=i){
//             smallestPrimeFactor[j]=i;
//         }
//     }    
// }
 ll sum[2005][2005];
 ll dp[2005][2005];
int main()
{
    //cout<<setprecision(12)<<fixed;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    
    ll T;
    //cin>>T;
    T = 1;
    while(T--)
    {
        //cout<<"Case #"<<cas<<": ";cas++;
        ll S;cin>>S;

        ll mxLen = S/3 + 1;

        clr(dp);
        clr(sum);
        for(ll j=3;j<=S;j++){
            dp[1][j]=1;
            sum[1][j]=(sum[1][j-1]+dp[1][j])%mod;
        }
        for(ll i=2;i<=mxLen;i++){
            for(ll j=3;j<=S;j++){

                dp[i][j] = (dp[i][j] + sum[i-1][j-3])%mod;
                sum[i][j] = (sum[i][j-1]+dp[i][j])%mod;
            }
        }

        ll ans = 0;
        for(ll i=1;i<=mxLen;i++)ans = (ans+dp[i][S])%mod;

        cout<<ans<<endl;

    }
}

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

#define ff first
#define ss second
#define mp make_pair
#define pb push_back

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int N;
    cin >> N;
    vector<int> travel_time(N-1);
    vector<int> first(N-1);
    vector<int> freq(N-1);
    
    for (int i=0; i<N-1; i++){
		cin >> travel_time[i] >> first[i] >> freq[i];
	}
	
	for (int i=0; i<N; i++) {
		int t = 0;
		for (int j=i; j<N-1; j++) {
			int other = (t % freq[j] == 0 ? t : (t/freq[j]+1)*freq[j]);
			t = max(first[j], other) + travel_time[j];
		}
		cout << t << endl;
	}
	return 0;
}


Measured memory_bytes: 256
function main(input){
  var line1 = input[0].split(' ');
  var n = parseInt(line1[0]);
  var p = parseInt(line1[1]);

  var ans = 1;
  var arr = primeFactorization(p);
  for (var i=0; i<arr.length; i++){
    var r = arr[i].r;
    while (n<=r) {
      ans *= arr[i].num;
      r=r-n;
    }
  }

  console.log(ans);
}


function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}

function primeFactorization(n) {
  var s = Math.floor(Math.sqrt(n));
  var r = 0;
  
  var result = [];
  for (var i = 2;i <= s;i++) {
    if ((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while ((n % i) == 0);
      result.push({num:i, r:r});
    }
  }
  if (n > s) {
    result.push({num:n, r:1});
  }
  
  return result;
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 21320
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string a=Console.ReadLine();
      string b = a.ToLower();
      if (a==b)
      {
        Console.WriteLine("a");
      }
      else
      {
        Console.WriteLine("A");
      }
    }
}

Measured memory_bytes: 26172
#include <iostream>
using namespace std;
int main(void){
    int n;
    while(true){
        cin >> n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            int m,e,j;
            cin >> m >> e >> j;
            if(m==100 || e == 100 || j == 100){
                cout << "A" << endl;
            }else if(((m+e)/2) >= 90){
                cout << "A" << endl;
            }else if(((m+e+j)/3) >= 80){
                cout << "A" << endl;
            }else if(((m+e+j)/3) >= 70){
                cout << "B" << endl;
            }else if(((m+e+j)/3) >= 50 && (m >= 80 || e >= 80)){
                cout << "B" << endl;
            }else{
                cout << "C" << endl;
            }
        }
        
    }
    return 0;
}


Measured memory_bytes: 3076
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); 
        double d = sc.nextDouble(); 
        int count = 0;
        for(int i=0;i<n;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            double rad = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
            if(rad <= d)count++;
        }
        System.out.println(count);
    }
}

class Monmo {
    
}


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

int main(){
    int n;
    cin >> n;
    char curr;
    cin >> curr;
    for(int i=0; i<n-1; i++){
        char c;
        cin >> c;
        curr = (curr == 'T' and c == 'F')? 'F': 'T';
    }
    cout << curr << endl;
    return 0;
}


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline
def main():

    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    total = 0
    for i in range(60):
        cnt_1, cnt_0 = 0, 0
        for j in range(N):
            if (A[j]>>i)&1:
                cnt_1 += 1
            else:
                cnt_0 += 1
        total += pow(2, i, p) * cnt_0 * cnt_1 %p
    print(total%p)
main()

Measured memory_bytes: 123132
#include<iostream>
#include<string>

using namespace std;

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

Measured memory_bytes: 256
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    b_s = list(map(int, input().split(' ')))
    ans = 0
    for i in range(n):
        if b_s[i] >= a_s[i]:
            ans += a_s[i]
            if (b_s[i] - a_s[i]) <= a_s[i+1]:
                ans += (b_s[i] - a_s[i])
                a_s[i+1] -= (b_s[i] - a_s[i])
            else:
                ans += a_s[i+1]
                a_s[i+1] = 0
        else:
            ans += b_s[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19156
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        _: usize,
        s: String
    };

    let res = s.split("ABC").count() - 1;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2224
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint a, b, k;
  cin >> a >> b >> k;
  if (k > a) {
    b = max(0LL, b - (k - a));
    a = 0;
  } else {
    a -= k;
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256