akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        w: usize, h: usize, x: usize, y: usize,
    }
    println!(
        "{} {}",
        w as f64 * h as f64 / 2.,
        (x * 2 == w && y * 2 == h) as usize
    );
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define MAX_N 200100
#define MAX_LOG_V 20 
vector<int> g[MAX_N];
int N,Q,root=0;
int parent[MAX_LOG_V][MAX_N];
ll data[MAX_LOG_V][MAX_N];
int depth[MAX_N];
void dfs(int v,int p,int d){
	depth[v]=d;
	parent[0][v]=p;
	for(int i=0;i<g[v].size();i++){
		if(g[v][i]!=p){
			dfs(g[v][i],v,d+1);
		}
	}
	return;
}
/*
struct state{
	int v,p,d;
	state(int v,int p,int d):v(v),p(p),d(d){};
};
void dfs(){
	stack<state> st;
	st.push(state(0,-1,0));
	while(!st.empty()){
		state now = st.top();
		st.pop();
		int v = now.v,p = now.p,d = now.d;
		depth[v]=d;
		parent[0][v]=p;
		for(int i=0;i<g[v].size();i++){
			edge e = g[v][i];
			if(e.to!=p){
				st.push(state(e.to,v,d+1));
			}
		}
	}
	return;
}*/
void init(){
	dfs(root,-1,0);
	//dfs();
	for(int i=0;i<MAX_LOG_V-1;i++){
		for(int v=0;v<N;v++){
			if(parent[i][v]==-1){
				parent[i+1][v]=-1;
				data[i+1][v]=data[i][v];
			}else{
				parent[i+1][v]=parent[i][parent[i][v]];
				data[i+1][v]=data[i][v]+data[i][parent[i][v]];
			}
			// cout << data[i][v] << ' ';
		}
		// cout << endl;
	}
	return;
}
// int lca(int u,int v){
// 	if(depth[u]>depth[v])swap(u,v);
// 	for(int i=MAX_LOG_V-1;i>=0;i--){
// 		if(((depth[v]-depth[u])>>i)&1)v=parent[i][v];
// 	}
// 	if(u==v)return u;
// 	for(int i=MAX_LOG_V-1;i>=0;i--){
// 		if(parent[i][u]!=parent[i][v]){
// 			u=parent[i][u];
// 			v=parent[i][v];
// 		}
// 	}
// 	return parent[0][u];
// }
int main(){
	cin >> N >> Q;
	for(int i=1;i<N;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	for(int i=0;i<Q;i++){
		int u,v;
		cin >> u >> v;
		u--;
		// cout << u << ' ' << v << endl;
		data[0][u] += v;
	}
	init();
	for(int i=0;i<N;i++){
		cout << data[MAX_LOG_V-1][i];
		if(i+1<N)cout << ' ';
		else cout << endl;
	}
	return 0;
}


Measured memory_bytes: 73344
#include <stdio.h>
#define REP(a) for(i = 0; i < a; i++)

int main(void)
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a * b <= c) {
        printf("%d\n",a * b);
    } else {
        printf("%d\n",c);
    }
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  S[K-1] = tolower(S[K-1]);
  cout << S << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
 
void solve(){
    string s;
    cin >> s;
    cout << s + (s.back() == 's' ? "es" : "s");
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		int d = (a + b) * c / 2;
		
		System.out.println(d);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000010
#define mod 1000000007
int n,f[MAXN],add;
int main()
{
    cin>>n;
    f[n]=n;
    f[n-1]=(long long)n*n%mod;
    for(int i=n-2;i>=1;--i)
    {
        add=(add+f[i+3])%mod;
        f[i]=f[i+1];
        f[i]=(f[i]+(long long)(n-1)*(n-1)%mod)%mod;
        f[i]=(f[i]+add)%mod;
        f[i]=(f[i]+i+1)%mod;
    }
    cout<<f[1]<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    ll N,A,B; cin>>N>>A>>B;
    ll x[N]; CINA(x,N);
    ll ans = 0;
    for(int i=1; i<N; ++i){
        ans += min( (x[i]-x[i-1])*A, B);
    }
    cout << ans << "\n";
    
}

Measured memory_bytes: 1024
#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(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define int long long
#define debug(var) cout << "[" << #var << "] " << var << endl
//using ll = long long;

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    double a_l, b_l, h, m;
    double a_t, b_t, d_t;
    cin >> a_l >> b_l >> h >> m;

    double rad = ((h * 60 + m) / 2.0 - (float)6*m) / 360.0 * (2*M_PI);
    double x, y;

    x = b_l * cos(rad) - a_l;
    y = b_l * sin(rad);
    printf("%.15f\n", sqrt(pow(x, 2) + pow(y, 2)));

}

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

