akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll reverse(ll num)
{
     ll n, reversedNumber = 0, remainder;
     n=num;
    while(n != 0)
    {
        remainder = n%10;
        reversedNumber = reversedNumber*10 + remainder;
        n /= 10;
    }
    return reversedNumber;
}

int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s="abcdefghijklmnopqrstuvwxyz";
    string jk="";
    ll idx;
    while(n>0)
    {
        idx=((n%26-1)+26)%26;
        jk+=s[idx];
        n=n-idx;
        n=n/26;
    }
    string ans="";
    for(ll i=jk.size()-1;i>=0;i--)
        ans+=jk[i];
    cout<<ans;

    return 0;
}


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

int main() {
	long long int n,a[10000],i,j,k,c=0;
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>a[i];
	}
	for(i=0;i<n;i++){
	    for(j=i+1;j<n;j++){
	        for(k=j+1;k<n;k++){
	            if(a[i]+a[j]>a[k]&&abs(a[i]-a[j])<a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]){
	                c++;
	                
	            }
	        }
	    }
	}
	cout<<c;
	
	
	return 0;
	
}

Measured memory_bytes: 3680
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//scanf("%d",&x);
//printf("%d",x);
//for(i=0;i<N;i++){  }
//if( == ){  }else{  }

int main()
{
	int N = 0;
	scanf("%d",&N);

	int x = (N - 1) / 111 + 1;
    
	printf("%d", x*111);



}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> Vull;
typedef vector<ll> Vll;
typedef vector<ui> Vui;
typedef vector<int> Vi;

typedef pair<ull, ull> Pull;
typedef pair<ll, ll> Pll;
typedef pair<ui, ui> Pui;
typedef pair<int, int> Pi;

int main() {
    int x; cin >> x;
    int h = x / 100, t = x / 10 % 10, o = x % 10;

    if (x > h * 100 + h * 10 + h) ++h;
    cout << h * 100 + h * 10 + h << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,k;
    scanf("%d %d %d",&a,&b,&k);
    int judge=1,i=1,gt,mini,max;
    if(a>=b){
        max=a;
        mini=b;
    }else{
        mini=a;
        max=b;
    }
    while(judge<=k){
        if(mini%i==0){
            int num=mini/i;
            if(max%num==0){
                gt=num;
                judge++;
            }
        }
        i++;
    }
    printf("%d\n",gt);
    return 0;
}

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

using namespace std;

