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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int H,W,K,A,B,C,D;
  cin>>H>>W>>K>>A>>B>>C>>D;
  A--;
  B--;
  C--;
  D--;
  vector<string> g(H);
  for(int i = 0; i < H; i++) cin>>g[i];
  vector<vector<int>> d(H,vector<int>(W,-1));
  queue<tuple<int,int,int>> bfs;
  bfs.push(make_tuple(A,B,-1));
  d[A][B]=0;
  while(!bfs.empty()&&d[C][D]==-1){
    tuple<int,int,int> p = bfs.front();
    bfs.pop();
    if(get<2>(p)!=1){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p)+i;
      int ny = get<1>(p);
      if(nx>=H) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1&&d[nx][ny]<=d[get<0>(p)][get<1>(p)]) break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,0));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
    if(get<2>(p)!=0){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p)-i;
      int ny = get<1>(p);
      if(nx<0) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1&&d[nx][ny]<=d[get<0>(p)][get<1>(p)]) break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,1));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
    if(get<2>(p)!=3){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p);
      int ny = get<1>(p)+i;
      if(ny>=W) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1&&d[nx][ny]<=d[get<0>(p)][get<1>(p)]) break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,2));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
    if(get<2>(p)!=2){
    for(int i = 1; i <= K; i++){
      int nx = get<0>(p);
      int ny = get<1>(p)-i;
      if(ny<0) break;
      if(g[nx][ny]=='@') break;
      if(d[nx][ny]!=-1&&d[nx][ny]<=d[get<0>(p)][get<1>(p)]) break;
      if(d[nx][ny]!=-1) continue;
      bfs.push(make_tuple(nx,ny,3));
      d[nx][ny]=d[get<0>(p)][get<1>(p)]+1;
    }
    }
  }
  cout<<d[C][D]<<endl;
}


Measured memory_bytes: 12144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string>
#include <sstream>
#include  <list>
//#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
/*
int cmp(shi a,shi b)
{
    return a.x<b.x;
}
long long cmd(long long a, long long  b)
{
    return a > b;
}*/

