akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    ll ans = 0;
    if (k <= a){
        ans = k;
    } else if (k > a+b) {
        ans = a - (k-(a+b));
    } else {
        ans = a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
N, L = map(int, input().split())
l = []
for i in range(N):
    l.append(i+L)
m = min(l)
x = max(l)
if m <= 0 and x >= 0:
    print(sum(l))
elif m > 0:
    print(sum(l)-m)
else:
    print(sum(l)-x)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using std::min;
using std::max;
#define DEBUG 0
int main(void)
{
	#if DEBUG
	freopen("_in","r",stdin);
	#endif
	int A_price,B_price,MIX_price,x,y,minValue=0,branch[2];
	scanf("%d%d%d%d%d",&A_price,&B_price,&MIX_price,&x,&y);
	if((A_price+B_price)>2*MIX_price)
		minValue=2*MIX_price*min(x,y);
	else
		minValue=(A_price+B_price)*min(x,y);

	branch[0]=max(x-min(x,y),y-min(x,y))*2*MIX_price;
	branch[1]=(x-min(x,y))*A_price + (y-min(x,y))*B_price;

	if(branch[0]>branch[1])
		minValue+=branch[1];
	else
		minValue+=branch[0];

	printf("%d\n",minValue);
	return 0;




}

Measured memory_bytes: 128
using System;

namespace C20191120
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var A = (int)str[0] - '0';
            var B = (int)str[1] - '0';
            var C = (int)str[2] - '0';
            var D = (int)str[3] - '0';
            if (A + B + C + D == 7) Console.WriteLine("{0}+{1}+{2}+{3}=7", A, B, C, D);
            else if (A + B + C - D == 7) Console.WriteLine("{0}+{1}+{2}-{3}=7", A, B, C, D);
            else if (A + B - C - D == 7) Console.WriteLine("{0}+{1}-{2}-{3}=7", A, B, C, D);
            else if (A + B - C + D == 7) Console.WriteLine("{0}+{1}-{2}+{3}=7", A, B, C, D);
            else if (A - B + C + D == 7) Console.WriteLine("{0}-{1}+{2}+{3}=7", A, B, C, D);
            else if (A - B + C - D == 7) Console.WriteLine("{0}-{1}+{2}-{3}=7", A, B, C, D);
            else if (A - B - C + D == 7) Console.WriteLine("{0}-{1}-{2}+{3}=7", A, B, C, D);
            else if (A - B - C - D == 7) Console.WriteLine("{0}-{1}-{2}-{3}=7", A, B, C, D);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef long long ll;

int main(){
	int N, K;
	string S;
	cin>>N>>S>>K;
	char k = S[K - 1];
	for(int i = 0; i < N; i++){
		if(S[i] != k)cout<<"*";
		else cout<<S[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<atcoder/all>
#define f(i)std::cout<<i<<' ';
int n,m,a;int main(){std::cin>>n>>m;atcoder::scc_graph g(n);for(;std::cin>>a>>n;)g.add_edge(a,n);auto v=g.scc();f(size(v))for(auto i:v){f(size(i))for(auto j:i)f(j)}}

Measured memory_bytes: 40060
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi stone(pow(2,n));
  for(auto &a:stone)cin>>a;

  for(int i=n;i>=1;i--){
    vi hoge;
    for(int j=0;j<stone.size();j+=2){
      if(stone[j]==stone[j+1]){
	hoge.pb(stone[j]);
      }else{
	hoge.pb(abs(stone[j]-stone[j+1]));
      }
    }
    stone.clear();
    for(auto a:hoge)stone.pb(a);
  }
  cout<<stone[0]<<endl;
  return 0;
}


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

int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i = 0;i<n;i++)
  cin>>a[i];
  long long int cost =0, min_cost = INT_MAX;
  for(int i = -100; i<=100; i++)
  {
    cost = 0;
    for(int j = 0; j<n; j++)
    {
      cost += (i-a[j])*(i-a[j]);
    }
    if(cost < min_cost)
    min_cost = cost;
  }
  cout<<min_cost<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <cmath>

#include <bits/stdc++.h>
#include <vector>

using namespace std;

#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define repj(i,j,n) for(int i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

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

long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}

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

  uint64_t t;
  cin >> t;
  uint64_t res = t;

  rep(i, N-1) {
    uint64_t t;
    cin >> t;
    res = lcm (res, t);
  }

  printf("%ld\n", res);

  return 0;
}



