akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N,M;
  	cin>> N >> M;
  	int a[N];
    float sum=0;
  
  	for(int i=0;i<N;i++){
     	 cin>>a[i];
      	 sum+=a[i];
    }
  
  	sort(a,a+N,greater<int>());
  
  	if(a[M-1]<sum/(4*M)){
     	cout<<"No"<<endl; 
    }
  	else{
     	cout<<"Yes"<<endl; 
    }
  
  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

vector<int> to[100009];
vector<int> a;
bool ok = true;

ll dfs(int v, int p=-1) {
  if (p != -1 && to[v].size() == 1) return a[v];
  ll sum = 0, mx = 0;
  for (auto u : to[v]) {
    if (u == p) continue;
    ll tmp = dfs(u, v);
    sum += tmp;
    chmax(mx, tmp);
  }
  if (sum > a[v] * 2 || a[v] > sum || mx > a[v]) ok = false;
  return a[v] * 2 - sum;
}

int main() {
  int n;
  cin >> n;
  a.resize(n);
  rep(i,n) cin >> a[i];
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  bool ans = false;
  if (n == 2) {
    if (a[0] == a[1]) ans = true;
  }
  else {
    int s;
    rep(i,n) {
      if (to[i].size() > 1) s = i;
    }
    ans = (dfs(s) == 0 && ok);
  }
  if (ans) puts("YES");
  else puts("NO");
  return(0);
}

Measured memory_bytes: 16156
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] inf = new int[N+1];
    int now = 0;
    int paint = 1;
    int[] ans = new int[N-1];
    int max = 0;
    int[][] val = new int[N-1][4];
    for(int i = 0; i < N-1; i++){
      String[] S = sc.nextLine().split(" ");
      val[i][0] = Integer.parseInt(S[0]);
      val[i][1] = Integer.parseInt(S[1]);
      val[i][2] = i;
    }
    Arrays.sort(val, (a,b)->Integer.compare(a[0],b[0]));
    
    for(int i = 0; i < N-1; i++){
      int a = val[i][0];
      int b = val[i][1];
      if(i == 0){
        now = a;
      }else{
        if(a == now){
          paint++;
        }else{
          now = a;
          paint = 1;
        }
        if(inf[a] == paint){
          paint++;
        }
      }
      val[i][3] = paint;
      inf[b] = paint;
      if(max < paint){
        max = paint;
      }
    }
    
    Arrays.sort(val, (a,b)->Integer.compare(a[2],b[2]));
    System.out.println(max);
    for(int i = 0; i < N-1; i++){
      System.out.println(val[i][3]);
    }
  }
}
    
    

Measured memory_bytes: 141648
N = int(input())
A = [int(s) for s in input().split()]

argmin_x = 1e10
min_cost = 1e10
for x in range(min(A), max(A) + 1):
    cost = 0
    for a in A:
        cost += pow(x - a, 2)
    if cost < min_cost:
        argmin_x = x
        min_cost = cost
print(min_cost)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
typedef long long ll;
const ll mod=1e9+7;
const int N=2e5+5;
ll sum[N],dp[N];
int a[N],n,b[N],m;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    m=1;b[1]=a[1];
    for(int i=2;i<=n;i++) if(a[i]!=a[i-1]) b[++m]=a[i];
    dp[0]=1;
    for(int i=1;i<=m;i++) {
        dp[i]=(dp[i-1]+sum[b[i]])%mod;
        sum[b[i]]=(sum[b[i]]+dp[i-1])%mod;
    }
    printf("%lld\n",dp[m]);
    return 0;
}


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


int main(){
    string a;
    cin>>a;
    bool check=true;
    for(int i=0;i<a.length();i++){
     if(islower(a[i])) continue;
      else check=false;
    }
    if(check){
    if(a[2]==a[3]&&a[5]==a[4]&&a.length()==6){
        cout<<"Yes";
    } 
    else cout<<"No";
    }
    else cout<<"No";
    
    
}



Measured memory_bytes: 256
#include <cstdio>

int H, N, A, S;

int main() {
  scanf("%d %d", &H, &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A);
    S += A;
  }
  printf(S >= H ? "Yes\n" : "No\n");
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	
	int n,i,j,jump,cnt=0,min;
	scanf("%d",&n);
	
	int A[n];
	
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	
	for(i=0;i<n;i++){
		min=i;
		for(j=i;j<n;j++){
			if(A[min]>A[j]){
				min=j;	
			}
			
		}
		
		if(i!=min){
				jump=A[i];
				A[i]=A[min];
				A[min]=jump;
				cnt++;
			}
		
	}
	
	for(i=0;i<n-1;i++){
		printf("%d ",A[i]);
	}
	printf("%d\n",A[i]);
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

void success(int x, int y, int z) {
  cout << x << " " << y << " " << z << endl;
  exit(0);
}

void err() {
  cout << -1 << " " << -1 << " " << -1 << endl;
  exit(0);
}

