akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); 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 m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

ll s;

int main() {
    cin >> s;
    int sq =ceil(sqrt(s));
    ll ts = s - sq * sq;
    printf("%d %d %d %d %d %d ", 0, 0, sq, 1, -1*ts, sq);
    return 0;

}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
struct piece { int d, w; };

int area(struct piece p) {
  return p.d * p.w;
}

int main(void) {
  for(int N, W, D; cin >> N >> W >> D, N || W || D;) {
    int P[N], S[N]; REP(i, 0, N) cin >> P[i] >> S[i], P[i]--;

    struct piece first = { D, W };
    vector<struct piece> pieces;
    pieces.push_back(first);

    REP(i, 0, N) {
      int p = P[i], s = S[i];
      struct piece target = pieces[p];
      REP(i, p, pieces.size() - 1) pieces[i] = pieces[i + 1];
      int c = S[i] % (target.d * 2 + target.w * 2);
      int d1, w1, d2, w2;
      if(0 < c && c < target.w) {
        int v = c;
        d1 = target.d;
        w1 = v;
        d2 = target.d;
        w2 = target.w - v;
      } else if(target.w + target.d < c && c < target.w * 2 + target.d) {
        int v = c - (target.w + target.d);
        d1 = target.d;
        w1 = v;
        d2 = target.d;
        w2 = target.w - v;
      } else if(target.w < c && c < target.w + target.d) {
        int v = c - target.w;
        d1 = v;
        w1 = target.w;
        d2 = target.d - v;
        w2 = target.w;
      } else if(target.w * 2 + target.d < c && c < target.w * 2 + target.d * 2) {
        int v = c - (target.w * 2 + target.d);
        d1 = v;
        w1 = target.w;
        d2 = target.d - v;
        w2 = target.w;
      }
      struct piece new1 = { d1, w1 };
      struct piece new2 = { d2, w2 };
      if(area(new1) > area(new2)) swap(new1, new2);
      pieces[pieces.size() - 1] = new1;
      pieces.push_back(new2);
    }

    vector<int> areas;
    REP(i, 0, pieces.size()) areas.push_back(area(pieces[i]));
    sort(areas.begin(), areas.end());

    REP(i, 0, areas.size()) cout << areas[i] << (i + 1 != areas.size() ? " " : "");
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3156
module Main where

import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as B
import Control.Monad
    

readLine:: B.ByteString -> [Int]
readLine s = map (fst . fromJust . B.readInt) (B.words s)

readLines :: [B.ByteString] -> [[Int]]
readLines [] = []
readLines (s:ss) = readLine s : readLines ss

main :: IO() 
main = do
    contents <- B.getContents
    let lines = B.lines contents
        [a,b] = readLine (head lines)
        ans = show (a*b) ++ " " ++ show (2*a + 2*b)
    putStrLn ans



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

int main()
{

  int n;
  scanf("%d",&n);

  int i,j;

  int ara[n];

  for(i=0;i<n;i++) scanf("%d",&ara[i]);

  int temp;

  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      if(ara[i]>ara[j])
      {
        temp=ara[i];
        ara[i]=ara[j];
        ara[j]=temp;
      }
    }
  }


  int mx=ara[0];


  int other=0;
  for(i=1;i<n;i++) other+=ara[i];


  if(mx<other) printf("Yes");
  else printf("No");

  return 0;
}



Measured memory_bytes: 128
n,m,k = map(int,input().split())
friend = [[] for _ in range(n+1)]
block = [[] for _ in range(n+1)]
cnd = [0]*(n+1)
"""
for i in range(m):
  a,b = map(int,input().split())
  friend[a].append(b)
  friend[b].append(a)
for i in range(k):
  c,d = map(int,input().split())
  block[c].append(d)
  block[d].append(c)
"""
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
ans = [-1]*n
uf = UnionFind(n)
for i in range(m):
  a,b = map(int,input().split())
  ans[a-1] -= 1
  ans[b-1] -= 1
  uf.union(a-1,b-1)
for i in range(n):
  ans[i] += uf.size(i)
root = [uf.find(i)-1 for i in range(n)]
for i in range(k):
  c,d = map(int,input().split())
  if root[c-1]==root[d-1]:
    ans[c-1] -= 1
    ans[d-1] -= 1