Measured memory_bytes: 256
K = int(input())
l = [1,2,3,4,5,6,7,8,9]
while K>0:
    if len(l) > K:
        print(l[K-1])
        break
    else:
        K -= len(l)
        newl = []
        for i in l:
            if i%10 == 0:
                newl.append(10*i)
                newl.append(10*i + 1)
            elif i%10 == 9:
                newl.append(10*i + 8)
                newl.append(10*i + 9)
            else:
                newl.append(10*i + i%10 - 1)
                newl.append(10*i + i%10 )
                newl.append(10*i + i%10 + 1)
        l = newl


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll N, A, B;
    string S;

    cin >> N >> A >> B;
    cin >> S;

    ll foreign = 0;
    ll pass = 0;
    ll kaigai = 0;
    for (char c : S)
    {

        if (c == 'a')
        {
            if (pass < (A + B))
            {
                ++pass;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else if (c == 'b')
        {
            if (pass < (A + B) && kaigai < B)
            {
                ++pass;
                ++kaigai;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N;

	cin >> N;

	if( N % 2 == 1) N *= 2;

	cout << N << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D , L , R;
  cin >> A >> B >> C >> D ;
  L = A + B;
  R = C + D;
  if (L > R){
      cout << "Left" << endl;
    }
    else if (L == R) {
      cout << "Balanced" << endl;
    }
    else if (L < R){
      cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_map>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

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

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

int main() {
	int A, B,C; cin >> A >> B >> C;
	if (A == B && A != C) { cout << "Yes" << endl; return 0; }
	if (A == C && B != C) { cout << "Yes" << endl; return 0; }
	if (C == B && A != C) { cout << "Yes" << endl; return 0; }
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 764
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N, M = map(int, readline().split())
A = map(int, readline().split())

sum_ = sum(A)

if sum_ > N:
    print(-1)
else:
    answer = N - sum_
    print(answer)

Measured memory_bytes: 9576
n, k = gets.split(" ").map(&:to_i)
hash = {}
for i in 0..n-1
  hash[i+1] = []
end
for i in 1..k
  sweets_num = gets.to_i
  holders = gets.split(" ").map(&:to_i)
  holders.each do |h|
    hash[h].push(sweets_num)
  end
end

if hash.group_by{|k, v| v.length > 0}[false].nil?
  puts 0
else
  puts hash.group_by{|k, v| v.length > 0}[false].length
end

Measured memory_bytes: 14356
#include <cstdio>

#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

const int MAXN = 100005;
const int INF = 1e9;

int n, m, S, T, dis1[MAXN], dis2[MAXN];
vector<int> G[MAXN], G_rev[MAXN];

void shortest_path(vector<int> G[], int dis[], int st) {
    priority_queue<pair<int, int>> pq;

    fill(dis + 1, dis + n + 1, INF);
    dis[st] = 0;
    pq.push({0, st});
    while (!pq.empty()) {
        int d = pq.top().first, u = pq.top().second;
        pq.pop();
        if (d > dis[u]) continue;
        for (auto v : G[u]) {
            if (dis[v] > dis[u] + 1) {
                dis[v] = dis[u] + 1;
                pq.push({dis[v], v});
            }
        }
    }
}

int main() {
    while (scanf("%d", &n) != EOF) {
        if (n == 0) break;
        for (int i = 1; i <= n; i++) {
            G[i].clear();
            G_rev[i].clear();
        }

        scanf("%d%d", &S, &T);
        scanf("%d", &m);
        vector<pair<int, int>> edges;
        for (int i = 1, u, v; i <= m; i++) {
            scanf("%d%d", &u, &v);
            G[u].push_back(v);
            G_rev[v].push_back(u);
            edges.push_back({u, v});
        }
        shortest_path(G, dis1, S);
        shortest_path(G_rev, dis2, T);
        int mn = dis1[T], mne = 0;
        for (int i = 0; i < edges.size(); i++) {
            int u = edges[i].first, v = edges[i].second;
            if (mn > dis1[v] + dis2[u] + 1) {
                mn = dis1[v] + dis2[u] + 1;
                mne = i + 1;
            }
        }
        printf("%d %d\n", mn, mne);
    }
    return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  long double n, m, d;
  cin >> n >> m >> d;

  long double ans = 0;

  if(d == 0){
    ans = (m-1) / n;
  } else {
    ans = (m-1) * 2 * (n-d) / n / n;
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define ld          long double
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);


void solve() 
{
	ll n; cin>>n;
	//ld ans=0;
	cout<<fixed<<setprecision(12);
	ld a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ld x=(a[0]+a[1])/2;
	for(ll i=2;i<n;i++) x=(x+a[i])/2;
	cout<<x<<endl;
} 

int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}



Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    a, b, k = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(list)
    for i in range(a, min(b + 1, a + k)):
        d[i]
    for i in range(b, max(a - 1, b - k), -1):
        d[i]
    for k, v in sorted(d.items()):
        print(k)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int,int> PI;
const LL N=100005;
LL R,C;
LL n;
vector<PI> vec[N];
LL fa[N],g[N];
LL find_fa (LL x)
{
	if (fa[x]==x) return x;
	LL ff=fa[x];
	fa[x]=find_fa(fa[x]);
	g[x]=g[x]+g[ff];
	return fa[x];
}
LL mn[N];
int main()
{
	scanf("%lld%lld",&R,&C);
	scanf("%lld",&n);
	for (LL u=1;u<=n;u++) 
	{
		LL x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		vec[x].push_back({y,c});
	}
	for (LL u=1;u<=C;u++) fa[u]=u,g[u]=0;
	for (LL u=1;u<=R;u++)
	{
		LL siz=vec[u].size();
		for (LL i=1;i<siz;i++)
		{
			LL x=vec[u][i].first,y=vec[u][i-1].first;
			LL c=vec[u][i].second-vec[u][i-1].second;
			if (find_fa(x)==find_fa(y))
			{
				if (g[x]-g[y]!=c)
				{
					printf("No\n");
					return 0;
				}
			}
			else
			{
				LL rt=find_fa(y);
				fa[rt]=x;
				g[rt]=-c-g[y];
			}
		}
	}
	memset(mn,127,sizeof(mn));
	for (LL u=1;u<=R;u++)
	{
		LL siz=vec[u].size();
		for (LL i=0;i<siz;i++)
		{
			LL x=vec[u][i].first,c=vec[u][i].second;
		//	printf("%lld %lld %lld %lld\n",x,find_fa(x),c,g[x]);
			mn[find_fa(x)]=min(mn[find_fa(x)],c-g[x]);
		}
	}
	for (LL u=1;u<=C;u++)
	{
		//printf("%lld %lld %lld\n",find_fa(u),mn[find_fa(u)],g[u]);
		if (mn[find_fa(u)]+g[u]<0)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 8064
// Created by CAD on 2020/4/18.
#include <bits/stdc++.h>

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x7fffffffffffffff
#define mst(name, value) memset(name,value,sizeof(name))
#define FOPEN freopen("C:\\Users\\14016\\Desktop\\cad.txt","r",stdin)
#define tst1(a) cout<<#a<<":"<<a<<endl
#define tst2(a, b) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl
#define tst3(a, b, c) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl
#define tst4(a, b, c, d) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl
#define lson (p<<1)
#define rson (p<<1|1)
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define ll long long
#define lowbit(i) (i&-i)
using namespace std;

const int maxn=4005;
ll ans=0;
void solve(vector<int> a, vector<int> b, vector<int> c){
//    tst1(ans);
    for(auto i:a){
        auto j=upper_bound(b.begin(),b.end(),i);
        while(j!=b.end()){
            auto k=upper_bound(c.begin(),c.end(),*j);
            int cnt=distance(k,c.end());
            auto bj=lower_bound(c.begin(),c.end(),(*j)+(*j-i));
//            tst1(cnt);
            if(bj!=c.end()&&(*bj)==(*j)+(*j-i)) cnt--;
            ans+=cnt;
            j++;
        }
    }
}
vector<int> r,g,b;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    for(int i=0;i<n;++i){
        if(s[i]=='R') r.push_back(i+1);
        else if(s[i]=='G') g.push_back(i+1);
        else if(s[i]=='B') b.push_back(i+1);
    }
    solve(r, g, b), solve(r, b, g);
    solve(g, r, b), solve(g,b,r);
    solve(b,g,r),solve(b,r,g);
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3716
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    d: usize,
    c: [usize; 26],
    s: [[i64; 26]; d],
  }
  
  let mut lc = Vec::with_capacity(26);

  for _ in 0..26 {
    lc.push(0);
  }

  
  for i in 0..d {
    let mut t:usize = 0;
    let mut ts = -10000000;
    for ti in 0..26 {
      let tc = s[i][ti] + c[ti] as i64 * (i + 1 - lc[ti]) as i64;
      if ts < tc {
        ts = tc;
        t = ti as usize;
      }
    }
    lc[t] = i + 1;
    println!("{}",t+1);
  }
}


Measured memory_bytes: 2300
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i;
  ll a[200005];
  
  cin >> n;
  for (i=1;i<=n;i++) cin >> a[i];
  
  a[0]=0;
  for (i=1;i<=n;i++) a[i]+=a[i-1];
  
  ll ans=1e18;
  for (i=2;i<n-1;i++){
    ll *p1,*p2;
    ll s;
    p1=lower_bound(a+1,a+i+1,a[i]/2+1);
    p2=lower_bound(a+i+1,a+n+1,(a[n]+a[i])/2+1);
    for (int j=0;j<2;j++){
      for (int k=0;k<2;k++){
        s=max({*p1,a[i]-*p1,*p2-a[i],a[n]-*p2})-min({*p1,a[i]-*p1,*p2-a[i],a[n]-*p2});
        ans=min(ans,s);
        p1--;
      }
      p1+=2;
      p2--;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
import Data.IORef
import Control.Monad

main :: IO()
main = do
  [n, k] <- map read . words <$> getLine :: IO([Int])
  hs <- map read . words <$> getLine :: IO([Int])
  sum <- solve k hs
  putStrLn $ show sum

solve :: Int -> [Int] -> IO (Int)
solve k hs = do
  sum <- newIORef 0
  forM_ hs $ (\h -> modifyIORef sum (+ if h >= k then 1 else 0))
  readIORef sum

Measured memory_bytes: 28156
n, m, x = map(int, input().split())


a = list(map(int, input().split()))

cost0 = costn = 0

for i in range(x, n):
    if i in a:
        costn += 1

for i in range(x, 0, -1):
   if i in a:
        cost0 += 1

print(min(cost0, costn))

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <map>
#include <tuple>
using namespace std;


int main()
{
    double a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b <= a) {
        b *= 2;
        k--;
    }
    while (c <= b) {
        c *= 2;
        k--;
    }
    if (k < 0) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int w;
  string s;
  cin>>s>>w;
  rep(i,s.size()){
    if(i%w==0)cout<<s[i];
  }
  cout<<endl;
  return 0;
}


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

bool isWin(const string& s) {
  int lose = 0;
  for (char c : s)
    lose += (c == 'x');
  return lose < 8;
}

int main() {
  string s;
  cin >> s;
  cout << (isWin(s) ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
typedef pair<P,P>P1;
int dp[300][300][6],x,y,n,sx,sy,gx,gy,lx,ly;
int dx[]={0,1,1,0,-1,-1,0};
int dy[2][7]={
  {1,0,-1,-1,-1,0,0},
  {1,1,0,-1,0,1,0}
};
int main(){
  set<P>s;
  r(i,300)r(j,300)r(k,6)dp[i][j][k]=1e9;
  cin>>sx>>sy>>gx>>gy>>n;
  sx+=150,sy+=150;
  gx+=150,gy+=150;
  r(i,n){
    cin>>x>>y;
    s.insert(P(x+150,y+150));
  }
  cin>>lx>>ly;
  dp[sy][sx][0]=0;
  priority_queue<P1,vector<P1>,greater<P1> >q;
  q.push(P1(P(0,0),P(0,sy*10000+sx)));
  while(!q.empty()){
    P1 p=q.top();q.pop();
    x=p.second.second%10000;
    y=p.second.second/10000;
    int t=p.second.first;
    int cost=p.first.first;
    if(dp[y][x][t]<cost)continue;
    r(i,7){
      int costt=1;
      if(i==(abs((x-150)*(y-150)*(t))%6))costt=0;
      int yy=y+dy[abs(x-150)%2][i];
      int xx=x+dx[i];
      if(s.count(P(xx,yy)))continue;
      if(abs(x-150)>lx||abs(y-150)>ly)continue;
      int tt=abs((x-150)*(y-150)*(t))%6;
      if(dp[yy][xx][(t+1)%6]>costt+cost){
        dp[yy][xx][(t+1)%6]=costt+cost;
        q.push(P1(P(costt+cost,(t+1)%6),P((p.second.first+1)%6,yy*10000+xx)));
      }
    }
  }
  int ans=1e9;
  r(i,6)ans=min(ans,dp[gy][gx][i]);
  if(ans==1e9)cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 5380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1001001001;

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> c(m);
    for(int i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; ++j){
            int x;
            cin >> x;
            --x;
            c[i].push_back(x);
        }
    }

    vector<vector<int>> dp(m+1, vector<int>((1<<n), INF));
    dp[0][0] = 0;
    int res = INF;
    for(int i = 0; i < m; ++i){
        int unlock = 0;
        for(int j = 0; j < b[i]; ++j){
            unlock |= 1 << c[i][j];
        }
        for(int j = 0; j < (1 << n); ++j){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j | unlock] = min(dp[i+1][j | unlock], dp[i][j] + a[i]);
        }
    }
    res = dp[m][(1<<n) - 1];
    if(res == INF)   res = -1;
    cout << res << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,A,B,C,D,E,fmin,ans;
  vl wait;
  cin >> N >>A >>B >>C >>D >>E;
  fmin = min(A,min(B,min(C,min(D,E))));
  if(N%fmin == 0){
    ans = N/fmin +4;
  }else{
    ans = N/fmin +5;
  };
  cout << ans<< endl;
  return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if((A-B)%2==0) System.out.println((A+B)/2);
        else System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 23636
from math import factorial

N = int(input())
N = factorial(N)

i = 2
num = 1
ans = 1
while N != 1:
    if N % i == 0:
        N //= i
        num += 1
    else:
        i += 1
        ans *= num
        num = 1
print(ans * num % (10**9 + 7))

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

using namespace std;

int main() {
	int a,b,c,d,e,k;

	cin >> a >> b >> c >> d >> e >> k;

	if (e - a > k) {
		cout << ":(";
	} else {
		cout << "Yay!";	
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
def fib(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]

n, m = [int(i) for i in input().split()]
a = []
frag = 1
ans = 0
step = []
for i in range(m):
    a.append(int(input()))
for i in range(m-1):
    if(a[i]+1 == a[i+1]):
        frag = 0
if(frag == 0):
    ans = 0
else:
    ans = 1
    sirusi = 0
    for i in range(len(a)):
        step.append(a[i] - 1 - sirusi)
        sirusi = a[i] + 1
    step.append(n - sirusi)
    for i in range(len(step)):
        ans = ans * fib(step[i]+1)
    ans = ans % 1000000007
print(ans)

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

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

    vector<int> A(N);
    vector<int> B(N);
    int num = 0;
    for(int i = 0; i < N; i++){
        cin >> num;
        A.at(i) = num;
        B.at(i) = num;
    }

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

    for(int Anum : A){
        if(Anum < B.at(N-1)){
            cout << B.at(N-1) << endl;
        }else{
            cout << B.at(N-2) << endl;
        }
    }
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  cout << (e-a>k ? ":(" : "Yay!") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef pair<int, pair<int, pair<int, int>>> PP;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const long long INF = 1LL << 60;
const int inf = 1e9;
const long long MOD = 1e9+7;

int n;
int cnt = 0;
Graph G;
vec seen;
int dfs(int s) {
	seen[s] = 1;
	cnt++;
	rep(i, G[s].size()) {
		if (seen[G[s][i]])continue;
		dfs(G[s][i]);
	}
	return cnt;
}


int main() {
	int m;
	int ans = 0;
	cin >> n >> m;
	G.resize(n);
	seen.assign(n, 0);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, n) {
		if (!seen[i]) {
			cnt = 0;
			int a = dfs(i);
			ans = max(a, ans);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20720
n = input()
x = list(map(int,input().split()))

min_hp = -1
for i in range(min(x),max(x)+1):
    hp = 0
    for j in x:
        hp += (j - i) ** 2
    if min_hp < 0:
        min_hp = hp
    min_hp = min(min_hp,hp)

print(min_hp)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = static_cast<double>(a) / static_cast<double>(b);
    std::cout << d << " " << r << " " << std::fixed << std::setprecision(5) << f << std::endl;
    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
long long n,a,b,c,d,ab;
int vis[500010],pan=0;
int main()
{
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    ab=b-a;
    n--;
    ff(i,0,n)
    {
        vis[i]=1;vis[n-i]=1;
        if((i*c-(n-i)*d)<=ab&&ab<=(i*d-(n-i)*c))
        {
            pan=1;
            break;
        }
    }
    if(pan)
    printf("YES");
    else
    printf("NO");
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long int,int> pli;
const int MAXN = 100005;
int A[MAXN], lf[MAXN], rt[MAXN], par[MAXN];
long long int wt[MAXN];
int parent(int pos)
{
	if(par[pos] != pos)
		par[pos] = parent(par[pos]);
	return par[pos];
}
long long int get_weight(int pos)
{
	pos = parent(pos);
	return wt[pos];
}
pli get_val(int pos)
{
	return pli(get_weight(pos) + get_weight(pos+1),pos);
}
set <pli, greater <pli> > S;
vector <int> ans;
int main()
{
	int n,l;
	scanf("%d %d", &n, &l);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &A[i]);
	for (int i = 0; i <= n+1; ++i)
	{
		par[i] = lf[i] = rt[i] = i;
		wt[i] = A[i];
	}
	for (int i = 1; i < n; ++i)
	{
		pli temp = get_val(i);
		S.insert(temp);
	}
	while(!S.empty())
	{
		pli top = *S.begin();
		if(top.first < l)
			break;
		S.erase(top);
		int pos = top.second;
		ans.push_back(pos);
		int p1 = parent(pos), p2 = parent(pos+1);
		pli lchain = get_val(lf[p1]-1), rchain = get_val(rt[p2]);
		lf[p2] = lf[p1];
		wt[p2]+=wt[p1];
		par[p1] = p2;
		if(lf[p2] > 1)
		{
			S.erase(lchain);
			lchain = get_val(lf[p2]-1);
			S.insert(lchain);
		}
		if(rt[p2] < n)
		{
			S.erase(rchain);
			rchain = get_val(rt[p2]);
			S.insert(rchain);
		}
	}
	if(!S.empty())
		printf("Impossible\n");
	else
	{
		printf("Possible\n");
		for (int i = n-2; i >= 0; --i)
		{
			printf("%d\n", ans[i]);
		}
	}
	return 0;
}

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

using namespace std;

int main() {
	string s {""}, t {""};
	cin >> s >> t;
	
	if (t.size() - s.size() == 1) {
		if (t.substr(0, t.size()-1) == s) {
			cout << "Yes" << "\n";
			}
		else cout << "No" << "\n";

			
		}
	else {cout << "No" << "\n";}

	}


Measured memory_bytes: 3616
import std.stdio;
import std.string;
import std.range;
import std.conv;

void main()
{
	auto ip = readln.split.to!(int[]), a = ip[0], b = ip[1], c = ip[2];
	if(b-a==c-b){
		writeln("YES");
	}else{
		writeln("NO");
	}
}

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

using namespace std;
typedef long long ll;
const int MAXM = 100;

int main() {
	int N, M, X;
	int l = 0;
	int r = 0;
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		if (a < X) {
			l++;
		}
		else {
			r++;
		}
	}
	cout << min(l, r) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll N;
  cin >> N;
  int sum = N%10;
  int M = N;
  while(N>0)
  {
    N /= 10;
    sum += N%10;
  }
  if(M%sum==0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N; cin >> N;
  string S;
  cin >> S;
  int r = 0, b = 0;
  REP(i, S.size()) {
    if (S[i] == 'R') r++;
    else b++;
  }
  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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



int main(){
	int w,n,i,j,k;
	int a,b;
	int ans[35];
	int tmp;
	char c;
	scanf("%d",&w);
	for(i=1; i<=w; i++){
		ans[i]=i;
	}
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d%c%d",&a,&c,&b);
		tmp=ans[a];
		ans[a]=ans[b];
		ans[b]=tmp;
	}
	for(i=1; i<=w; i++){
		printf("%d\n",ans[i] );
	}

	return 0;
}

Measured memory_bytes: 596
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  int N,X;
  cin>>N>>X;
  vector<int>v(N+1);
  v[0]=0;
  REP(i,N+1){
    cin>>v[i+1];
  }
  
  for(int i=1;i<N+1;i++){
    v[i]+=v[i-1];
    if(v[i]>X){
      cout<< i <<endl;
      break;
    }
    else if(i==N){
      cout<<N+1<<endl;
    }
  }
    
}

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

using namespace std;

typedef long long ll;

void solve() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n + 1), b(m + 1);
	for (int i = 1; i < n + 1; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for (int i = 1; i < m + 1; i++) {
		cin >> b[i];
		b[i] += b[i - 1];
	}

	int otv = 0;
	for (int i = 0; i <= n; i++) {
		if (k - a[i] < 0)
			continue;
		int pos = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
		otv = max(otv, i + pos - 1);
	}
	cout << otv;

}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

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

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
unsigned long long a[1000005],cnt,sum;
int n;
int main() {
	cin>>n;
	for (int i=1;i<=n;i++) {
		cin>>a[i];
		sum=sum+a[i];
	}
	for (int i=1;i<=n;i++) {
		sum=sum-a[i];
		cnt=(cnt+(sum%mod*a[i])%mod)%mod;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 5196
a, b = map(int, input().split())

# 0〜a - 1と0〜bの排他的論理和を考えればいい
# 排他的論理和は4つセットで消える（ぷよぷよのようだ）
def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return x ^ (x - 1)
    elif x % 4 == 2:
        return x ^ (x - 1) ^ (x - 2)
    else:
        return 0

print(solve(a - 1) ^ solve(b))

Measured memory_bytes: 9052
N = int(input())
a = [int(i) for i in input().split()]

count = 1
colour = a[0]
magic = 0
a.append(-1)
for i in range(1,N+1):
    if a[i] == colour:
        count += 1
    else:
        magic += count//2
        count = 1
        colour = a[i]

print(magic)

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B<C+D){
    cout << "Right" << endl;
  }
  if (A+B==C+D){
    cout << "Balanced" << endl;
  }
  if (A+B>C+D){
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
a, b, x = gets.split.map(&:to_f)
v = a ** 2 * b
tv = v - x
if tv <= (v / 2)
  h = tv * 2 / a / a
  puts Math.atan2(h, a) * 180 / Math::PI
else
  h = x * 2 / b / a
  puts 90 - Math.atan2(h, b) * 180 / Math::PI
end



Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int a[5];
	int osoi=0;
	rep(i, 5)
	{
		cin >> a[i];
		if (a[i] % 10 < a[osoi] % 10&&a[i]%10!=0)
		{
			osoi = i;
		}
	}

	int ans=0;
	for (int i = 0;i < 5;i++)
	{
		if (a[i] % 10 == 0)
		{
			ans += a[i];
		}
		else if(i!=osoi)
		{
			ans += ((a[i] / 10) + 1) * 10;
		}
	}

  	if(a[osoi]%10==0){
      cout<<ans<<endl;
    }
  else{
	cout << ans+a[osoi] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);



int main() {


    ll s;
    cin>>s;

    ll x1=0,y1=0;

    ll x2,y2,x3,y3;
    y2=1;
    x2=1000000000;




    x3=(x2-s%x2)%x2;


    y3 = (s+x3)/x2;
   // y3 = (s+x2)/x2-1;

   if(s%x2==0){
       x3 = 0;
       y3 = s/x2;
   }else{
       y3 = s/x2+1;
       x3 = x2*y3-s;
   }



    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int n;
  cin >> n;
  map<string, int> m;
  rep(i, n) {
    string c;
    cin >> c;
    m.insert(mp(c, 1));
  }

  int cnt = 0;
  for(auto _ : m) {
    cnt++;
  }

  if(cnt == 3) cout << "Three" << endl;
  else cout << "Four" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
 
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++);
#define F0R(i, a) for (int i=0; i<(a); i++);
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;

 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	if(n%2==0) cout<<n/2<<endl;
	else cout<<(n/2)+1<<endl;	
	return 0;
}
 

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

check1 = 0
count1 = 0
while check1 == 0:
    for i in range(len(A)):
        if(A[i]%2 == 0):
            A[i] = A[i]/2
        else:
            check1 = 1
            break
    count1 += 1
        
count1 -= 1
print(count1)



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

int main()
{
	int n;

	cin >> n;

	if (n < 105)
		cout << 0 << endl;
	else if (n < 135)
		cout << 1 << endl;
	else if (n < 165)
		cout << 2 << endl;
	else if (n < 189)
		cout << 3 << endl;
	else if (n < 195)
		cout << 4 << endl;
	else
		cout << 5 << endl;
	
	return 0;
}

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

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

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

    private void solve(Scanner sc) {
        int H = sc.nextInt();
        int W = sc.nextInt();
        sc.nextLine();
        for (int i = 0; i <= H + 1; ++i) {
            if (i > 0 && i <= H) {
                _out.print("#");
                _out.print(sc.nextLine());
                _out.print("#");
            } else {
                for (int j = 0; j <= W + 1; ++j) {
                    _out.print("#");
                }
            }
            _out.println();
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

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

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

Measured memory_bytes: 23892
#include "bits/stdc++.h"
using namespace std;
string t[4] = {"dream", "dreamer", "erase", "eraser"};
int main()
{
	string s;
	cin >> s;
	int n = s.length();
	vector<bool> a(n + 10, false);
	a[0] = true;
	for(int i = 0; i < n; ++i)		
	{
		for(int j = 0, same; a[i] && j < 4; ++j)
		{
			same = true;
			for(int k = 0; k < t[j].length(); ++k)
			{
				same &= s[i + k] == t[j][k];
			}
			if(same)
			{
				a[i + t[j].length()] = true;
			}
		}
	}
	printf(a[n] ? "YES\n" : "NO\n");
}

Measured memory_bytes: 512
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n;
		Ice ice;
		
		while(true){
			n = scan.nextInt();
			if(n == 0){
				break;
			}
			ice = new Ice();
			for(int i=0;i<n;i++){
				ice.sellIce(scan.nextInt());
			}
			
			for(int i=0;i<10;i++){
				System.out.println(ice.show(i));
			}
		}
	}
}

class Ice{
	HashMap<Integer,Integer> sales = new HashMap<Integer,Integer>();
	
	Ice(){
		for(int i=0;i<10;i++){
			sales.put(i,0);
		}
	}
	
	public String show(int num){
		int n = sales.get(num);
		String str = "";
		if(n == 0){
			return "-";
		}
		
		for(int i=0;i<n;i++){
			str += "*";
		}
		return str;
	}
	
	public void sellIce(int num){
		sales.put(num,sales.get(num)+1);
	}
}

Measured memory_bytes: 84872
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll n,a,b;
vl s;

int main(){
	cin>>n>>a>>b;
	s=vl(n);
	for(int i=0;i<n;i++) cin>>s[i];
	// 0:X 1:Y
	vvl dp(n,vl(2));
	int x=0,y=0;
	dp[0][0]++;
	dp[0][1]++;
	for(int i=1;i<n;i++){
		auto it=upper_bound(s.begin(),s.end(),s[i]-a);
		auto jt=upper_bound(s.begin(),s.end(),s[i]-b);
		if(it==s.begin()+i) dp[i][0]=(dp[i-1][0]+dp[i-1][1])%mod;
		else if(y<=it-s.begin()) dp[i][0]=dp[it-s.begin()][1];
		if(jt==s.begin()+i) dp[i][1]=(dp[i-1][0]+dp[i-1][1])%mod;
		else if(x<=jt-s.begin()) dp[i][1]=dp[jt-s.begin()][0];
		if(s[i]-s[i-1]<a) x=i;
		if(s[i]-s[i-1]<b) y=i;
	}
	cout<<(dp[n-1][0]+dp[n-1][1])%mod<<endl;
}

Measured memory_bytes: 6528
s = int(input())
max_size = s//3
ans = 0
for size in range(1,max_size+1):
  a = s - 3*size
  c = size-1
  b = a+c
  b_1 = 1
  c_1 = 1
  for i in range(1,c+1):
    b_1 *= a+i
    c_1 *= i
  ans += b_1//c_1
print(ans % (10**9+7))

Measured memory_bytes: 9192
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();

		String[] s = new String[n];
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
		}

		Arrays.sort(s);

		for(int i = 0; i < n; i++) {
			System.out.print(s[i]);
		}

		return;

	}

}



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

struct Point{
  double x, y;
};

void kota(struct Point, struct Point, int);

int main(){

  struct Point p1, p2;
  int n;

  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x, p1.y);
  kota(p1,p2,n);
  printf("%.8f %.8f\n",p2.x, p2.y);

  return 0;
}

void kota(struct Point p1, struct Point p2, int n){

  if(n==0) return;

  struct Point a, b, c;
  double rad=M_PI/3;

  a.x=(2*p1.x+p2.x)/3;
  a.y=(2*p1.y+p2.y)/3;
  b.x=(p1.x+2*p2.x)/3;
  b.y=(p1.y+2*p2.y)/3;
  c.x=(b.x-a.x)*cos(rad)-(b.y-a.y)*sin(rad)+a.x;
  c.y=(b.x-a.x)*sin(rad)+(b.y-a.y)*cos(rad)+a.y;

  kota(p1,a,n-1);
  printf("%.8f %.8f\n", a.x, a.y);
  kota(a,c,n-1);
  printf("%.8f %.8f\n", c.x, c.y);
  kota(c,b,n-1);
  printf("%.8f %.8f\n", b.x, b.y);
  kota(b,p2,n-1);
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
#define maxLL 1000000000000000000
#define PI 3.14159265358979323846264338327950L
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

int cmp(const void *a,const void *b){
	return(*(int*)b - *(int*)a);
}

int GCD(int a,int b){
	return b?GCD(b,a%b):a;
}

int LCM(int a,int b){
	return a/__gcd(a,b)*b;
}

int main(){
	int n,k;
	cin>>n>>k;
	int a[n] = {0};
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636