int main() {
  int N, Y;
  cin >> N >> Y;

  int T = Y / 10000;
  int F = (Y - T * 10000) / 5000;
  int O = (Y - T * 10000- F * 5000) / 1000;

  int A = T + F + O;
  int D = N - A;
  if (A > N) err();
  if (A == N) success(T, F, O);
  while (D > 17 && T > 0) {
    T--;
    O += 10;
    D -= 9;
  }

  queue<tuple<int,int,int>> q;

  q.push(make_tuple(T, F, O));
  while (!q.empty()) {
    int x, y, z;
    tie(x, y, z) = q.front(); q.pop();
    if (x + y + z == N) success(x, y, z);
    if (x + y + z > N) continue;
    if (x <= 0 && y <= 0) break;
    int D = N - (x + y + z);
    if (x > 0) q.push(make_tuple(x - 1, y, z + 10));
    if (y > 0) q.push(make_tuple(x, y - 1, z + 5));
    if (x > 0) q.push(make_tuple(x - 1, y + 2, z));
  }
  err();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll x,y;cin>>x>>y;
    ll count=0;
    while(x<=y){
        x*=2;
        count++;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int main(){
	char a;
	cin >> a;
	if (a >= 'A'&&a <= 'Z'){
		cout << 'A' << endl;
	}
	else{
		cout << 'a' << endl;
	}


	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    map<string,int> M;
    int null=0;
    M.insert(make_pair("aaaaaaaaaaa",0));
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        M.insert(make_pair(s,null));
        M[s]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        string s;
        cin>>s;
        M.insert(make_pair(s,null));
        M[s]--;
    }
    int ans=-110;
    for(auto it=M.begin();it!=M.end();it++){
        ans=max(ans,it->second);
    }
    cout<<ans<<"\n";
    return(0);
}

Measured memory_bytes: 3612
pub fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let x: u64 = iter.next().unwrap().parse().unwrap();

    println!("{}", calc(n, x));
}

fn len(level: usize) -> u64 {
    2u64.pow(level as u32) * 4 - 3
}

fn calc(p: usize, q: u64) -> u64 {
    if p == 0 && q == 1 {1}
    else if q <= 1 {0}
    else if q <= 1 + len(p-1) {calc(p-1, q-1)}
    else if q == 2 + len(p-1) {calc(p-1, len(p-1)) + 1}
    else if q <= 2 + 2*len(p-1) {calc(p-1, len(p-1)) + 1 + calc(p-1, q - len(p-1) - 2)}
    else {calc(p-1, len(p-1))*2 + 1}
}


Measured memory_bytes: 4352
/*
 * (c) fushar (Ashar Fuadi)
*/

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define RESET(c,v) memset(c, v, sizeof c)

typedef long long ll;
const ll oo = 100000000000;

int H, W;

ll min_area(ll a, ll b, ll c) {
    return max({a, b, c}) - min({a, b, c});
}

ll solve(ll h, ll w) {
    ll res = oo;
    FOR(i, 1, h-1) {
        ll h_rem = h-i;
        ll h1 = h_rem/2;
        ll h2 = h_rem-h1;

        if (h1 && h2) {
            res = min(res, min_area(i*w, h1*w, h2*w));
        }


        ll w1 = w/2;
        ll w2 = w-w1;

        if (w1 && w2) {
            res = min(res, min_area(i*w, h_rem*w1, h_rem*w2));
        }
    }
    return res;
}

int main() {
    cin >> H >> W;
    cout << min(solve(H, W), solve(W, H)) << endl;
}


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

typedef long long ll;
const int MOD = 1e9 + 7;
map<ll, ll> mp;


inline ll f(ll x) {
	if (mp[x])   return mp[x];
	return mp[x] = (f(x / 2) + f((x - 1) / 2) + f((x - 2) / 2)) % MOD;
}

int main() {
	ll n;
	scanf("%lld", &n);
	mp[0] = 1;
	mp[1] = 2;
	printf("%lld\n", f(n));

	return 0;
}


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

int main(){

    int N;
    cin>>N;
    int a=0,w=0,t=0,r=0;

    for(int i=0;i<N;i++){

        string S;
        cin>>S;

        if(S.at(0)=='A'){
            a++;
        }

        if(S.at(0)=='W'){
            w++;
        }

        if(S.at(0)=='T'){
            t++;
        }

        if(S.at(0)=='R'){
            r++;
        }


    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
}

Measured memory_bytes: 3600
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split(' ');
            ulong A = ulong.Parse(input[0]);
            ulong B = ulong.Parse(input[1]);
            ulong C = ulong.Parse(input[2]);
            ulong D = ulong.Parse(input[3]);
            
            //最小公倍数を求める
            ulong x = C * D;
            ulong a = C;
            ulong b = D;

            if(C < D)
            {
                ulong tep = a;
                a = b;
                b = tep;
            }

            ulong r = a % b;
            while(r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }

            ulong CD = x / b;
            //最大のときを数える
            ulong sum1 = 0;

            ulong sumc1 = B /C;
            ulong sumd1 = B /D;
            ulong sumcd1 = B /CD;

            sum1 = B - sumc1- sumd1 + sumcd1;

            //最小のときを数える
            ulong sum2 = 0;

            ulong sumc2 = (A-1) / C;
            ulong sumd2 = (A -1) / D;
            ulong sumcd2 = (A -1)/CD;

            sum2 = A -1 - sumc2 - sumd2 + sumcd2;

            Console.WriteLine(sum1 -sum2);
        }
    }

