akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int x, y, z;
    int n;
    cin >> n;
    VI v(101010);
    for (x = 1; x <= 100; x++) {
        for (y = 1; y <= 100; y++) {
            for (z = 1; z <= 100; z++) {
                v[x * x + y * y + z * z + x * y + y * z + z * x]++;
            }
        }
    }
    for (i = 1; i <= n; i++) {
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 3952
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

struct Node {
	char str[12] = "\0";
	Node *p_r = NULL;
	Node *p_l = NULL;
};

class Dictionary {
private:
	Node dummy;
public:
	void insert(const char str[]);
	bool find(const char str[]);
};

void Dictionary::insert(const char str[])
{
	Node *p_node = &dummy;
	Node **pp_node = NULL;
	while (p_node != NULL) {
		int rt = strcmp(str, p_node->str);
		if (rt == 0) return;
		if (rt > 0) {
			pp_node = &(p_node->p_r);
			p_node = p_node->p_r;
		}
		else {
			pp_node = &(p_node->p_l);
			p_node = p_node->p_l;
		}
	}

	Node *p_newnode = new Node;
	strcpy(p_newnode->str, str);
	*pp_node = p_newnode;
}

bool Dictionary::find(const char str[])
{
	Node *p_node = &dummy;
	while (p_node != NULL) {
		int rt = strcmp(str, p_node->str);
		if (rt == 0) return true;
		if (rt > 0) {
			p_node = p_node->p_r;
		}
		else {
			p_node = p_node->p_l;
		}
	}
	return false;
}

int main(void)
{
	Dictionary dic;

	int n;
	cin >> n;

	char cm[7] = "\0", str[13] = "\0";
	for (int i = 0; i < n; i++) {
		cin >> cm >> str;
		if (strcmp(cm, "insert") == 0) {
			dic.insert(str);
		}
		else if (strcmp(cm, "find") == 0) {
			bool result = dic.find(str);
			if (result) cout << "yes";
			else cout << "no";
			cout << endl;
		}
	}

	return 0;
}

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

int main(void) {

	int M;
	cin >> M;

	long int K;
	cin >> K;

	long int tmp = 1;
	for (int i = 1; i <= M; i++) { tmp *= 2; }

	if (K >= tmp) { cout << -1 << endl; return 0; }

	if (M == 1 && K == 1) { cout << -1 << endl; return 0; }

	if (K == 0) {
		for (int i = 0; i < tmp; i++) {
			if (i != 0) { cout << " "; }
			cout << i<<" "<<i;

		}
		cout << endl;

		return 0;
	}

	long int Y = K^1;

	vector<long long int> V;

	V.push_back(Y);
	for (long long int i = tmp - 1; i >= 0; i--) {
		if (i == Y) { continue; }
		if (i == 1) { continue; }
		V.push_back(i);
	}

	V.push_back(Y);
	V.push_back(1);

	for (long long int i = 0; i <= tmp - 1; i++) {
		if (i == Y) { continue; }
		if (i == 1) { continue; }
		V.push_back(i);
	}

	V.push_back(1);

	for (int i = 0; i < (int)V.size(); i++) {
		if (i != 0) { cout << " "; }
		cout << V[i];
	}cout << endl;


	return 0;
}

Measured memory_bytes: 3952
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
long long x,y,A,B,C;
struct node
{
	long long w,id;
}a[maxn*3];
long long cmp(node x,node y)
{
	return x.w>y.w;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld",&x,&y,&A,&B,&C);
	for(long long i=1;i<=A;i++)scanf("%lld",&a[i].w),a[i].id=1;
	for(long long i=1;i<=B;i++)scanf("%lld",&a[i+A].w),a[i+A].id=2;
	for(long long i=1;i<=C;i++)scanf("%lld",&a[i+A+B].w),a[i+A+B].id=3;
	sort(a+1,a+1+A+B+C,cmp);
	long long ans=0,cnt=0;
	for(long long i=1;i<=A+B+C;i++)
	{
		if(a[i].id==1)
		{
			if(x)x--,ans+=a[i].w;
			if(x+y==cnt)break;
		}
		else if(a[i].id==2)
		{
			if(y)y--,ans+=a[i].w;
			if(x+y==cnt)break;
		}
		else 
		{
			cnt++;
			ans+=a[i].w;
			if(x+y==cnt)break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;
	for (int i = 0; i <= A; i++)
	{
		for (int j = 0; j <= B; j++)
		{
			for (int k = 0; k <= C; k++)
			{
				if (500 * i + 100 * j + 50 * k == X)
					res++;
			}
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
def resolve():
    X, Y, A, B, C = map(int, input().split())
    p = sorted(list(map(int, input().split())), reverse=True)
    q = sorted(list(map(int, input().split())), reverse=True)
    r = sorted(list(map(int, input().split())), reverse=True)
    pre = sorted(p[:X] + q[:Y])
    for i in range(min(X + Y, C)):
        if pre[i] < r[i]:
            pre[i] = r[i]
        else:
            break
    print(sum(pre))

resolve()

Measured memory_bytes: 24096
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;

int main(){

  ll x,y;cin>>x>>y;

  ll ans=0;
  while(x<=y){
    x*=2;
    ans++;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pli;
vector<int> g[55];
int m[55],y[55];
ll x[55],dp[2][166375];
void dfs(int u){
	x[u]=m[u];
	y[u]=1;
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		dfs(v);
		x[u]+=x[v];
		y[u]+=y[v];
	}
}
struct Item{
	ll x;
	int y,z;
	Item(ll _x=0,int _y=0,int _z=0):x(_x),y(_y),z(_z){}
	inline bool operator<(const Item& rhs) const{
		return x*rhs.y<rhs.x*y;
	}
} item[55];
pli dq[166375];
int main(){
	int n,D,p;
	ll X;
	scanf("%d%lld%d",&n,&X,&D);
	scanf("%d",m+1);
	for(int i=2;i<=n;i++){
		scanf("%d%d",m+i,&p);
		g[p].push_back(i);
	}
	dfs(1);
	memset(dp,0x3f,sizeof dp);
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
		int limt=min((i==1)?0x7fffffff:D,50);
		int ori=(i==1)?0x7fffffff:D;
		for(int j=0;j<y[i];j++){
			int head=0,rear=0;
			for(int k=0;k*y[i]+j<=125000;k++){
				pli p=pli(dp[~i&1][k*y[i]+j]-x[i]*k,k);
				while(head<rear && dq[rear-1].first>=p.first) rear--;
				dq[rear++]=p;
				while(head<rear && k-dq[head].second>limt) head++;
				dp[i&1][k*y[i]+j]=dq[head].first+x[i]*k;
			}
		}
		item[i]=Item(x[i],y[i],ori-limt);
	}
	sort(item+1,item+1+n);
	// for(int i=1;i<=n;i++)
		// printf("de: %lld %d %d\n",item[i].x,item[i].y,item[i].z);
	ll ans=0;
	for(int i=1;i<=125000;i++){
		if(dp[n&1][i]<=X){
			// printf("de: %d %lld\n",i,dp[n&1][i]);
			ll remain=X-dp[n&1][i],taken=i;
			for(int j=1;j<=n && remain;j++){
				ll t=min((ll)item[j].z,remain/item[j].x);
				remain-=t*item[j].x;
				taken+=t*item[j].y;
			}
			ans=max(ans,taken);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>

typedef struct dice {
	int num[6];
}dice;

//dice???1?????¢?????????.
void mov(dice *d, char c);

//dice??????????¨??????????1?????¢?????????.
void spin(dice *d);

//dice??????????????????????????§??????.
int check(dice d1, dice d2);

int main(void) {
	int i = 0;
	int j = 0;
	int k = 0;
	int l = 0;

	int judge = 0;

	int n;		//dice?????°.
	scanf("%d", &n);

	//dice?????????.
	dice di[100];

	//??¢???????????????.
	for (i = 0; i < n; i++) {
		for (j = 0; j < 6; j++) {
			scanf("%d", &di[i].num[j]);
		}
	}

	//i????????¨j????????????????????????.
	for (i = 0; i < n-1; i++) {
		for (j = i + 1; j < n; j++) {

			//di[j]????????¢?????????dice[i]??¨??§?????????.
			for (k = 0; k < 4; k++) {
				mov(&di[j], 'E');

				for (l = 0; l < 4; l++) {
					spin(&di[j]);
					judge = check(di[i], di[j]);

					if (judge)break;
				}
				if (judge)break;
			}

			if (!judge) {
				for (k = 0; k < 4; k++) {
					mov(&di[j], 'N');

					for (l = 0; l < 4; l++) {
						spin(&di[j]);
						judge = check(di[i], di[j]);

						if (judge)break;
					}
					if (judge)break;
				}
			}
			if (judge)break;
		}
		if (judge)break;
	}

	//??????.
	if (judge)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}

void mov(dice *d, char c) {
	int tmp = 0;

	if ('E' == c) {
		tmp = (*d).num[0];
		(*d).num[0] = (*d).num[3];
		(*d).num[3] = (*d).num[5];
		(*d).num[5] = (*d).num[2];
		(*d).num[2] = tmp;
	}
	else if ('N' == c) {
		tmp = (*d).num[0];
		(*d).num[0] = (*d).num[1];
		(*d).num[1] = (*d).num[5];
		(*d).num[5] = (*d).num[4];
		(*d).num[4] = tmp;
	}
	else if ('S' == c) {
		tmp = (*d).num[0];
		(*d).num[0] = (*d).num[4];
		(*d).num[4] = (*d).num[5];
		(*d).num[5] = (*d).num[1];
		(*d).num[1] = tmp;
	}
	else if ('W' == c) {
		tmp = (*d).num[0];
		(*d).num[0] = (*d).num[2];
		(*d).num[2] = (*d).num[5];
		(*d).num[5] = (*d).num[3];
		(*d).num[3] = tmp;
	}
}

void spin(dice *d) {
	int tmp = 0;

	tmp = (*d).num[1];
	(*d).num[1] = (*d).num[3];
	(*d).num[3] = (*d).num[4];
	(*d).num[4] = (*d).num[2];
	(*d).num[2] = tmp;
}

int check(dice d1, dice d2) {
	int i = 0;
	int judge = 1;

	for (i = 0; i < 6; i++) {
		if (d1.num[i] != d2.num[i])
			judge = 0;
	}

	return judge;
}

Measured memory_bytes: 584
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    println!("{}", n * n);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    var (tH, tA, aH, aA) = (0 until 4).map { sc.nextInt() }
    while (tH > 0 && aH > 0) {
        aH -= tA
        tH -= aA
    }
    if (aH < 1) {
        println("Yes")
    } else {
        println("No")
    }

}

Measured memory_bytes: 37596
#include<stdio.h>
int main(void)
{
	int a,b,c;
	int d,e,f;
	int x,y,z;
	int s,t,u;
	scanf("%d %d %d",&a,&b,&c);
	while(a!=-1 && b!=-1 && c!=-1) {
		d=2;
		e=0;
		f=0;
		if((f-c)>=0) {
			z=f-c;
		}
		if((f-c)<0) {
			if(e!=0) {
				e=e-1;
				f=f+60;
				z=f-c;
			}
			if(e==0) {
				d=d-1;
				e=e+60;
				e=e-1;
				f=f+60;
				z=f-c;
			}
		}
		if((e-b)>=0) {
			y=e-b;
		}
		if((e-b)<0) {
			if(d!=0) {
				d=d-1;
				e=e+60;
				y=e-b;
			}
		}
		x=d-a;
		if(x<10 && y<10 && z<10) {
			printf("0%d:0%d:0%d\n",x,y,z);
		}
		if(x>=10 && y<10 && z<10) {
			printf("%d:0%d:0%d\n",x,y,z);
		}
		if(x<10 && y>=10 && z<10) {
			printf("0%d:%d:0%d\n",x,y,z);
		}
		if(x<10 && y<10 && z>=10) {
			printf("0%d:0%d:%d\n",x,y,z);
		}
		if(x>=10 && y>=10 && z<10) {
			printf("%d:%d:0%d\n",x,y,z);
		}
		if(x<10 && y>=10 && z>=10) {
			printf("0%d:%d:%d\n",x,y,z);
		}
		if(x>=10 && y<10 && z>=10) {
			printf("%d:0%d:%d\n",x,y,z);
		}
		if(x>=10 && y>=10 && z>=10) {
			printf("%d:%d:%d\n",x,y,z);
		}
		s=x*3;
		t=y*3;
		u=z*3;
		while(!(t<60)) {
			t=t-60;
			s=s+1;
		}
		while(!(u<60)) {
			u=u-60;
			t=t+1;
			if(t>=60) {
				t=t-60;
				s=s+1;
			}
		}
		if(s<10 && t<10 && u<10) {
			printf("0%d:0%d:0%d\n",s,t,u);
		}
		if(s>=10 && t<10 && u<10) {
			printf("%d:0%d:0%d\n",s,t,u);
		}
		if(s<10 && t>=10 && u<10) {
			printf("0%d:%d:0%d\n",s,t,u);
		}
		if(s<10 && t<10 && u>=10) {
			printf("0%d:0%d:%d\n",s,t,u);
		}
		if(s>=10 && t>=10 && u<10) {
			printf("%d:%d:0%d\n",s,t,u);
		}
		if(s<10 && t>=10 && u>=10) {
			printf("0%d:%d:%d\n",s,t,u);
		}
		if(s>=10 && t<10 && u>=10) {
			printf("%d:0%d:%d\n",s,t,u);
		}
		if(s>=10 && t>=10 && u>=10) {
			printf("%d:%d:%d\n",s,t,u);
		}
	scanf("%d %d %d",&a,&b,&c);
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;

#define mod (int) (1e9+7)




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


 
 ll ncr(ll x, ll y){
 	ll ans=1;
 	
 	y=(y > x-y? x-y: y);
 	
 	for(ll i=0; i<y; i++){
 		ans=ans*(x-i);
 		ans=ans/(i+1);
 		ans=ans%mod;
 	}
 
 	
 	return ans;
 }

ll power(ll x, ll y){
    ll ans=1;
    while(y){
        if(y&1){
            ans=ans*x;
            ans=ans%mod;
        }
        
        x=x*x;
        x=x%mod;
        y=y>>1;
    }
    
    return ans;
    
}

// void transpose(ll arr[][0],ll b[][0],ll ind){
	
// 	for(int i=0; i<ind; i++){
// 		for(int j=0; j<ind; j++){
// 			b[j][i]=arr[i][j];
// 		}
// 	}
	
// 	for(int i=0; i<ind; i++){
// 		for(int j=0; j<ind; j++){
// 			arr[i][j]=b[i][j];
// 		}
// 	}
	
// 	return;
	
// }


 
void solve(){
	
  ll a,b,c,d; cin>>a>>b>>c>>d;
  
  ll m1=max(a*c,a*d);
  
  ll m2=max(b*c,b*d);
  
  cout<<max(m1,m2)<<"\n";


   return ;
	
}




int main(){
    ios_base::sync_with_stdio(0);
    
    cin.tie(0);
    
    int t=1;//cin>>t;
    
   
    
//    clock_t begin, end;
//    
//    double time_spent;
//    
//    begin = clock(); // Time taken till now.
    
    
    while(t--){
    
	  solve();
        
    }
    
 
    
   
//   end= clock(); // Total  Time taken till now.
//   
//   time_spent= (end- begin) / CLOCKS_PER_SEC; 
//   
//   cout<<time_spent<<"\n";
   
   
   
	
	return 0;
}



Measured memory_bytes: 3492
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Pair{
	long long int a;
	long long int b;
	Pair(){
		a=0;
		b=0;
	}
	bool operator ()(const Pair x,const Pair y){
		return x.a<y.a;
	}
};
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	long long int sum=0;
	int min=1e9+1,cnt;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]<0){
			sum-=a[i];
			if(min>-a[i]) min=-a[i];
			cnt++;
		}else{
			sum+=a[i];
			if(min>a[i]) min=a[i];
		}
	}
	if(cnt%2==0){
		cout<<sum<<endl;
	}else{
		cout<<sum-min*2<<endl;
	}




	return 0;
}

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

using namespace std;

#define ll long long

int main()
{
	ll N, K;
	cin >> N >> K;

	ll nMod = N % K;

	ll ans = min(min(N, abs(N - K)), min(nMod, abs(nMod - K)));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();

main(){
    ios
    int tc=1;
    // tc=in();
    while(tc--){
        go();
    }
    return 0;
}


void go(){
    int n=in();
    vec p(101000,1);
    p[2]=1;
    for(int i=2;i<=100000;i++){
        if(p[i])
        for(int j=i*2;j<=100000;j+=i){
            p[j]=0;
        }
    }
    int cnt=0;
    rep2(i,2,100000){
        if(p[i] and i%5==2){cout<<i<<" ";
        cnt++;}
        if(cnt==n)return;
    }
        
}





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

int main(){
  string S;
  cin >> S;
  int A=S.size()-1;
  long long sum_all=0;
  for(int bit=0;bit<(1<<A);bit++){
    long long sum=0;
    for(int i=0;i<A;i++){
      int B=S.at(i)-'0';
      sum=10*sum+B;
      if(bit & (1<<i)){
        sum_all+=sum;
        sum=0;
      }
    }
    int B=S.at(A)-'0';
    sum=10*sum+B;
    sum_all+=sum;
  }
  cout << sum_all << endl;
} 

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

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

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=true;

    ll ans=0,sum=0;
    
    int n,k;
    cin >>n>>k;

    if(n%k == 0)cout << 0 << endl;
    else cout << 1 << endl;
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define erep(i, n) for(ll i = 1; i <= (n); i++)
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void) {
  int p, q, r;
  cin >> p >> q >> r;
  int ans=min({p+q,q+r,r+p});
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main()
{
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k)
    {
        cout << s << endl;
    }
    else
    {
        for (ll i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout << "Bad";
    else cout << "Good";
    cout << '\n';
    return 0;
}

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


void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans = LONG_LONG_MIN;
    ans = max(ans,a*c);
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans, b*d);
    cout<<ans;

}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll q;
    q=1;
    // cin>>q;
    while(q--) solve();


    return 0;
}


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

int solve(vector <int> &arr,int n )
{
    vector <int>dp(n+1);
    dp[1]=0;

    for(int i=2;i<=n;i++)
    {
        int op1= abs(arr[i]-arr[i-1])+dp[i-1];
        int op2=(i==2) ? INT_MAX:abs(arr[i]-arr[i-2])+dp[i-2];
        dp[i]=min(op1,op2);
    }
    return dp[n];
}
int main() 
{
    int n;cin>>n;
    vector <int> arr(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    cout<<solve(arr,n)<<endl;
}


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

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

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  int a,b=0,d;
  cin>>a>>d;
  rep(i,a+1){
    rep(j,a+1){
      if(d-i-j>-1&&d-i-j<a+1)b++;
    }
  }
  cout<<b;
  }


Measured memory_bytes: 256
n = int(input())
C = []
S = []
F = []
for i in range(n-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for start in range(n-1):
    time = S[start]
    for i in range(start,n-1):
        time += C[i]
        if i != n-2:
            if time <= S[i+1]:
                time = S[i+1]
            elif time%F[i+1] != 0:
                time += F[i+1]-time%F[i+1]
    print(time)
print(0)

Measured memory_bytes: 74196
import sys
from collections import deque

S=raw_input()
Q=input()
Query=[ sys.stdin.readline().split() for _ in range(Q) ]

s1=deque()
s2=deque()
judge={}
judge["front"]="s1"
judge["end"]="s2"

cnt=0
for x in Query:
    if x[0]=="1":
        n=x[0]
        cnt+=1
    elif x[0]=="2":
        n,f,c=x[0],x[1],x[2]
    if n=="1":
        judge["front"],judge["end"]=judge["end"],judge["front"]
    elif n=="2":
        if f=="1":
            if judge["front"]=="s1":
                s1.appendleft(c)
            elif judge["front"]=="s2":
                s2.append(c)
        elif f=="2":
            if judge["end"]=="s1":
                s1.appendleft(c)
            if judge["end"]=="s2":
                s2.append(c)

str1=""
for x in s1:
    str1+=x
str2=""
for x in s2:
    str2+=x

if judge["front"]=="s1" and judge["end"]=="s2":
    print str1+S+str2
elif judge["front"]=="s2" and judge["end"]=="s1":
    print str2[::-1]+S[::-1]+str1[::-1]


Measured memory_bytes: 186908
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b)
		{
			if(b>c)cout<<c<<" "<<b<<" "<<a<<endl;
			else if(a>c)cout<<b<<" "<<c<<" "<<a<<endl;
			else cout<<b<<" "<<a<<" "<<c<<endl;
			}
	else
		{if(a>c)cout<<c<<" "<<a<<" "<<b<<endl;else if(b>c)cout<<a<<" "<<c<<" "<<b<<endl;else cout<<a<<" "<<b<<" "<<c<<endl;} 
}    


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  vector<int> b {a};
  sort(b.begin(), b.end());
  rep(i, n) {
    if (a[i] == b[n-1]) {
      cout << b[n-2] << endl;
    } else {
      cout << b[n-1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    vector<ll> y(m);
    rep(i, m) cin >> y[i];
    
    ll mod = 7LL + 1e9;

    vector<ll> Sx(n+1);
    rep(i, n) Sx[i+1] = (Sx[i] + x[i]) % mod;
    vector<ll> Sy(m+1);
    rep(i, m) Sy[i+1] = (Sy[i] + y[i]) % mod;

    ll xsum = 0;
    for (int i = 1; i < n; i++) {
        xsum += i * x[i] % mod + mod - Sx[i]; 
        xsum %= mod;
    }
    ll ysum = 0;
    for (int i = 1; i < m; i++) {
        ysum += i * y[i] % mod + mod - Sy[i]; 
        ysum %= mod;
    }

    ll res = xsum * ysum % mod;
    put(res);

}
signed main(){ Main();return 0;}

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

int main()
{
    int n;
    cin >> n;
    int sum_s = 0;
    vector<int> s(n);
    rep(i, n)
    {
        cin >> s.at(i);
        sum_s += s.at(i);
    }

    sort(s.begin(), s.end());

    if (sum_s % 10 != 0)
    {
        cout << sum_s << endl;
        return 0;
    }
    else
    {
        rep(i, n)
        {
            if ((sum_s - s.at(i)) % 10 != 0)
            {
                cout << sum_s - s.at(i) << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
s=int(input())

a=[s]+[0]*1000000

if s%2==0:
    a[1]=s//2
else:
    a[1]=3*s+1
#print(a)
i=1
while a[i] not in a[:i]:
    if a[i]%2==1:
        a[i+1]=3*a[i]+1
    else:
        a[i+1]=a[i]//2
    i+=1

print(i+1)

Measured memory_bytes: 18676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  bool zero = false;
  for(int i=0; i<N; i++){
    cin >> vec[i];
    if(vec[i] == 0){
      zero = true;
    }
  }
  bool over = false;
  int64_t ans = vec[0];
  int64_t INF = 1e18;
  for(int i=1; i<N; i++){
    if(zero){
      ans = 0;
      break;
    }
    if(vec[i] > INF / ans){
      over = true;
      break;
    }
    else{
      ans *= vec[i];
    }
  }
  
  
  if(over && !zero){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
}


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

// 最小値を左に詰めていくようにソートする
int SelectionSort(int A[], int N)
{
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        int minj = i;
        for (int j = i; j < N; j++)
        {
            if (A[minj] > A[j])
                minj = j;
        }
        if (minj != i)
            cnt++;
        swap(A[minj], A[i]);
    }
    return cnt;
}

int main()
{
    int N;
    int A[100];
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%d", &A[i]);
    int rel = SelectionSort(A, N);
    for (int i = 0; i < N; i++)
    {
        if (i != 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d", rel);
    printf("\n");
}


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

using namespace std;

#define int long long
const int mod=(int)1e9+7;

void test_case(){
    int k,sum=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            int g=__gcd(i,j);
            for(int p=1;p<=k;p++){
                sum+=__gcd(g,p);
            }
        }
    }
    cout<<sum;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        test_case();
    }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (a != c) << endl;
  return 0;
}


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

inline int readInt(){
  int ret = 0;
  char c;
  while((c=getchar()) && isdigit(c)){
    ret = ret * 10 + (c-'0');
  }
  return ret;
}

main(){
  int n,s;
  while(true){
    n = readInt();
    if (n==0)break;
    s = readInt();
    int r[101]={0};
    //for(int i=0;i<n;i++){
    for(int i=n;i;i--){
      int tmp;tmp=readInt();r[tmp]++;
    }
    int ans = 0;
    for(int i=100;i;i--){
      if (r[i] && i+i > s)ans += r[i]*(r[i]-1)/2;
      if (!r[i])continue;
      for(int j=100;j > i;j--){
	if (i+j <= s)break;
	ans += r[i]*r[j];
      }
    }
    printf("%d\n",ans);
  }
}

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

void draw_frame(int h, int w)
{
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cout << ((i==0) || (i == h-1) || ((j == 0) || (j == w-1)) ? '#' : '.');
		}
		cout << endl;
	}
}

int main()
{
	int h, w;

	while(true) {
		cin >> h >> w;
		draw_frame(h, w);
		if(h == 0 && w == 0)
			break;
		cout << endl;
	}
}

Measured memory_bytes: 3096
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }
 
long double N, K;
 
int main()
{
    cin >> N >> K;
    if (N < K)
    {
        long double sum = 0.0;
        const long double log2K = log2(K);
        for (int i = 1; i <= N; ++i)
        {
            sum += pow((long double)0.5, (long double)ceil(log2K - log2(i)));
        }
        sum = sum / N;
 
        cout << std::setprecision(13) << sum << endl;
    }
    else
    {
        long double sum = 0.0;
        const long double log2K = log2(K);
        for (int i = 1; i <= K - 1; ++i)
        {
            sum += pow((long double)0.5, (long double)ceil(log2K - log2(i)));
        }
        sum = sum / N;
        sum += (long double)(N - K + 1) / N;
 
        cout << std::setprecision(13) << sum << endl;
 
    }
 
 
    return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a_s = input().split()
for i in range(N):
  a_s[i] = int(a_s[i])
  
a_s = sorted(a_s)

ans = 0
sum_ = 0
for i in range(N):
  if (sum_ + a_s[i] <= x)&(i<N-1):
    sum_ += a_s[i]
    ans += 1
  elif (sum_ + a_s[i] == x)&(i==N-1):
    ans += 1
  else:
    break

print(ans)

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

vector<vector<int>> connect;
int dp[8][256];

int Ways(int pos, int bit) {
  if (dp[pos][bit])
    return dp[pos][bit];
  int visited = bit ^ (1 << pos);
  int sum = 0;
  for (int a : connect[pos]) {
    if ((1 << a) & bit)
      sum += Ways(a, visited);
  }
  return dp[pos][bit] = sum;
}

int main() {
  int n, m;
  cin >> n >> m;
  connect.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    connect[a - 1].push_back(b - 1);
    connect[b - 1].push_back(a - 1);
  }
  dp[0][1] = 1;

  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += Ways(i, (1 << n) - 1);
  }
  cout << sum << "\n";

  return 0;
}


Measured memory_bytes: 256
#kenken race
n,a,b,c,d = map(int,input().split())
s = str(input())

a-=1
b-=1
c-=1
d-=1

if '##' in s[a:c+1] or '##' in s[b:d+1]:
    print('No')  # そもそも移動経路の中に岩が二つ並んでいたら不可能ということ！
else:
    if c < d:  # この状態ならBにいる人をDに動かしてから、AをCに動かすだけでOK
        print('Yes')
    elif c > d:  # Aの目的地が、Bの目的地よりも右にあるなら
        # B-1からD+2にまでの中にBくんを退避させることが可能なスペースがあるか。
        # BくんはDまでしか動けない
        if "..." in s[b-1:d+2]:
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int h, w, n; cin >> h >> w >> n;
	vector<vi> v(w);
	REP(i, n)
	{
		int x, y; cin >> x >> y; x--; y--;
		v[y].push_back(x);
	}
	REP(i, w)
	{
		v[i].push_back(h);
		sort(ALL(v[i]));
	}
	int p = 0;
	int ans = 1e9;
	REP(i, w)
	{
		int l = *upper_bound(ALL(v[i]), p);
		chmin(ans, l);
		if (i == w - 1) break;
		p++;
		while (p < h)
		{
			if (!binary_search(ALL(v[i+1]), p)) break;
			p++;
		}
		if (p == h)
		{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    string S;
    int a[3] = {0};
    cin >> S;

    for (int i = 0; i < 3; i++)
    {
        a[S[i] - 'a']++;
        if (a[S[i] - 'a'] >= 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=2e5+5;
int a[MN],n;
ll s[MN],tot[4],ans=0x3f3f3f3f3f3f3f3f;
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i),s[i]=s[i-1]+a[i];
	reg int p1=1,p2=3;
	for(reg int i=2;i<n-1;i++){
		while(p1<i&&llabs(s[p1]+s[p1]-s[i])>=llabs(s[p1+1]+s[p1+1]-s[i]))p1++;
		while(p2<n&&llabs(s[p2]+s[p2]-s[i]-s[n])>=llabs(s[p2+1]+s[p2+1]-s[i]-s[n]))p2++;
		tot[0]=s[p1];tot[1]=s[i]-s[p1];tot[2]=s[p2]-s[i];tot[3]=s[n]-s[p2];
		sort(tot,tot+4);ans=min(ans,tot[3]-tot[0]);
	}
	cout<<ans<<endl;
	return 0;
}

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

bool solve(int i,vector<int> &A,int M){
    if(i==0){
        if(M==0) return true;
        else return false;
    }
    return solve(i-1,A,M) || solve(i-1,A,M-A.at(i-1));
}

int main(){
    int n,q;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin >> A.at(i);
    }
    cin >> q;
    vector<int> M(q);
    for(int i=0;i<q;i++){
        cin >> M.at(i);
    }
    for(int i=0;i<q;i++){
        if(solve(n,A,M.at(i))) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3112
#include<stdio.h>
int solve(int,int);
int a,A[2000];
int main(){
  int b,i,j,M;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&b);
  for(j=0;j<b;j++){
    scanf("%d",&M);
    if(solve(0,M)==0){
      printf("no\n");
    }
    else{
      printf("yes\n");
    }
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m==0){
    return 1;
  }
  if(i>=a){
    return 0;
  }
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long int
pair<ll,ll> p[101];
int main(){
  int n,w;
  cin >> n >> w;
  ll sum = 0;
  for(int i=0;i<n;i++){
    cin >> p[i].f >> p[i].s;
    sum+=p[i].s;
  }
  vector<ll> dp(sum+1, 1e18+5);
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=sum-p[i].s;j>=0;j--){
      dp[j+p[i].s] = min(dp[j+p[i].s], dp[j]+p[i].f);
    }
  }
  ll ans = 0ll;
  for(ll i=0;i<=sum;i++){
    if(dp[i]<=w){
      ans = max(ans,i);
    }
  }
  cout<<ans<<endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> rate(4800 / 400 + 10);
  for (i = 0; i < a.size(); i++) {
    rate[a[i] / 400]++;
  }
  int result_min = 0;
  for (i = 0; i < 3200 / 400; i++) {
    if (rate[i]) {
      result_min++;
    }
  }
  int over3200 = 0;
  for (i = 3200 / 400; i < rate.size(); i++) {
    over3200 += rate[i];
  }
  cout << max(result_min, 1) << ' ' << result_min + over3200 << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int r, c;
    cin >> r >> c;

    vector<vector<int>> table(r, vector<int>(c, 0));
    vector<int> rsum(r, 0);
    vector<int> csum(c + 1, 0);

    for (int y = 0; y < r; ++y)
    {
        for (int x = 0; x < c; ++x)
        {
            int i;
            cin >> i;
            table[y][x] = i;
            rsum[y] += i;
            csum[x] += i;
            csum[c] += i;
        }
        cin.ignore();
    }
    

    for (int y = 0; y < r; ++y)
    {
        for (int x = 0; x < c; ++x)
            cout << table[y][x] << " ";
        cout << rsum[y] << endl;
    }

    for (int x = 0; x <= c; ++x)
        cout << csum[x] << (x != c ? ' ' : '\n');

    return 0;
}

Measured memory_bytes: 3124
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c1 = sc.nextInt();
		int c5 = sc.nextInt()*5;
		int c10 = sc.nextInt()*10;
		int c50 = sc.nextInt()*50;
		int c100 = sc.nextInt()*100;
		int c500 = sc.nextInt()*500;
		if(c1+c5+c10+c50+c100+c500>=1000){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}

}

Measured memory_bytes: 17360
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	vector<vector<int> >a(3,vector<int>(3));
	vector<vector<int> >bingo(3,vector<int>(3,0));
	for (int i=0; i<3; i++) {
		for (int j=0; j<3; j++) {
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	vector<int> b(n);
	for (int i=0; i<b.size(); i++)
		cin >> b[i];

	for (int i=0; i<3; i++) {
		for (int j=0; j<3; j++) {
				for (int k=0; k<b.size(); k++) {
					if (a[i][j] == b[k]){
						bingo[i][j] = 1;
					}
				}
		}
	}

	bool isBingo = false;
	for (int i=0; i<3; i++) {
		if (bingo[i][0] == 1 && bingo[i][1] == 1 && bingo[i][2] == 1)
			isBingo = true;
	}
	for (int j=0; j<3; j++) {
		if (bingo[0][j] == 1 && bingo[1][j] == 1 && bingo[2][j] == 1)
			isBingo = true;
	}
	if (bingo[0][0] == 1 && bingo[1][1] == 1 && bingo[2][2] == 1)
		isBingo = true;
	if (bingo[0][2] == 1 && bingo[1][1] == 1 && bingo[2][0] == 1)
		isBingo = true;

	// for (size_t i = 0; i < bingo.size(); ++i) {
	// 	for (size_t j = 0; j < bingo[i].size(); ++j) {
	// 			//配列の中身を出力
	// 			std::cout << bingo[i][j] << ',';
	// 	}
	// 	//改行
	// 	std::cout << std::endl;
  // }

	if(isBingo)
		cout << "Yes" << endl;
	else
		cout << "No"	 << endl;

	return 0;
}

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

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

    vector<P> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(),p.end());

    map<P, int> diffs;

    rep(i, n - 1) {
        for (int j = i + 1; j < n; j++) {
            int diffx = p[j].first - p[i].first;
            int diffy = p[j].second - p[i].second;
            P diff(diffx,diffy);
            diffs[diff] += 1;
        }
    }

    int mx = 0;
    for (auto itr = diffs.begin(); itr != diffs.end(); ++itr) {
    // cout << itr->first.first << " " << itr->first.second << endl;
      mx = max(mx,itr->second);
    }
    cout << n - mx << endl;
}

Measured memory_bytes: 384
# https://abc109.contest.atcoder.jp/tasks/abc109_b

def solve(words):
    word = words[0]
    uniq_words = {word: True}

    ans = "Yes"
    for key in range(1, len(words)):
        next_word = words[key]
        if next_word in uniq_words:
            ans = "No"
            break
        uniq_words[next_word] = True
        if word[-1] != next_word[0]:
            ans = "No"
            break
        word = next_word

    return ans

def main():
    n = int(input())
    words = []
    for i in range(n):
        words.append(input())

    ans = solve(words)
    print(ans)

main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<vvvi> vvvvi;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int l, r;
    cin >> l >> r;
    int mn = 1e9;
    for (int i = l; i <= min(r, l+2019); ++i) {
        for (int j = i+1; j <= min(r, l+2019); ++j) {
            mn = min(mn, ((i%2019)*(j%2019))%2019);
        }
    }
    cout << mn << "\n";
    return 0;
}

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

using namespace std;

int N;
long long A[105];
int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    cout << A[N-1]-A[0] << endl;

    
}

Measured memory_bytes: 256
#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 <stack>
#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 PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

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

int main(){
    int n,u,v,du;
    cin>>n>>u>>v;
    vi a(n),b(n),used(n+1,0),depth(n+1,mod),used2(n+1,mod),used3(n+1,mod);
    vii g(n+1,vi());
    FOR(i,1,n){
        cin>>a[i-1]>>b[i-1];
        g[a[i-1]].PB(b[i-1]);
        g[b[i-1]].PB(a[i-1]);
    }
    queue<int> q;
    q.push(u);
    used[u]=1;
    while(q.size()){
        auto nw=q.front();
        q.pop();
        for(auto x:g[nw]){
            if(used[x]||x==v)continue;
            q.push(x);
            used[x]=1;
        }
    }
    q.push(v);
    depth[v]=0;
    while(q.size()){
        auto nw=q.front();
        q.pop();
        for(auto x:g[nw]){
            if(used[x]==0||depth[x]!=mod)continue;
            q.push(x);
            depth[x]=depth[nw]+1;
            if(x==u)du=depth[x];
        }
    }
    int th=du/2,ans=du-th-1,st=-1;
    q.push(u);
    used2[u]=0;
    while(q.size()){
        auto nw=q.front();
        q.pop();
        for(auto x:g[nw]){
            if(used[x]==0||depth[x]<=th||used2[x]!=mod)continue;
            q.push(x);
            used2[x]=used2[nw]+1;
            if(depth[x]==th+1&&used2[x]+depth[x]==du)st=x;
        }
    }
    if(st==-1){
        cout<<th<<endl;
        return 0;
    }
    q.push(st);
    used3[st]=0;
    int mx=0;
    while(q.size()){
        auto nw=q.front();
        q.pop();
        for(auto x:g[nw]){
            if(used[x]==0||depth[x]<=th||used3[x]!=mod)continue;
            q.push(x);
            used3[x]=used3[nw]+1;
            mx=max(mx,used3[x]);
        }
    }
    ans=ans+mx;
    if(du%2==0)ans++;


    cout<<ans<<endl;




}


Measured memory_bytes: 8192
M,D = map(int,input().split())
ans = 0

for i in range(1,M+1):
    for j in range(1,D+1):
        d0  = j%10
        d10 = j // 10
        if d0 >= 2 and d10 >= 2 and d0*d10 == i:
            ans += 1
print(ans)

Measured memory_bytes: 3316
/*
Program NAME
Written by "Vaibhav" aka 'ZodiacBestro'
In 2017
*/

#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eps 1e-9
#define fast_cin ios_base::sync_with_stdio(false)

const int MOD = 1e9+7;

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

int main()
{
	//freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	fast_cin;
	ll a,b,c; cin >> a >> b >> c;
	if (a >= b && a >= c)
	{
		cout << b + c << endl;
	}
	else if (b >= c && b >= a)
	{
		cout << a + c << endl;
		
	}
	else 
	{
		cout << b + a << endl;
		
	}
	return 0;
}

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

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

  int a, b;
  cin >> a >> b;

  int n = b - a;
  cout << n * (n + 1) / 2 - b << endl;

  return 0;
}

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

