akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
using pii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Fri Dec 13 18:17:44 PST 2019
 **/

const Int INF = 1e18;
signed main() {
    Int n = in(), T = in();
    vector<Int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    vector<Int> ord(n);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&a](Int i, Int j) {
        return a[i] < a[j];
    });
    vector<Int> dp(T, -INF);
    dp[0] = 0;
    Int ans = 0;
    REP(i_, n) {
        Int i = ord[i_];
        for (Int j = T - 1; j >= 0; j--) {
            chmax(ans, dp[j] + b[i]);
            if (j + a[i] < T) {
                chmax(dp[j + a[i]], dp[j] + b[i]);
            }
        }
    }
    dump(dp);
    cout << ans << endl;
}


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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int N;
    int ans = 0;
    bool j = false;
    string S;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    Rep(i,N){
        cin >> s[i] >> t[i];
    }
    cin >> S;
    Rep(i,N){
        if(j) ans += t[i];
        if(s[i] == S)j = true;
    }
    cout << ans << endl;
    //cin >> N;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll a[300001];
int main()
{
    ll n,one=0,zero=0,ans=0,d=1;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=0;i<60;i++){
        ll bit = 1LL<<i;
        one=zero=0;
        for(int j=1;j<=n;j++){
            if(a[j] & bit ){
                one++;
            }
            else zero++;
        }
       ans+=(bit%mod)*((one*zero)%mod)%mod;
    }
    printf("%lld\n",ans%mod);
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int a[n],dp[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}


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

#define TAX 1.08

int main(void){
	double x;
	double right, left;
	int n;
	scanf("%lf",&x);
	left = x/TAX;
	right = (x+1.0)/TAX - 0.0001;
	n = (int) right;
	if((int) right < left){
		printf(":(\n");
		return 0;
	}
	else{
		printf("%d\n", n);
	}
    return 0; 
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int N;
P G[20000];
int solve(){
  int res = 0;
  int c = 0;
  for (int i = 0; i < 2*N; i++){
    if (G[i].second){
      c++;
      res = max(c, res);
    }
    else{
      c--;
    }
  }
  return res;
}
int main(){
  while (1){
    cin >> N;
    if (N == 0) break;
    for (int i = 0; i < N; i++){
      for (int j = 0; j < 2; j++){
	char str[10];
	cin >> str;
	int a = (str[0]-'0')*10 + str[1]-'0';
	int b = (str[3]-'0')*10 + str[4]-'0';
	int c = (str[6]-'0')*10 + str[7]-'0';
	G[i*2+j] = P(a*60*60 + b*60 + c, 1-j);
      }
    }
    sort(G, G+2*N);
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1324
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    // dp[i][j] := i 枚目のコインまでで j 回表が出たときの確率
    dp[0][0] = 1;

    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1 - p[i]);
        }
    }

    double ans = 0;
    for(int i=n/2+1; i<=n; i++){
        ans += dp[n][i];
    }

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 70784
#include "bits/stdc++.h"
using namespace std;
#define int long long int
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define mod 1000000007
int in(){
int n;cin>>n;
return n;}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
	int t=1;
	while(t--){
		int n=in(),m=in();
		int a[m],sum=0;
		rep(i,0,m){
			a[i]=in();
			sum+=a[i];
		}
		if(sum>n)cout<<-1<<endl;
		else cout<<n-sum<<endl;
	}
	return 0;
	}

Measured memory_bytes: 3732
#include<stdio.h>
#include<stdlib.h>
#define INF (1<<21)
int matrix(int *p,int x){
  int i,j,k,l,q;
  int m[x+1][x+1];
  for(i=1;i<=x;i++)m[i][i]=0;
  for(l=2;l<=x;l++){
    for(i=1;i<=x-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
        q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
        if(q<m[i][j])m[i][j]=q;
      }
    }
  }
  return m[1][x];
}
int main(){
  int n,i,k;
  int *p;
  scanf("%d",&n);
  n++;
  p=(int *)malloc(n *sizeof(int));
  n--;
  for(i=1;i<=n;i++)scanf("%d%d",&p[i-1],&p[i]);
  k=matrix(p,n);
  printf("%d\n",k);
  free(p);
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll x;
  cin >> x;
  ll s = 0;
  s += (x/500) * 1000;
  x = x%500;
  s += (x/5) * 5;
  cout << s << endl;
  return 0;
}



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

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

  vector<int> c(27);
  rep(i, 26) cin >> c.at(i);

  vector<vector<int>> s(d + 1, vector<int>(27));
  rep(i, d)
  {
    rep(j, 26)
    {
      cin >> s.at(i).at(j);
    }
  }

  srand((unsigned)time(NULL));
  vector<int> t(d);
  rep(i, d)
  {
    t.at(i) = rand() % 26 + 1;
    cout << t.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int a = sc.nextInt();
    if(h%a==0){
      System.out.println(h/a);
    }else{
      System.out.println(h/a+1);
    }
  }
}


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