Measured memory_bytes: 11092
// Problem : D - Powerful Discount Tickets
// Contest : AtCoder - AtCoder Beginner Contest 141
// URL : https://atcoder.jp/contests/abc141/tasks/abc141_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,M;
	cin>>N>>M;
	map<int,int> m;
	F0R(x,N)
	{
		int nb;
		cin>>nb;
		m[nb]++;
	}
	while(M--)
	{
		auto i=m.rbegin();
		i->s--;
		m[i->f/2]++;
		if(i->s==0)
		{
			m.erase(i->f);
		}
	}
	ll ans=0;
	for(auto i:m)
	{
		ans+=i.f*(ll)i.s;
	}
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 8348
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch StrawberryCakes | diff StrawberryCakes.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address StrawberryCakes.cpp && ./a.out

/*
 
 11/23/2019
 
 4:15-
 
 */

const int MAX_N=300;
string A[MAX_N];
int N,M,K;

VI X[MAX_N];
void solve() {
  VV<int> res(N,VI(M,0));
  REP(i,N) REP(j,M)if(A[i][j]=='#') X[i].push_back(j);
  int k=0;
  REP(i,N)if(SZ(X[i])) {
    ++k;
    int p=0;
    REP(j,M) {
      res[i][j]=k;
      if(p<SZ(X[i])-1&&j==X[i][p]) ++k,++p;
    }
  }
  
//  dump(k,K);
  assert(k==K);
  REP(j,M){
    int cur=0;
    REP(i,N) {
      if(res[i][j]>0) cur=res[i][j];
      res[i][j]=cur;
    }
  }
  REP(j,M) {
    int cur=0;
    for(int i=N-1; i>=0; --i) {
      if(res[i][j]>0) cur=res[i][j];
      res[i][j]=cur;
    }
  }
  REP(i,N)REP(j,M){
    assert(res[i][j]!=0);
    printf("%d%c",res[i][j]," \n"[j==M-1]);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M>>K;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt=0;
    int right=0;
    bool hantei=true;
    while(right != 1){
        if(cnt == 1000000) {
            hantei = false;
            break;
        }
        right = a[right]-1;
        cnt++;
    }
    if(hantei) cout << cnt << endl;
    else cout << -1 <<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll ans, mx, sum,temp, mn = 1e14, flag,cnt;

int main(){
	ll n,l;
	cin>>n>>l;
	for(ll i=1; i<=n; i++){
		sum+=l+i-1;
	}
	for(ll i=1; i<=n; i++){
		ll k=l+i-1;
		if(abs(sum-(sum-k))<=mn){
			mx=sum-k;
			mn=abs(sum-(sum-k));
		}
	}
	cout<<mx;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 1;
  rep(i,n-1) if (s.at(i) != s.at(i+1)) ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;
ll fac[200001];

ll power(ll x, ll p){
  ll res = 1;
  ll curr = x;
  ll tmp = p;
  while(tmp){
    if(tmp % 2 == 1)res = (res * curr) % mod;
    curr = curr * curr % mod;
    tmp /= 2;
  }
  return res;
}

int main(int argc, char const* argv[])
{
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  fac[0] = 1;
  for(int i = 1; i < 200001; i++){
    fac[i] = fac[i - 1] * i % mod;
  }
  ll res = 0;
  for(int i = 0; i < h - a; i++){
    ll tmp = fac[i + b - 1] * power(fac[i], mod - 2) % mod;
    tmp = tmp * power(fac[b - 1], mod - 2) % mod;
    tmp = tmp * fac[h - 1 - i + w - b - 1] % mod;
    tmp = tmp * power(fac[h - 1 - i], mod - 2) % mod;
    tmp = tmp * power(fac[w - b - 1], mod - 2) % mod;
    res = (res + tmp) % mod;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			long[] a = new long[3];
			long[] m = new long[3];
			for(int i=0;i<3;i++){
				a[i] = sc.nextLong();
				m[i] = sc.nextLong();
			}
			if(a[0]==0 && a[1]==0 && a[2]==0 && m[0]==0 && m[1]==0 && m[2]==0)break;

			long x = 1;
			long y = 1;
			long z = 1;
			long countx = 0;
			long county = 0;
			long countz = 0;
			
			while(true){
				x = (a[0]*x)%m[0];
				countx++;
				if(x==1)break;
			}
			while(true){
				y = (a[1]*y)%m[1];
				county++;
				if(y==1)break;
			}
			while(true){
				z = (a[2]*z)%m[2];
				countz++;
				if(z==1)break;
			}

			long l = 0;
			long k = countx;
			long n = county;
			long b = 0;
			
			if(n>k){
				l=k;
				k=n;
				n=l;
			}
		
			while(n!=0){
				l = n;
				n = k%n;
				k = l;
			}
			
			b = countx*county/k;
			
			k = b;
			n = countz;
			
			if(n>k){
				l=k;
				k=n;
				n=l;
			}
		
			while(n!=0){
				l = n;
				n = k%n;
				k = l;
			}
			b = b*countz/k;		
			System.out.println(b);
		}
	}	
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> V(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> V.at(i).at(j);
    }
  }
  vector<vector<int>> WC(H, vector<int>(W));
  vector<vector<int>> HC(H, vector<int>(W));
  for (int i = 0, cnt = 0; i < H; i++) {
    V.at(i).push_back('#');
    for (int j = 0; j < W + 1; j++) {
      if (V.at(i).at(j) == '.') cnt++;
      else if (cnt) {
        for (int k = j - cnt; k < j; k++) WC.at(i).at(k) = cnt;
        cnt = 0;
      }
    }
    V.at(i).pop_back();
  }
  vector<char> tmp(W, '#');
  V.push_back(tmp);
  for (int j = 0, cnt = 0; j < W; j++) {
    for (int i = 0; i < H + 1; i++) {
      if (V.at(i).at(j) == '.') cnt++;
      else if (cnt) {
        for (int k = i - cnt; k < i; k++) HC.at(k).at(j) = cnt;
        cnt = 0;
      }
    }
  }
  V.pop_back();
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans = max(ans, WC.at(i).at(j) + HC.at(i).at(j));
    }
  }
  cout << ans - 1 << "\n";
}