int main(){
    int N;
    long long A[100010], B[100010];
    cin >> N;
    long long count = 0;

    for(int i = 0; i <= N; i++){
        cin >> A[i];
    }

    for(int i = 0; i < N; i++){
        cin >> B[i];
    }

    for(int i = 0; i < N; i++){
        if(A[i] < B[i]){
            if(B[i] > A[i] + A[i+1]){
                count += A[i] + A[i+1];
                A[i+1] = 0;
            }
            else{
                count += B[i];
                A[i+1] -= B[i] - A[i];
            }
        }
        else{
            count += B[i];
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
def f(n, x):
    if n % x == 0:
        return (n // x * 2 - 1) * x
    else:
        return (n // x * 2) * x + f(x, n % x)
n, x = map(int,input().split())
ans = n + f(n - x, x)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

    int sum = accumulate(a.begin(), a.end(),0);
    
    int count = 0;
    for(int i = 0;i < n;i++)
    {
        if ((float)a[i] >= ((float)sum / (4.0 * m)) )
        {
            count++;
        }
    }


    cout << (count >= m? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import random
d = int(sys.stdin.readline().rstrip())
list_c = list(map(int, sys.stdin.readline().rstrip().split()))
list_s = []
list_t = []
need = 0
for i in range(d):
  list_s.append(list(map(int, sys.stdin.readline().rstrip().split())))
for i in range(d):
  print(random.randint(1,26))

Measured memory_bytes: 83400
/*
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
*/
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=200005;

void solve(){
  int h1,m1,h2,m2;
  int len;
  cin>>h1>>m1>>h2>>m2>>len;
  cout<<max(h1*60+m1,h2*60+m2-len)-h1*60-m1;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 3648
N, T = list(map(int, input().split()))
array = [list(map(int,input().split())) for i in range(N)]
list =[ 9999 for i in range(N)]
for i in range(N):
    if array[i][1] <= T:
        list.append(array[i][0])

if(min(list) == 9999):
    print("TLE")
else:
    print(min(list))


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

int main() {
  vector<int> A;
  int b, c;
  for (cin >> b; cin >> c; A.push_back(c));
  for (c = 0; b && c != 1; b--) c = A.at(c) - 1;
  if (b) cout << A.size() - b;
  else cout << -1;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

#define N 100001

int parent[N];
int visited[N];
ll num[N];
int findroot(int a){
  if (parent[a] == a)
    return a;

  int newparent = findroot(parent[a]);
  parent[a] = newparent;
  return newparent;
}

/*
vector<vector<int>> edge(N, vector<int>(0));
void dfs(int cur){
  if (visited[cur])
    return;

  visited[cur] = 1;
  for (int i = 0; i < edge[cur].size(); i++){
    int u = findroot(cur);
    int v = findroot(edge[cur][i]);
    if (u != v){
      parent[v] = u;
      num[u] = num[u] + num[v];
    }
    dfs(edge[cur][i]);
  }
}
*/

void init(){
  for (int i = 0; i < N; i++){
    parent[i] = i;
    num[i] = 1;
  }
}

int main(void){
  ll n, m;
  cin >> n >> m;
  
  init();
  ll res = n;
  for (int i = 0; i < m; i++){
    ll x, y, z;
    cin >> x >> y >> z;

    if (findroot(x) != findroot(y)){
      parent[findroot(y)] = x;
      res--;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
using namespace std;
int n,m,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		if(a>=m)ans++;
	}
	cout<<ans;
	return 0;
}

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

const int N = 1e5;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,ll> pil;
const ll INF = 1e18;

struct data{
	ll maksi, mini;
	
	data(){
		maksi = -INF;
		mini = INF;
	}
	
	data (ll _a, ll _b){
		maksi = _a;
		mini  = _b;
	}
	
};

vector<pil> edge;
ll ans[N+5];
int n,m;

data ST[4*N+5];

data operate(data a, data b){
	a.maksi = max(a.maksi,b.maksi);
	a.mini = min(a.mini,b.mini);
	return a;
}

void build(int node, int l, int r){
	if(l==r){
		ST[node].maksi = ST[node].mini = ans[l];
//		cout << node << " >> " << l << " ke " << r << " " << ST[node].mini << endl;
		return;
	}
	int mid =  (l+r)/2;
	build(node*2,l,mid);
	build(node*2+1,mid+1,r);
	ST[node] = operate(ST[node*2],ST[node*2+1]);
	return;
}

void update(int node, int l, int r, int ul, int ur,ll val){ // min(val, x);
	if(ul > r || ur < l) return;
	if(ST[node].maksi <= val) return;
	if(l == r){
		if(ST[node].mini >= val){
			ST[node].maksi = ST[node].mini = val;
			return;
		}
	}
	int mid = (l+r)/2;
	update(node*2,l,mid,ul,ur,val);
	update(node*2+1,mid+1,r,ul,ur,val);
	ST[node] = operate(ST[node*2] , ST[node*2+1]);
	return;
}

data query(int node, int l, int r, int ql, int qr){
	if(ql > r || qr < l) return data(-INF,INF);
	if(l >= ql && r<=qr){
//		cout << "PART OF " << l << "-" << r << endl;
		return ST[node];
	}
	int mid = (l+r)/2;
	return operate( query(node*2,l,mid,ql,qr) , query(node*2+1,mid+1,r,ql,qr));
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		ll w;
		scanf("%d%d%lld",&u,&v,&w);
		edge.push_back(make_pair(make_pair(u,v),w));
	}
	sort(edge.begin(),edge.end());
	ans[1] = 0;
	for(int i=2;i<=n;i++){
		ans[i] = INF;
	}
	build(1,1,n);
//	cout << query(1,1,n,n,n).mini << endl;
	int r = 1;
	int idx = 0;
	bool chang = 1;
	for(int i=0;i<edge.size();i++){
		int s = edge[i].first.first;
		int t = edge[i].first.second;
		ll w = edge[i].second;
		ll tmp = query(1,1,n,s,t).mini;
//		cout << "DARI " << s << " KE " << t << endl;
//		cout << tmp << endl;
		tmp += w;
//		cout << ">> " << tmp << endl;
		update(1,1,n,s,t,tmp);
//		for(int j=1;j<=n;j++){
//			printf("%lld ",query(1,1,n,j,j).mini);
//		}
//		printf("\n");
	}
	ll jaw = query(1,1,n,n,n).mini;
	if(jaw == INF) jaw = -1;
	printf("%lld\n",jaw);
	return 0;
}


Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
int a[50][50],c[50],sum[50],ans=INT_MAX,cost;
int n,m,x;
void dfs(int cur){
	if(cur==n+1){
		bool f=0;
		for(int i=1;i<=m;++i){
			if(sum[i]<x)f=1;
		}
		if(f) return ;
		ans=min(ans,cost);
		return ;
	}
	dfs(cur+1);
	for(int i=1;i<=m;++i){
		sum[i]+=a[cur][i];
	}
	cost+=c[cur];
	dfs(cur+1);
	for(int i=1;i<=m;++i)sum[i]-=a[cur][i];
	cost-=c[cur];
}
int main(){
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++)cin>>a[i][j];
	}
	dfs(1);
	if(ans==INT_MAX)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n;
int t[N], b[N];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> t[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    for(int i = 1; i <= n; i++) t[i] += t[i - 1];
    for(int i = n; i >= 1; i--) b[i] += b[i + 1];

    int res = 0;
    for(int i = 1; i <= n; i++)
        res = max(res, t[i] + b[i]);

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


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
int d,n;
cin>>d>>n;
if (n==100){
  n=101;
  for (;d--;) n*=100;
  cout<<n;return 0;
  }
for (;d--;) n*=100;
cout<<n;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
ret=0
while a+2<=max([a,b,c]):
    a+=2
    ret+=1
while b+2<=max([a,b,c]):
    b+=2
    ret+=1
while c+2<=max([a,b,c]):
    c+=2
    ret+=1
cnt=0
cnt+=1 if a<max([a,b,c]) else 0
cnt+=1 if b<max([a,b,c]) else 0
cnt+=1 if c<max([a,b,c]) else 0
if cnt==0:
    print(ret)
elif cnt==1:
    print(ret+2)
elif cnt==2:
    print(ret+1)

Measured memory_bytes: 3064
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n;
		cin >> n;
		cout << 360/__gcd(360,n) << endl;
		return 0;  
}  


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

int N;

void search1(vector<vector<int>> &connect,vector<int> &length, int temp, int k)
{
    for(int i = 0;i<connect[k].size();i++)
    {
        if(length[connect[k][i]] == 0 && connect[k][i] != 0)
        {
            length[connect[k][i]] = temp + 1;
            search1(connect,length,temp+1,connect[k][i]);
        }
    }
}
void search2(vector<vector<int>> &connect,vector<int> &length, int temp, int k)
{
    for(int i = 0;i<connect[k].size();i++)
    {
        if(length[connect[k][i]] == 0 && connect[k][i] != N-1)
        {
            length[connect[k][i]] = temp + 1;
            search2(connect,length,temp+1,connect[k][i]);
        }
    }
}

int main()
{
    
    cin >> N;
    
    vector<vector<int>> connect(N);
    for(int i = 0;i<N-1;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        connect[a].push_back(b);
        connect[b].push_back(a);
    }
    
    vector<int> lengthF(N,0);
    vector<int> lengthS(N,0);
    
    search1(connect,lengthF,0,0);
    search2(connect,lengthS,0,N-1);
    
    int f,s;
    f = 0;
    s= 0;
    for(int i = 0;i<N;i++)
    {
        if(lengthF[i] <= lengthS[i])
        {
            f++;
        }
        else
        {
            s++;
        }
    }
    
    if(f>s)
    {
        cout << "Fennec" << endl;
    }
    else
    {
        cout << "Snuke" << endl;
    }
    
    
    //Fennec ->
    
    return 0;
    
}

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int p = r * 100 + g * 10 + b;
    cout << (((p % 4) == 0) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	TreeMap<Double, String> minimumMap = new TreeMap<Double, String>();
	minimumMap.put(48.00, "light fly");
	minimumMap.put(51.00, "fly");
	minimumMap.put(54.00, "bantam");
	minimumMap.put(57.00, "feather");
	minimumMap.put(60.00, "light");
	minimumMap.put(64.00, "light welter");
	minimumMap.put(69.00, "welter");
	minimumMap.put(75.00, "light middle");
	minimumMap.put(81.00, "middle");
	minimumMap.put(91.00, "light heavy");
	minimumMap.put(Double.MAX_VALUE, "heavy");

	while (in.hasNext()) {
	 System.out.println(minimumMap.ceilingEntry(in.nextDouble()).getValue());
	}
 }
}

Measured memory_bytes: 12000
using System;

namespace AtCoder.ABC094
{
    class b
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var N = int.Parse(spl[0]);
            var M = int.Parse(spl[1]);
            var X = int.Parse(spl[2]);
            line = Console.ReadLine().Trim();
            spl = line.Split(' ');
            var list = new int[M];
            for(var i = 0; i < M; ++i)
            {
                list[i] = int.Parse(spl[i]);
            }
            for(var i = 0; i < M-1; ++i)
            {
                if (list[i] < X && list[i + 1] > X)
                {
                    Console.WriteLine(i + 1 > M - i - 1 ? M - i - 1 : i + 1);
                    return;
                }
            }
            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 11092
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
ab = []
cd = []
for i in range(n):
    ab.append(tuple(inl()))
for i in range(n):
    cd.append(tuple(inl()))
ab.sort()
cd.sort()
usedcd = [0]*n
while len(ab)>0:
    a,b = ab.pop()
    mn = BIG
    for i in range(n-1,-1,-1):
        if a>=cd[i][0]:
            break
        if usedcd[i]==0 and b<cd[i][1]<mn:
           mn = cd[i][1]
           mni = i
    if mn<BIG:
        usedcd[mni] = 1
print(sum(usedcd))


Measured memory_bytes: 39024
#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() {
  ll n, m, q;
  cin>>n>>m>>q;
  ll a[q], cnt[n];
  rep(i, n) cnt[i]=0;
  rep(i, q) {
    cin>>a[i];
    cnt[a[i]-1]++;
  }
  rep(i, n) {
    if(m+cnt[i]-q>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 2176
//g++ foo.cpp -o foo
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int N = 0;
    int L[110] = {0};
    cin >> N;
    for(int i=0;i<N;i++) cin >> L[i];

    int count=0;
    int maxL;

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                if(L[i]==L[j] || L[i]==L[k] || L[j]==L[k]) continue;
                    maxL = max(L[i],max(L[j],L[k]));
                    if(L[i]+L[j]+L[k]-maxL>maxL) count++;
            }
        }
    }
    cout << count << endl;

    return 0;
};

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define ll long long

using namespace std;

int digitAt(int arg, int d){
    int ret;

    ret = arg % (int)pow(10, d+1);
    ret /= (int)pow(10, d);
    return ret;
}

int bitcount(int arg){
    int ret=0;
    while(arg > 0){
        if(arg & 1) ret++;
        arg >>= 1;
    }
    return ret;
}

int main(){
    int a,b,k,tmp=0,borrow=0,ta,tb,ret=0;
    cin >> a >> b >> k;

    int n = log10(a) + 1;

    for(int i=0;i<(1 << n);i++){
        if(bitcount(i) <= k){
            tmp = 0;
            borrow = 0;
            for(int j=0;j<n;j++){
                ta = digitAt(a,j);
                tb = digitAt(b,j);
                if(ta - borrow >= tb){
                    tmp += (ta - tb - borrow) * pow(10, j);
                    borrow = 0;
                }else{
                    tmp += (ta - tb - borrow + 10) * pow(10, j);
                    if((1 << j) & i){
                        borrow = 0;
                    }else{
                        borrow = 1;
                    }
                }
            }
            ret = max(ret, tmp);
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 0
//    ŦĦ€Ř€'Ş ŇØŦĦƗŇǤ ĦØŁĐƗ'Ň Μ€ βΔĆҜ ΔŁŴΔ¥Ş ΔŇĐ ₣ØŘ€V€Ř 😈🤩😇😈💪🤜👊🤛🤟😉🤩:

#include<bits/stdc++.h>

#define mod 1000003
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define B(a) a.begin()
#define E(a) a.end()
#define For(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define M_P make_pair
#define P_B push_back
#define endd "\n"

using namespace std;

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

    int n,x,t,cnt=0;
    cin>>n>>x>>t;

    while(n>0)
    {
       n=n-x;
       cnt=cnt+t;

    }

    cout<<cnt<<endd;





    return 0;
}


Measured memory_bytes: 3608
n, k = [ int(v) for v in input().split() ]
hope = [ [ a for a in input().split() ] for i in range(n) ]

b_board = [ [ 0 for i in range(k)] for j in range(k) ]
w_board = [ [ 0 for i in range(k)] for j in range(k) ]
b_board_2 = [ [ 0 for i in range(k)] for j in range(k) ]
w_board_2 = [ [ 0 for i in range(k)] for j in range(k) ]
b_board_3 = [ [ 0 for i in range(k+1)] for j in range(k+1) ]
w_board_3 = [ [ 0 for i in range(k+1)] for j in range(k+1) ]

for h, w, c in hope:
    a1, a2 = divmod(int(w),k)
    b1, b2 = divmod(int(h),k)
    if (a1+b1) % 2 == 1:
        if c == "B":
            c = "W"
        else:
            c = "B"

    if c == "B":
        b_board[int(w)%k][int(h)%k] += 1
    else:
        w_board[int(w)%k][int(h)%k] += 1
    

for i in range(k):
    b, w = 0, 0
    for j in range(k):
        b += b_board[i][j]
        b_board_2[i][j] = b
        w += w_board[i][j]
        w_board_2[i][j] = w

for i in range(k):
    b, w = 0, 0
    for j in range(k):
        b += b_board_2[j][i]
        b_board_3[j+1][i+1] = b
        w += w_board_2[j][i]
        w_board_3[j+1][i+1] = w

total_b, total_w = b_board_3[k][k], w_board_3[k][k]
ans = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        b1 = b_board_3[i][j] - b_board_3[0][j] - b_board_3[i][0]
        b2 = total_b - b_board_3[i][k] - b_board_3[k][j] + b_board_3[i][j]
        w1 = w_board_3[i][j] - w_board_3[0][j] - w_board_3[i][0]
        w2 = total_w - w_board_3[i][k] - w_board_3[k][j] + w_board_3[i][j]
        ans = max(b1+b2+(total_w-w1-w2),w1+w2+(total_b-b1-b2),ans)

print(ans)


Measured memory_bytes: 125144
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  int n;
  cin >> n;
  ll Min = LINF, ans = -LINF;
  rep(i, n)
  {
    ll r;
    cin >> r;
    ans = max(ans, r - Min);
    Min = min(Min, r);
  }
  cout << ans << endl;
  return 0;
}



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

const int N = 410, inf = 1e18;
int n, a[N], dp[N][N], pref[N];
bool visited[N][N];

int solve(int l, int r) {
	if (visited[l][r])
		return dp[l][r];
	visited[l][r] = true;
	if (l == r)
		return dp[l][r] = 0;
	dp[l][r] = inf;
	for (int i = l; i <= r; i++)
		dp[l][r] = min(dp[l][r], solve(l, i) + solve(i + 1, r));
	return dp[l][r] = dp[l][r] + pref[r] - pref[l - 1];
}

signed main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}
	memset(visited, false, sizeof(visited));
	int ans = solve(1, n);
	cout << ans;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
double a=0.0;
int n,k;
double ll(int x,int y)
{
	double b=1.0;
	int c=y;
	while(c<x)
	{
		c*=2;
		b/=2;
	}
	return b;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
	//	cout<<b<<endl;
		a+=ll(k,i);
		//cout<<a<<endl;
	}
	printf("%.12lf\n", a/n);
	return 0;
}


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

int main() {
  int N;
  int sum = 0;
  cin >>  N;
  int a = N;
  while(N>0){
      sum+=N%10;
      N/=10;
  }

  if(a%sum==0)
  cout <<"Yes" << endl;
  else
  cout <<"No" << endl;
} 

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

int main() {
    string A;
    cin >> A;

    map<string, int> answer;

    answer.insert(make_pair("SUN",7));
    answer.insert(make_pair("MON",6));
    answer.insert(make_pair("TUE",5));
    answer.insert(make_pair("WED",4));
    answer.insert(make_pair("THU",3));
    answer.insert(make_pair("FRI",2));
    answer.insert(make_pair("SAT",1));

    cout <<  answer[A] << endl;

    return 0;
}



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

int main() {
  int N, K, sum = 0;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    int x, a, b;
    cin >> x;
    
    a = x;
    b = K - x;
    
    if(a < b){
      sum += a * 2;
    }else{
      sum += b * 2;
    }
    
  }
  
  cout << sum << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<vector>
#include<set>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = (int)1e5 + 5;
using namespace std;

int a[maxn];

int main()
{
	FAST;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	int x = a[n-1] / 2;
	if(a[n-1] & 1) x++;
	ll Min = 10000000000, flag;
	for(int i = 0; i < n; i++){
		if(abs(a[i] - x) < Min) Min = abs(a[i] - x), flag = i;
	}
	int x1 = abs(a[flag] * 2 - a[n-1]);
	int x2 = abs(a[flag+1] * 2 - a[n-1]);
	int x3 = abs(a[flag-1] * 2 - a[n-1]);
	int ans;
	if(x1 < x2 && x1 < x3) ans = a[flag];
	if(x2 < x1 && x2 < x3) ans = a[flag+1];
	if(x3 < x1 && x3 < x2) ans = a[flag-1];
	cout << a[n-1] << ' ' << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int N,K,c=1;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		if(c*2<c+K){
			c=c*2;
		}
		else{
			c=c+K;
		}
	}
	cout<<c;
}

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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int A=0,B=0;
  for(int i=0;i<M;i++){
    int C;
    cin >> C;
    if(C<X){
      A++;
    }
    else{
      B++;
    }
  }
  cout << min(A,B) << endl;
}

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

template<class T,class F>
struct segtree{
  int n;
  T e;
  F f;
  std::vector<T> dat;

  segtree(){}
  segtree(int sz,T _e,F _f):e(_e),f(_f){
    n = 1;
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
  }
  segtree(std::vector<T> const& v,T _e,F _f):e(_e),f(_f){
    build(v);
  }
  void build(std::vector<T> const& v){
    n = 1;
    int sz = v.size();
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
    for(int i=0;i<sz;++i){
      dat[i+n] = v[i];
    }
    for(int i=n-1;i>0;--i){
      dat[i] = f(dat[i<<1],dat[i<<1|1]);
    }
  }
  void set(int p,T v){
    for(dat[p+=n]=v;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  void increment(int p){
    for(dat[p+=n]=1;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  T query(int l,int r){
    T res = e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l&1){
        res = f(res,dat[l]);
        l++;
      }
      if(r&1){
        r--;
        res = f(res,dat[r]);
      }
    }
    return res;
  }
  T operator[](int k){
    return query(k,k+1);
  }
};

vector<int64_t> frac;

signed main(){

  int n;
  cin>>n;
  frac.resize(n+1);
  frac[0] = frac[1] = 1;
  for(int64_t i=2;i<=n;++i)frac[i]=frac[i-1]*i;
  vector<int64_t> a(n),b(n);
  for(auto& ai:a)cin>>ai;
  for(auto& bi:b)cin>>bi;

  auto get = [](vector<auto> const& a){
    int n = a.size();
    auto sum = [](auto a,auto b){return a+b;};
    segtree<int64_t,decltype(sum)> seg(n+1,0,sum);

    auto k = 0;
    for(auto i=0;i<n;++i){
      auto t = seg.query(0,a[i]);
      k += (a[i]-t-1)*frac[n-i-1];
      seg.increment(a[i]);
    }
    return k;
  };

  cout<<abs(get(a)-get(b))<<endl;

}


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

map<string,int> M;

int str2int(string S){
    if(M.find(S)==M.end()){
        int n = M.size();
        M[S]=n;
    }
    return M[S];
}

int E[200][200];//[a][b]=a to b

int main(){
    int N;
    while(cin>>N,N){
        fill(E[0],E[200],10000);
        M.clear();
        for(int i=0;i<N;i++){
            string S;
            cin>>S;
            for(int c=0;c<S.size();c++){
                if(S[c]=='-'){
                    string S1=S.substr(0,c);
                    string S2=S.substr(c+1,S.size()-c-1);
                    int i1=str2int(S1);
                    int i2=str2int(S2);
                    E[i1][i2]=1;
                    break;
                }
            }
        }
        int m = M.size();
        cout<<m<<endl;
        for(int i=0;i<m;i++){
            for(int j=0;j<m;j++){
                if(E[i][j]==1||E[j][i]==1) continue;
                //cond1
                bool b=false;
                for(int k=0;k<m;k++){
                    if(k==i||k==j) continue;
                    if((E[i][k]==1||E[k][i]==1)&&(E[j][k]==1||E[k][j]==1)){
                        b=true;
                        break;
                    }
                }
                //cond2,3
                for(int k=0;k<m;k++){
                    if(k==i||k==j) continue;
                    if((E[k][i]==1&&E[j][k]==1)||(E[i][k]==1&&E[k][j]==1)){
                        b=false;
                        break;
                    }
                }
                if(b) E[i][j]=E[j][i]=0;
            }
        }
        //WF
        for(int i=0;i<m;i++) E[i][i]=0;
        for(int k=0;k<m;k++){
            for(int i=0;i<m;i++){
                for(int j=0;j<m;j++){
                    E[i][j]=min(E[i][j],E[i][k]+E[k][j]);
                }
            }
        }
        int Q;
        cin>>Q;
        for(int i=0;i<Q;i++){
            string S;
            cin>>S;
            for(int c=0;c<S.size();c++){
                if(S[c]=='-'){
                    string S1=S.substr(0,c);
                    string S2=S.substr(c+1,S.size()-c-1);
                    int i1=str2int(S1);
                    int i2=str2int(S2);
                    if(i1>=m||i2>=m||E[i1][i2]%2==0){
                        cout<<"NO"<<endl;
                    }else{
                        cout<<"YES"<<endl;
                    }
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3148
c=0
while True:
    W=int(input())#重さの上限
    if W==0:
        break
    c+=1
    N=int(input())#宝物の数

    vl=[0]#価値のリスト
    wl=[0]#重さのリスト
    for i in range(N):
        [v,w]=list(map(int,input().split(",")))#vとwのリストを作る
        vl.append(v)
        wl.append(w)
    #横がW+1で縦がN+1の表を作成する
    dp=[[0 for i in range(W+1)]for j in range(N+1)]
    #表を埋める
    for i in range(N+1):
        for j in range(W+1):
            if i==0 or j==0:
                dp[i][j]=0
            else:
                if wl[i]<=j:
                    dp[i][j]=max(dp[i-1][j-wl[i]]+vl[i],dp[i-1][j])
                else:
                    dp[i][j]=dp[i-1][j]

    #print(dp)
    ls=dp[N].copy()
    ls.reverse()
    #print(ls)
    max_w=W
    for i in range(1,W+1):
        if ls[i]==dp[N][W]:
            max_w-=1
        else:
            break
    print("Case "+str(c)+":")
    print(dp[N][W])
    print(max_w)



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

int main(){
  int n;
  cin >> n;
  int a1,a2,a3,a4;
  a1 = n % 10;
  a2 = (n % 100 - n % 10) / 10;
  a3 = (n % 1000 - n % 100) / 100;
  a4 = (n % 10000 - n % 1000) / 1000;
  if ((a1==a2 && a2==a3)||(a2==a3 && a3==a4)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int T, D, Ta, Tb, Da, Db;

  cin >> T >> D >> Ta >> Tb >> Da >> Db;

  double ans = 1e9;

  for (int i = 0; i * Da <= D; i++) {
    for (int j = 0; j * Db <= D; j++) {
      if (i + j == 0 || i * Da + j * Db > D) continue;

      int total = i * Da + j * Db;
      int sumT = i * Ta * Da + j * Tb * Db;

      double t = (double)sumT / total;

      ans = min(ans, abs(T - t));
    }
  }

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

  return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;




int main(void) {
  ll H, W;
  cin >> H >> W;
  ll i, j;
  ll a[555][555];
  
  for(i=0; i<H; i++) {
    for(j=0; j<W; j++) {
      cin >> a[i][j];
      a[i][j]%=2;
    }
  }
  
  vector<pair<P, P>> v;
  ll f=0;
  for(i=0; i<H; i++) {
    
    if((i&1)==0) {
      
      for(j=0; j<W-1; j++) {
        if(a[i][j]==1) {
          a[i][j]--;
          a[i][j+1]++; a[i][j+1]%=2;
          v.push_back({{i, j}, {i, j+1}});
        }
      }
      
      if(i<H-1 && a[i][W-1]==1) {
        a[i][W-1]--;
        a[i+1][W-1]++; a[i+1][W-1]%=2;
        v.push_back({{i, W-1}, {i+1, W-1}});
      }
      
    }else {
      
      for(j=W-1; j>0; j--) {
        if(a[i][j]==1) {
          a[i][j]--;
          a[i][j-1]++; a[i][j-1]%=2;
          v.push_back({{i, j}, {i, j-1}});
        }
      }
      
      if(i<H-1 && a[i][0]==1) {
        a[i][0]--;
        a[i+1][0]++; a[i+1][0]%=2;
        v.push_back({{i, 0}, {i+1, 0}});
      }
      
    }
    
  }
  
  pt(v.size());
  for(i=0; i<v.size(); i++) {
    cout << v[i].first.first+1 <<" "<<v[i].first.second+1  << " ";
    cout << v[i].second.first+1<<" "<<v[i].second.second+1 << endl;
  }
  
  
  
  
}






Measured memory_bytes: 8560
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
int A[2][100], S[2][100];
int main() {
	int N;
	scanf("%d", &N);
	rep(i, 0, 2)rep(i2, 0, N)scanf("%d", &A[i][i2]);
	S[0][0] = A[0][0];
	rep(i, 0, 2){
		rep(i2, 0, N) {
			if (i)S[i][i2] = max(A[i][i2] + S[i - 1][i2], S[i][i2]);
			if(i2)S[i][i2] = max(A[i][i2] + S[i][i2 - 1], S[i][i2]);
			//printf("%d ", S[i][i2]);
		}
		//puts("");
	}
	printf("%d\n", S[1][N - 1]);
	return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  int d, e;
  while (cin >> d >> e && d && e) {
    double ans = 1e9 + 7;
    double cost = e;
    for (int i = 0; i * 2 <= d; i++) {
      ans = min(ans, abs(cost - sqrt(i * i + (d - i)*(d - i))));
    }
    cout << fixed << setprecision(10) << ans << "\n";
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

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

int main() {
	int d, n, yakusu, amari, i;
	cin >> d >> n;
	if (d == 0) {
	    cout << n / 100 + n;
	} else if (d == 1) {
	    cout << (n / 100) * 100 + n * 100;
	} else {
	    cout << (n / 100) * 10000 + n * 10000;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a > b)swap(a, b);
	if (b > c)swap(c, b);
	ll ans = (c - b) / 2 + (c - a) / 2;
	b += (c - b) / 2 * 2;
	a += (c - a) / 2 * 2;
	if (a > b)swap(a, b);
	if (b > c)swap(c, b);
	if (a % 2) {
		ans += !(b % 2) + !(c % 2);
	}
	else {
		ans += (b % 2) + (c % 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int k; cin >> k;
  vector<int> v;
  while(k--){ 
     int tmp; cin >> tmp;
     v.push_back(tmp);
  }
  int opts = 0;
  bool breakout=false;
  while(true){
    // cout << "in while loop" << endl;
    for(int i=0; i < v.size(); ++i){
      if(v[i] % 2 ==1){  breakout=true; break;}
    }
    // cout << "before if" << endl;
    if(breakout) break;
    // cout << "before for loop" << endl;
    for(int i=0; i < v.size(); ++i){
       v[i] = v[i]/2;
    }
    opts++;
  }
  cout << opts << endl;
  // cout << "exit" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000

int H, A[MAX];

void maxHeapify(int i);

int main(){
  int i;
  scanf("%d", &H);
  for(i = 1; i <= H; i++){
    scanf("%d", &A[i]);
  }
  for(i = H/2; i >= 1; i--) maxHeapify(i);
  for(i = 1; i <= H; i++){
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}

void maxHeapify(int i){
  int l, r, largest, tmp;
  l = 2 * i;
  r = 2 * i + 1;
  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 3700