using namespace std;

#define MAX_N 10
#define MAX_M 100000
#define INF 1e9

int N,M,coin[MAX_N];
int dp[MAX_M+1];

bool c(int x){
  memset(dp,-1,sizeof(dp));
  dp[0] = 0;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j <= M ; j++){
      if(dp[j] >= 0){
        dp[j] = x;
      }else if(j < coin[i] || dp[j-coin[i]] <= 0){
        dp[j] = -1;
      }else{
        dp[j] = dp[j-coin[i]]-1;
      }
    }
  }
  return (dp[M] >= 0);
}

int main(){
  while(cin >> N >> M,(N|M)){
    for(int i = 0 ; i < N ; i++){
      cin >> coin[i];
    }
    sort(coin,coin+N);
    int l = 0, r = M+1;
    while(r-l > 0){
      int m = (l + r) / 2;
      if(c(m)){
        r = m;
      }else{
        l = m+1;
      }
    }
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 1572
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;

void solve()
{
 ll n,k;
 cin>>n>>k;
 if(n%k==0)
 cout<<0;
 else if(n>k)
 {
   ll q=n/k;
   ll r=q+1;
   ll ans=min(abs(q*k-n),abs(r*k-n));
   cout<<ans;
 }
 else
 {
   ll ans=min(n,abs(n-k));
   cout<<ans;
 }
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, t,s;
    cin >> d >> t >> s;
    cout << (d/s + bool(d%s) <= t ? "Yes\n":"No\n");

}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N, M;
int A[100005], B[100005];

vector<int> Adj[100005];

int used[100005];

void visit(int k) {
	used[k] = 1;
	for (auto y : Adj[k]) {
		if (used[y] == 0) { visit(y); }
	}
}

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		Adj[A[i]].push_back(B[i]);
		Adj[B[i]].push_back(A[i]);
	}

	int num = 0;

	for (int i = 1; i <= N; i++) {
		if (used[i] == 0) {
			num++;
			visit(i);
		}
	}

	cout << num - 1 << endl;

	return 0;
}

