akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int H, W, M;
    cin >> H >> W >> M;
    vector<pair<int, int>> hw(M);
    vector<int> cntH(H, 0);
    vector<int> cntW(W, 0);

    int h, w;
    for(int i = 0; i < M; i++){
        cin >> h >> w;
        cntH[h - 1]++;
        cntW[w - 1]++;
        hw[i] = make_pair(h - 1, w - 1);
    }

    int maxCntH = *max_element(cntH.begin(), cntH.end());
    int maxCntW = *max_element(cntW.begin(), cntW.end());

    vector<int> maxIndexH, maxIndexW;
    for(int i = 0; i < H; i++){
        if(cntH[i] == maxCntH){
            maxIndexH.push_back(i);
        }
    }

    for(int i = 0; i < W; i++){
        if(cntW[i] == maxCntW){
            maxIndexW.push_back(i);
        }
    }

    long long s = (int)maxIndexH.size() * (int)maxIndexW.size();
    if(s > M){
        cout << maxCntH + maxCntW << endl;
    }
    else{
        int cnt = 0;
        for(auto temp: hw){
            int x = temp.first;
            int y = temp.second;
            if(cntH[x] == maxCntH){
                if(cntW[y] == maxCntW){
                    cnt++;
                }
            }
        }

        if(cnt == s){
            cout << maxCntH + maxCntW - 1 << endl;
        }
        else{
            cout << maxCntH + maxCntW << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 12132
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] arg) {

        string[] tmp = Console.ReadLine().Split(' ');
        long n = long.Parse(tmp[0]);
        long a = long.Parse(tmp[1]);
        long b = long.Parse(tmp[2]);

        long num = 0;

        num =(n / (a + b)) * a;

        if (n % (a + b) <= a)
        {
            num += n % (a + b);
        }
        else
        {
            num += a;
        }
        
        Console.WriteLine(num);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

char a[7];
int s=0;

int main()
{
    int i;
    scanf ("%s",a) ;
	for (i=0;i<=3;i++)
	{
	    if (a[i]=='+')
		{
			s++;
		}
		else
		{
			s--;
		}
	}
	cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
typedef long long ll;

using namespace std;

int main() {
  ll L, R;
  cin >> L >> R;

  int m = 2018;
  for (ll i = L; i < R; i++) {
    for (ll j = L + 1; j < R + 1; j++) {
      int a = (i * j) % 2019;
      if (a == 0) {
        cout << a << endl;
        return 0;
      }
      if (a < m) {
        m = a;
      }
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split(' '))
    if m == -1 and f == -1 and r == -1:
        break
    
    elif m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= m + f and m + f < 80:
        print('B')
    elif 50 <= m + f and m + f < 65:
        print('C')
    elif 30 <= m + f:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5596
n = int(input())
a = list(map(int, input().split()))
num = abs(a[0])
rec = [num]
for i in range(n - 1):
    num += abs(a[i + 1] - a[i])
    rec.append(abs(a[i + 1] - a[i]))

for i in range(n):
    if i == 0:
        print(num - abs(a[0]) - rec[1] + abs(a[1]) + abs(a[-1]))
    elif i == n - 1:
        print(num - rec[-1] + abs(a[-2]))
    else:
        print(num - rec[i] - rec[i + 1] + abs(a[i + 1] - a[i - 1]) + abs(a[-1]))

Measured memory_bytes: 14048
#include <algorithm>
#include <cstdio>
struct data
{
	int mn, pos; 
	inline bool operator <(const data &a) const
	{
		return mn < a.mn; 
	}
} seg[800005]; 
int arr[200005], app[200005], lazy[800005];
inline void paint(int u, int x)
{
	seg[u].mn += x; 
	lazy[u] += x; 
}
inline void push_down(int u)
{
	if (lazy[u])
	{
		paint(u << 1, lazy[u]);
		paint(u << 1 | 1, lazy[u]); 
		lazy[u] = 0; 
	}
}
void build(int u, int l, int r)
{
	if (l == r)
	{
		seg[u] = {app[l], l}; 
		return; 
	}
	int m = l + r >> 1; 
	build(u << 1, l, m); 
	build(u << 1 | 1, m + 1, r); 
	seg[u] = std::min(seg[u << 1], seg[u << 1 | 1]); 
}
void modify(int u, int l, int r, int L, int R, int x)
{
	if (L <= l && r <= R)
	{
		paint(u, x);
		return; 
	}
	push_down(u); 
	int m = l + r >> 1; 
	if (L <= m)
		modify(u << 1, l, m, L, R, x); 
	if (m < R)
		modify(u << 1 | 1, m + 1, r, L, R, x); 
	seg[u] = std::min(seg[u << 1], seg[u << 1 | 1]); 
}
data query(int u, int l, int r, int L, int R)
{
	if (L <= l && r <= R)
		return seg[u]; 
	push_down(u); 
	int m = l + r >> 1; 
	if (R <= m)
		return query(u << 1, l, m, L, R); 
	if (m < L)
		return query(u << 1 | 1, m + 1, r, L, R); 
	return std::min(query(u << 1, l, m, L, R), query(u << 1 | 1, m + 1, r, L, R)); 
}
int main()
{
	// freopen("CF17-ex-B.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i); 
		app[i] = arr[i]; 
	}
	std::sort(app, app + n); 
	int cnt = std::unique(app, app + n) - app;
	build(1, 0, cnt - 1); 
	long long ans = 0; 
	for (int i = 0; i < n; i++)
	{
		int pos = std::lower_bound(app, app + cnt, arr[i]) - app; 
		auto res = query(1, 0, cnt - 1, pos, cnt - 1); 
		ans += res.mn - arr[i]; 
		if (res.pos)
			modify(1, 0, cnt - 1, 0, res.pos - 1, 1); 
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	long long int A0, B0, C0, K;

	cin >> A0 >> B0 >> C0 >> K;

	if (K % 2 != 0)
		cout << B0 - A0;
	else
		cout << A0 - B0;
	return 0;

}

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

using usize = ::std::size_t;
using u64 = ::std::uint_least64_t;

int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    u64 H, W, K;
    cin >> H >> W >> K;
    
    vector<vector<char>> grid(H, vector<char>(K));
    
    u64 cases = 0;
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
        }
    }
    
    for (int i = 0; i < (1 << H); i++) {
        for (int j = 0; j < (1 << W); j++) {
            u64 cnt = 0;
            for (int ii = 0; ii < H; ii++) {
                for (int jj = 0; jj < W; jj++) {
                    if (i & (1 << ii) || j & (1 << jj)) {
                        continue;
                    }
                    if (grid[ii][jj] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == K) {
                cases++;
            }
        }
    }
    
    cout << cases << endl;
    
    
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int A, B, C, X, Y, mi = 0x3f3f3f3f;
int main() {
	read(A), read(B), read(C), read(X), read(Y);
	for (int i = 0; i <= 2*max(X, Y); i++)
		mi = min(mi, A*max(X-i/2, 0)+B*max(Y-i/2, 0)+C*i);
	return printf("%d\n", mi), 0;
}


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

int main() {
    int n; cin >> n;
    long long front = 0;
    vector<int> A(n + 1);
    vector<int> B(n);
    for (int i = 0; i < n + 1; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> B[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        if (A[i] <= B[i])
        {
            B[i] -= A[i];
            front += A[i];
            A[i] = 0;
            if (A[i + 1] <= B[i])
            {
                B[i] -= A[i + 1];
                front += A[i + 1];
                A[i + 1] = 0;
            }
            else
            {
                A[i + 1] -= B[i];
                front += B[i];
                B[i] = 0;
            }
            
        }
        else
        {
            A[i] -= B[i];
            front += B[i];
            B[i] = 0;
        }
        
        
    }
    cout << front << endl;
}


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

using namespace std;

typedef pair<int,int> P;

int main(){
  int N, M, d, p;

  while(cin >> N >> M, (N | M)){
    vector<P> vec;
    for(int i = 0 ; i < N ; i++){
      cin >> d >> p;
      vec.push_back(P(-p,d));
    }
  
    int res = 0;
    sort(vec.begin(),vec.end());
    for(int i = 0 ; i < N ; i++){
      P now = vec[i];
      if(M-now.second >= 0){
        M -= now.second;
      }else{
        if(M){
          now.second -= M;
          M = 0;
        }
        res += now.second*(-now.first);
      }
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1328
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, T = mi()
Ts = list(mi())

ans = T * N + T
prev = 0
for t in Ts:
  #無駄にした時間
  ans -= max(0, T-(t-prev))
  prev = t

print(ans)



Measured memory_bytes: 78064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int N; cin >> N;
    Int ans = 0;
    auto f = [&](Int k) {
        if (k == 1) return;
        Int t = N;
        while (t % k == 0) t /= k;
        if (t % k == 1) ans++;
    };
    for (Int k = 1; k * k <= N; k++) {
        if (N % k == 0) {
            f(k);
            if (k != N / k) f(N / k);
        }
    }
    for (Int k = 1; k * k <= N - 1; k++) {
        if ((N - 1) % k == 0) {
            f(k);
            if (k != (N - 1) / k) f((N - 1) / k);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  ll N,M,V,P;
  cin >> N >> M >> V >> P;
  vector<ll> v(N);
  rep(i,N) cin >> v[i];
  sort(all(v));
  vector<ll> S(N-P+2);
  S[0]=0;
  for(int i=0;i<=N-P;i++){
    S[i+1]=S[i]+v[i];
  }
  ll ans=0;
  for(int i=0;i<=N-P;i++){
    if(v[i]+M>=v[N-P]&&((v[i]+M)*((N-P+1)-i)+M*i)-(S[N-P+1]-S[i])>=M*V-M*(P-1)){
      ans=i;
      break;
    }
  }
  cout << N-ans << endl;
}

Measured memory_bytes: 1792
/* ****revpro**** */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll m[2],d[2];
		cin>>m[0]>>d[0]>>m[1]>>d[1];
		cout<<(m[0]!=m[1]);
	}
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int n;
ll a[3*int(1e5)];
vector<int> graph[3*int(1e5)];
vector<ll> lis(3*int(1e5));
int ans[3*int(1e5)];
void dfs(int now){
  for(int i=0;i<graph[now].size();i++){
    int next = graph[now][i];
    if(ans[next] != -1) continue;
    auto itr = lower_bound(lis.begin(),lis.end(),a[next]);
    int bv = *itr;
    int index = itr - lis.begin();
    lis[index] = a[next];
    auto temp = lower_bound(lis.begin(),lis.end(),MOD);
    ans[next] = (temp - lis.begin())-1;
    dfs(next);
    lis[index] = bv;
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> a[i];
  int u,v;
  for(int i=0;i<n-1;i++){
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  for(int i=0;i<3*int(1e5);i++) lis[i] = MOD;
  for(int i=0;i<n;i++) ans[i] = -1;
  ans[0] = 1;
  lis[0] = -1*MOD;
  lis[1] = a[0];
  dfs(0);
  for(int i=0;i<n;i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 32600
#include <bits/stdc++.h>
using namespace std;
bool tree[100][100];
int main() {
    int N;
    while(scanf("%d",&N),N) {
        int W,H;
        scanf("%d %d",&W,&H);
        memset(tree,0,sizeof(tree));
        for(int i=0;i<N;i++) {
            int x,y;
            scanf("%d %d",&x,&y);
            tree[x][y]=1;
        }
        int S,T;
        scanf("%d %d",&S,&T);
        int max_sum=0;
        for(int i=1;i<=W-S+1;i++) {
            for(int j=1;j<=H-T+1;j++) {
                int sum=0;
                for(int k=0;k<S;k++) {
                    for(int l=0;l<T;l++) {
                        sum+=tree[i+k][j+l];
                    }
                }
                max_sum=max(max_sum,sum);
            }
        }
        printf("%d\n",max_sum);
    } 
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,m;
deque<ll> G[300000],p;
bool used[300000];
int main(){
	cin >> n >> m;
	REP(i,m) {
		ll a,b;
		cin >> a >> b;
		a--;b--;
		G[a].pb(b);G[b].pb(a);
	}

	p.pb(0);p.pb(G[0][0]);
	used[0] = used[G[0][0]] = true;

	while(true) {
		bool ff = true;
		ll v = p[0];
		REP(i,G[v].size()) {
			if(!used[G[v][i]]) {
				used[G[v][i]] = true;
				ff = false;
				p.push_front(G[v][i]);
				break;
			}
		}
		bool fe = true;
		v = p[p.size() - 1];
		REP(i,G[v].size()) {
			if(!used[G[v][i]]) {
				used[G[v][i]] = true;
				fe = false;
				p.push_back(G[v][i]);
				break;
			}
		}
		if(ff && fe) {
			break;
		}
	}
	cout << p.size() << endl;
	REP(i,p.size()){
		cout << p[i] + 1 << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 203264
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var kx = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var k = kx[0];
        var px = kx[1];

        var s = Math.Max(px - k + 1, -(int)1e6);
        Console.WriteLine(string.Join(" ", E.Range(s, k * 2 - 1)));
    }
}


Measured memory_bytes: 13396
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<Pair> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i].first >> A[i].second;
  }
  map<Pair, int64_t> counts;
  sort(A.begin(), A.end());
  for (int64_t i = 0; i < N; ++i) {
    for (int64_t j = i + 1; j < N; ++j) {
      const Pair d = Pair(A[j].first - A[i].first, A[j].second - A[i].second);
      if (counts.find(d) == counts.end()) {
        counts[d] = 1;
      } else {
        ++counts[d];
      }
    }
  }
  int64_t max_count = 0;
  for (const auto count_p : counts) {
    if (count_p.second > max_count) {
      max_count = count_p.second;
    }
  }
  int64_t result = N - max_count;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#define MAX 10

int cmp(const void *, const void *);

int main(void) {
    int i, ary[MAX];
    for(i = 0; i < MAX; i++) {
        scanf("%d", &ary[i]);
    }
    qsort((void *)ary, MAX, sizeof(int), cmp);
    for(i = 0; i < 3; printf("%d\n", ary[i++]));
    return 0;
}

int cmp(const void *x, const void *y) {
    return *(int *)y - *(int *)x;
}

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

int main(){
  int K , X;
  cin >> K >> X;
  int N , start; //startは開始位置
  N = (K * 2) - 1;
  start = X - K + 1;
  
  for(int i = 0; i < N; i++){
    cout << start + i;
    if(i < N - 1 ){
      cout << " ";
    }
  }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll a, b, c,i;
char s[1010];
int main(){
    scanf("%lld%s", &a,s);
    fornum(i,0,a){
        if(s[i]=='R'){
            b++;
        }
    }
    printf("%s", b > a - b ? "Yes" : "No");
    return 0;
}

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

class calc{
  string s;
  string::iterator it;

public:
  calc(const string&str){
    s = str;
    it = s.begin();
  }

  int fact(){
    if(*it == '('){
      ++it;
      int ret = exp();
      ++it;
      return ret;
    }
    else{
      int ret = 0;
      while('0' <= *it && *it <= '9'){
	ret *= 10;
	ret += *it - '0';
	++it;
      }
      return ret;
    }
  }

  int term(){
    int ret = fact();
    while(*it == '*' || *it == '/'){
      if(*it == '*'){
	++it;
	ret *= fact();
      }
      else if(*it == '/'){
	++it;
	ret /= fact();
      }
    }
    return ret;
  }
  
  int exp(){
    int ret = term();

    while(*it == '+' || *it == '-'){
      if(*it == '+'){
	++it;
	ret += term();
      }
      else if(*it == '-'){
	++it;
	ret -= term();
      }
    }
    return ret;
  }
};

int main(){
  string str;
  int n;

  cin >> n;
  while(n--){
    cin >> str;
    calc ans(str);
    cout << ans.exp() << endl;
  }

  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll a; cin >> a;
  if(a>=30)cout<<"Yes";
  else cout <<"No";
}

Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val s = readLine() ?: return
    val keyence = "keyence"
    if (s == keyence) {
        println("YES")
        return
    }
    if (s.indexOf(keyence) == 0) {
        println("YES")
        return
    }
    if (s.indexOf(keyence) == s.length - keyence.length) {
        println("YES")
        return
    }
    1.until(7).forEach {
        val a = keyence.take(it)
        val b = keyence.drop(it)
        if (s.indexOf(a) == 0 && s.lastIndexOf(b) == s.length - b.length) {
            println("YES")
            return
        }
    }
    println("NO")
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int k[12], s[12][12];
    int d[12][12];
    for(int i = 0; i < 12; i++){
        fill(d[i], d[i] + 12, 0);
    }
    for(int i = 0; i < m; i++){
        cin >> k[i];
        for(int j = 0; j < k[i]; j++){
            cin >> s[i][j];
            s[i][j]--;
            d[s[i][j]][i] = 1;
        }
    }
    int p[12];
    for(int i = 0; i < m; i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        int a[12] {0};
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                for(int j = 0; j < m; j++){
                    a[j] = (a[j] + d[i][j]) % 2;
                }
            }
        }
        bool f = true;
        for(int j = 0; j < m; j++){
            if(a[j] != p[j]) f = false;
        }
        if(f) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	n=(n%10);
	if(n==3)
	cout<<"bon"<<endl;
	else if(n==0 || n==1 || n==6 || n==8)
	cout<<"pon"<<endl;
	else cout<<"hon"<<endl;

	return 0;
}


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

int main()
{
    array<array<int, 3>, 3> c;
    for(auto& v: c) for(auto& e: v) cin>>e;

    for(int i=0; i<3; ++i) for(int j=0; j<3; ++j) for(int k=0; k<3; ++k)
        if (c[k][i]-c[k][j]!=c[0][i]-c[0][j])
            return !printf("No\n");
    puts("Yes");
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
    int h, w;
    
    while(scanf("%d %d", &h, &w), h > 0 && w > 0){
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                putchar(i == 0 || j == 0 || i == h - 1 || j == w - 1 ? '#' : '.');
            }
            
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_156b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] number = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            List<int> S = new List<int>();
            while(number[0] > number[1] || number[0] == number[1])
            {
                S.Add(number[0] % number[1]);

                number[0] = number[0] / number[1];
            }
            
            Console.WriteLine(S.Count + 1);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
/*
　　　　　 　 _... ..._
　　　　　 , ´⌒ ⌒ヽ
　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
　　　　　　△ﾑ,8ﾑﾌつ
　　　　　/(ﾝ_/＿ヽ＼
　　　　 ～～i_ﾌ_ﾌ～´
*/
	int n, q;
	ll ans = 0;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>start(q);
	vector<int>end(q);
	vector<ll>count(n + 1);
	count[0] = 0;
	count[1] = 0;
	rep0(i, q - 1) {
		scanf("%lld%lld", &start[i], &end[i]);
	}
	REP(2, s.length()) {
		if (s[i - 2] == 'A' && s[i - 1] == 'C') {
			ans++;
		}
		count[i] = ans;

	}
	rep0(k, q - 1) {
		printf("%lld\n", count[end[k]] - count[start[k]]);
	}
	return 0;
} 


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

using namespace std;

int main() {
	string S;
	cin >> S;
	long long int ans = 0;
	for( size_t i = 1; i < S.size(); i++ ) {
		if( S[i] != S[i - 1] ) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1020
l_a = []
l_ab = []
l_b = []
l = []

N = int(input())
A, B = map(int, input().split())
inputs = input().split()

for i in inputs:
    if(int(i) <= A):
        l_a.append(i)
    elif(int(i) >= A + 1 and int(i) <= B):
        l_ab.append(i)
    elif(int(i) >= B + 1):
        l_b.append(i)

l.append(len(l_a))
l.append(len(l_ab))
l.append(len(l_b))

print(min(l))

Measured memory_bytes: 3064
#include<bits//stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef pair< int , int > Pt;
const int dx[] = { 0, 1, -1, 0}, dy[] = { 1, 0, 0, -1};
int w, h, cost[30][30];
bool mas[30][30][30][30];
int bfs(){
  fill_n(cost[0],900,0);
  queue<Pt> que;cost[0][0] = 1;
  que.push(Pt(0,0));
  while(!que.empty()){
    Pt p = que.front(); que.pop();
    if(p.fr == h - 1 && p.sc == w - 1) break;
    for(int i = 0 ; i < 4 ; i++ ){
      int ny = p.fr + dy[i], nx = p.sc + dx[i];
      if(ny >= 0 && ny < h && nx >= 0 && nx < w && !cost[ny][nx] && !mas[p.fr][p.sc][ny][nx]  && !mas[ny][nx][p.fr][p.sc]){
        cost[ny][nx] = cost[p.fr][p.sc] + 1;
        que.push(Pt(ny,nx));
      }
    }
  }return cost[h-1][w-1];
}
int main(){
  while(cin >> w >> h , w){
    for(int i = 0 ; i < 2 * h - 1 ; i++ ){
      if(i % 2)
        for(int j = 0 ; j < w ; j++ ) cin >> mas[i/2][j][i/2+1][j];
      else
        for(int j = 0 ; j < w - 1 ; j++ ) cin >> mas[i/2][j][i/2][j+1];
    }cout << bfs() << endl;
  }
}


Measured memory_bytes: 3948
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

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

void solve()
{
    int A , B ;
    cin >> A >> B ;
    cout << A * B ;
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstring>

using namespace std;

const int MAXN = 1e5 + 10 ;
int n,a,x=-1,zb,l[MAXN][3],memo[MAXN][3];
bool flag = true;

int dp(int m,int x){
    if(m==n-1)
        return l[m][x];
    if(memo[m][x] != l[m][x])
        return memo[m][x];
    int mx = 0;
    for(int i=0;i<3;i++){
        if(memo[m+1][i] == l[m+1][i])
            memo[m+1][i] = dp(m+1,i);
        if(mx < memo[m+1][i] && i != x){
            mx = memo[m+1][i];
        }
    }
    return memo[m][x] += mx;
}

int main (){
    cin >> n;
    memset(memo,-1,MAXN);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> l[i][j];
            memo[i][j] = l[i][j];
        }
    }
    int MX = 0;
    for(int i=0;i<n;i++){
        if(dp(0,i) > MX)
            MX = memo[0][i];
    }
    cout<<MX;
    return 0;
}


Measured memory_bytes: 10368
n = int(input())
x = list(map(int, input().split()))
xmin = min(x)
xmax = max(x)
hp = 10e10
for p in range(xmin, xmax+1):
    temp = 0
    for xi in x:
        temp += (xi-p)*(xi-p)
    hp = min(temp, hp)
print(hp)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>

using namespace std;

int main(void){
	
	int d;
	
	cin>>d;
	
	cout<<"Christmas";
	
	for(int k=0;k<25-d;k++){
		cout<<" Eve";
		}
	cout<<endl;
		
	
	return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    if(N == 1) {
        cout << "YES";
        return 0;
    }
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];

    int odd = 0;
    for(int i = 0; i < N; i++)
        if(A[i] % 2) odd++;

    if(odd % 2)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
	public static void main(String[] args) {
		
		FastReader sc = new FastReader();
	 long l = sc.nextLong();
	 long r = sc.nextLong();
	 if(l<=2019 && r>=2019) out.println(0);
	 else {

	
	 long min = ((l%2019)*(r%2019))%2019;
	 for(long i=l;i<=Math.min(l+2019, r);++i) {
		 for(long j=i+1;j<=Math.min(l+2019, r);++j) {
			 long temp = ((i%2019)*(j%2019))%2019;
			 min = Math.min(min,temp);
			
		 }
		 
	 }
	 out.println(min);
	 
	 }	out.close();
		
	}
	
}

Measured memory_bytes: 22100
from random import randint
D = int(input())
C = [int(T) for T in input().split()]
S = [[] for TD in range(0,D)]
for TD in range(0,D):
    S[TD] = [int(T) for T in input().split()]
SatM = 0
TesM = [1]*D
for TV in range(0,1000):
    Type = 26
    Last = [0]*Type
    SatS = 0
    Test = [randint(1,26) for TD in range(0,D)]
    for TD in range(0,D):
        Last[Test[TD]-1] = TD+1
        SatS += S[TD][Test[TD]-1]
        for TC in range(0,Type):
            SatS -= C[TC]*(TD+1-Last[TC])
    if SatS>SatM:
        SatM = SatS
        TesM = Test
print('\n'.join(str(TD) for TD in TesM))

Measured memory_bytes: 78884
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int L, now=1, count=0, d=1;
  std::cin >> L;
  while(now<=L) count++, now*=2;
  count--, now/=2;
  vvi ans = vv(0, 3, 0, int);
  for(int i=0;i<count;i++){
    ans.push_back(std::vector<int> {i+1, i+2, d});
    ans.push_back(std::vector<int> {i+1, i+2, 0});
    d*=2;
  }
  for(int i=count-1;i>=0;i--){
    if((L-(1<<i))>=(1<<count)){
      ans.push_back(std::vector<int> {i+1, count+1, L-(1<<i)});
      L-=(1<<i);
    }
  }
  std::cout << count+1 << " " << ans.size() << '\n';
  for(int i=0;i<ans.size();i++) std::cout << ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  if(n == 0) {
    cout << 0 << endl;
    return 0;
  }
  vl v(62, 0);
  rep(i, 62) v[i] = pow(2, i);
  ll now = 0;
  vl ans(62, 0);
  ll i = 0;
  if(n < 0) {
    n = abs(n);
    i = 1;
  }
  for(; now < n; i += 2) {
    now += v[i];
    ans[i] = 1;
  }
  for(; i >= 0; i--) {
    if(now - v[i] >= n) {
      now -= v[i];
      ans[i] = 1 - ans[i];
    }
  }
  reverse(all(ans));
  bool ok = false;
  rep(i, 62) {
    if(ans[i] == 1) ok = true;
    if(ok) cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0

for i in range(n):
    s += b[a[i] - 1]
    if i < n - 1:
        if a[i] + 1 == a[i+1]:
            s += c[a[i]-1]
print(s)


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

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }
    vector<int> ord(N);
    iota(ord.begin(), ord.end(), 0);
    double ans = 0;
    int num = 0;
    do {
        double sum = 0;
        for (int i = 0; i < N - 1; ++i) {
            int v = ord[i + 1], u = ord[i];
            sum += hypot(x[v] - x[u], y[v] - y[u]);
        }
        ans += sum;
        num++;
    } while (next_permutation(ord.begin(), ord.end()));
    ans /= num;
    cout << fixed << setprecision(10) << ans << endl;
}

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

int main()
{
    int n, d, x, ans;
    cin >> n >> d >> x;
    ans = x;
    while(n--){
        int tmp;
        cin >> tmp;
        ans += ((d-1)/tmp +1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] arg){
	Scanner sc= new Scanner(System.in);
	int n=sc.nextInt();
	int i=1;
	do { 
	    int x = i; 
	   if (x % 3 == 0) { 
		    System.out.print(" " + i); 
	   } else{
	       do{
		   if (x % 10 == 3){
		       System.out.print(" "+i);
		       break;
		   }
		   x/=10; 
	       }while(x!=0);
	}
	}	while (++i <= n);
 System.out.println();



    }
}

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

int main(){
    int N;
    cin >> N;
    int W[N];
    for(int i = 0;i < N;++i){
        int w;
        cin >> w;
        W[i] = w;
    }
    int S1 = W[0];
    int S2 = 0;
    for(int i = 1;i < N;++i){
        S2 += W[i];
    }
    int Diff = abs(S1-S2); 
    for(int i = 1;i < N-1;++i){
        S1 += W[i];
        S2 -= W[i];
        Diff = min(abs(S1-S2), Diff);
    }
    cout << Diff << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
//HASFJGHOGAKZZFEGA
//ASFJG HOGAK ZZ

int main(){
	
	int s = 0, g = 0;
	string str;
	cin >> str;

	for(int d = 0; d < str.length(); d++){
		//cout << str[d] << endl;
		if(str[d] == 'A') {
			s = d;
			break;
		}
	}
	for(int d = str.length()-1; d > 0; d--){
		if(str[d] == 'Z') {
			g = d;
			break;
		}
	}
	//cout << g << endl;
	//cout << s << endl;
	cout << g-s+1 << endl;
	
	return 0;
}

Measured memory_bytes: 768
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
P = LF()

# dp[i][j]: i番目のコインまで投げた時，j枚のコインが表になる確率
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1

# 調和級数
# O(NlogN)
for i in range(n):
    for j in range(i + 1):
        if dp[i][j] == 0:
            continue
        # P[i]が裏
        dp[i + 1][j] += dp[i][j] * (1 - P[i])
        # P[i]が表
        dp[i + 1][j + 1] += dp[i][j] * P[i]

print(sum(dp[n][n // 2 + 1:]))


Measured memory_bytes: 255496
#include<iostream>
#include<vector>
#include<string>

int main(){
    int N, D;
    std::cin >> N >> D;
    int now = D;
    int cnt = 1;
    while(1){
        if(now + D >= N - 1) break;
        now += 2 * D + 1;
        cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}


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

using namespace std;

int main(){
  
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  char a, b, c;
  a = s1[0] - 32;
  b = s2[0] - 32;
  c = s3[0] - 32;

  cout << a << b << c << endl;

}

Measured memory_bytes: 256
R = range(100)
M = [[2,5,2,2,2][i%5] for i in R]
Out = [-1] *100
P = [-1]*100
S = [-1]*17
Q = []
W = [0]*100

def stand(I, s):
  n = M[I]
  P[I] = -1
  S[s:s+n] = [-1] * n
  Out[I] = -1
  return 1

def sit(I, s):
  n = M[I]
  P[I] = s
  S[s:s+n] = [I] * n
  Out[I] = t+ 17*(I%2)+3*(I%3)+19
  W[I] = t - I*5
  return

def check(I):
  n = M[I]
  for s in range(17-n+1):
    if S[s:s+n] == [-1]*n: return s
  return -1

t = 0
c = 0
while c<100:
  while t in Out:
    I = Out.index(t)
    c += stand(I, P[I])

  if t<500 and t%5==0: Q.append(t/5)
 
  while len(Q)>0:
    s = check(Q[0])
    if s==-1: break
    sit(Q.pop(0), s)
  t += 1

while 1:
  try: print W[int(raw_input())]
  except: break

Measured memory_bytes: 4320
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	s := ""
	base := 1
	mod := 2
	for N != 0 {
		if N%mod != 0 {
			s = "1" + s
			N -= base
		} else {
			s = "0" + s
		}
		base *= -2
		mod *= 2
	}
	if s == "" {
		s = "0"
	}
	fmt.Println(s)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main() {
  int n;
  cin >> n;
  long a[n][n], s(0);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      cin >> a[i][j];
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      bool nf(true);
      for (int k = 0; k < n; ++k) {
        if (i == k || j == k) continue;
        if (a[i][j] > a[i][k] + a[k][j]) {
          cout << -1;
          return 0;
        }
        if (a[i][j] == a[i][k] + a[k][j]) nf = false;
        
      }
      if (nf) s += a[i][j];
    }
      
  cout << s << endl;
  return 0;
}

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

typedef struct{
  int x; //?¨????
  int y; //??????
}rect;

int area(rect r){
  return r.x*r.y;
}

int main(){
  while (1) {
    int n,w,h;
    cin >> n >> w >>h;
    if(n==0 && w==0 && h==0) break;

    vector<rect> v;
    v.resize(1);
    v[0].x=w;
    v[0].y=h;
    for(int i=0; i<n; ++i){
      int p,s;
      scanf(" %d %d", &p, &s);
      p--; //0-index???????????????

      //??????????????¢?????¨???
      rect f=v[p];

      //????????¢???1??¨??\???????????????????§?
      s%=(f.x+f.y)*2;

      //??????????????¢?????????????¨??????????????????¨???
      //?§?????????¢????¨???????????¨???????
      //??????????????????????????\???????????°???
      rect r1,r2;
      if(s-f.x<0){ //?????????
        //2??????????????¢?????????f.y????¨?s??¨f.x-s?????????
        r1.x=s; r1.y=f.y;
        r2.x=f.x-s; r2.y=f.y;
      }
      else if(s-f.x-f.y<0){ //?????????
        //2??????????????¢?????????s-f.x??¨f.y-(s-f.x)????¨?f,x?????????
        r1.x=f.x; r1.y=s-f.x;
        r2.x=f.x; r2.y=f.y-(s-f.x);
      }
      else if(s-f.x-f.y-f.x<0){ //?????????
        //2??????????????¢?????????f.y????¨?s-f.x-f.y??¨f.x-(s-f.x-f.y)?????????
        r1.x=s-f.x-f.y; r1.y=f.y;
        r2.x=f.x-(s-f.x-f.y); r2.y=f.y;
      }
      else{ //?????????
        //2??????????????¢?????????s-2*f.x-f.y??¨f.y-(s-2*f.x-f.y)????¨?f,x?????????
        r1.x=f.x; r1.y=s-2*f.x-f.y;
        r2.x=f.x; r2.y=f.y-(s-2*f.x-f.y);
      }

      //printf("cut (%d*%d) and (%d*%d)\n", r1.x, r1.y, r2.x, r2.y);

      //??????????????¢????????????????????????????????????????????§??????
      v.erase(v.begin()+p);
      //???????????°??????2??????????????¢??????????????\
      if(area(r1)<area(r2)){
        v.push_back(r1);
        v.push_back(r2);
      }else{
        v.push_back(r2);
        v.push_back(r1);
      }

    }

    vector<int> ans;
    for(int i=0; i<v.size(); ++i){
      ans.push_back(area(v[i]));
    }
    sort(ans.begin(), ans.end());

    for(int i=0; i<ans.size(); ++i){
      if(i) printf(" ");
      printf("%d", ans[i]);
    }
    printf("\n");
  }
}

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	int MIN=1000;
	int MAX=0;
	for (int i=0; i<N; i++) {
		int a;
		cin >>a;
		MIN=min(MIN, a);
		MAX=max(MAX, a);
	}
	cout <<MAX-MIN <<endl;
	return 0;
}



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

void insertionSort(int *A, int n, int g);
void shellSort(int *A, int n);

unsigned long long cnt = 0ULL;

int main(void) {
	
	int n;
	int *A;
	int i;
	
	scanf("%d", &n);
	
	A = (int*)malloc(n * sizeof(int));
	
	for (i = 0; i < n; i++) {
		scanf("%d", A + i);
	}
	
	shellSort(A, n);
	
	for (i = 0; i < n; i++) {
		printf("%d\n", A[i]);
	}
	
	free(A);
	
	return 0;
}

void insertionSort(int *A, int n, int g) {
	int i, j, v;
	for (i = g; i < n; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int *A, int n) {
	int m = 1, g;
	int i;
	int *G = (int*)malloc(101 * sizeof(int));
	G[0] = 1;
	for (i = 0; i < 100 && G[i] < n; i++) {
		G[i + 1] = 3 * G[i] + 1;
	}
	if (i > 0) {
		m = i;
	}
	cnt = 0ULL;
	printf("%d\n", m);
	for (i = 0; i < m; i++) {
		g = G[(m - 1) - i];
		if (i > 0) {
			putchar(' ');
		}
		printf("%d", g);
		insertionSort(A, n, g);
	}
	putchar('\n');
	printf("%llu\n", cnt);
	free(G);
}

Measured memory_bytes: 4252
import java.util.Scanner;

public class Main {

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

		for(int k=0;k<10000000;k++){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			int p[] = new int[n];
			for(i=0;i<n;i++){
				p[i]=sc.nextInt();
			}
			for(i=0;i<n;i++){
				if(i==0){
					if(n==1){
					System.out.print(p[0]+"\n");
					}else{
						System.out.print(p[0]);
					}
				}else if(i==n-1){
					if(p[i]-1==p[i-1]){
						System.out.print("-"+p[i]+"\n");
					}else{
						System.out.print(" "+p[i]+"\n");
					}
				}else{
					if(p[i]-1!=p[i-1]){
						System.out.print(" "+p[i]);
					}
					if(p[i]-1==p[i-1]&&p[i]+1!=p[i+1]){
						System.out.print("-"+p[i]);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 34620
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		if(n%2 == 1 && k%2 == 1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
bool isYY(char a, char b) {
  return ('0' <= a && a <= '9') && ('0' <= b && b <= '9');
}
bool isMM(char a, char b) {
  if (a == '0') {
    return '1' <= b && b <= '9';
  } else if (a == '1') {
    return '0' <= b && b <= '2';
  }
  return 0;
}

int main() {
  string S;
  cin >> S;
  bool maeYY = isYY(S[0], S[1]);
  bool maeMM = isMM(S[0], S[1]);
  bool usiYY = isYY(S[2], S[3]);
  bool usiMM = isMM(S[2], S[3]);

  bool YYMM=0, MMYY=0;

  if(maeYY && usiMM){
    YYMM=1;
  }
  if(maeMM && usiYY){
    MMYY=1;
  }
  DUMP(YYMM, MMYY);
  if(YYMM&& !MMYY){
    cout<<"YYMM";
  }else if(!YYMM && MMYY){
    cout<<"MMYY";
  }else if(YYMM && MMYY){
    cout<<"AMBIGUOUS";
  }else{
    cout<<"NA";
  }
  cout<<endl;
}


Measured memory_bytes: 256