int main(){
    string A,B;

    cin >> A >> B;

    if(A.length() > B.length()){
        cout << "GREATER" << endl;
    }
    else if(A.length() < B.length()){
        cout << "LESS" << endl;
    }
    else{
        int len = A.length();
        int f = 0;

        for(int i=0;i<len;i++){
            if(A[i] < B[i]){
                cout << "LESS" << endl;
                f = 1;
                break;
            }
            else if(A[i] > B[i]){
                cout << "GREATER" << endl;
                f = 1;
                break;
            }
        }

        if(!f)cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define ss second
#define pb push_back
#define mp make_pair


int n, d, x, a[1010], ans=0;


int main(){

ios::sync_with_stdio(0);
cin.tie(0);

cin >> n >> d >> x;
rep(i, 1, n){
cin >> a[i];
}

rep(i, 1, n){

int c= a[i];
int t=0;
while(c*t+1 <= d){
    ans++;
    t++;
}

}
cout << ans +x << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <math.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int mon = 1900 * b + (a - b) * 100;
	cout << pow(2, b)*mon << endl;
}

//mon=9500+9500=19000

//32

Measured memory_bytes: 384
N = int(input())
X = list(map(int, input().split()))
L = int(input())
Q = int(input())

V = [0]*N
ib = 0
for i in range(N):
    while X[i]-X[ib] > L:
        V[ib] = i-1
        ib += 1
while ib!=N-1:
    V[ib]=N-1
    ib += 1
dbl = [[0]*N for i in range(18)]
dbl[0]=V
for i in range(1, 18):
    for j in range(N):
        ii = dbl[i-1][j]
        if ii == 0:
            break
        dbl[i][j] = dbl[i-1][ii]
for i in range(Q):
    a, b = map(int, input().split())
    a, b = sorted([a, b])
    a-=1
    b-=1
    ind = a
    ans = 0
    for j in range(17, -1, -1):
        if dbl[j][ind]==0:
            continue
        if dbl[j][ind]>b:
            continue
        if dbl[j][ind]==b:
            ans |= 1<<j
            break
        else:
            ans |= 1<<j
            ind = dbl[j][ind]
    else:
        ans += 1
    print(ans)


Measured memory_bytes: 26412
#include<stdio.h>

#define M 100

int main(){
  int i,j,k,l;
  int n,r,c;
  int P[M],H[M][M];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d %d",&r,&c);
    P[i] = r;
    if(i == n-1)P[i+1] = c;
  }

  for(i=1; i<=n; i++){
    H[i][i] = 0;
  }

  for(i=2; i<=n; i++){
    for(j=1; j<=n-i+1; j++){
      k = j+i-1;
      H[j][k] = 1000000000;
      for(l=j; l<=k-1; l++){
	if(H[j][k] > H[j][l]+H[l+1][k]+P[j-1]*P[l]*P[k]) H[j][k] = H[j][l]+H[l+1][k]+P[j-1]*P[l]*P[k];
	else H[j][k] = H[j][k];
      }
    }
  }

  printf("%d\n",H[1][n]);

  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count = 1;
  int color = s[0];
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == color)
      continue;
    color = s[i];
    ++count;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
using ll = long long;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int main(){
    int n,m; cin >> n >> m;
    int a[n+1],num[n+1];
    fill(a,a+n+1,0);
    fill(num,num+n+1,1);
    a[1] = 1;

    for(int i = 0; i < m; i++){
        int x,y; cin >> x >> y;
        if (num[x] > 1 && a[x] == 1){
            num[x]--;
            num[y]++;
            a[y] = 1;
        } else if (num[x] == 1 && a[x] == 1){
            num[x]--;
            num[y]++;
            a[x] = 0;
            a[y] = 1;
        } else if (a[x] == 0){
            num[x]--;
            num[y]++;
            a[y] = max(a[y],a[x]);
        }
    }
    int ans = 0;
    for(int i = 0; i < n+1; i++){
        ans += a[i];
    }
    cout << ans << endl;
}
  



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
  ll a;
  cin>>a;
  cout<<a+(a*a)+(a*a*a);
    
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

namespace std {
	#define u(x, a, b) for(ll x = a; x < b; x++)
	#define d(x, a, b) for(ll x = a; x > b; x--)
}

typedef long long ll;
typedef long double ld;

#define MAXI 100010
#define MOD 1000000007

int main(){
	ll n;
	cin >> n;
	
	string s;
	cin >> s;
	ll num = 1;
	u(one, 1, n){
		if(s[one]!=s[one-1]){num++;}
	}
	
	cout << num;
}

Measured memory_bytes: 3744
#include<iostream>
#include<cstring>
#include<cstdio>
char a;
using namespace std;
int main()
{
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') cout<<"vowel";
	else cout<<"consonant";
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  COMinit();
  ll n,k ;cin >> n >> k;
  FOR(i,1,k+1){
      cout << COM(n-k+1, i) * COM(k-1, i-1) % MOD << endl;
  }
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> price(n);
    vector<vector<int>> point(n, vector<int>(m));
    const int INF = 1000000000;
    rep(i, n)
    {
        cin >> price.at(i);
        for (int j = 0; j < m; j++)
        {
            cin >> point.at(i).at(j);
        }
    }

    int ans = INF;

    rep(s, 1 << n)
    {
        int cost = 0;
        vector<int> sum(m);
        rep(i, n)
        {
            if (s >> i & 1)
            {
                cost += price.at(i);
                rep(j, m)
                {
                    sum.at(j) += point.at(i).at(j);
                }
            }
        }
        bool ok = true;
        rep(j, m)
        {
            if (sum.at(j) < x)
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            ans = min(ans, cost);
        }
    }
    if (ans == INF)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	long long n;
	long long a[10];
	while (cin >> n) {
		for (int i = 0; i < 5; i++) {
			cin >> a[i];
		}
		sort(a, a + 5);
		long long sum;
		if (n < a[0]) {
			cout << "5" << endl;
			continue;
		}
		if (n % a[0] == 0) {
			sum = (n / a[0]) + 4;
		}
		else {
			n = n - 1;
			sum = (n / a[0]) + 5;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

dp = [0] * (H + 1)

for i in range(1, H + 1):
    dp[i] = min(dp[max(i - damage, 0)] + cost for damage, cost in magic)

ans = dp[H]

print(ans)


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int bg = -1, en = n;
    int ans = -1;
    do {
        for (int i = bg + 1; i < n; i++) {
            bg++;
            if (s[i] == 'W') break;
        }
        for (int j = en - 1; j >= 0; j--) {
            en--;
            if (s[j] == 'R') break;
        }
        ans++;
    } while(bg < en);
    cout << ans << '\n';
}

Measured memory_bytes: 3676
while 1:
    n,w=map(int,input().split())
    if n==w==0:break
    a=[0]*100
    s=h=int(0)
    while n:
        b=int(input())
        a[b//w]+=1
        s=max(s,b//w)
        h=max(h,a[b//w])
        n-=1
    ans=0.01
    for i in range(int(s)+1):
        ans+=a[i]/h*(s-i)/s
    print(ans)

Measured memory_bytes: 7692
A, B, K = [int(i) for i in input().split()]
cnt = 1
while True:
    if A % min(A,B) == B % min(A, B) == 0:
        break
    if A > B:
        A %= B
    else:
        B %= A

target = min(A,B)
if K == 1:
    print(target)
else:
    for i in range(2,target):
        if target % i == 0:
            cnt += 1
        if cnt == K:
            break
    print(int(target / i))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  string S;
  ll res = 0;
  cin >> N >> S;
 
  ll r=0, g=0, b=0;
  rep(i,N) {
    if(S[i]=='R') r++;
    if(S[i]=='G') g++;
    if(S[i]=='B') b++;
  }
  res = r * g * b;
 
  for(int i=0; i<N; i++) {
    for(int j=1; i+j*2<N; j++) {
      int pos1 = i;
      int pos2 = i + j;
      int pos3 = pos2 + j;
      if(S[pos1] != S[pos2] && S[pos2] != S[pos3] && S[pos3] != S[pos1]){
        res--;
      }
    }
  }
 
  cout << res << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  vector<int> vec = {1, 1,  1, 2, 1,  2, 1, 5, 2, 2, 1,
                     5, 1,  2, 1, 14, 1, 5, 1, 5, 2, 2,
                     1, 15, 2, 2, 5,  4, 1, 4, 1, 51};
  int k;
  cin >> k;
  k--;
  cout << vec[k] << endl;
  return 0;
}

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

int gcd(int a, int b){
    int x,y;
    x=max(a,b);
    y=min(a,b);
    if(x%y==0) return y;
    else return gcd(x%y, y);
}

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> dif(n);
    for(int i=0; i<n; i++){
        int k;
        cin >> k;
        dif.at(i) = abs(x-k);
    }
    int ans=dif.at(0);
    for(int i=0; i<n; i++){
        ans = gcd(ans, dif.at(i));
    }
    cout << ans << endl;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n; cin >> n;
	map<ll,bool> A;
	rep(i,n){
		ll a;
		cin >> a;
		if(!A.count(a)||A[a] == false){//存在していないならばboolをtrueにする
			A[a] = true;
		}else{
			//すでに入っているんだったらfalse にする
			A[a] = false;
		}
	}
	ll ans = 0 ;
	for(auto x : A){//true を数える
		if(x.second){
			ans ++ ;
		}
	}
	cout << ans << endl;


}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
typedef vector<vector<int>> Graph;

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> mp(h,vector<char>(w));
    char s;
    rep(i,h){
        rep(j,w){
            cin >> s;
            mp[i][j] = s;
        }
    }
    int ans = 0;
    rep(i,h){
        rep(j,w){
            if(mp[i][j]=='#') continue;
            queue<pair<int,int>> que;
            vector<V> dist(h,V(w,-1));
            dist[i][j] = 0;
            que.push(make_pair(i,j));
            while(!que.empty()){
                int x = que.front().first, y = que.front().second;
                que.pop();
                if(x>0&&dist[x-1][y]==-1&&mp[x-1][y]=='.'){
                    dist[x-1][y] = dist[x][y] + 1;
                    que.push(make_pair(x-1,y));
                    ans = max(ans,dist[x-1][y]);
                }
                if(y>0&&dist[x][y-1]==-1&&mp[x][y-1]=='.'){
                    dist[x][y-1] = dist[x][y] + 1;
                    que.push(make_pair(x,y-1));
                    ans = max(ans,dist[x][y-1]);
                }
                if(x<h-1&&dist[x+1][y]==-1&&mp[x+1][y]=='.'){
                    dist[x+1][y] = dist[x][y] + 1;
                    que.push(make_pair(x+1,y));
                    ans = max(ans,dist[x+1][y]);
                }
                if(y<w-1&&dist[x][y+1]==-1&&mp[x][y+1]=='.'){
                    dist[x][y+1] = dist[x][y] + 1;
                    que.push(make_pair(x,y+1));
                    ans = max(ans,dist[x][y+1]);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {
static ArrayList<edge> []adj;
static boolean []visited;
static int []dist;
public static boolean dfs(int u,int d)
{
	visited[u]=true;
	boolean ans=true;
	if(d!=dist[u] && dist[u]!=-1)
		ans= false;
	
	dist[u]=d;
	for(edge e:adj[u])
	{
		if(visited[e.v])
		{
			ans&=dist[e.v]==d+e.w;
		}
		else
			ans &=dfs(e.v,d+e.w);
	}
	return ans;
}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		adj=new ArrayList[n];
		visited=new boolean[n];
		dist=new int [n];
		Arrays.fill(dist, -1);
		for(int i=0;i<n;i++)
			adj[i]=new ArrayList();
		while(m-->0)
		{
			int u=sc.nextInt()-1,v=sc.nextInt()-1,w=sc.nextInt();
			adj[u].add(new edge(v,w));
			adj[v].add(new edge(u,-w));
			
		}
		boolean ans=true;
		for(int i=0;i<n;i++)
			if(!visited[i])
				ans&=dfs(i,0);
		System.out.println(ans?"Yes":"No");

	}
	static class edge
	{
		int v,w;
		edge(int a,int b)
		{
			v=a;w=b;
		}
	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream S)
		{
			br=new BufferedReader(new InputStreamReader(S));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next()  throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(nextLine());
			return st.nextToken();
		}
		public int nextInt()  throws IOException
		{
			return Integer.parseInt(next());
		}
		public double nextDouble()  throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
	}
}


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

int main() {
    string s;cin>>s;
    int n = s.size();
    int low_c = 0;
    int cc = 0;
    rep(i,n)if(islower(s[i]))++low_c;
    for(int i=2;i<=n-2;++i)if(s[i]=='C')++cc;
    
    if(s[0]=='A' && n - low_c ==2 && cc == 1)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
	return 0;
}

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

dp=[[[0]*(a*n+1) for i in range(n+1)] for i in range(n+1)]
dp[0][0][0]=1
#dp[i番目のカード][選んだ枚数][数の合計]=何組あるか
for i in range(n):
    for j in range(n):
        for k in range(a*n+1):
            if k+x[i]<=a*n:
                #i番目を入れる場合
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k]
            #いれない場合
            dp[i+1][j][k]+=dp[i][j][k]
ans=0
cnt=0
#print(*dp,sep='\n')
for i in dp[-1]:
    ans+=i[cnt*a]
    cnt+=1
print(ans-1)

Measured memory_bytes: 93020
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = nums[0];
            int M = nums[1];
            WriteLine(N == M ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
using namespace std;
char s[105];
int main()
{
 long long k;
 cin>>s;
 cin>>k;
 if(k==1)cout<<s[0];
 else
 {
  int len=strlen(s);
  for(int i=0;i<len;i++)
   if(s[i]=='1')
   {
   	if(k==i+1)
   	{
   	 cout<<1;
   	 break;
   	}
   }
   else
   {
   	cout<<s[i];
   	break;
   }
 }
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int n = scan.nextInt();
	int k = scan.nextInt();

	int ans = 1;
	for(int i = 0; i < n; i++){
	    if(ans < k){
		ans *= 2;
	    }else{
		ans += k;
	    }
	}

	System.out.println(ans);
    }
}

		  


Measured memory_bytes: 22864
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct { int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll X; cin >> X;
  for(ll i = 0; i < 1000; i++) {
    ll l = -1000, r = 1000;
    while(r - l > 1) {
      ll m = (l + r) / 2;
      if((i * i * i * i * i - m * m * m * m * m) >= X) l = m;
      else r = m;
    }
    if((i * i * i * i * i - l * l * l * l * l) == X/* || (i * i * i * i * i - r * r * r * r * r) == X*/) {
      cout << i << " " << l << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define lint long long

using namespace std;
int n;
int h[200];
int l;
int r;
int ans;

int main(){
  cin >> n;
  FOR(i,n) cin >> h[i];
  h[0]=0;
  h[n+1]=0;

  while(1){
    l=0;
    while(h[l]==0)l++;
    if(l>n) break;
    r = l;
    while(h[r]!=0&&r<=n)r++;
    for(int j=l;j<r;j++){
      h[j]--;
    }
    ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
A = LI()
N = [0]*n

for a in A:
    N[a-1] += 1

for i in range(n):
    print(N[i])

Measured memory_bytes: 105184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define a(a)         \
    for (auto i : a) \
        cout << i << " ";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    ll a[n];
    rep(i, n) a[i] = k - q;
    while (q--)
    {
        ll x;
        cin >> x;
        x--;
        a[x]++;
    }
    rep(i, n)
    {
        if (a[i] <= 0)
        {
            c("No")
        }
        else
            c("Yes")
    }
    //c("Yes")
}

Measured memory_bytes: 1408
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int n;
int s;
int a[1001];
int v[1001];
int t[10001];
int all2=0;
void solve() {
	int b[1001];
	for (int i = 0; i < n; i++) {
		b[i] = a[i];
	}
	sort(b, b + n);
	for (int i = 0; i < n; i++) {
		t[b[i]] = i;
	}
	for (int i = 0; i < n; i++) {
		int key = 0;
		int all = 0;
		int j = i;
		int count = 0;
		while (!v[i])
		{
			key = a[j];
			if (key == b[i])
			{
				v[i] = 1;
				break;
			}
			all += b[i] + a[j];
			v[t[a[j]]] = 1;
			j = t[a[j]];
			count++;
		}
		all2 += min(all,all+2*(b[i]+b[0])-count*(b[i]-b[0]));
	}
}
int main() {
	cin >> n;
	s = 10000;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s = min(s, a[i]);
	}
	solve();
	cout << all2<<endl;
}


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

int main() {
    while (true) {
        int start, end;
        cin >> start >> end;
        if (start == 0) {
            break;
        }
        int count = 0;
        for (int i = start; i <= end; i++) {
            int temp = i;
            while (temp > 1) {
                if (temp % 2 == 0) {
                    temp /= 2;
                } else if (temp % 3 == 0) {
                    temp /= 3;
                } else if (temp % 5 == 0) {
                    temp /= 5;
                } else {
                    break;
                }
            }
            if (temp == 1) {
                count++;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 864
def solve():
    X = int(input())

    def _solve(x):
        if x <= 6:
            return 1

        if x <= 11:
            return 2

        base = (x // 11) * 2
        remain = x % 11
        if 0 < remain:
            base += _solve(remain)

        return base

    return _solve(X)


if __name__ == '__main__':
    res = solve()
    print(res)


Measured memory_bytes: 38256
n = gets(chomp:true).to_i

# 最大利益を負の無限大に設定！！！
maxv = -Float::INFINITY

# 最小値を読み込み
minv = gets(chomp:true).to_i

(1...n).each do

  # 比較する価格を読み込み
  price = gets(chomp:true).to_i

  # 最大利益が価格-最小値より小さい場合。最大利益を更新
  maxv < price - minv && maxv = price - minv

  # 最小値が価格より大きい場合、最小値を更新
  minv > price && minv = price

end

puts maxv


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

int main() {
	// your code goes here
	string s;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			char x;
			cin>>x;
			if(i==j)s+=x;
		}
		
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int MAXN = 500005;
int data[MAXN], n;
void maxHeapify(int i){
    int l = i*2;
    int r = i*2+1;
    int largest;
    if (l <= n && data[l] > data[i]) largest = l;
    else largest = i;
    if (r <= n && data[r] > data[largest]) largest = r;
    if (largest != i){
        swap(data[i], data[largest]);
        maxHeapify(largest);
    }
}
void buildMaxHeap(){
    for (int i = n/2 ; i >= 1 ; i--)
        maxHeapify(i);
}
int main(){ _
    cin >> n;
    data[0] = 2147483647;
    for (int i = 1 ; i <= n;  i++)
        cin >> data[i];
    buildMaxHeap();
    for (int i = 1 ; i <= n ; i++){
        cout << " " << data[i];
    }
    cout << '\n';
}



Measured memory_bytes: 5044
d,m=1e9+7,p[10001][200]={1};i,j,k,x,I;char s[11111];main(L){scanf("%s%d",s,&d);for(;i<strlen(s);i+=++j/2,j%=2)for(x=L=j?9:s[i]-48,k=0;~x;x-=++k/d,k%=d)p[i+1][I=(j|x<L)*d+(k+x)%d]+=p[i][j*d+k],p[i+1][I]%=m;printf("%d",(*p[i]+p[i][d]-1+m)%m);}

Measured memory_bytes: 7936
(let ((n (read))
      (a (make-array 0 :element-type 'integer
                       :adjustable t
                       :fill-pointer 0)))
     (dotimes (i n)
       (vector-push-extend (read) a))
     (sort a #'<)
     (princ (- (aref a (floor n 2)) (aref a (1- (floor n 2))))))

Measured memory_bytes: 57828
local n, m = io.read("*n", "*n")
local parent = {}
for i = 1, n do
  parent[i] = i
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, m do
  local x, y, _z = io.read("*n", "*n", "*n")
  local xp, yp = uf_findroot(x), uf_findroot(y)
  parent[yp], parent[y] = xp, xp
end

local c = 0
local map = {}
for i = 1, n do
  local p = uf_findroot(i)
  if not map[p] then
    c = c + 1
    map[p] = true
  end
end
print(c)


Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long A, long long B){
    cout << 6 -A-B << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

MOD = 10**9+7
fac = [1,1] + [0]*N
finv = [1,1] + [0]*N
inv = [0,1] + [0]*N
for i in range(2,N+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = 0
prev = 0
for k in range((N+1)//2, N):
    tmp = ncr(k-1, N-1-k) * fac[k] * fac[N-1-k]
    tmp %= MOD
    ans += (tmp - prev) * k
    ans %= MOD
    prev = tmp
print(ans)

Measured memory_bytes: 88688
x = int(input())

if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
elif x <= 1999:
    print(1)


Measured memory_bytes: 9196
"""
n, mod = int(input()), 10 ** 9 + 7
memo = [{} for i in range(n+1)]
def check(l):
    for i in range(4):
        t = list(l)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1] # 順序の入れ替え
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for c in 'ACGT':
        if check(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
    memo[cur][last3] = ret
    print(cur, memo)
    return ret

print(dfs(0, 'TTT'))
"""

n, mod = int(input()), 10 ** 9 + 7
memo = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(n + 1)]
memo[0][3][3][3] = 1
for length in range(n):
    for s3 in range(4):  # 一番最後の文字
        for s2 in range(4):  # 最後から2番目の文字
            for s1 in range(4):  # 最後から3番目の文字
                # if memo[length][s3][s2][s1] == 0: continue
                # 新しく追加する文字
                for s4 in range(4):
                    # ダメな条件の時はcontinue
                    if s4 == 2 and s3 == 1 and s2 == 0: continue
                    if s4 == 2 and s3 == 0 and s2 == 1: continue
                    if s4 == 1 and s3 == 2 and s2 == 0: continue
                    if s4 == 2 and s3 == 1 and s1 == 0: continue
                    if s4 == 2 and s2 == 1 and s1 == 0: continue
                    
                    memo[length + 1][s4][s3][s2] += memo[length][s3][s2][s1]
                    memo[length + 1][s4][s3][s2] %= mod
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += memo[n][i][j][k]
            ans %= mod

print(ans)


Measured memory_bytes: 3312
import math
import fractions
from functools import reduce


def main():
    n = int(input())
    a = input_list()
    if len(set(a)) == 1:
        print(n//2)
        exit(0)
    evens = {}
    odds = {}
    for i, v in enumerate(a):
        if i % 2 == 0:
            if v in evens:
                evens[v] += 1
            else:
                evens[v] = 1
        else:
            if v in odds:
                odds[v] += 1
            else:
                odds[v] = 1
    if len(evens) == 1 and len(odds) == 1:
        print(0)
        exit(0)

    e = sorted(evens.items(), key=lambda x: x[1], reverse=True)
    o = sorted(odds.items(), key=lambda x: x[1], reverse=True)
    if e[0][0] != o[0][0]:
        even_ans = (n // 2) - e[0][1]
        odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[0][1]
        a1 = even_ans+odd_ans

        even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[0][1]
        odd_ans = (n // 2) - o[0][1]
        a2 = even_ans+odd_ans
        print(min(a1, a2))
    else:
        even_ans = (n // 2) - e[0][1]
        odd_ans = (n // 2) if len(o) == 1 else (n // 2) - o[1][1]
        a1 = even_ans + odd_ans

        even_ans = (n // 2) if len(e) == 1 else (n // 2) - e[1][1]
        odd_ans = (n // 2) - o[0][1]
        a2 = even_ans + odd_ans
        print(min(a1, a2))

# 6
# 3 1 3 2 4 2

def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()


Measured memory_bytes: 25860
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double w, h, x, y; cin >> w >> h >> x >> y;
    double mx = w * h / 2;
    ll div = 0;
    if(w == 2 * x && h == 2 * y) div = 1;
    printf("%.9f %d\n", mx, div);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
 int A,B,C,K;
 scanf("%d %d %d %d",&A,&B,&C,&K);
 if(K<=A)printf("%d",K);
  else if(K<=A+B)printf("%d",A); 
   else printf("%d",2*A-K+B);
 return 0;
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
 
ll A[300100];
ll S[300100];
int N;
 
ll calc1(int l, int m, int r){
    ll sum0 = S[l];
    ll sum1 = S[m] - S[l];
    ll sum2 = S[r] - S[m];
    ll sum3 = S[N-1] - S[r];
    ll high = max(max(sum0, sum1), max(sum2, sum3));
    ll low = min(min(sum0, sum1), min(sum2, sum3));
    return high - low;
}
 
ll calc2(int l, int m, int r){
    ll sum0 = S[l];
    ll sum1 = S[m] - S[l];
    ll sum2 = S[r] - S[m];
    ll sum3 = S[N-1] - S[r];
    ll sum = abs(sum0-sum1) + abs(sum0-sum2) + abs(sum0-sum3)
                + abs(sum1-sum2) + abs(sum1-sum3) + abs(sum2-sum3);
    return sum;
}
 
int main(){
    cin >> N;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        S[i] = a;
        if(i > 0) S[i] += S[i-1];
    }
 
    int left = 0;
    int mid = 1;
    int right = 2;
    ll ans = LLONG_MAX;

    for(int mid = 1; mid < N-1; mid++){
        if(mid == right) right++;
        ll C = calc2(left, mid, right);
        while(left < mid){
            ll cost = calc2(left+1, mid, right);
            if(C > cost){
                C = cost;
                left++;
            }
            else break;
        }

        while(right < N){
            ll cost = calc2(left, mid, right+1);
            if(C > cost){
                C = cost;
                right++;
            }
            else break;
        }

        ans = min(ans, calc1(left, mid, right));
    }
 
    //printf("l:%d, m:%d, r:%d\n", left, mid, right);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3840
#include <algorithm>
#include <iostream>
#define N 100
#define M 16
using namespace std;
typedef long long ll;
typedef struct data{
  int m,l,s[M],e[M],bit;
} dat;

int main(){
  int n;
  ll ans,dp[(1<<16)];
  dat d[N];
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++){
      cin>>d[i].m>>d[i].l;
      d[i].bit=0;
      for(int j=0;j<d[i].m;j++){
	cin>>d[i].s[j]>>d[i].e[j];
	for(int k=d[i].s[j]-6;k<d[i].e[j]-6;k++) d[i].bit=d[i].bit|(1<<k);
      }      
    }
    for(int i=0;i<(1<<16);i++) dp[i]=-1;
    dp[0]=ans=0;
    for(int i=0;i<(1<<16);i++){
      if(dp[i]==-1) continue;
      for(int j=0;j<n;j++){
	if((i&d[j].bit)==0){
	  dp[i|d[j].bit]=max(dp[i|d[j].bit],dp[i]+d[j].l);
	  ans=max(ans,dp[i|d[j].bit]);
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1680
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    int i = 1;
    while ((i+1)*(i+1) <= N) {
      ++i;
    }
  
    cout << i*i << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cstdio>
#include <cmath>
#include <deque>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int ans = 1;
	int a = 1;
	int n;
	cin >> n;
	REP(i, n){
		int tmp;
		cin >> tmp;
		a *= tmp % 2 == 0 ? 2 : 1;
		ans *= 3;
	}
	cout << ans - a << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(z) (z).begin(),(z).end() 
#define MOD 1000000007
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll isprime(ll n)
{
	for(int i=2;i<n;i++)
		if(n%i==0)
		return 0;
		
	return 1;	
}
int main()
{ 
    FAST;
	long double d,t,s;
	cin>>d>>t>>s;
	if(d/s<=t)cout<<"Yes";
	else cout<<"No";

	
	
	
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M; cin >> N >> M;
    ll id_min = -INF;
    ll id_max = +INF;
    rep(i, M){
        ll l, r;
        cin >> l >> r;
        if (id_min < l){id_min = l;}
        if (id_max > r){id_max = r;}
    }
    if (id_max >= id_min){
    	cout << id_max - id_min + 1 << endl;
    } else {
    	cout << 0 << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256