Measured memory_bytes: 10700
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		long ans = 0;
		int x = 1;
		for (int i = 0; i < n; i++) {
			if (a[i] == x) {
				x++;
			}
			ans += (a[i] - 1) / x;
			if (x == 1) {
				x++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 30704
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(a,p);
    cout << (a*3+p)/2 << nn;
    return 0;
}

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

int main() {
  string s, t, u;
  ll a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  if (u == s) {
    cout << a - 1 << " " << b << endl;
  } else {
    cout << a << " " << b - 1 << endl;
  }
}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/05/19
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	char S[4] = {0};
	int i = 0;
	int up = 0, low = 0;
	int yymm = 0, mmyy = 0, amb = 0, na = 0;
	scanf("%s",S);
	for(i = 0; i < 4; i++) {
		S[i] -= 0x30;
	}
	up = (S[0] * 10) + S[1];
	low = (S[2] * 10) + S[3];

    if(up == 0) {
    	if((1 <= low) && (low <= 12)) {
    		yymm = 1;
    		printf("YYMM\n");
    	} else {
    		na = 1;
    		printf("NA\n");
    	}
    } else if((1 <= up) && (up <= 12)) {
    	if((1 <= low) && (low <= 12)) {
    		amb = 1;
    		printf("AMBIGUOUS\n");
    	} else {
    		mmyy = 1;
    		printf("MMYY\n");
    	}
    } else {
    	if((1 <= low) && (low <= 12)) {
    		yymm = 1;
    		printf("YYMM\n");
    	} else {
    		na = 1;
    		printf("NA\n");
    	}
    }
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int a,b,k;
    cin >> a >> b >> k;
    int gd=gcd(a,b);
    vi div;
    for(int i=1;i*i<=gd;i++){
        if(gd%i!=0) continue;
        div.push_back(i);
        if(i*i!=gd) div.push_back(gd/i);
    }
    sort(div.begin(),div.end());
    reverse(div.begin(),div.end());
    cout << div[k-1] <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main() {
	int a[3][3], n, b;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> a[i][j];
		}
	}

	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> b;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (a[j][k] == b)a[j][k] = 0;
			}
		}
	}

	bool flag = false;
	for (int i = 0; i < 3; i++) {
		if (a[i][0]==0&& a[i][1]==0&& a[i][2]==0) {
			flag = true;
			break;
		}
		if (a[0][i] ==0&& a[1][i] ==0&& a[2][i]==0) {
			flag = true;
			break;
		}
		if (i == 0 ) {
			if ((a[i][i] == 0 && a[i + 1][i + 1] == 0 && a[i + 2][i + 2] == 0) || (a[i][i + 2] == 0 && a[i + 1][i + 1] == 0 && a[i + 2][i] == 0)) {
				flag = true;
				break;
			}
		}
	}
	
	if (flag)std::cout << "Yes\n";
	else std::cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        Scanner scan = new Scanner(System.in);
        
        while(true){
            //parts number
            int supply = scan.nextInt();
            int motor = scan.nextInt();
            int cable = scan.nextInt();
            if (supply==0){
                break;
            }
            

            int len = scan.nextInt();
            int[] res = new int[supply+motor+cable];
			Arrays.fill(res, 2);
			ArrayList<Integer> intList = new ArrayList<Integer>();
            int len2 = 0;
            
            // pass 
            for (int i=0; i<len; i++){
                int no1 = scan.nextInt()-1;
                int no2 = scan.nextInt()-1;
                int no3 = scan.nextInt()-1;
                int ans = scan.nextInt();
                if (ans==1){
                    res[no1]=1;
                    res[no2]=1;
                    res[no3]=1;
                }else{
                    intList.add(no1);
                    intList.add(no2);
                    intList.add(no3);
                    len2+=3;
                }
            }
            
            //not pass
            for (int i=0; i<len2; i+=3){
                int no1 = intList.get(i);
                int no2 = intList.get(i+1);
                int no3 = intList.get(i+2);
                if (res[no1]==1 && res[no2]==1){
                    res[no3]=0;
                }
                else if (res[no3]==1 && res[no2]==1){
                    res[no1]=0;
                }
                else if (res[no1]==1 && res[no3]==1){
                    res[no2]=0;
                }
            }
            
            for (int i=0;i<supply+motor+cable; i++){
                System.out.println(res[i]);
            }
            
            
        }
    }
}





Measured memory_bytes: 38576
package main

import (
	"fmt"
)

func solution(x, y, z int) (a, b, c int) {
	a = y
	b = x
	a = z
	c = y
	return a, b, c
}

func main() {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	a, b, c := solution(x, y, z)
	fmt.Printf("%d %d %d\n", a, b, c)
}


Measured memory_bytes: 512
n = int(input())
data = list(map(int, input().split()))

max_edge = []
for depth, a in enumerate(data):
    if depth == 0:
        edge = 1 - a
    else:
        edge = max_edge[depth-1]*2 - a
    
    if edge < 0:
        print(-1)
        exit()
    max_edge.append(edge)

ans = 0
prev_edges = 0
for idx in range(n, -1, -1):
    a = data[idx]
    cap = max_edge[idx]
    if prev_edges > 2*cap:
        print(-1)
        exit()
    edges = min(prev_edges, cap) + a
    ans += edges
    prev_edges = edges

print(ans)

Measured memory_bytes: 668712
"""
# B - Go to Jail
"""
count = int(input())

zoro = 0
for _ in range(count):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        zoro += 1
        if zoro == 3:
            print("Yes")
            break
    else:
        zoro = 0
else:
    print("No")


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