int cmd(int a, int b)
{
    return abs(a)<abs(b);
}
int main()
{
    string s;
    while(cin >>s){
        int falg=1,sum=0;
        int len =s.length();
        for(int i=0;i<len;i++){
                if(s.find(s[i],i+1)!=-1)
                {
                    cout<<"no"<<endl;
                    break;
                }
                else sum++;

        }
        if(sum==len)
            cout<<"yes"<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;

long long n,m;
long long islands[100010];//島名　(親の島の個数)
int par[100010];//親
int path[100010][2];
long long ucv[100010];
int root(int x){
	if(x==par[x])
		return x;
	return par[x]=root(par[x]);
}
long long unite(int x,int y){
	int tx=root(x);
	int ty=root(y);
	if(tx==ty)return 0;
	par[tx]=ty;
	islands[ty]+=islands[tx];
	return islands[tx]*(islands[ty]-islands[tx]);
}



int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>path[i][0]>>path[i][1];
	}
	for(int i=1;i<=n;i++)
	{
		islands[i]=1;
		par[i]=i;
	}
	ucv[m]=(n*(n-1))/2;
	for(int i=0;i<m-1;i++)
	{
		ucv[m-i-1]=ucv[m-i]-unite(path[m-1-i][0],path[m-1-i][1]);
	}
	for(int i=1;i<=m;i++)
	{
		cout<<ucv[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4096
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int n;
	
	cin >> n;

	int a[n+2];

	a[0] = 0;

	int total = 0;

	rep(i, n)
	{
		cin >> a[i+1];
		total += abs(a[i+1] - a[i]);
	}
	a[n+1] = 0;
	total += abs(a[n+1] - a[n]);
	rep(i, n)
	{
		cout << (total + abs(a[i+2] - a[i]) - abs(a[i+2]-a[i+1]) - abs(a[i+1]-a[i])) << endl;
	}

	
	return 0;
}


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

int main(){
  int n,r=0; 
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }  
  sort(a.begin(),a.end());
  
  cout<<a[n/2]-a[n/2-1]<<endl;
}

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

int main()
{
    int N, M;
    int all = 0;
    cin >> N >> M;
    int a[101];
    for(int i = 0; i < N; ++i)
    {
        cin >> a[i];
        all += a[i];
    }
    int count = M;
    for(int i = 0; i < N; ++i)
    {
        if(a[i] * 4 * M >= all)
        {
            --count;
            if(count == 0)
            break;
        }            

    }
    if(count == 0)
        cout << "Yes";
    else
        cout << "No";
}

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

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
typedef std::pair <ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll r;
    cin >> r;
    cout << 3* r * r;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x,long long int y) {
	return(x + y-1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	char a1,a2;
	int year, month, day;
	cin >> year >> a1 >> month >> a2 >> day;
	if (year < 2019) {
		cout << "Heisei";
		return 0;
	}
	if ((year == 2019) && (month < 4)) {
		cout << "Heisei";
		return 0;
	}
	if ((year == 2019) && (month == 4)&&(day<=30)) {
		cout << "Heisei";
		return 0;
	}
	cout << "TBD";

}

Measured memory_bytes: 256
import time
st = time.time()

d = int(input())
clist = list(map(int,input().split()))
last_c = [0]*26
select_c = [0]*26
for i in range(26):
    select_c[i] = []

slist = [0] * d
for i in range(d):
    slist[i] = list(map(int,input().split()))

tlist = [0]*d
satisfy = [0]*(d+1)

#貪欲法
for i in range(0,d):
    max = 0
    max_n = 0
    for n in range(26):
        if i > 0:
            curr = slist[i][n] + satisfy[i-1]
        else:
            curr = slist[i][n]
        minus = 0
        for j in range(26):
            if n != j:
                minus -= clist[j] * (i - last_c[j])
        curr += minus
        if curr > max:
            max = curr
            max_n = n
    satisfy[i] = max
    last_c[max_n] = i+1 
    select_c[max_n].append(i+1)
    tlist[i] = max_n+1

import random
import numpy as np

sum = 0
total_c = 0


for i in range(d):
    sum += slist[i][tlist[i]-1]

ct = time.time()

for i in range(len(select_c)):
    start = 1
    c_change = 0
    if select_c[i] == []:
        c_change = np.sum(np.arange(d+1))
    else:
        for j in range(len(select_c[i])):
            end = select_c[i][j]
            if end > start:
                c_change += np.sum(np.arange(end-start+1))
            start = end
        end = d+1
        c_change += np.sum(np.arange(end-start))
        start = end
    total_c += clist[i]*c_change

current_max = sum - total_c

try:

    import bisect
    while ct-st < 1.9:
        change_d = random.randint(1,d)
        change_d_to_c = random.randint(0,len(select_c)-1)
        for x in range(len(select_c)):
            try:
                ind = select_c[x].index(change_d)
                change = x
                s_change = slist[change_d-1][ind]
                select_c[x].remove(change_d)
                break
            except:
                None

        s_change2 = slist[change_d-1][change_d_to_c]

        bisect.insort(select_c[change_d_to_c],change_d)
        #calc
        sum2 = sum - s_change + s_change2
        total_c2 = 0
        for i in range(len(select_c)):
            start = 1
            c_change = 0
            if select_c[i] == []:
                c_change = np.sum(np.arange(d+1))
            else:
                for j in range(len(select_c[i])):
                    end = select_c[i][j]
                    if end > start:
                        c_change += np.sum(np.arange(end-start+1))
                    start = end
                end = d+1
                c_change += np.sum(np.arange(end-start))
                start = end
            total_c2 += clist[i]*c_change

        percent = random.random()
        if percent > 0.15 and sum - total_c < sum2 - total_c2:
            sum = sum2
            total_c = total_c2
            tlist[change_d-1] = change_d_to_c+1
        else:
            bisect.insort(select_c[change],change_d)
            select_c[change_d_to_c].remove(change_d)

        

        ct = time.time()
except:
    None
#remove first
for i in tlist:
    print(i)

Measured memory_bytes: 27476
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 403
using namespace std;

int n, a[N];
long long sum[N], f[N][N];

inline long long dp(int l, int r) {
    long long& res = f[l][r];
    if (res != -1) return res;
    if (l == r) return res = 0;
    if (l + 1 == r) return res = a[l] + a[r];
    res = 0x3f3f3f3f3f3f3f3fLL;
    for (int k = l; k <= r - 1; ++k)
        res = min(res, dp(l, k) + dp(k + 1, r));
    res += sum[r] - sum[l - 1]; 
    return res;
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    memset(f, -1, sizeof f);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i), sum[i] = sum[i - 1] + a[i];
    cout << dp(1, n);
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main()
{
    cin >> a >> b >> c;
    if (a == b && a != c || a == c && a != b || b == c && b != a)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

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

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

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        int r, g, b;
        int R, G, B;
        int n;
        int ans = 0;

        Scanner sc = new Scanner(System.in);

        r = sc.nextInt();
        g = sc.nextInt();
        b = sc.nextInt();
        n = sc.nextInt();

        for (R = 0; R <= 3000; R++) {
            for (G = 0; G <= 3000; G++) {
                int tmp = (n - R * r - G * g);

                if (tmp >= 0 && tmp % b == 0) {
                    ans++;
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

template <class T>
class SegmentTree {
    long long n; // 葉の数
    vector<T> data;  // データを格納する配列
    T def;  // 初期値（単位元）
    function<T(T, T)> operation;  // 区間クエリで使う処理
    function<T(T, T)> update;  // 点更新で使う処理

    T _query(long long a, long long b, long long k, long long l, long long r) {
        if (r <= a || b <= l) return def;
        if (a <= l && r <= b) return data[k];  // a,l,r,bの順で含まれる
        else {
            T c1 = _query(a, b, 2*k+1, l, (l+r)>>1);
            T c2 = _query(a, b, 2*k+2, (l+r)>>1, r);
            return operation(c1, c2);
        }
    }

public:
    SegmentTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
            n = 1;
            while (n < _n) n<<=1;
            data = vector<T>(2*n-1, def);
        }
    
    void change(long long i, T x) {
        i += n-1;
        data[i] = update(data[i], x);
        while (i>0) {
            i = (i-1)>>1;
            data[i] = operation(data[i*2+1], data[i*2+2]);
        }
    }

    T query(long long a, long long b) {
        return _query(a, b, 0, 0, n);
    }

    T operator[](long long i) {
        return data[i+n-1];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vll l(m), r(m), c(m);
    REP(i, m) {
        cin >> l[i] >> r[i] >> c[i];
        l[i]--;
    }

    SegmentTree<ll> seg(n, HIGHINF, 
        [&](ll i, ll j){ return min(i, j); },
        [&](ll i, ll j){ return min(i, j); });
    seg.change(0, 0);

    vll ord(m); iota(ALL(ord), 0LL);
    sort(ALL(ord), [&](ll i, ll j) {
        if (l[i] == l[j]) return r[i] < r[j];
        else return l[i] < l[j];
    });

    for (ll idx: ord) {
        ll tmp = seg.query(l[idx], r[idx]);
        seg.change(r[idx]-1, tmp + c[idx]);
    }
    
    if (seg[n-1] == HIGHINF) cout << -1 << '\n';
    else cout << seg[n-1] << '\n';
    return 0;
}


Measured memory_bytes: 5376
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

signed main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  rep(i, B) {
    rep(j, A) {
      cout << '0';
    }
    rep(j, W - A) {
      cout << '1';
    }
    cout << endl;
  }
  rep(i, H - B) {
    rep(j, A) {
      cout << '1';
    }
    rep(j, W - A) {
      cout << '0';
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([])
for i in range(c+1):
    s[-1].append(0)
for i in range(c):
    for j in range(r):
        s[r][i]+=s[j][i]
s[-1][-1]+=sum(s[r])
for i in s:
    print(*i)


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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

pll norm(ll x,ll y)
{
  ll g=__gcd(abs(x),abs(y));
  x/=g;
  y/=g;
  if(x<0)return mp(-x,-y);
  else return mp(x,y);
}


int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);


ll a,b;
cin>>a>>b;
ll x=(a+b);
if(x&1)x++;
cout<<x/2<<"\n";

return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
   long long int x,y;
   cin>>x>>y;

   int sum=0;
   long long int i=x;

   while(1){

       if(i>y){break;}
       else{
           sum++;
           i = i*2;
       }

   }
    cout<<sum<<endl;

    return 0;
}

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

namespace AtCoderPractice
{
    class NotDivisible
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int max = a.Max();
            int[] check = new int[max + 1];
            int count = 0;

            for (int i = 0;i<n;i++)
            {
                int j = 1;
                while (j*a[i] <= max)
                {
                    check[j * a[i]]++;
                    j++;
                }
            }

            foreach (var date in a)
            {
                if (check[date]==1) 
                {
                    count++;
                }
            }
            
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 47084
N,K,Q = map(int,input().split())
Seikai = [0 for i in range(N)]
for i in range(Q):
    tmp = int(input())
    Seikai[tmp-1] += 1
for i in range(N):
    ans = K-Q+Seikai[i]
    if ans<=0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 4672
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int x,y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int N = sc.nextInt();
		int A = sc.nextInt();
		String ans = "No";
		if (N % 500 <= A) {
			ans = "Yes";
		}

		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
data = []
tmp = []
for x in range(0,1000000):
    a,b = map(int, input().split())
    if a==0:
        if b==0:
            break
        pass
    data.append((a,b))
for x in range(0,len(data)):
    tmp = list(data.pop(0))
    tmp.sort()
    print(tmp[0],tmp[1])
    tmp.clear()


Measured memory_bytes: 8196
z[2002],*a=z,*b=z+1001,m,i,j,t;main(n){
	for(;scanf("%d",&n),i=n;printf("%d\n",m))
		for(memset(a,m=0,4004);i--;t=a,a=b,b=t)
			for(j=scanf(" ");j++<n;)
				m=fmax(m,b[j]=getchar()-'*'?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);
}

Measured memory_bytes: 0
n, q = map(int, input().split())
s = input()

# 'AC'の累積和を求める
d = [0]*n
for i in range(1, n):
    d[i] += d[i-1]
    if s[i-1] == 'A' and s[i] == 'C':
        d[i] += 1
        
lr = [list(map(int, input().split())) for _ in range(q)]
for l, r in lr:
    print(d[r-1] - d[l-1])

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

#define ll long long

int main()
{
    ll a,b,sum=0,c=1;
    cin>>a>>b;
    ll ar[a+5];
    for(ll i=0; i<a; i++)
        cin>>ar[i];
    for(ll i=0; i<a; i++)
    {
        sum+=ar[i];
        if(sum<=b)
            c++;
    }
    cout<<c<<endl;
}


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

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

  int min_ = 101;
  for(int i = S.size() - 1; i >= 0; i--){
    char x = S.at(i);
    int max_ = S.size() - i - 1;
    
    if(max_ > min_)
      break;

    int c = 0;
    for(int j = i - 1; j >= 0; j--){
      if(S.at(j) != x){
        c++;
      }
      else{
        max_ = max(max_, c);
        c = 0;
      }
    }
    max_ = max(max_,c);

    min_ = min(min_,max_);
  }

  cout << min_ << endl;
}


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

int main(){
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

int main(void){
  int n;
  double temp,sum = 0;
  char string[4];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> temp >> string;
    if(string[0] == 'J')sum += temp;
    else sum += 380000 * temp;
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    int parity = N % 2;
    vector<int> cnt(N, 0);
    int ok = true;
    for (int i = 0; i < N; ++i) {
        if (A[i] == parity) {
            ok = false;
            break;
        }
        cnt[A[i]]++;
        if (A[i] > 0 && cnt[A[i]] > 2) {
            ok = false;
            break;
        }
        if (cnt[0] > 1) {
            ok = false;
            break;
        }
    }
    if (ok) {
        ll ans = 1;
        int n = N / 2;
        for (int i = 0; i < n; ++i) ans = (ans * 2) % MOD;
        cout << ans << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 1024
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));

  let a = s[0];
  let b = s[1];

  if (a === 1) a += 13;
  if (b === 1) b += 13;

  let ans = '';

  if (a > b)   ans = 'Alice';
  if (a < b)   ans = 'Bob';
  if (a === b) ans = 'Draw';

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi 2*acos(0.0)
#define MOD 1000000007
#define N 100001
#define SZ 1000006
int main()
{
    long double b;
    ll ans,a,c;
    cin>>a>>b;
    c=(ll)round(b*100);
    //printf("%0.3llf\n",temp);
    ans=a*c/100;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3780
from sys import stdin,stdout
import math
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
ani,total = iia()
if total>4*ani:
    print('No')
elif total % 2==0:
    crane=(4*ani - total)
    tor = total-2*ani
    if crane%2==0 or tor%2==0:
        if 0<=crane//2<=ani and 0<=tor//2<=ani:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

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

int n;
map<int, int> mp;
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		mp[a]++;
		mp[a - 1]++;
		mp[a + 1]++;
	}
	int ans = 0;
	for (auto it : mp){
		ans = max(ans, it.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

    a--;
    if(a<0) a=-x;

    cout << b/x - a/x << endl;

    return 0;
}


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

public class Main {

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

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);

        int Alice = 0;
        int Bob = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += A[N-1-i];
            } else {
                Bob += A[N-1-i];
            }
        }

        System.out.printf("%d\n", Alice - Bob);
        sc.close();
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	getline(cin,s);
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		cout<<s[i];
		if(i==3)  cout<<" ";
	}
	cout<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "Rainy")
    cout << "Sunny";
  if (s == "Sunny")
    cout << "Cloudy";
  if (s == "Cloudy")
    cout << "Rainy";
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<P> D(N);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    D[i] = {a, b};
  }
  sort(D.begin(), D.end());
  ll ans = 0;
  rep(i, N) {
    P p = D[i];
    ll A = p.first;
    ll B = p.second;
    if (M - B >= 0) {
      M -= B;
      ans += A * B;
    } else {
      ans += A * M;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 1e5+9;

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n>>m>>k;
    if(m*k>=n)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3636
n,h=map(int,input().split())
x=[]
for i in range(n):
  a,b=map(int,input().split())
  x.append([a,0])
  x.append([b,1])
x.sort(reverse=1)
i=ans=0
while h>0:
  if x[i][1]:
    h-=x[i][0]
    ans+=1
  else:
    ans+=0--h//x[i][0]
    h=0
  i+=1
print(ans)

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

int main(){
    int n;  cin >> n;
    vector<string> s(n);

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

    bool isRule = true;
    for(int i = 0; i < n-1; i++){
        if(s[i].back() != s[i+1].front()){
            isRule =  false;
            break;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(s[i] == s[j]){
                isRule = false;
                break;
            }
        }
    }

    if(isRule){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<pii> task;

    rep(i,n){
        int a,b;
        cin>>a>>b;
        task.emplace_back(b,a);
    }
    sort(task.begin(),task.end());
    bool ans=true;
    int time=0;
    for (auto v:task){
        time += v.second;
        if(time>v.first){
            ans=false;
            break;
        }
    }

    cout << (ans ? "Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 2420
#include "bits/stdc++.h"
using namespace std;

int N, M;
int path[100][100];
int cost[100][100];

void init(){
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            path[i][j] = 200000;
            cost[i][j] = 200000;
        }
    }
}

int main(){

    init();

    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        path[a][b] = c;
        path[b][a] = c;
        cost[a][b] = c;
        cost[b][a] = c;
    }
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            if(path[i][j] == 200000)continue;
            if(path[i][j] > cost[i][j])ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
k = int(input())
a, b = map(int, input().split())
x = a // k
y = b // k
if a % k == 0:
    if y >= x:
        print("OK")
    else:
        print("NG")
else:
    if y >= x + 1:
        print("OK")
    else:
        print("NG")


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9

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

int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll cnt = b/c-(a-1)/c + b/d -(a-1)/d -(b/bds(c,d) -(a-1)/bds(c,d)  );
	cout<<b-a+1-cnt<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s[] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    string str;
    cin>>str;
    int i;
    for(i=0; i<7; i++){
        if(str == s[i])
            break;
    }
    cout<<i+1<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
ab = []
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
ab = sorted(ab, key=lambda x:x[0])
cnt = 0
for a, b in ab:
    cnt += b
    if k <= cnt:
        ans = a
        break
print(ans)

Measured memory_bytes: 18988
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> cnt(100010,0);
    for(int i=0;i<n;i++){
        int k = a[i];
        cnt[k+5]++;
        cnt[k+6]++;
        cnt[k+4]++;
    }
    int res=0;
    for(int i=0;i<100010;i++){
        res=max(res,cnt[i]);
    }
    cout<<res<<endl;
}

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

int main() {
	long long int n,m,i,s=0;
	cin>>n>>m;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	if(n<=m)
	cout<<"0";
	else{
	    sort(a,a+n);
	    for(i=0;i<n-m;i++)
	    s+=a[i];
	    cout<<s;
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];
        long MAX = (long)Math.pow(10,18);
        long ans = 1;
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextLong();
            if(a[i] == 0){
                System.out.println(0);
                return;
            }
        }
        for(int i=0; i<N; i++){
            if(MAX/ans < a[i]){
                System.out.println(-1);
                return;
            }else{
                ans *= a[i];
                //System.out.println(ans);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62004
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

int main()
{
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	//長方形の縦の長さもしくは横の長さを超えられてたらNo

	if (W < x + r || H < y + r || x < 0 || y < 0) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	cout << endl;
 
	return 0;

}



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

import math

for a in range(-int(math.pow(x,1./3.)),int(math.pow(x,1./3.))+1):
    for b in range(-int(math.pow(x,1./3.))+1,int(math.pow(x,1./3.))+1):
        if a!=b:
            if x/(a-b) == a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b:
                print(a,b)
                break
    else:
        continue
    break

Measured memory_bytes: 68808
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h, h + n);
    int ans = 1000000000;
    for(int i = k-1; i < n; i++){
        if (ans > h[i] - h[i-k+1]) {
            ans = h[i] - h[i-k+1];
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 640
N, M = map(int,input().split())
num = list(map(int,input().split()))
sss = sorted(num,reverse=True)
f = True

for i in range(M):
  s = sum(num)
  if sss[i] >= s/(4*M):
    pass
  else:
    print('No')
    f = False
    break
if f:
  print('Yes')

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

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

int main() {
	int n, i, j, m, sum;

	cin >> n;
	sum = 0;
	m = 0;
	rep(i, n) {
		cin >> j;
		sum += j;
		m = max(m, j);
	}
	sum -= m;

	if (sum > m) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;  // 夏休み日数
  int m;  // 宿題の数
  vector<int> needday(m);  // 必要日数

  
  cin >> n >> m;
  
  for (int i = 0; i < m; i++) {
  	cin >> needday[i];
  }
  
  for (int i = 0; i < m; i++){
    n = n - needday[i];
 
  	if (n < 0)
    {
      cout << -1 << endl;
      exit(0);
    }
  }
  
 cout << n << endl; 
}

Measured memory_bytes: 3752
import sys
import math

input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
ans = [0]*N
for i in range(N-1,-1,-1):
    if i > N//2 - 1:
        ans[i] = a[i]
    else:
        sm = 0
        for j in range(i+i+1, N, i+1):
            sm += ans[j]
        if sm % 2 == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1

out = ''
for i in range(N):
    if ans[i] == 1:
        out += str(i+1) + ' '
print(ans.count(1))
print(out)


Measured memory_bytes: 9116
h,n = map(int,input().split())

ls = [list(map(int,input().split())) for _ in range(n)]

amax = max(a for a,b in ls)

dp = [0]*(h+amax)

for i in range(1,h+amax):
  dp[i] = min(dp[i-a]+b for a,b in ls)

print(min(dp[h:]))



Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;


int main()
{
  int n ;
  cin >> n ;
  vector<int> a(n) ;
  vector<int> b(n) ;
  vector<int> c(n-1) ;
  int sum = 0 ;
  
  REP(i,n){
    cin >> a.at(i) ;
  }
  REP(i,n){
    cin >> b.at(i) ;
  }
  REP(i,n-1){
    cin >> c.at(i) ;
  }
  REP(i,n){
    sum += b.at(i) ;
  }
  REP(i,n-1){
    if(a.at(i)+1==a.at(i+1)){
      int x = a.at(i) -1 ;
      sum += c.at(x) ;
    }
  }
  
  cout << sum <<endl ;
  

  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
inline ll read() {
                                 ll x=0, tmp=1;
                               char ch=getchar();
                            //233333333333333333333333
                          while( (ch<'0') || (ch>'9') ){
                         if(ch=='-')tmp=-1; ch=getchar();}
                          while( (ch>='0')&&(ch<='9') ){
                            x=x*10+ch-'0';ch=getchar();
                               }//233333333333333
                                 return (x*tmp);

}
using namespace std;
int a[100005];
int main(){
	int n=read();rep(i,1,n)a[read()]=i;
	rep(i,1,n)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<vi> vii;
typedef map<int, int> mp;
typedef multiset<int> mset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int64> vi64;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define form(i,j,k,l) for(int i=j;i<int(k);i+=l)
#define rform(i,j,k,l) for(int i=int(j);i>int(l);i-=l)
#define rep(i, j) for(int i=0;i<int(j);i++)
#define rrep(i, j) for(int i=int(j);i>=0;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define forc(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define INF (int)1e9
#define INF64 (int64)1e18
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define F first
#define S  second
const double pie = acos(-1.0);
template <typename T>
T Max(T x, T y)
{
  return (x > y) ? x : y;
}
template <typename T>
T Min(T x, T y)
{
  return (x > y) ? y : x;
}
int gcd(int n1, int n2)
{
  if (n2 != 0) return gcd(n2, n1 % n2);
  else return n1;
}
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
clock_t time_p = clock();
void rtime() { time_p = clock() - time_p; cerr << "Time Taken : " << (float)1000 * (time_p) / CLOCKS_PER_SEC << "\n";}
int main()
{ fast;
  string s;
  cin >> s;
  int l = s.length();
  int64 sum = 0;
  for (int i = 0; i < l; i++)
  { int64 t = (long long int)(s[i] - '0');
    sum = sum + t;
  }
  if (sum % (long long int)9 == 0)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 3784
#include<stdio.h>
#include <stdlib.h>
#define max 1000005
#define NIL -1

typedef struct
{
    int parent,left,right;
}Node;



Node node[max];
int depth[max];

int getDepth(int i)
{
   if(node[i].parent == NIL)
   {
       return 0;
   }
   return getDepth(node[i].parent)+1;
    }


void printing(int i, int n, int temp)
{
    for (i = 0; i != n; i++) {
  printf("node %d: parent = %d, depth = %d, ", i, node[i].parent, depth[i]);
  if (node[i].parent == NIL) {
   printf("root, ");
  }
  else if (node[i].left == NIL) {
   printf("leaf, ");
  }
  else
   printf("internal node, ");
printf("[");
  if (node[i].left != NIL) {
   printf("%d", node[i].left);
   temp = node[i].left;
   for(;;) {
    if (node[temp].right == NIL) {
     break;
    }
    printf(", %d", node[temp].right);
    temp = node[temp].right;
   }
  }
  printf("]\n");
 }
}



int main()
{
    int n;
    int i,j,k;
    int ID;
    int temp,m;
    int u;

    //size
    scanf("%d", &n);
    
    //set NIL
    for(i=0;i<n;i++){
        node[i].parent=node[i].left=node[i].right=NIL;
    }
    //scan
    for (i = 0; i != n; i++) {
  scanf("%d %d", &ID, &k);
  for (j = 0; j != k; j++) {
   scanf("%d", &m);
   if (j == 0) {
    node[ID].left = m;
    node[m].parent = ID;
    temp = m;
   }
   else {
    node[temp].right = m;
    node[m].parent = ID;
    temp = m;
   }
  }
 }

 for(i=0;i<n;i++)
 {
     depth[i]=getDepth(i);
 }

printing(i,n,temp);

 return 0;

} 



Measured memory_bytes: 3344
#include <iostream>
#include <vector>

using namespace std;

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

int solve(int n, int S, vector<int>& M){
    vector<vector<int> > dp(S+1, vector<int>(2*n));
    for(int i=2; i<=S; ++i)for(int j=0; j<(int)M.size(); ++j){
        for(int k=1; k<=M[j] && k<=i; ++k){
            if(!dp[i-k][(j+1)%(int)M.size()]){
                dp[i][j] = 1;
                break;
            }
        }
    }
    return dp[S][0];
}

int main(){
    int n;
    while(cin >> n, n){
        int S;
        cin >> S;
        vector<int> M(2*n);
        rep(i, 2*n)cin >> M[i];
        cout << solve(n, S, M) << '\n';
    }
    return 0;
}

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

def out(s, e):
    while s < e:
        print("{} {}".format(s, e))
        s += 1
        e -= 1

if m % 2 == 0:
    out(1, m)
    out(m + 1, 2 * m + 1)
else:
    out(1, m + 1)
    out(m + 2, 2 * m + 1)

Measured memory_bytes: 9220
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> p;
int h, w;
string s[1002];
int d[1002][1002];
queue<p> que;
int dx[4] = { -1,1,0,0 };
int dy[4] = { 0,0,-1,1 };
int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)d[i][j] = -1;
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++) if (s[i][j] == '#') {
				que.push(make_pair(i, j));
				d[i][j] = 0;
			}
	
	while (!que.empty()) {
		int x = que.front().first;
		int y = que.front().second;
		que.pop();
		for (int i = 0; i < 4; i++) {
			int wx = x + dx[i];
			int wy = y + dy[i];
			if (wx > -1 && wx<h&&wy>-1 && wy < w&&d[wx][wy] == -1 && s[wx][wy] == '.') {
				d[wx][wy] = d[x][y] + 1;
				que.push(make_pair(wx, wy));
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)if (d[i][j] > ans)ans = d[i][j];
	cout << ans;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
  
using namespace std;
 
#define endl "\n"
#define JAM(x) cout<< #x <<" = "<<x<<"\n"
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { ll a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
 
 
//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPI;
 
const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;
const double PI=acos(-1.0);

vector<int> sieve(100001);


long long int power(long long int a,long long int b)
{
    a %= MOD;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if(n==1)
    return 0;
    int i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}

void SIEVE()
{
    int i,j;
    for(i=0;i<=100000;i++)
    sieve[i]=i;
    for(i=2;i*i<=100000;i++)
    {
        if(sieve[i]!=i)
        continue;
        for(j=i*i;j<=100000;j=j+i)
        {
            if(sieve[j]==j)
            sieve[j]=i;
        }
    }
}


/*_______________________________________________*/


int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    cout<<fixed<<setprecision(0)<<ceil((double)n/x)*t;
}


Measured memory_bytes: 3784
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		for(int i=1;;i++){
			int num=in.nextInt();
			if(num==0)
				break;
			System.out.println("Case "+i+": "+num);
		}
	}
}

Measured memory_bytes: 42552
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int stoi( string str )
{
	int res = 0;

	for ( unsigned int i = 0; i < str.length(); i++ )
	{
		res *= 10;
		res += str[i] - '0';
	}

	return res;
}

int main()
{
	int n;

	cin >> n;

	for ( int i = 0; i < n; i++ )
	{
		string buffer;
		cin >> buffer;

		string big, small;
		big = small = buffer;

		sort( big.begin(), big.end(), greater<char>() );
		sort( small.begin(), small.end() );

		cout << stoi( big ) - stoi( small ) << endl;
	}

	return 0;
}

Measured memory_bytes: 0