print(*ans)

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    string s;
    cin >> n >> s;

    ll r = 0, g = 0, b = 0;
    rep(i, 0, n) {
        if (s[i] == 'R') { ++r; }
        if (s[i] == 'G') { ++g; }
        if (s[i] == 'B') { ++b; }
    }

    ll ans = r * g * b;

    rep(i, 0, n) {
        for (int j = 1; i + 2 * j < n; ++j) {
            // i : i + j : i + 2 * j
            if (s[i] != s[i + j] && s[i + j] != s[i + 2 * j] && s[i + 2 * j] != s[i]) {
                --ans;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int d, day = 1;
vector<int> c(26), last(26, -1);
vector<vector<int>> s;
int score;

void input() {
    cin >> d;
    s = vector<vector<int>>(d, vector<int>(26));

    for (int& i : c) cin >> i;
    for (auto& v : s)
        for (int& i : v) cin >> i;
}

int f(int contest) {
    int k = 0;
    for (int i = 0; i < 26; ++i) {
        if (i == contest) k += s[day][i], last[i] = day;
        k -= c[i] * (day - last[i]);
    }
    return k;
}

int main() {
    input();
    for (day = 0; day < d; ++day) {
        int dscore = 0, mi = -1;
        for (int con = 0; con < 26; ++con) {
            int tpen = 0, tsat = 0;
            for (int i = 0; i < 26; ++i) {
                if (i == con)
                    tsat = s[day][i];
                else
                    tpen += c[i] * (day - last[i]);
            }
            if (dscore < tsat - tpen || con == 0) dscore = tsat - tpen, mi = con;
        }
        cout << mi + 1 << endl;
    }
}


Measured memory_bytes: 3688
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
const int inf = 1012345678;
struct edge {
	int to, cost;
	edge() : to(-1), cost(0) {};
	edge(int to_, int cost_) : to(to_), cost(cost_) {};
};
vector<int> shortest_path(vector<vector<edge> > G, int src) {
	struct state {
		int pos, cost;
		state() : pos(-1), cost(0) {};
		state(int pos_, int cost_) : pos(pos_), cost(cost_) {};
		bool operator<(state s2) const {
			return cost > s2.cost;
		}
	};
	int V = G.size();
	vector<int> dist(V, inf); dist[src] = 0;
	priority_queue<state> que; que.push(state(src, 0));
	while (!que.empty()) {
		int u = que.top().pos; que.pop();
		for (edge e : G[u]) {
			if (dist[e.to] > dist[u] + e.cost) {
				dist[e.to] = dist[u] + e.cost;
				que.push(state(e.to, dist[e.to]));
			}
		}
	}
	return dist;
}
struct flow_edge {
	int to, cap, rev;
	flow_edge() : to(-1), cap(0), rev(-1) {};
	flow_edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
};
int max_flow(vector<vector<flow_edge> > G, int src, int dst) {
	int V = G.size();
	vector<bool> vis(V);
	function<int(int, int)> dfs = [&](int pos, int curflow) {
		if (pos == dst) return curflow;
		vis[pos] = true;
		for (flow_edge &e : G[pos]) {
			if (vis[e.to] || e.cap == 0) continue;
			int res = dfs(e.to, min(curflow, e.cap));
			if (res > 0) {
				e.cap -= res;
				G[e.to][e.rev].cap += res;
				return res;
			}
		}
		return 0;
	};
	int ret = 0;
	while (true) {
		fill(vis.begin(), vis.end(), false);
		int res = dfs(src, inf);
		if (res > 0) ret += res;
		else break;
	}
	return ret;
}
int main() {
	int V, E, s, t;
	cin >> V >> E >> s >> t; s--, t--;
	vector<int> a(E), b(E), d(E), c(E);
	vector<vector<edge> > G1(V), G2(V);
	for (int i = 0; i < E; i++) {
		cin >> a[i] >> b[i] >> d[i] >> c[i]; a[i]--, b[i]--;
		G1[a[i]].push_back(edge(b[i], d[i]));
		G2[b[i]].push_back(edge(a[i], d[i]));
	}
	vector<int> d1 = shortest_path(G1, s);
	vector<int> d2 = shortest_path(G2, t);
	vector<vector<flow_edge> > G(V);
	for (int i = 0; i < E; i++) {
		if (d1[a[i]] + d2[b[i]] + d[i] == d1[t]) {
			G[a[i]].push_back(flow_edge(b[i], c[i], G[b[i]].size()));
			G[b[i]].push_back(flow_edge(a[i], 0, G[a[i]].size() - 1));
		}
	}
	int ret = max_flow(G, s, t);
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


int main() {
    // input
    ll A,B;
    cin>>A>>B;

    //process
    cout<<A*B;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using sii = tuple<string, int, int>;

int main() {
  int N;
  cin >> N;
  vector<sii> list(N);
  for (int i = 0; i < N; i++){
    string s;
    int p;
    cin >> s >> p;
    list.at(i) = sii(s, -p, i + 1);
  }
  sort(list.begin(), list.end());
  for (int i = 0; i < N; i++){
    int no;
    tie(ignore, ignore, no) = list.at(i);
    cout << no << endl;;
  }
    
}

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

using int64 = long long;

int main() {
    int64 A, B, C;
    cin >> A >> B >> C;

    if (A % 2 == 0 and A == B and B == C) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    while (true) {
        if (A % 2 == 1 or B % 2 == 1 or C % 2 == 1) break;
        ans++;

        int nA = (B + C) / 2,
            nB = (A + C) / 2,
            nC = (A + B) / 2;
        A = nA;
        B = nB;
        C = nC;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H,W,d[22][22],D,r,i,j,k,l,t[22][22];
char c;
void move(int i,int j,int n){
	if(t[i][j]&&(d[i][j]>n||d[i][j]==-1)){
		d[i][j]=n;
		move(i+1,j,n+1);
		move(i-1,j,n+1);
		move(i,j+1,n+1);
		move(i,j-1,n+1);
	}
}
int main(){
	cin>>H>>W;
	for(i=1;i<=H;i++) {
        for(j=1;j<=W;j++){
		    cin>>c;
		    t[i][j]=(c=='.');
        }
	}
	for(i=1;i<=H;i++) {
        for(j=1;j<=W;j++){
		    memset(d,-1,sizeof(d));
		    move(i,j,0);
		    D=0;
		    for(k=1;k<=H;k++) {
                for(l=1;l<=W;l++){
                    D=max(D,d[k][l]);
		            r=max(D,r);
                }
            } 
        }   
    }
	cout<<r;
    return 0;
}


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

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main(){
	string s;
	cin >> s;
	if (s=="Sunny") {
		cout<<"Cloudy"<<endl;
	} else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	} else {
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = list(input())
S_work = []
s = []
f = []
i = 0
while len(s) < K:
  if S[i] == "o":
    s.append(i)
    i += C + 1
  elif S[i] == "x":
    i += 1
  elif i == len(S):
    break
i = 1
while len(f) < K:
  if S[N - i] == "o":
    f.append(N - i)
    i += C + 1
  elif S[N - i] == "x":
    i += 1
  elif i == len(S):
    break
f.sort()
for i in range(K):
  if s[i] == f[i]:
    print(s[i] + 1)

Measured memory_bytes: 22012
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >>a>>b;
    if(a==1||a==3||a==5||a==7||a==8||a==10||a==12){if(b==1||b==3||b==5||b==7||b==8||b==10||b==12){printa("Yes");exit(0);}else{printa("No");exit(0);}}
    else if(a==4||a==6||a==9||a==11){if(b==4||b==6||b==9||b==11){printa("Yes");exit(0);}else{printa("No");exit(0);}}
    else if(a==2){if(b==2){printa("Yes");exit(0);}else{printa("No");exit(0);}}
    printa("No");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n, k;
	cin>>n>>k;
	vector<int> a(n), b(n);
	rep(i, n){
		cin>>a[i]>>b[i];
	}
	ll res = 0;
	for(int i = 0; i < 30; i++){
		int k2 = k;
		if(i>0){
			if(!(1&(k>>i))) continue;
			k2 = k&(~(1<<i))|((1<<i)-1);
		}
		ll s = 0;
		rep(j, n) if((k2|a[j])==k2) s += b[j];
		res = max(res, s);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
<?php

$whxy = explode(' ', trim(fgets(STDIN)));
$w = $whxy[0];
$h = $whxy[1];
$x = $whxy[2];
$y = $whxy[3];

$a = $w*$h/2;
$x==$w/2 && $y==$h/2? $b = 1 : $b = 0;

echo $a." ".$b;
  
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll ans = 0;
    ll signs = 0;
    REP(i, N) {
        if (A[i] < 0) {
            signs++;
            A[i] = -A[i];
        }
        ans += A[i];
    }

    std::sort(ALL(A));

    if (signs % 2 == 1) {
        ans -= A[0] * 2;
    }
    cout << ans << LF;

    return 0;
}


Measured memory_bytes: 1024
# フェルマーの小定理
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
m = 1000000007
 
fac = [0] * (N + 1)
fac[0] = 1
for i in range(N):
    fac[i + 1] = fac[i] * (i + 1) % m
 
 
def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m
 
 
A.sort(reverse=True)
maxX = 0
for i in range(N - K + 1):
    maxX += A[i] * mcomb(N - (i + 1), K - 1)
    maxX %= m

A.sort()
minX = 0
for i in range(N - K + 1):
    minX += A[i] * mcomb(N - (i + 1), K - 1)
    minX %= m

print((maxX - minX) % m)

Measured memory_bytes: 20148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = CinT();
            double all = 0;
            for (int i = 0; i < N; i++)
            {
                var t = CinAr();
                if(t[1] == "JPY")
                {
                    all += S2D(t[0]);
                }
                else
                {
                    all += S2D(t[0]) * 380000;
                }
            }
            Cout(all);
            Cin();
        }

        static readonly int MOD1E9 = (int)1e9 + 7;
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void OYes() { Cout("Yes"); }
        static void ONo() { Cout("No"); }
        static void Cout(object s) { WriteLine(s); }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
int A,B,C,K;
cin >> A >> B >> C ;
cin >> K;
int M = max({A,B,C});
int ans = M;
for(int i = 0; i < K; i++){
    ans = ans * 2;
}
if(M == A){
    cout << B + C + ans << endl;
}
else if (M == B){
    cout << A + C + ans << endl;
}
else{
    cout << A + B + ans << endl;
} 

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;
int a, b, c;
int main()
{
	while(scanf("%d %d %d",&a, &b, &c) != EOF)
	{
		int d;
		d = (a - c)/ (b + c);
		printf("%d\n",d);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n;
  cin>>n;
  vector<int> a(n),b;
  for(int i=0;i<n;i++) cin>>a[i];
  b=a;
  if(prev_permutation(b.begin(),b.end())){
    for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<b[i];
    }
    cout<<endl;
  }

  b=a;
  for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<b[i];
  }
  cout<<endl;

  b=a;
  if(next_permutation(b.begin(),b.end())){
    for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<b[i];
    }
    cout<<endl;
  }

  return 0;

}



Measured memory_bytes: 3132
X,K,D = map(int,input().split())
X = abs(X)
T = X//D
if K < T:
    print(min(abs(X-K*D),abs(X+K*D)))
else:
    X -= D*T
    K -= T
    if K%2:
        print(min(abs(X+D),abs(X-D)))
    else:
        print(abs(X))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios()                \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in()
{
	int x;
	cin >> x;
	return x;
}
template <typename T>
inline void out(const T &x) { cout << x << endl; }
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
	if (a < b)
		gcd(b, a);
	int r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}
void eratos(bool *isPrime, int max)
{
	fill(isPrime, isPrime + max, true);
	isPrime[0] = false;
	isPrime[1] = false;
	for (int i = 2; i <= max / i; ++i)
		if (isPrime[i])
			for (int j = 2; j <= max / i; ++j)
				isPrime[i * j] = false;
}
//

vector<int> divisor(int n)
{
	vector<int> ret;
	for (int i = 0; i * i <= n; i++)
	{
		ret.push_back(i);
		if (i * i != n)
			ret.push_back(i);
	}
	sort(ALL(ret));
	return ret;
}

char m[51][51];
int w, h;

void dfs(int x, int y, vector<vector<bool>> &cmap, char color, vector<vector<bool>> &checked)
{
	if (x >= w || y >= h || y < 0 || x < 0) return;
	if (checked[x][y]) return;
	checked[x][y] = true;
	if (m[x][y] != '.') return;

	cmap[x][y] = true;
	for (int di = 0; di < 4; di++)
	{
		dfs(x + dx[di], y + dy[di], cmap,color,checked);
	}
}

void checkAllGrid(vector<vector<bool>> &inArea, char color)
{

	vector<vector<bool>> checked(w,vector<bool>(h,false)) ;
	for (int xi = 0; xi < w; xi++)
	{
		for (int yi = 0; yi < h; yi++)
		{
			if (m[xi][yi] == color)
			{
				for(int i = 0; i < 4; i++) {
					dfs(xi + dx[i], yi + dy[i], inArea, color, checked);

				}
			}
		}
	}
}

signed main()
{
	ios();
	int X,A;
	cin >> X >> A;
	if(X < A) {
		cout << 0 << endl;
	} else {
		cout << 10 << endl;
	}
	
}


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

using namespace std;

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

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

#endif

ll pow(ll x, ll y, ll mod) {
    if (y == 0) {
        return 1;
    }
    if (y % 2 == 0) {
        return pow(x * x % mod, y / 2, mod) % mod;
    } else {
        return x * pow(x, y - 1, mod) % mod;
    }
}

void Main() {
    ll M, N;
    cin >> M >> N;
    cout << pow(M, N, MOD) << '\n';
}

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



Measured memory_bytes: 3204
#include<stdio.h>
#define datamax 500001
#define banpei 1000000001
int left[datamax/2 +1];
int right[datamax/2 + 1];
int cnt;
void merge(int *,int,int,int,int);
void mergeSort(int *,int,int,int);
  int main(){
  int a[datamax],n,i;
  cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  mergeSort(a,n,0,n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}

void merge(int a[],int n, int leftnum ,int mid,int rightnum){
  int n1,n2,i=0,j=0,k;
   n1 = mid - leftnum;
   n2 = rightnum - mid;
  for(i=0;i<n1;i++)left[i] = a[leftnum + i];
  for(i=0;i<n2;i++)right[i] = a[mid + i];
  left[n1] = right[n2] = banpei;
  i=0;
  for(k=leftnum;k<rightnum;k++){
    cnt++;
    if(left[i] <= right[j]){
      a[k] = left[i++]; 
    }else{
      a[k] = right[j++];
    }
  }
}

void mergeSort(int a[],int n,int leftnum,int rightnum){
  int mid;
  if(leftnum +1 != rightnum){
    mid = (leftnum + rightnum) / 2;
    mergeSort(a,n,leftnum,mid);
    mergeSort(a,n,mid,rightnum);
    merge(a,n,leftnum,mid,rightnum);
  }
}





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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, x, total = 0;
  cin >> n >> x;
  vector<int> m(n);
  rep(i, n) {
    cin >> m[i];
    total += m[i];
  }
  x -= total;
  sort(m.begin(), m.end());
  cout << n + x / m[0] << endl;
  return 0;
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};


ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b,ll r)
{
    a%=r;
    b%=r;
    return (a+b)%r;
}
ll mulmod(ll a,ll b,ll r)
{
    a%=r;
    b%=r;
    return (a*b)%r;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll sum = 0,ans =0;
ll n; cin>>n;
vi arr(n);
rep(i,0,n)cin>>arr[i],sum+=arr[i];
rep(i,0,n)
{
    sum-=arr[i];
    ans=addmod(ans,mulmod(sum,arr[i],mod),mod);

}
cout<<ans<<"\n";
return 0;
}
/*
1
4
1 2
2 3
3 4
2
2 2
*/


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> v={A, B, C};
  sort(v.begin(), v.end());
  cout << v.at(2)*10+v.at(0)+v.at(1) << endl;
}

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

signed main(){
  int N;
  cin>>N;
  if(N%10==3){
    cout<<"bon"<<endl;
    return 0;
  }
  if(N%10==0||N%10==1||N%10==6||N%10==8){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3592
import sys
input_lines = sys.stdin.readlines()[1:]
index_list = ['S', 'H', 'C', 'D']
numset = [[str(i+1) for i in range(13)] for i in range(4)]
for card in input_lines:
    [char, rank] = card.split()
    index = index_list.index(char)
    numset[index].remove(rank)

for i in range(4):
    char = index_list[i]
    for num in numset[i]:
        print(' '.join([char, num]))


Measured memory_bytes: 5572
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		a[0] = a[0] ^ read();
	}
	if (a[0] == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
N,K = map(int,input().split())
h = []
for i in range(N):
    h.append(int(input()))

h.sort()


min = 100000000000
for i in range(N-K+1):
    if min  > h[i+K-1]-h[i]:
        min  = h[i+K-1] - h[i]

print(min)

Measured memory_bytes: 7488
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n, m;
  cin >> n >> m;
  set<int> st[n + 1];
  rep(i, m){
    int a, b; cin >> a >> b;
    st[a].insert(b);
    st[b].insert(a);
  }
  
  ll ans = 0;
  bool moved = true;
  while(moved){
    moved = false;
    for(int i = 1; i <= n; i++){
      if(st[i].size() == 1){
        auto itr = st[i].begin();
        st[i].erase(itr);
        st[*itr].erase(i);
        ans++;
        moved = true;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N, K;
    cin >> N >> K;
    long long ans = 0;
    ans += (long long) pow(N / K, 3);
    if (K % 2 == 0) ans += (long long) pow(N / (K / 2) - N / K, 3);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    ll a; cin >> a;
    string s; cin >> s;
    int b;
    b = 100*(s[0]-'0') + 10*(s[2]-'0') + (s[3]-'0');
    ll d = a * b;
    d /= 100;
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 3628
n=gets.to_i
x=Array.new(4){Array.new(3){Array.new(10){0}}}
while line=gets;(b,f,r,v)=line.split().map(&:to_i)
  x[b-1][f-1][r-1] += v
end
x.each_with_index do |bb,i|
  bb.each do |ff|
    puts " "+ff.join(" ")
  end
  puts "####################" if i != 3
end

Measured memory_bytes: 6108
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B;
	scan(A>>B);
	if(A>=13) prin(B);
	else if(A>=6) prin(B/2);
	else prin(0);
	return 0;
}


Measured memory_bytes: 256
// oh yea mr krabs
// REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
#include<bits/stdc++.h>
using namespace std;

const long long maxn = 1e5+10 ;
const long long mod = 1e9+7 ;

long long a[maxn] ;
long long ans ;

int main(){

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

    long long n ;
    cin >> n ;

    long long z = -1 ;
    for(long long i = 1; i*i <= n; i++){

        if(n%i == 0){

            z = i ;

        }

    }
    cout << z + n/z - 2;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>

using namespace std;
typedef long long ll;
const int maxn = 2e5+10;

int main(){
    int n;
    cin>>n;
    if(n == 1){
        cout<<"Hello World"<<endl;
        exit(0);
    }
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
}



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

int main() {
	
	int A;
	int B;
	int ans;

	scanf("%d", &A);
	scanf("%d", &B);

	if (A + B == 3) {
		ans = 3;
	}
	else if (A + B == 4) {
		ans = 2;
	}
	else if (A + B == 5) {
		ans = 1;
	}
	
	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 128
let k=[0;1;2;3];;
let h()=Scanf.scanf"%d %d %d %d "(fun a b c d->[a;b;c;d]);;
let rec f()=
  let a,b=h(),h()in
  let g(m,n)s i=
    let z(m,n)x j=
      if x=s&&i=j then(m+1,n)else if x<>s then(m,n)else(m,n+1)
    in
    List.fold_left2 z(m,n)a k
  in
  let m,n=List.fold_left2 g(0,0)b k in
  f(Printf.printf "%d %d\n"m n);;
try f()with _->()

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

#define MAX 100002

int main(){
    int X, prime[MAX];
    for(int i=0;i<MAX;i++){
        prime[i] = 1;
    }
    prime[1] = 0;
    cin >> X;
    for(int i=4;i<X;i++){
        for(int j=2;j<i;j++){
            if(prime[j]==0){
                continue;
            }else{
                if(i%j==0){
                    prime[i] = 0;
                    break;
                }
            }
        }
    }
    int i;
    while(1){
        for(i=2;i<X;i++){
            if(prime[i]==0){
                continue;
            }else{
                if(X%i==0){
                    break;
                }
            }
        }
        if(i==X){
            cout << X << endl;
            return 0;
        }
        X++;
    }
    return 0;
}

Measured memory_bytes: 640
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
void warshall(vvl& d, vvi& es, map<pii, int>& cost){
    int N = es.size();
    d = vvl(N, vl(N, LINF));
    // d[i][j] : the shortest distance from i to j

    REP(i, N) d[i][i] = 0;
    REP(i, N) {
        for (int t : es[i]) {
            d[i][t] = cost[pii(i, t)];
            d[t][i] = cost[pii(t, i)];
        }
    }
    REP(k, N) {
        REP(i, N) {
            if (d[i][k] == LINF) continue;
            REP(j, N) {
                if (d[k][j] == LINF) continue;

                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }
}
#endif


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


    int H, W; cin >> H >> W;
    vvi C(10, vi(10));
    REP(i, 10)
        REP(j, 10) cin >> C[i][j];

    vvi A(H, vi(W));
    REP(i, H)
        REP(j, W) cin >> A[i][j];

    vvi es(10);
    map<pii, int> cost;
    REP(i,10){
        FOR(j,i+1,10){
            es[i].push_back(j);
            es[j].push_back(i);
            cost[pii(i, j)] = C[i][j];
            cost[pii(j, i)] = C[j][i];
        }
    }

    vvl dist;
    warshall(dist, es, cost);

    ll ans = 0;
    REP(i,H){
        REP(j,W){
            if (A[i][j] >= 0) {
                ans += dist[A[i][j]][1];
            }
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();

        boolean ans = false;

        for (int i = 0; i < 100; i++) {
            if(A * i % B == C)ans = true;
        }

        if (ans) {
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }


    }
}

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

struct Edge {
	int to;
	int64_t dist{1};

	int64_t cost;
	int64_t capacity;
	int rev_i;
};
using EdgeVec = std::vector<Edge>;
using EdgeLists = std::vector<EdgeVec>;

///////////////////
// ダイクストラ法 //
///////////////////

// 負辺を含まないグラフの最短経路アルゴリズム
// Edgeは{to, dist}
decltype(auto) dijkstra(const EdgeLists& edges, const int source)
{
	using Metric = decltype(Edge::dist);
	std::vector<Metric> distance(edges.size(), std::numeric_limits<Metric>::max());
	using DistPoint = std::pair<Metric, int>;
	std::priority_queue<DistPoint, std::vector<DistPoint>, std::greater<DistPoint>> updatedQueue;
	distance[source] = 0;
	updatedQueue.push({0, source});
	while (!updatedQueue.empty())
	{
		DistPoint now{updatedQueue.top()};
		updatedQueue.pop();
		if (now.first > distance[now.second]) continue;
		for (const Edge& next: edges[now.second])
			if (now.first + next.dist < distance[next.to])
			{
				distance[next.to] = now.first + next.dist;
				updatedQueue.push({distance[next.to], next.to});
			}
	}
	return distance;
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
int main()
{
	int V, E, r;
	scanf("%d%d%d", &V, &E, &r);
	EdgeLists edges(V);
	for (int i{}; i < E; i++)
	{
		int s, t, d;
		scanf("%d%d%d", &s, &t, &d);
		edges[s].push_back({t, d});
	}
	auto distance{dijkstra(edges, r)};
	
	constexpr int64_t inf{std::numeric_limits<int64_t>::max()};
	for (int64_t& e: distance)
		if (e == inf)
			puts("INF");
		else
			printf("%lld\n", e);
	return 0;
}


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

int h, w;
long long ans[10] = {};
map<int, map<int, bool> > mp;

int nineSearch(int x, int y){
  int ans = 0;
  for(int p = -1;p < 2;p++){
    for(int q = -1;q < 2;q++){
      if(x+p < 0 || x+p >= w || y+q < 0 || y+q >= h) return 10;
      if(mp[x+p][y+q]) ans++;
    }
  }

  return ans;
}

int main(){
  int n;
  cin >> h >> w >> n;
  ans[0] = (long long)(h-2) * (long long)(w-2);

  int x, y;
  for(int i = 0;i < n;i++){
    cin >> y >> x;
    y--; x--;
    for(int p = -1;p < 2;p++){
      for(int q = -1;q < 2;q++){
        int tmp = nineSearch(x+p,y+q);
        if(tmp < 9){
          ans[tmp]--;
          ans[tmp+1]++;
        }
      }
    }
    mp[x][y] = true;
  }

  for(int i = 0;i < 10;i++){
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 164352
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,v,b,w,t;
  cin >> a>>v>>b>>w>>t;
  if(v>w &&(t*v-w*t) >=abs(b-a)){cout << "YES" << endl;}
else{cout << "NO" << endl;}
}


Measured memory_bytes: 3636
#include <stdio.h>
typedef long long ll;
int l[10000010] = {0};
int main() {
	int n;
	scanf("%d", &n);
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll s = 0;
		while (s <= n) {
			l[s]++;
			s += i;
		}
	}
	for (int i = 1; i <= n; i++) {
		int x = i;
		// printf("%d,%d:%lld\n", i, l[i], (ll)i * l[i]);
		ans += (ll)i * l[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 40752
H,W,D = map(int, input().split())
map_ = []
for i in range(H):
    map_.append(list(map(int, input().split())))
    
#for i in range(H):
#    print(map_[i])

n_to_pos = [[0,0]] * (H * W + 1)
for i in range(H):
    for j in range(W):
        n_to_pos[map_[i][j]] = [i,j]

reach_cost = [0] * (H * W + 1)
for i in range(D + 1,H * W + 1):
    reach_cost[i] = reach_cost[i - D] + abs(n_to_pos[i][0] - n_to_pos[i - D][0]) + abs(n_to_pos[i][1] - n_to_pos[i - D][1])

Q = int(input())
for i in range(Q):
    B,E = map(int, input().split())
    print(reach_cost[E]-reach_cost[B])

Measured memory_bytes: 20784
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
string s;
int state = 0;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> s;
    int q;
    vector<vector<char>> add(2);
    cin >> q;
    while (q--){
        int t;
        cin >> t;
        if (t == 1) state ^= 1;
        else {
            int f; char c;
            cin >> f >> c;
            f--;
            add[state^f].eb(c);
        }
    }

    string t = "";
    //if (state) reverse(all(s));
    
	for(int i=(int)add[0].size()-1; ~i; --i)
		t+=add[0][i];
	
    t+=s;
	for(char c : add[1])
		t+=c;
	if(state)
		reverse(t.begin(), t.end());

    cout << t;
    return 0;
}

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

using namespace std;

int main () {
	int n;
	cin >> n;
	int a[]={2,4,8,16,32,64,1000};
	for (int i=0;i<=6;i++) {
		if (a[i]>n) {
			cout <<a[i-1];
			return 0;
		}
	}
}

Measured memory_bytes: 256
n,m,x,y = map(int, input().split())
x_list = list(map(int , input().split()))
y_list = list(map(int , input().split()))

x_max = max(x_list)
y_min = min(y_list)

z = [i for i in range(-100,100) if i > x and i <= y and i > x_max and i <= y_min]
if not z:
    print("War")
else:
    print("No War")


Measured memory_bytes: 3060
n = int(input())
n_list = list(map(int,input().split()))
count = 0
for i in n_list:
    if i % 4 == 0:
        count += 1
    elif i%2 == 0:
        count += 0.5
if count >= n//2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string str,Hoshino="Hoshino";
    cin>>n;
    cin.ignore();
    for(int i=0;i<n;i++){
        getline(cin,str);
        for(int j=0;str[j]!='\0';j++){
            if(str[j]=='H'){
                for(int k=j;k<7+j;k++){
                    if(str[k]!=Hoshino[k-j])break;
                    if(k==j+6)str[k]='a';
                }
            }
        }
        cout<<str<<endl;
    }
}

Measured memory_bytes: 1212