int main(){
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	
	if(llabs(a-b)<=t*(v-w))
	cout<<"YES";
	else cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 3636
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] a = new int[3 * N];
        for (int i = 0; i < 3 * N; ++i) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        long sum = 0;
        for (int i = N; i < 3 * N; i += 2) {
            sum += a[i];
        }
        _out.println(sum);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();

		pr.println((a + b) * h / 2);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9552
import collections
n=int(input())
c=[0]+[int(input()) for i in range(n)]
d=collections.defaultdict(int)
mod=10**9+7
dp=[1 for i in range(n+1)]
for i in range(0,n):
    if c[i]==c[i+1]:
        dp[i+1]=dp[i]
    else:
        t=c[i+1]
        dp[i+1]=(dp[i]+d[t])%mod
        d[t]+=dp[i]
        d[t]%=mod
print(dp[n])

Measured memory_bytes: 34272
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

stack<pli> stk; ///fi = nr se = amt
ll v[maxn+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  ll ans = 0;
  stk.push(pli(infl, 1));
  for (i = n; i >= 1; i--) {
    ll amt = 1;
    while (stk.top().fi < v[i]) {
      ans += (v[i]-stk.top().fi)*stk.top().se;
      amt += stk.top().se;
      stk.pop();
    }
    stk.push(pli(v[i], amt));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 8336
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for((i)=0;(i)<(int)(a);(i)++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        int h;
        int a;
        cin>>h>>a;
        int cnt = 0;
        while(true){
            if(h<=0)break;
            h-=a;
            cnt++;
        }
        cout<<cnt<<endl;




return 0;
}







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

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if (u == s) cout << a-1 << " " << b << endl;
  else cout << a << " " << b-1 << endl;
}


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

using namespace std;

int main(){
	string s,a;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='0'){
			a+='0';
		}
		else if(s[i]=='1'){
			a+='1';
		}
		else if(s[i]=='B'){
			if(a.empty()==0)a.pop_back();
		}
	}
	cout<<a<<endl;
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0, c[10][10][10] = {};
  for (int i = 0; i < n; i++) {
    int p = s[i] - '0';
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        if (i > 1 && c[j][k][p] == 2) {
          c[j][k][p] = 3;
          ans++;
        }
        if ((i > 0 || i < n-1) && c[j][p][k] == 1) {
          c[j][p][k] = 2;
        }
        if (i < n-2 && c[p][j][k] == 0) {
          c[p][j][k] = 1;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
a = []

mod = 1000000007

dp=[0]*(n+1)

dp[0]=1
dp[1]=1
d={}
for j in range(n+1):
    d[j]=0

for _ in range(m):
    s = int(input())
    d[s]=1
    dp[s]=0

for i in range(2,n+1):
    if d[i]==1:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[-1]%mod) 


Measured memory_bytes: 469352
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  n PIC 9(08).
       01  m PIC 9(08).
       01  r PIC 9(08).
       01  d PIC 9(08).
       01  g PIC 9(08).
       01 RES PIC 9(08) VALUE 0.
       01 disp   PIC Z(4)9.
       PROCEDURE DIVISION.
        ACCEPT indata

        move 0 to RES.

        UNSTRING indata DELIMITED BY SPACE INTO n m.

        DIVIDE n BY m GIVING g REMAINDER d.

        add g to RES.
        
         IF d > 0 THEN
                 ADD 1 TO g GIVING RES
         END-IF

         MOVE FUNCTION TRIM(RES) to disp.
         DISPLAY disp.

       STOP RUN.


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define MOD 1e9+7;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n,y;
  cin >> n >> y;
  int sum = y - 1000*n; //9000a + 4000b = Y - 1000N
  if(sum < 0){
    cout << "-1 -1 -1" << endl;
    return 0;
  }
  int maxb = sum / 4000;
  int tmpsum;
  int a,b,c;
  for(int i=0;i<=maxb;i++){
    tmpsum = sum - 4000*i;
    if(tmpsum % 9000 == 0){
      a = tmpsum / 9000;
      b = i;
      c = n - a - b;
      if(c < 0) continue;
      cout << a << " " << b << " " << c << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1" << endl; 
}

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

int main(){
    double x;
    while(scanf("%lf",&x)){
        if(x<0) break;
        x *= 16;
        if(x > (1<<16)-1)
            printf("NA\n");
        else if(x == (int)x){
            char str[20];
            str[8] = '.';
            str[13] = '\0';
            int n = x;
            for(int i=0; i<12; i++)
                str[(i<4)?(12-i):(11-i)] = (n & (1<<i))?'1':'0';
            printf("%s\n",str);
        }
        else
            printf("NA\n");
    }

    return 0;
}

Measured memory_bytes: 0
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
vector<pair<int, int>>v;
priority_queue<int>q;
void solve()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		v.pb(MP(a, b));
	}
	sort(v.begin(), v.end());
	int j = 0;
	int sol = 0;
	for (int i = m-1; i >= 0; i--)
	{
			while (j<n&&i + v[j].first <= m)
			{
				q.push(v[j].second);
				j++;
			}
			if (!q.empty())
			{
				sol = sol + q.top();
				q.pop();
			}
		
	}
	cout << sol;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 1908
from collections import deque,defaultdict
import sys
from collections import defaultdict
input = sys.stdin.readline

H, W = map(int, input().split())
C = [list(input()) for i in range(H)]
INF = 10 ** 9
go = [[1, 0], [0, 1], [-1, 0], [0, -1]]
que = deque()
ans  = -1

mass = ["#","."]
groups = [[-1 for _ in range(W)] for _ in range(H)]
group_num = -1
for sx in range(W):
    for sy in range(H): # スタート地点のループ
        if C[sy][sx] == "#" and groups[sy][sx] == -1:
            group_num += 1
            que.append((sy,sx))
            groups[sy][sx] = group_num
            while que: #行けるだけいく
                y,x = que.popleft()
                for temp in go:
                    gx,gy = temp
                    nx = x + gx
                    ny = y + gy
                    should = abs(sx - nx) + abs(sy - ny) #奇数→
                    should %= 2
                    if 0<= nx < W and 0<= ny < H and C[ny][nx] == mass[should]:
                        if groups[ny][nx] == -1: # ここの更新にminはいらない(幅優先なので自明に最短距離を進む)
                            groups[ny][nx] = group_num
                            que.append( (ny,nx))
ans = 0
di_sharp = defaultdict(lambda :0)
di_dot = defaultdict(lambda :0)
ma = -1
for sx in range(W):
    for sy in range(H):
        if groups[sy][sx] >= 0:
           color = groups[sy][sx]
           ma = max(ma,color)
           if C[sy][sx] =="#":
               di_sharp[color] += 1
           else:
               di_dot[color] += 1

for i in range(ma + 1):
    ans += di_dot[i]  * di_sharp[i]

print(ans)





Measured memory_bytes: 73820
import java.util.Scanner;
 
public class Main {
 
 
	public static void main (String[] args)  {
 
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int c = Math.max(a,b);
		int d = Math.min(a,b);
		
		
		String str = "";
		for (int i=0;i<c;i++) {
			str += d;
		}
		
		System.out.println(str);
		
	}
	
	
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define LL long long
#define zeros(x) x^(x-1)&x
#define pint pair<int,int>
#define inf 2e9
using namespace std;

int x,y,X,Y,t,nr,DP[18002],DP2[18002],ok;
string s;

vector<int> dx,dy;

int main()
{

    cin>>s;
    cin>>X>>Y;
    t = 0;
    ok = 1;
    for (int i=0;i<s.size();i++)
    {
        if (s[i]=='F')
            nr++;
        else
        {
            if (ok)
            {
                ok = 0;
                X-=nr;
            }
            else
            {
                if (t==1)
                {
                    if (nr!=0)
                    dy.push_back(nr);
                }
                else
                {
                    if (nr!=0)
                    dx.push_back(nr);
                }
            }
            t = 1-t;
            nr = 0;
        }
    }
    if (ok)
        X-=nr;
    else
    {
        if (t==1)
            dy.push_back(nr);
        else
            dx.push_back(nr);
    }

    X += 9000;
    Y += 9000;
    DP[9000] = 1;
    int mx = 9000,mn=9000;
    for (auto it : dx)
    {
        for (int i=mn;i<=mx;i++)
        {
            if (DP[i]==1)
            {
                DP2[i-it] = DP2[i+it] = 1;
                mn = min(mn,i-it);
                mx = max(mx,i+it);
            }
        }
        memcpy(DP,DP2,sizeof(DP));
        memset(DP2,0,sizeof(DP2));
    }
    if (X<0 || DP[X]==0)
    {
        cout<<"No\n";
        return 0;
    }

    memset(DP,0,sizeof(DP));
    DP[9000] = 1;

    mx = 9000;
    mn = 9000;
    for (auto it : dy)
    {
        for (int i=mn;i<=mx;i++)
        {
            if (DP[i]==1)
            {
                DP2[i-it] = DP2[i+it] = 1;
                mn = min(mn,i-it);
                mx = max(mx,i+it);
            }
        }
        memcpy(DP,DP2,sizeof(DP));
        memset(DP2,0,sizeof(DP2));
    }
    if (Y<0 || DP[Y]==0)
    {
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1);
int f[100];
int main()
{
    double a,b,x;
    cin >> a>> b >>x;
    double shangdi=x*2/a/a-b;

    if(shangdi<=0)
    {
        shangdi=2*x/a/b;
        printf("%.10f",atan(b/shangdi)*180.0/PI);
    }
    else
    {

        shangdi=b-shangdi;
        printf("%.10f",atan(shangdi/a)*180.0/PI);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    f1(n) {
        if (i % 3 == 0 || i % 5 == 0)continue;
        ans += i;
    }
    cout << ans << '\n';
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> V(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;

    V.at(--a)++;
    V.at(--b)++;
  }

  for (int i = 0; i < n; i++)
  {
    cout << V.at(i) << endl;
  }
}


Measured memory_bytes: 3612
H,W=map(int,input().split())

arr=[list(input()) for _ in range(H)]

for i in range(H):
  for j in range(W):
    if arr[i][j]!='.': continue
    # replace
    bom=0
    for row_offs in [-1,0,1]:
      for col_offs in [-1,0,1]:
        if row_offs==0 and col_offs==0:   continue
        if i+row_offs<0 or H<=i+row_offs: continue
        if j+col_offs<0 or W<=j+col_offs: continue  
        if arr[i+row_offs][j+col_offs]=='#':
          bom+=1
    arr[i][j]=bom
    
for arr_ in arr:
  print(*arr_,sep="")

Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

    lint a,b,c;cin>>a>>b>>c;
    Yes(a<=c&&c<=b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int n, m;
lint a[100010];

typedef struct UnionFindTree{
    vector<int> par, min_v;
    
    UnionFindTree(int n_){
        par.resize(n_, -1);
        min_v.resize(n_);
        rep(i, n_) min_v[i] = i;
    }
    
    int find(int x){
        if(par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    
    int size(int x){
        return -par[find(x)];
    }
    
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        if(a[min_v[x]] > a[min_v[y]]) min_v[x] = min_v[y];
        par[y] = x;
        return true;
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
}UF;

int main(){
    scanf("%d%d", &n, &m);
    if(m == n-1){
        printf("0\n");
        return 0;
    }
    rep(i, n) scanf("%lld", &a[i]);
    UF uf(n);
    int con = n;
    rep(i, m){
        int x, y;
        scanf("%d%d", &x, &y);
        con -= uf.unite(x, y);
    }
    lint ans = 0;
    bool used_par[n], used_v[n];
    rep(i, n) used_par[i] = used_v[i] = false;
    rep(i, n){
        int p = uf.find(i);
        if(used_par[p]) continue;
        used_par[p] = true;
        ans += a[uf.min_v[p]];
        used_v[uf.min_v[p]] = true;
    }
    vector<lint> rest;
    rep(i, n)if(!used_v[i]) rest.push_back(a[i]);
    if(rest.size() < 2*(n-1-m) - con){
        printf("Impossible\n");
        return 0;
    }
    sort(rest.begin(), rest.end());
    rep(i, 2*(n-1-m) - con) ans += rest[i];
    printf("%lld\n", ans);
}

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

int main() {
  int x, a;
  cin >> x >> a;
  if (x<a)
  cout << 0 << endl;
  else cout << 10 <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,m,a[555][555],stp[555];
bool s[555];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;stp[i++]=1)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=m;++i) s[i]=1;
	int ans=1e9;
	for(int p=1;p<=m;++p)
	{
		int cnt[555];
		for(int j=1;j<=m;++j) cnt[j]=0;
		for(int i=1;i<=n;++i)
		{
			while(!s[a[i][stp[i]]]) ++stp[i];
			++cnt[a[i][stp[i]]];
		}
		pii mx(-1,-1);
		for(int j=1;j<=m;++j)
			mx=max(mx,pii(cnt[j],j));
		int sb=mx.se; s[sb]=0;
		ans=min(ans,mx.fi);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int dight(int n){
  return n==0?1:int(log10(n)+1);
}
int kakeru(int n){
  int m = 1;
  for(int i=0;i<n;i++) m *= 10;
  return m;
}
int main(){
  int n,count=0;
  cin >> n;
  int s[n],m[n];
  for(int i=0;i<n;i++) cin >> s[i]; 
  sort(s,s+n);
  for(int i=0;i<4;i++) m[i] = s[i];
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(i!=j){
	m[count] = s[i] * kakeru(dight(s[j]));
	m[count] += s[j];
	count++;
      }
    }
  }
  sort(m,m+count);
  //for(int i=0;i<count;i++) cout << m[i] << endl;
  cout << m[2] << endl;
  return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::vector;

static int C[2001][2001] = {0};

static int
fix(long a)
{
  return int(a % 1000000007);
}

static int
add_fix(int a, int b)
{
  return fix(long(a) + long(b));
}

static int
mul_fix(int a, int b)
{
  return fix(long(a) * long(b));
}

// C(n, k) == C(n - 1, k - 1) + C(n - 1, k)
static int
combination(int n, int k)
{
  if (n < k)
  {
    return 0;
  }
  if (k == 0 || k == n)
  {
    return 1;
  }
  int c = C[n][k];
  if (c == 0)
  {
    C[n][k] = c = add_fix(combination(n - 1, k - 1), combination(n - 1, k));
  }
  return c;
}

int
main()
{
  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= K; i++)
  {
    cout << mul_fix(combination(N - K + 1, i), combination(K - 1, i - 1))
         << endl;
  }
  return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <vector>

int main(){
    int n;
    while(std::cin >> n){
        if(0 == n){
            break;
        }else{
            std::vector<double> s(n);
            double sum;
            for(int i = 0; i < n; ++i){
                std::cin >> s.at(i);
            }

            double avg = std::accumulate(s.begin(), s.end(), 0.0)/s.size();

            double sigma_sqrd = 0;
            for(int i = 0; i < n; ++i){
                sigma_sqrd += std::pow(s.at(i) - avg, 2);
            }

            std::cout << std::fixed << std::setprecision(4) << std::sqrt(sigma_sqrd/s.size()) << std::endl;
        }
    }
    return 0;
}


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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  string R;
  rep(i,2000){
    if(a<=k*i && k*i<=b){
      R="OK";
      break;
    }
    else{
      R="NG";
    }
  }
  cout << R << endl;
}
      



Measured memory_bytes: 3608
#include<cstdio>
#include<utility>
#include<algorithm>

using namespace std;

struct RMQ{
	int N;
	int dat[524288];
	void init(int N_){
		N=1;
		while(N<N_) N*=2;
		for(int i=1;i<=N*2-1;i++) dat[i]=-1;
	}
	void update(int i,int x){
		i+=N;
		while(i>0){
			dat[i]=max(dat[i],x);
			i/=2;
		}
	}
	int get(int i){//,i)
		int k=1,l=0,r=N;
		int res=-1;
		while(r-l>1){
			int mid=(l+r)/2;
			if(mid<i){
				res=max(res,dat[k*2]);
				k=k*2+1;
				l=mid;
			}else{
				r=mid;
				k*=2;
			}
		}
		return res;
	}
};

RMQ rmq;

int N;
int lo1[100100],lo2[100100],hi1[100100],hi2[100100];
int clo1[100100],clo2[100100];

int lo_vals[200200];

int getPos(int x){
	return lower_bound(lo_vals,lo_vals+N*2,x)-lo_vals;
}

void input(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d%d%d%d",lo1+i,lo2+i,hi1+i,hi2+i);
		lo_vals[i*2]=lo1[i];
		lo_vals[i*2+1]=lo2[i];
	}
	sort(lo_vals,lo_vals+N*2);
	for(int i=0;i<N;i++){
		clo1[i]=getPos(lo1[i]);
		clo2[i]=getPos(lo2[i]);
	}
}

typedef pair<int,int> P;
typedef pair<P,P> PP;

PP pps[200200];

int ans[100100];

int solve(){
	for(int i=0;i<N;i++){
		PP pp=PP(P(hi1[i],clo1[i]),P(i,0));
		pps[i*2]=pp;
		pp=PP(P(hi2[i],clo2[i]),P(i,1));
		pps[i*2+1]=pp;
	}
	sort(pps,pps+N*2);
	rmq.init(N*2);
	for(int i=0;i<N*2;i++){
		PP pp=pps[i];
//		printf("%d %d\n",pps[i].first.first,pps[i].first.second);
		if(pp.second.second==0){
			int pos=pp.first.second;
			int val=rmq.get(pos+1);
			int id=pp.second.first;
			ans[id]=val+1;
//			printf("pos=%d,ans=%d\n",pos,val+1);
		}else{
			int id=pp.second.first;
			int val=ans[id];
			int pos=pp.first.second;
			rmq.update(pos,val);
//			printf("upd pos=%d,val=%d\n",pos,val);
		}
	}
	int res=0;
	for(int i=0;i<N;i++) res=max(res,ans[i]+1);
	return res;
}

int main(){
	input();
	int ans=solve();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9736
n, k = map(int, input().split())
Hs = list(map(int, input().split()))

dp = [None] * n
for i in range(n):
    if i == 0:
        dp[i] = 0
        continue
    if i-k < 0:
        # ここまで来る方法はi通り
        costs = [abs(Hs[i-j] - Hs[i]) + dp[i-j] for j in range(1, i+1)]
    else:
        costs = [abs(Hs[i-j] - Hs[i]) + dp[i-j] for j in range(1, k+1)]
    
    dp[i] = min(costs)
print(dp[-1])

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

int main()
{
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    vector<int>ans;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='B'){
            if(!ans.empty())
                ans.pop_back();
        }
        else
            ans.push_back(s[i]-'0');
    }
    for(auto x : ans)
        cout << x;

    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);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int cnt = 0;
    if (b == 1) ;
    else if (a >= b) cnt = 1;
    else {
      int x = (b - a) / (a-1);
      if ((b-a)%(a-1) != 0) x++;
      cnt = x +1;
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(){
    string str;
    while(cin >> str){
        int total=0;
        int arr[3]={};
        for(int i=0;i<3;i++){
            if(str[i]=='R'){
                total+=1;
                arr[i]=total;
            }else{
                total=0;
                arr[i]=total;
            }
        }int sum=0;
        for(int i=0;i<3;i++){
            if(arr[i]>sum){
                sum=arr[i];
            }
        }
        cout << sum << '\n';
    }
}

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

using namespace std;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)

int main() {
  int N; cin >> N;
  vector<int> num(N);
  REP(i, N) cin >> num[i];

  set<int> num_set;
  REP(i, N) {
    int t = 0;
    for (int j = i; j < N; j++) {
      if (j - i + 1 > 6) break;
      t = t * 10 + num[j];
      num_set.insert(t);
    }
  }

  REP(i, 1e6) {
    if (num_set.find(i) == num_set.end()) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3260
import numpy as np
li = list(map(int,input().split()))
N = li[0]
D = li[1]

a = []
for i in range(N):
    a.append(list(map(int,input().split())))
count = 0
for i in range(N):
    for j in range(i+1,N):
        d = np.linalg.norm(np.array(a[i])-np.array(a[j]))
        if d % 1 == 0:
            count += 1
print(count)

Measured memory_bytes: 12504
def check(l, c):
    if l[0] == l[1] == l[2]:
        print(c)
        return True
    return False

n = [int(x) for x in input().split()]
n = sorted(n)
count = 0

if not check(n, count):
    while True:
        if n[1] < n[2]:
            n[0] += 1
            n[1] += 1
            count += 1
            n = sorted(n)
            if check(n, count):
                break
        if n[1] == n[2]:
            n[0] += 2
            count += 1
            n = sorted(n)
            if check(n, count):
                break


Measured memory_bytes: 3064