Measured memory_bytes: 39680
from itertools import combinations_with_replacement as C

N, M, Q = map(int, input().split())

a = [0] * Q
b = [0] * Q 
c = [0] * Q 
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

A_ = list(range(1, M + 1))
A_ = list(C(A_, N))

ans = 0
ans_ = 0
for A in A_:
    ans_ = 0
    for i in range(Q):
        if A[b[i] - 1] - A[a[i] - 1] == c[i]:
            ans_ += d[i]
    if ans < ans_:
        ans = ans_

print(ans)

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

int main(){
  int n,f=0;
  cin >> n;
  string a;
  cin >> a;
  
  if(n%2==1) f=1;
  else{
    for(int i=0; i<n/2; i++){
      if(a.at(i)!=a.at((n/2)+i)){
        f=1;
        break;
      }
    }
  }
  if(f==0) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


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

    int n,m;
    cin >> n >> m;

    ll sum = 0;
    int tmp;
    REP(i,m) {
        cin >> tmp;
        sum += tmp;
    }
    ll ans  = n-sum >= 0? n-sum:-1;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3164
def bi(i):
    o = [0]*10
    c = 0
    while i > 0:
        o[c] = i % 2
        i //= 2
        c += 1
    return o

v = []
N = int(input())
F = [0]*N
C = [0]*N
for i in range(N):
    F[i] = list(map(int,input().split(" ")))

for i in range(N):
    C[i] = list(map(int,input().split(" ")))

i = 1
while i < 1024:
    o = bi(i)
    i += 1
    a = 0
    j = 0
    while j < N:
        f = F[j]
        c = C[j]
        a += c[sum([o[x]*f[x] for x in range(10)])]
        j += 1
    v.append(a)

print(max(v))

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> data(H, vector<char>(W));
  
  int flag;
  vector<int> h_vec;
  for (int i=0; i<H; i++) {
    flag = 0;
    for (int j=0; j<W; j++) {
      cin >> data.at(i).at(j);
      if (data.at(i).at(j) == '#') flag = 1;
    }
    if (flag == 1) h_vec.push_back(i);
  }

  vector<int> w_vec;
  for (int j=0; j<W; j++) {
    flag = 0;
    for (int i : h_vec) {
      if (data.at(i).at(j) == '#') flag = 1;
    }
    if (flag == 1) w_vec.push_back(j);
  }
  
  for (auto i = h_vec.begin(); i != h_vec.end(); i++) {
    for (auto j = w_vec.begin(); j != w_vec.end(); j++) {
      cout << data.at(*i).at(*j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    int a,b; cin >> a >> b;
    string s;
    cin >> s;
    string t = s.substr(0, a) + s.substr(a+1, b);
    irep(i, a+b-1) {
        if(isdigit(t[i]) == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a] == '-') {
        cout << "Yes" << endl;
    } else {
        cout << "No" <<endl;
    }
    return 0;
}
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL A[3]; rep(i, 3) cin >> A[i];
		vector<UL> L(N); rep(i, N) cin >> L[i];
		vector<UL> S(1 << N);
		vector<UL> D(1 << N);
		vector<UL> dp[4]; dp[0].assign(1 << N, 0);
		rep(i, N) rep(j, 1 << N) {
			if (j & (1 << i)) { S[j] += L[i]; D[j] += 10; }
		}
		rep(a, 3) {
			dp[a + 1].assign(1 << N, 100000);
			rep(i, 1 << N) {
				if (i == 0) continue;
				UL d = D[i];
				if (A[a] < S[i]) d += S[i] - A[a];
				if (A[a] > S[i]) d += A[a] - S[i];
				rep(j, 1 << N) {
					if (i & j) continue;
					dp[a + 1][i | j] = min(dp[a + 1][i | j], dp[a][j] + d);
				}
			}
		}
		cout << (dp[3][(1 << N) - 1] - 30) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

using namespace std;

int main() {
    string n;
    cin>>n;
    int ans=700;
    if(n[0]=='o')ans+=100;
    if(n[1]=='o')ans+=100;
    if(n[2]=='o')ans+=100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;
struct chap{
int x,y;

};
 
int main(){

	int n,m;
	while(1){
	struct chap M[250]={};
	struct chap N[100001]={};

	cin>>m;if(m==0)break;
	for(int i=0;i<m;i++)
	{cin>>M[i].x;cin>>M[i].y;}

	cin>>n;
	for(int i=0;i<n;i++)
	{cin>>N[i].x;cin>>N[i].y;}

	for(int i=0;i<m;i++)
		for(int j=m-1;j>i;j--)
		{if(M[j].x<M[j-1].x){
			struct chap T;
			T=M[j-1];M[j-1]=M[j];M[j]=T;
		}
		}
		for(int i=0;i<m;i++)
		for(int j=m-1;j>i;j--)
		{if(M[j].x==M[j-1].x&&M[j].y<M[j-1].y){
			struct chap T;
			T=M[j-1];M[j-1]=M[j];M[j]=T;
		}
		}
	for(int i=0;i<n;i++)
		for(int j=n-1;j>i;j--)
		{if(N[j].x<N[j-1].x){
			struct chap TT3;
			TT3=N[j-1];N[j-1]=N[j];N[j]=TT3;
		}}

		for(int i=0;i<n;i++)
		for(int j=n-1;j>i;j--)
		{if(N[j].x==N[j-1].x&&N[j].y<N[j-1].y){
			struct chap T2;
			T2=N[j-1];N[j-1]=N[j];N[j]=T2;
		}
		}

//	for(int i=0;i<n;i++)
	//	cout<<N[i].x<<N[i].y<<endl;

		struct chap ans[203]={};

		for(int i=0;i<m;i++)
		{ans[i]=M[i];}
		int dx=0,dy=0;int R=0;
		bool f=false;
		for(int i=0;i<n;i++)
		{
			dx=0,dy=0;
			dx=N[i].x-M[0].x;dy=N[i].y-M[0].y;
			int P=0;
			for(int j=i;j<n;j++){
				if(N[j].x-dx==M[P].x&&N[j].y-dy==M[P].y&&P==m-1){f=true;R=N[j].x;break;}//cout<<dx<<" "<<dy<<R<<endl;break;}
				if(N[j].x-dx==M[P].x&&N[j].y-dy==M[P].y){
					P++;}
				

				//cout<<P;
			}
			if(f==true)break;
		}
	//	if(f==true)cout<<"#"<<endl;
		cout<<dx<<" "<<dy<<endl;
}
		return 0;
}

	

Measured memory_bytes: 1948
import sys
N = int(input())
A_arr = list(map(int, input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

gcd_l = [A_arr[0]]
gcd_r = [A_arr[N-1]]

for i in range(0,N-1):
    gcd_l.append(gcd(gcd_l[i], A_arr[i+1]))

for i in range(0,N-1):
    gcd_r.append(gcd(gcd_r[i], A_arr[N-2-i]))

gcd_list = []
for i in range(0, N):
    if i == 0:
        gcd_list.append(gcd_r[N-1-i-1])
    elif i == N-1:
        gcd_list.append(gcd_l[i-1])
    else:
        gcd_list.append(gcd(gcd_l[i-1], gcd_r[N-1-i-1]))

print(max(gcd_list))

Measured memory_bytes: 14584
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    ll N,A,B;
    cin >>N>>A>>B;
    vector<ll> X(N);
    REP(i,N) cin >> X[i];
    ll ans=0;
    REP(i,N-1){
        ans+=min((X[i+1]-X[i])*A,B);
    }   
    cout << ans <<endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define pi 3.141592653589
//#define mod 998244353 
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

/*___________________________TEMPLATE END______________________________*/

signed main() {
    quickie
    string s;
    cin >> s ;
    if(s[s.size()-1] == '2' || s[s.size()-1] == '4' || s[s.size()-1] == '5' || s[s.size()-1] == '7' || s[s.size()-1] == '9')
        cout << "hon\n" ;
    else if(s[s.size()-1] == '0' || s[s.size()-1] == '1' || s[s.size()-1] == '6' || s[s.size()-1] == '8')
        cout << "pon\n" ;
    else cout << "bon\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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

Measured memory_bytes: 3640
import os, sys, re, math

N = int(input())
H = [int(n) for n in input().split()]

possible = True
for i in range(N - 1, 0, -1):
    if H[i - 1] >= H[i] + 2:
        possible = False
        break
    elif H[i - 1] == H[i] + 1:
        H[i - 1] -= 1

print('Yes' if possible else 'No')


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

using namespace std;

int main() {
    long long a, b, k;
    cin >> a >> b >> k;


    if (k <= a) {
        a -= k;
    } else if (k <= a + b) {
        b -= (k - a);
        a = 0;
    } else {
        a = 0;
        b = 0;
    }

    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

    double x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    std::cout << std::fixed << std::setprecision(6) << std::sqrt(std::pow(x1-x2, 2) + std::pow(y1-y2, 2)) << "\n";
    return 0;
}

Measured memory_bytes: 3260
def aux(xa,ya,ra,xb,yb,rb)
  x = Math.sqrt((xa-xb)**2+(ya-yb)**2)
  if x > ra+rb
    0
  elsif x >= (ra-rb).abs
    1
  elsif x < ra-rb
    2
  elsif x < rb-ra
    -2
  end
end

def main
  fh=STDIN
  #fh=File.new("x.txt", "r")
  n=fh.gets.chomp.to_i
  n.times {
    xa,ya,ra,xb,yb,rb = fh.gets.chomp.split.map(&:to_f)
    puts aux(xa,ya,ra,xb,yb,rb)
  }
end

if $0 == __FILE__ then
  main
end


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

int main()
{
	while (true) {
		int N, M, P;
		cin >> N >> M >> P;

		if (N == 0 && M == 0 && P == 0) {
			break;
		}

		int top;
		int sum = 0;

		for (int i = 1; i <= N; i++) {
			int temp;
			cin >> temp;

			sum += temp;

			if (M == i) {
				top = temp;
			}
		}

		int ans;

		if (top != 0) {
			ans = sum*(100 - P) / top;
		}
		else {
			ans = 0;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3072
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(xa, xb, xMax) = readLine.split(" ").map(_.toInt).sorted

    // make Xa = Xb
    val count2 = (xb - xa) / 2
    val count1 = (xb - xa) % 2
    // mak Xb = xa = xb
    val count3 = (xMax + count1) - xb

    println(count1 + count2 + count3)
  }
}


Measured memory_bytes: 25548
#include<stdio.h>
int main(void)
{
	int a,b,c;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	if(a<b&&b<c){
		printf("Yes\n");

	}

	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2068
MODULE intQsortMod
! 整数型のクイックソート
! precisionで整数の精度を定める．
! インデックスの小さいほうが値も小さい(昇順)．

! 参考
! https://t.doujin-constant.net/post/143374686394/fortranをより使いこなしたquick-sort

      implicit none
      integer,parameter,private :: precision = 16
      
      interface qSort
        module procedure :: intQsort
      end interface
      
      contains
      pure recursive function intQsort( a ) result( r )
        implicit none
        integer(precision), intent(in) :: a(:)
        integer(precision) :: r( size(a) )
        integer(precision) :: sample(3), len, i,j
        
        len = size( a(:) )
        if( len<=1 )then
          r = a
        else
          !select pivot
          sample(1:3) = [a(1), a(len/2), a(len)]
          do i = 1,2
            do j = 2,3
              if( sample(i)>sample(j) )then
                len = sample(i) !len is buffer
                sample(i) = sample(j)
                sample(j) = len
              end if
            end do
          end do
          
          r = [ qSort( pack(a(:), a(:)< sample(2) ) ), &
                       pack(a(:), a(:)==sample(2) )  , &
                qSort( pack(a(:), a(:)> sample(2) ) ) ]
        end if
      end function intQsort
      END MODULE intQsortMod
      
      
      program main
      use intQsortMod
      implicit none
      integer(16) :: n,p(50),origP(50),cnt= 0,i
      
      read*,n
      read*,p(1:n)
      
      origP(1:n) = p(1:n)
      
      
      p(1:n) = qsort( p(1:n) )
      
      do i = 1,n
        if( origP(i)/=p(i) ) cnt = cnt + 1
      end do
      
      if( cnt==2.or.cnt==0 )then
        print*,'YES'
      else
        print*,'NO'
      end if
      
      end

Measured memory_bytes: 2824
#include <iostream>
using namespace std;
int main(void){
    int x, y, z, w, u;
    int a, b, c, d, e;
    cin >> x >> y >> z >> w;
    u = x + y + z + w;
    cin >> a >> b >> c >> d;
    e = a + b + c + d;
    if(u > e){
        cout << u << endl;
    }
    else{
        cout << e << endl;
    }
}



Measured memory_bytes: 3080
import sys

input = sys.stdin.readline


def main():
    W, a, b = map(int, input().split())

    if a + W < b:
        ans = b - (a + W)
    elif b + W < a:
        ans = a - (b + W)
    else:
        ans = 0
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
	int num[26] = {0};
	char input, res;

	while (cin>>input)
	{

		if (input >= 65 && input <= 90)
			num[input - 65]++;
		else if (input >= 97 && input <= 122)
			num[input - 97]++;
	}

	for (int i = 0; i < 26; i++)
	{
		res = 'a' + i;
		cout << res << " : " << num[i] << endl;
	}

}

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

int main() {
  
  string S; cin >> S;
  
  int L = S.size();
  
  for (int i = 0; i < L - 1; i++) {
    
    for (int j = i + 1; j < L; j++) {
      
      if (S.at(i) == S.at(j)) {
        cout << "no" << endl;
        return 0;
      }
      
    }
    
  }
  
  cout << "yes" << endl;
  
}

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

int main(){
	int n;
	cin>>n;
	int a[n];
	int box[n]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		box[a[i]]++;
	}
	int m=0;
	long long int x=1;
	int mod=1000000007;
	if(n%2==0){
		for(int i=0;i<n;i++){
			if(box[i]!=0&&box[i]!=2){
				cout<<0<<endl;
				return 0;
			}
			else if(box[i]==2){
				m++;
			}
		}
		for(int i=0;i<m;i++){
			(x*=2)%=mod;
		}
		cout<<x<<endl;
	}
	else{
		if(box[0]!=1){
			cout<<0<<endl;
			return 0;
		}
		for(int i=1;i<n;i++){
			if(box[i]!=0&&box[i]!=2){
				cout<<0<<endl;
				return 0;
			}
			else if(box[i]==2){
				m++;
			}
		}
		for(int i=0;i<m;i++){
				(x*=2)%=mod;
		}
		cout<<x<<endl;
	}
		
		
}		

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;


int main() {
    string s; cin >> s;
    for(int i = 0; i < s.length();i++){
        if(i % 2 == 0){
            cout << s[i];
        }
    }
}




Measured memory_bytes: 512
#include <stdio.h>

int solve(int,int);

int n,A[20],res;

int main(){
  int q,M[200],i,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }
  for(i=0;i<q;i++){
    r=solve(0,M[i]);
    if(r==1){printf("yes\n");}
    if(r==0){printf("no\n");}
  }
  return 0;
}

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

  



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll t,n,m;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
ll b[100][100005];
int main(){
    //    cout<<fixed<<setprecision(2);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
ll w;
cin>>n>>w;
ll a[n][2];
for(int i=0;i<n;i++){cin>>a[i][0]>>a[i][1];}
//memset(b,1e12,sizeof b);
for(int i=0;i<n;i++){
for(int j=0;j<=1e5;j++){
b[i][j]=1e12;
}}
for(int i=0;i<n;i++){
b[i][a[i][1]]=a[i][0];
}
//cout<<b[5][1024]<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<=1e5;j++){
    if(b[i][j]!=1e12){
        for(int k=i+1;k<n;k++){
            if(b[i][j]+a[k][0]<=w){
                b[k][j+a[k][1]]=min(b[k][j+a[k][1]] , b[i][j]+a[k][0]);
            }
        }
    }
}
}

//for(int i=0;i<n;i++){
//for(int j=1;j<=20;j++){
 //   cout<<b[i][j]<<" ";
//}
//cout<<endl;
//}

//cout<<"QLO";
for(int j=1e5;j>=0;j--){
    for(int i=0;i<n;i++){
       if(b[i][j]!=1e12){
            cout<<j<<endl;
            return 0;
       }
    }
}
}



Measured memory_bytes: 78336
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b && b < c)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 26276
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < k; i++){
        ans += v[i];
    }
    cout << ans << nl;
}

Measured memory_bytes: 3616
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int lli;
lli gcd(lli a, lli b){
    return !b? a : gcd(b, a % b);
}
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
void solve(){
    lli n;
    cin >> n;
    vector <lli> v(n);
    lli length = 0;
    for(lli i = 0; i < n; i++){
        cin >> v[i];

    }
    lli current = 0;
    lli prev = INT_MIN;
    lli ans = 0;
    for(lli i = 0; i < n; i++){
        if(v[i] == current + 1){
            current = v[i];
            length++;
        }
    }
    cout << (length == 0 ? -1 : n - length) << endl;

}
int main(){
    
    fastio
    solve();

    return 0;
}




Measured memory_bytes: 1920
N=int(input())
A=list(map(int,input().split()))
d0={0:0}
for a in A[::2]:d0[a]=d0.get(a,0)+1
d0=sorted([(k,v) for k,v in d0.items()],key=lambda x:-x[1])
d1={0:0}
for a in A[1::2]:d1[a]=d1.get(a,0)+1
d1=sorted([(k,v) for k,v in d1.items()],key=lambda x:-x[1])
if d0[0][0]!=d1[0][0]:print(N-d0[0][1]-d1[0][1])
else:print(min(N-d0[0][1]-d1[1][1],N-d0[1][1]-d1[0][1]))

Measured memory_bytes: 20316
#include<stdio.h>
#include<math.h>

int main(void)
{
  int x[100],h[100];
  double s[100];
  int i=0,j;

  while(1){
    scanf("%d", &x[i]); scanf("%d", &h[i]);
    if(x[i] == 0 && h[i] == 0)
      break;
    
    s[i] = (4 * h[i] * h[i] + x[i] * x[i]);
    s[i] = x[i] * sqrt(s[i]) + x[i] * x[i];
    i++;
  }

  for(j=0; j<i; j++){
    printf("%f\n", s[j]);
  }

  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = mod * mod;
#define MAX_N 100000

int main() {
	int n, m; cin >> n >> m;
	int s, t; cin >> s >> t; s--; t--;
	vector<pair<int,ll> > E[MAX_N];
	for (int i = 0; i < m; i++) {
		int p, q;
		ll r; cin >> p >> q >> r; p--; q--;
		E[p].push_back(make_pair(q, r));
		E[q].push_back(make_pair(p, r));
	}
	ll cost[MAX_N];
	/* cost initialize */
	for (int i = 0; i < n; i++) {
		cost[i] = INF;
	}
	/* djikstra */
	cost[s] = 0;
	bool used[MAX_N] = {};
	priority_queue<pair<ll, int>,vector<pair<ll,int>>, greater<pair<ll,int> > > pq;
	pq.push(make_pair(0LL, s));
	while (!pq.empty()) {
		int id = pq.top().snd; pq.pop();
		if (used[id])continue;
		for (auto &&e : E[id]) {
			if (cost[e.fst] > cost[id] + e.snd) {
				cost[e.fst] = cost[id] + e.snd;
				pq.push(make_pair(cost[e.fst], e.first));
			}
		}
		used[id] = true;
	}
	ll route[MAX_N],route_r[MAX_N];
	pair<ll, int> cost_id[MAX_N];
	for (int i = 0; i < n; i++) {
		cost_id[i] = make_pair(cost[i], i);
	}
	sort(cost_id, cost_id + n);
	for (int i = 0; i < n; i++) {
		route[i] = route_r[i] = 0LL;
	}
	route[s] = 1LL;
	for (int i = 1; i < n; i++) {
		int id = cost_id[i].snd;
		for (auto &&e : E[id]) {
			if (cost[e.fst] == cost[id] - e.snd) {
				route[id] += route[e.fst];
				route[id] %= mod;
			}
		}
	}
	route_r[t] = 1LL;
	for (int i = n-2; i >=0; i--) {
		if (cost_id[i].fst >= cost[t])continue;
		int id = cost_id[i].snd;
		for (auto &&e : E[id]) {
			if (cost[e.fst] == cost[id] + e.snd) {
				route_r[id] += route_r[e.fst];
				route_r[id] %= mod;
			}
		}
	}
	int ans = route[t] * route[t] % mod;/* include collision */
	for (int i = 0; i < n; i++) {
		if (2LL * cost[i] == cost[t] ) {
			ll sub= route[i] * route_r[i] % mod;
			ans -= sub * sub%mod;
		}
		if (ans < 0)ans += mod;
	}
	for (int i = 0; i < n; i++) {
		if (cost[i] * 2LL < cost[t]) {
			for (auto &&e : E[i]) {
				if (cost[i]+e.snd==cost[e.fst] && cost[e.fst] * 2LL > cost[t]) {
					ll sub = route[i] * route_r[e.fst] % mod;
					ans -= sub *sub % mod;
				}
				if (ans < 0)ans += mod;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] abc = sc.intarr;
            int K = sc.intarr[0];

            Array.Sort(abc);

            

            for (int i=1; i<=K; i++)
            {
                abc[2] *= 2;
            }

            int sum = abc[0] + abc[1] + abc[2];

            wr.wri(sum);

        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 11348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt(); 
			int C = in.nextInt();
			int ans = 0;
			if(C >= B) {
				C -= B;
				ans += B * 2;
			} else {
				ans += B + C;
				C = 0;
			}
			if(C > 0) {
				if(A >= C) {
					ans += C;
				}else {
					ans += A + 1;
				}
			}
			
			out.println(ans);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 21204
graph1 = zip s f
  where
    s = " ',-.?" ++ ['A'..'Z']
    f = ["101","000000","000011","10010001","010001","000001","100101","10011010",
         "0101","0001","110","01001","10011011","010000","0111","10011000",
         "0110","00100","10011001","10011110","00101","111","10011111","1000",
         "00110","00111","10011100","10011101","000010","10010010","10010011","10010000"]
graph2 = zip f2 s2
  where
    f2 = ["00000","00001","00010","00011","00100","00101","00110","00111",
          "01000","01001","01010","01011","01100","01101","01110","01111",
          "10000","10001","10010","10011","10100","10101","10110","10111",
          "11000","11001","11010","11011","11100","11101","11110","11111"]
    s2 = ['A'..'Z'] ++ " .,-'?"

change1 :: String -> String
change1 [] = []
change1 (x:xs) = (getG1 x graph1) ++ (change1 xs)
  where
    getG1 :: Char -> [(Char,String)] -> String
    getG1 x [] = []
    getG1 x ((k,v):r)
      | x == k = v
      | otherwise = getG1 x r

change2 :: String -> String
change2 [] = []
change2 (x1:x2:x3:x4:x5:r) = (getG2 [x1,x2,x3,x4,x5] graph2) : (change2 r)
change2 xs = [getG2 (xs ++ (replicate (5 - length xs) '0')) graph2]

getG2 :: String -> [(String,Char)] -> Char
getG2 s ((k,v):r)
  | s == k = v
  | otherwise = getG2 s r

main :: IO ()
main = do
  ls <- getContents
  let ls' = lines ls
      ansL = map (change2 . change1) ls'
  mapM_ putStrLn ansL

Measured memory_bytes: 4132