int main() {
	ll x;
	cin >> x;
	int ans = 0;
	ll now = 100;
	while(x > now) {
		ans++;
		now = now * 1.01;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    x, y = [int(x) for x in input().split()]
    a, b = abs(x), abs(y)
    ans = abs(a - b)
    if x >= 0 and y > 0:
        if a > b:
            ans += 2
    elif x < 0 and y <= 0:
        if a < b:
            ans += 2
    else:
        ans += 1
    
    print(ans)



        
    

    
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""


"""


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

int cntNum(int a){
    int cnt=0;
    for(int i=1;i<=a;i++){
        if(a%i==0)cnt++;
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int cnt=0;
    //cout <<cntNum(3)<<endl;

    for(int i=1;i<=n;i+=2){
        if(cntNum(i)==8){
            cnt++;
        }
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
     int n,i,j,k;
    int a[4][3][10];
    for(k=0;k<4;k++){
        for(j=0;j<3;j++){
            for(i=0;i<10;i++){
                a[k][j][i]=0;
            }
        }
    }
    
   
    int b,f,r,v;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        a[b-1][f-1][r-1]+=v;
    }
    
    for(k=0;k<4;k++){
        for(j=0;j<3;j++){
            for(i=0;i<10;i++){
                printf(" %d",a[k][j][i]);
            }
            printf("\n");  
        }
    if(k!=3){
        printf("####################\n"); 
    }
   
    
    }
    return 0;
}


Measured memory_bytes: 2084