akhauriyash/Code-Regression huggingface dataset:
import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in);
  def soroban(n: Int) = {
    val c = Array.ofDim[Char](5, 8)
    var m = n
    for(i <- (0 until 5).reverse) {
      c(i)(0) = if (m%10 >= 5) ' ' else '*'
      c(i)(1) = if (m%10 >= 5) '*' else ' '
      c(i)(2) = '='
      for(j <- 3 to 7) {
        c(i)(j) = if (m%5 == j-3) ' ' else '*'
      }
      m /= 10
    }
    c.transpose
  }
  def main(args: Array[String]) {
    while(sc.hasNext) {
      val n = sc.nextInt
      val c = soroban(n)
      c.map(_.mkString).foreach(println)
      if(sc.hasNext) println
    }
  }
}

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

using namespace std;

int main() {
  int N, H, ans = 0, val = 0;
  pair <int, int> a[200005];
  cin >> N >> H;
  for (int i = 1; i <= N; ++i) cin >> a[2 * i - 1].first >> a[2 * i].first;
  for (int i = 1; i <= N; ++i) a[2 * i - 1].second = 0, a[2 * i].second = 1;
  sort(a + 1, a + 2 * N + 1);
  for (int i = 2 * N; i >= 1; --i) {
    if (a[i].second == 1) val += a[i].first, ans++;
    if (a[i].second == 0) {
      ans += (H - val) / a[i].first;
      if ((H - val) % a[i].first != 0) ++ans;
      val = H + 1;
    }
    if (val >= H) break;
  }
  cout << ans << '\n';
  return 0;
}


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

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

using namespace std;

int main(){
	int n,ans=0; cin>>n;
	rep(i,n){
		int l,r; cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
const ll LINF = (1LL<<60);
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
vector<pl> g[100100];
ll n , q , k;

vl dijkstra(ll s){
	priority_queue<pl, vector<pl>, greater<pl>> q;
	vl dist(n , LINF);
	dist[s] = 0;
	q.push(pl(dist[s] , s));
	while(!q.empty()){
		pl p = q.top(); q.pop();
		ll cost = p.first;
		ll from = p.second;
		if(dist[from] < cost)continue;
		for(auto c:g[from]){
			ll to = c.first;
			ll di = c.second;
			if(dist[from] + di < dist[to]){
				dist[to] = dist[from] + di;
				q.push(pl(dist[to] , to));
			}
		}
	}
	return dist;
}

signed main(){
	//cout << fixed << setprecision(10);
    cin >> n;
	rep(i,0,n - 1){
		ll a,b,c; cin >> a >> b >> c;
		--a; --b;
		g[a].push_back(pl(b,c));
		g[b].push_back(pl(a,c));
	}
	cin >> q >> k;
	--k;
	auto dist = dijkstra(k);
	while(q--){
		ll x,y; cin >> x >> y;
		--x; --y;
		cout << dist[x] + dist[y] << endl;
	}

	return 0;
}

Measured memory_bytes: 14044
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	for (int n; cin >> n, n;) {
		string P = "I";
		for (int i = 0; i < n; i++)P += "OI";
		int m; cin >> m;
		string s; cin >> s;
		int cnt = 0;
		for (size_t a = s.find(P); a != string::npos; a = s.find(P, a + 1)) {
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 2132
import java.util.Scanner;
import java.lang.StringBuilder;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int tmp = 0;
        int count = 1;
        while(true) {
            tmp = sc.nextInt();
            if(tmp==0){
                break;
            }
            StringBuilder sb = new StringBuilder();
            // sb.append("Case ");
            // sb.append(String.valueOf(count));
            // sb.append(": ");
            // sb.append(String.valueOf(tmp));
            // System.out.print(new String(sb));
            // sb=null;
            System.out.println("Case " + String.valueOf(count) + ": " + String.valueOf(tmp));
            count++;
        }
    }
}


Measured memory_bytes: 42648
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const ll MOD = 1000000007;
 
int main() {
   int n; scanf("%d", &n);
   vector<int> b(n - 1);
   for (int& i : b)
      scanf("%d", &i);
   int ans = b[0];
   for (int i = 1; i < n - 1; ++i) {
      ans += min(b[i - 1], b[i]);
   }
   ans += b[n - 2];
   printf("%d", ans);
   return 0;
}

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

int n;
std::vector<std::vector<int>> profits, times;
std::vector<int> vec;

int main() {
    std::cin >> n;
    times.assign(n, std::vector<int>(10, 0));
    profits.assign(n, std::vector<int>(11, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            std::cin >> times[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            std::cin >> profits[i][j];
        }
    }
    for (int i = 1; i < 1024; i++) {
        int sum = 0;
        for (int p = 0; p < n; p++) {
            int c = 0;
            for (int k = 0; k < 10; k++) {
                if ((i >> k) & times[p][9-k] == 1) {
                    c++;
                }
            }
            sum += profits[p][c];
        }
        vec.push_back(sum);
    }
    std::cout << *std::max_element(vec.begin(), vec.end()) << std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math

def solve(N: int, H: int, a: "List[int]", b: "List[int]"):
    to_swing = max(a)
    to_throw = [s for s in sorted(b, reverse=True) if s > to_swing]
    count = 0
    for s in to_throw:
        H -= s
        count += 1
        if H <= 0:
            print(count) 
            break
    else:
        count += math.ceil(H / to_swing)
        print(int(count))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, H, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12712
#include<bits/stdc++.h>
//#pragma GCC optimize ("-O3")

using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const long double PI = 3.14159265358979323846;


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    string s, t;

    cin >> s >> t;
    int n = s.length(), m = t.length();
    int ans = 1e9;
    for (int i = 0; i < n; i++)
    {
        int j = i + m - 1;
        if (j < n)
        {
            int ta = 0;
            for (int x = 0; x < m; x++)
                ta += t[x] != s[i + x];
            ans = min(ans, ta);
        }
    }
    cout << ans << "\n";
    return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A, B, C, D; cin >> A >> B >> C >> D;
  ll p = max(A, C);
  ll q = min(B, D);
  cout << max(0LL, q - p) << endl;

  return 0;
}



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll S[10];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(S, 0, sizeof(S));
    REP(i, N) {
        ll a;
        cin >> a;
        if (a >= 3200)
            a = 3200;
        S[a / 400]++;
    }

    ll p = S[8];
    ll a = 0;
    REP(i, 8) {
        if (S[i] > 0)
            a++;
    }
    cout << std::max(a, 1LL) << " " << a + p << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
G = [[float('inf')] * N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    G[a][b] = c
    G[b][a] = c


for k in range(N):
    G[k][k] = 0
    for i in range(N):
        for j in range(N):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j])


ans = float('inf')
for perm in permutations(r):
    tmp = 0
    for i in range(R - 1):
        tmp += G[perm[i]][perm[i + 1]]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 72408
n,k=map(int,input().split())
r,s,p = map(int,input().split())
T=list(input())

a=[[] for i in range(k)]
for i in range(n):
    a[i%k].append(T[i])

d={'r':p,'s':r,'p':s}
score=0
for j in range(k):
    b=a[j]
    flg=0
    for l in range(len(b)):
        if l==0:
            score+=d[b[l]]
        else:
            if b[l-1]==b[l] and flg==0:
                flg=1
                continue
            elif b[l-1]==b[l] and flg==1:
                score+=d[b[l]]
            elif b[l-1]!=b[l]:
                score+=d[b[l]]
            flg=0
print(score)




Measured memory_bytes: 14164
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]

point = [K-Q for i in range(N)]
for i in range(Q):
    point[A[i]-1] += 1
for i in range(N):
    if point[i] > 0:
        print('Yes')
    else:
        print('No')

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

int main() {
  std::string a;
  std::cin >> a;
  int64_t v = 0;
  for (char c : a) {
    int n = c - '0';
    v += n;
  }
  if (v % 9 == 0) printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

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

int main()
{
 ll a, b;
 cin >> a >> b;
 cout << a*b/gcd(a,b);
 return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    int x1, y1, x2, y2, dx, dy;
    std::cin >> x1 >> y1 >> x2 >> y2;
    dx = x2 - x1;
    dy = y2 - y1;
    x1 = x2 - dy;
    y1 = y2 + dx;
    std::cout << x1 << " " << y1 << " ";
    dx = x1 - x2;
    dy = y1 - y2;
    x2 = x1 - dy;
    y2 = y1 + dx;
    std::cout << x2 << " " << y2 << std::endl;

    return 0;
}


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

int main()
{
  int N;
  scanf("%d", &N);
  int tmp = N;
  int count = 9;
  int start = 1;
  int cur = 0;
  int ret = 0;
  bool check = true;
  while (tmp) {
    if (check) ret += min(N-start+1, count);
    count *= 10;
    start *= 10;
    tmp /= 10;
    check ^= true;
  }
  printf("%d\n", ret);
  return 0;
}

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

int main() {
    char S;
     int N = 700; 
    for (int i = 0;  i < 3 ; i++){
    cin >> S;
    if (S == 'o')
    N += 100;
    }
    cout << N << endl;
    }
    
    

Measured memory_bytes: 3608
#include <stdio.h>

int N,M,C[100005]; bool R[100005];

int main()
{
	scanf ("%d %d",&N,&M);
	for (int i=1;i<=N;i++) C[i] = 1;
	R[1] = 1;

	for (int i=0;i<M;i++){
		int x,y; scanf ("%d %d",&x,&y);
		if (R[x]) R[y] = 1;
		C[y]++; C[x]--;
		if (C[x] == 0) R[x] = 0;
	}

	int ans = 0;
	for (int i=1;i<=N;i++) if (R[i]) ans++;
	printf ("%d\n",ans);

	return 0;
}

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

typedef long long ll;

ll N, Z, W;
vector<ll> A;
unordered_map<ll, ll> Memo;

ll calc(ll me, ll him, ll deck, bool turn_x) {
  if (deck == N) return abs(me - him);
  ll key = him * 2 * (N + 1) + deck * 2 + turn_x;
  if (Memo.count(key)) return Memo.at(key);
  ll res = calc(him, A[deck], deck + 1, !turn_x);
  if (deck != N - 1) {
    ll rest = calc(me, him, deck + 1, turn_x);
    res = turn_x ? max(res, rest) : min(res, rest);
  }
  return Memo[key] = res;
}
int main() {
  cin >> N >> Z >> W;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  cout << calc(Z, W, 0, true) << endl;
  return 0;
}


Measured memory_bytes: 159448
from math import hypot
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

if N == 2:
    d = hypot(XY[0][0]-XY[1][0], XY[0][1]-XY[1][1])
    print(d/2)
    exit()

def center(a,b,c,d,e,f):
    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f
    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))
    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))
    r = hypot(px - a, py - b)
    return (r,px,py)

eps = 10**-10
ans = float('inf')
for i in range(N-2):
    x1,y1 = XY[i]
    for j in range(i+1,N-1):
        x2,y2 = XY[j]
        for k in range(j+1,N):
            x3,y3 = XY[k]
            try:
                r,px,py = center(x1,y1,x2,y2,x3,y3)
            except ZeroDivisionError:
                continue
            for x,y in XY:
                d = hypot(px-x, py-y)
                if d <= r+eps:
                    continue
                break
            else:
                ans = min(ans,r)
for i in range(N-1):
    for j in range(i+1,N):
        x1,y1 = XY[i]
        x2,y2 = XY[j]
        x = (x1+x2)/2
        y = (y1+y2)/2
        r = hypot(x1-x, y1-y)
        for x3,y3 in XY:
            d = hypot(x-x3,y-y3)
            if d <= r+eps:
                continue
            break
        else:
            ans = min(ans,r)

print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
int ans = 0;
bool ok = true;
while(ok){
    ok = false;
    rep(i,n){
        if(a[i]%2==0){
            a[i] /= 2;
            ans++;
            ok = true;
        }
    }
}
cout << ans  << endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
	map<int,int> Mx,My;
	vector<set<int>> S(maxn);
	int h,w,m;cin>>h>>w>>m;
	for(int i=1;i<=m;i++) {
		int y,x;cin>>y>>x;
		Mx[x]++;My[y]++;
		S[y].insert(x);
	}
	int ans=0;
	multiset<int> cnt;
	for(int i=1;i<=w;i++) cnt.insert(Mx[i]);
	for(int i=1;i<=h;i++) {
		for(auto x:S[i]) if(cnt.count(Mx[x])) cnt.erase(cnt.find(Mx[x]));
		if(cnt.size()) ans=max(ans,*(--cnt.end())+My[i]);
		for(auto x:S[i]) cnt.insert(Mx[x]);
		for(auto x:S[i]) ans=max(ans,Mx[x]+My[i]-1);
	}
	cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define out(x) cout << x << endl
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const ll INF = 1e16;

int main() {
    ll N;
    cin >> N;
    vector<ll> dp(N + 1, INF);
    dp[0] = 0;
    rep(i, 1, N+1) {
        ll x = 1;
        while (x <= i) {
            dp[i] = min(dp[i], dp[i-x] + 1);
            x *= 6;
        }
        ll y = 1;
        while (y <= i) {
            dp[i] = min(dp[i], dp[i-y] + 1);
            y *= 9;
        }
    }
    out(dp[N]);
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int a,b,c; cin >> a >> b >> c;
    if(b-a==c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3560
import java.util.*;
public class Main {
	static int count = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int height[] = new int[num];
		for(int i = 0; i < num; i ++) {
			height[i] = sc.nextInt();
		}

		reduceHeight(height, 0, num);

		System.out.println(count);
	}

	public static void reduceHeight(int height[], int first, int last) {
		if(first != last) {
			int min = height[first];
			int index = first;
			for(int i = first; i < last; i ++) {
				if(height[i] < min) {
					min = height[i];
					index = i;
				}
			}
			boolean shouldContinue = false;
			for(int i = first; i < last; i ++) {
				height[i] -= min;
			}
			count += min;
			reduceHeight(height, first, index);
			reduceHeight(height, index + 1, last);
		}
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1e5 + 5, M = 2e6 + 5;
const long long inf = 1e16;
map< pair<int, int>, int> id;
int lastid;
vector< pair<int, int> > adj[N + M];
long long dist[N + M];

void addEdge(int u, int v, int c1, int c2) {
  adj[u].push_back({v, c1});
  adj[v].push_back({u, c2});
}

int getId(int u, int c) {
  if (id.count({u, c})) return id[{u, c}];
  addEdge(u, lastid, 1, 0);
  id[{u, c}] = lastid;
  return lastid++;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  lastid = n+1;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a = getId(a, c);
    b = getId(b, c);
    addEdge(a, b, 0, 0);
  }
  for (int i = 0; i < lastid; i++)
    dist[i] = inf;
  set < pair< long long, int > > st;
  st.insert({0, 1});
  dist[1] = 0;
  while (!st.empty()) {
    auto it = st.begin();
    int v = it->second;
    long long now = it->first;
    st.erase(it);
    if (v == n) {
      printf("%lld\n", now);
      return 0;
    }
    for (auto it : adj[v]) {
      long long cur = now + it.second;
      if (dist[it.first] > cur) {
        st.erase(make_pair(dist[it.first], it.first));
        dist[it.first] = cur;
        st.insert(make_pair(cur, it.first));
      }
    }
  }
  puts("-1");
  return 0;
}

Measured memory_bytes: 104948
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int N,M,X;
    cin >> N >> M >> X;
    int a = 0;
    int b = 0;
    for(int i=0; i<M; i++){
        int tmp;
        cin >> tmp;
        if(tmp < X) a++;
        else b++;
    }
    cout << min(a,b) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
int n;
int arr[200005];
int main(void){
	RI(n);
	REP(i,n) RI(arr[i]);
	if(n&1){
		for(int i=n-1;i>=0;i-=2) printf("%d ",arr[i]);
		for(int i=1;i<n;i+=2){
			printf("%d",arr[i]);
			if(i!=n-1&&i!=n-2) printf(" ");
		}
	} else {
		for(int i=n-1;i>=0;i-=2) printf("%d ",arr[i]);
		for(int i=0;i<n;i+=2){
			printf("%d",arr[i]);
			if(i!=n-1&&i!=n-2) printf(" ");
		}
	}
	
	puts("");
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
char n;
int a,b;
int main()
{
    cin>>a>>b;
    for(int s=0;s<a;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cin>>n;
    if(n!='-')
    {
        cout<<"No"<<endl;
        return 0;

    }
    for(int s=0;s<b;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  double n;
  cin >> n;
  double x = ceil(n/1.08);
  if (floor(x*1.08) != n) {
    cout << ":(" << endl;
  } else {
    cout << ceil(n/1.08) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
require 'set'

n, m = gets.split.map(&:to_i)

t = Array.new(n+1).map{[]}

m.times do
    a, b = gets.split.map(&:to_i)
    t[a].push(b);
    t[b].push(a);
end

ans = Array.new(n+1).map{[]}

set = Set.new
q = Array.new(2).map{[]}
q[0].push(1)
set.add(1)

ans = Array.new(n+1)
for l in 0...n
    ll = l%2
    lll = (l+1)%2
    while !q[ll].empty?
        pos = q[ll].pop
        t[pos].each do |tt|
            unless set.include?(tt)
                ans[tt] = pos
                q[lll].push(tt)
                set.add(tt)
            end
        end
    end
    break if set.size == n
end

if set.size == n
    puts "Yes"
    for i in 2..n
        puts ans[i]
    end
else
    puts "No"
end

Measured memory_bytes: 42592
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#include <deque>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  string s;
  unsigned int q,t,f,sum;
  sum = 0;
  char c;
  cin >> s;
  deque <char> dq;
  rep(i,s.size()){
    dq.push_back(s[s.size()-1-i]);
  }
  cin >> q;
  rep(i,q){
    cin >> t;
    sum += t;
    if(t == 2){
      cin >> f >> c;
      if((sum%2)^(f%2)){
        dq.push_back(c);
      }
      else{
        dq.push_front(c);
      }
    }
  }
  if(sum%2 == 0){
    rep(i,dq.size()){
      cout << dq[dq.size()-1-i];
    }
  }
  else{
    rep(i,dq.size()){
      cout <<dq[i];
    }
  }
  return 0;
}


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


int main() {
  ll n;
  cin >> n;
  int mid;
  mid = std::pow(n,0.5) + 1;
  ll a,b;
  for (ll i = 1; i < mid+1 ; i++){
    if (n%i == 0){
      a = i;
      b = n/i;
    }
  }
  cout << a+b-2 << endl;
}


Measured memory_bytes: 256
nums_ary = [[0 for i in range(3)] for i in range(3)]
check_ary = [[0 for i in range(3)] for i in range(2)]
good = True

for i in range(3):
    nums_ary[i] = list(map(int,input().split()))

check_ary[0][0] = 0

for x in range(3):
    check_ary[1][x] = nums_ary[0][x] - check_ary[0][0]

for y in range(3):
    check_ary[0][y] = nums_ary[y][0] - check_ary[1][0]

for x in range(3):
    for y in range(3):
        if not check_ary[0][x] + check_ary[1][y] == nums_ary[x][y]:
            good = False

if good :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
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;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long int big[60][2] = {};

int main() {
	long long int n, m;
	cin >> n >> m;
	long long int sum = 0;
	for (int i = 0; i < m; i++) {
		long long int a;
		cin >> a;
		sum = sum + a;
	}
	long long int k = -1;
	cout << max(k, n - sum);
}

Measured memory_bytes: 3628
#include <stdio.h>
#define MAX 500000

int H,A[MAX+1];

void maxHeapify(int i)
{
  int l,r,largest,a;
  l = 2*i;
  r = 2*i+1;

  if(l<=H && A[l]>A[i]) largest = l;
  else largest = i;
  if(r<=H && A[r] > A[largest]) largest = r;

  if(largest != i)
  {
    a=A[i];
    A[i]=A[largest];
    A[largest]=a;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);

  for(i=1 ; i<=H ; i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2 ; i>=1 ; i--){
    maxHeapify(i);
  }
  for(i=1 ; i<=H ; i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3680
s = list(input())
k = int(input())
n = len(s)

ans = 0

# すべて同じ文字の場合
if s == [s[0]] * n:
    print((n*k)//2)
    exit(0)

# 先頭と末尾が異なる場合
i = 1
while i < n:
    if s[i-1] == s[i]:
        t = 2
        i+=1
        while i < n and s[i-1] == s[i]:
            t+=1
            i+=1
        ans += (t//2)*k
    i+=1
if s[0] != s[-1]:
    print(ans)
    exit(0)
# 先頭と末尾が一致する場合
# まず不一致の場合と同様に数えて、左右端の連続長さを数える
# 連結したとき、左右の1ブロックのみはそのまま数えられる
# 残りのk-1ブロックは、左右がつながった形で数えられる
i = 1
left = 1
right = 1
for i in range(n):
    if s[i] == s[i+1]:
        left += 1
    else:
        break
for i in range(n-1, -1, -1):
    if s[i] == s[i-1]:
        right += 1
    else:
        break
if s[0] == s[-1]:
    ans = ans - (k-1) * (left//2 + right//2) + (k-1) * ((left+right)//2)
    print(ans)


Measured memory_bytes: 9164
#include<cstdio>
#include<algorithm>
int n,a[60];
int main() {
	scanf("%d",&n);
	for (int i=1; i<=n; ++i) scanf("%d",a+i);
	std::sort(a+1,a+n+1);
	double t=a[1];
	for (int i=2; i<=n; ++i) t=(t+a[i])/2;
	printf("%.7lf",t);
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n;
int ans;
int h[110];

int main(){
  cin>>n;
  rep(i,n){
    cin>>h[i];
  }
  int a=0;
  rep(i,n){
    if(a<=h[i]){
      ans++;
      a=h[i];
    }
  }

  cout<<ans<<endl;
}


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

const int INF = 1e9 + 5;

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

    vector<int> h(N), dp(N, INF);

    for (int &x: h)
        scanf("%d", &x);

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j: { i+1, i+2 }) {
            if (j < N)
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

    printf("%d\n", dp[N-1]);
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            //System.Threading.Thread.Sleep(1000);
        }

        public void Solve(ConsoleInput cin)
        {
            int h = cin.ReadInt;
            int w = cin.ReadInt;

            string[,] map = new string[h, w];
            for (int i = 0; i < h; i++)
            {
                char[] l = cin.ReadLine.ToCharArray();
                for (int j = 0; j < w; j++)
                {
                    map[i, j] = l[j].ToString();
                }
            }

            bool can = true;
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                {
                    if (map[i, j].Equals(".")) continue;
                    if (i > 0 && map[i - 1, j].Equals("#")) continue;
                    if (j > 0 && map[i, j - 1].Equals("#")) continue;
                    if (i < h-1 && map[i + 1, j].Equals("#")) continue;
                    if (j < w-1 && map[i, j + 1].Equals("#")) continue;
                    can = false;
                }

            Console.WriteLine(can ? "Yes" : "No");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13240
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int x3, y3,x4,y4;
	int lenx = (x2-x1);
	int leny = y2 - y1;

	x3 = x2 - leny;
	y3 = y2 + lenx;
	x4 = x3 - lenx;
	y4 = y3 - leny;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long  N,X,T;
	cin>>N>>X>>T;
	long long  ans{},ans1{};
	if(N%X==0)
	cout<<(N/X)*T<<endl;
	else
	cout<<((N/X)+1)*T<<endl;
	
}


Measured memory_bytes: 3616
#include <algorithm>
#include <cstdio>

using namespace std ;

int main ()
{
    int a , b , c ;
    scanf("%d%d%d",&a,&b,&c);
    if ( b>c ) swap(b,c);
    if ( a>b ) swap(a,b);
    if ( b>c ) swap(b,c);
    printf("%d\n",a+b);
    return 0 ;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, E, T;
vint W, G, C;
vector<vint> S;
vint minseed;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> E >> T; T--;

  resz(W, N);
  rep(i, N) cin >> W[i];

  resz(G, E);
  resz(C, E);
  resz(S, E);
  rep(i, E) {
    cin >> G[i] >> C[i]; G[i]--;
    resz(S[i], C[i]);
    rep(j, C[i]) {
      cin >> S[i][j]; S[i][j]--;
    }
  }

  resz(minseed, N, inf);
  rep(i, N) if(W[i]) minseed[i] = 1;

  rep(i, N) {
    rep(j, E) {
      vint seed;
      rep(k, C[j]) seed.push_back(minseed[S[j][k]]);
      sort(all(seed)); reverse(all(seed));
      int needseed = C[j];
      rep(k, C[j]) chmax(needseed, seed[k]+k);
      chmin(minseed[G[j]], needseed);
    }
  }

  cout << (minseed[T] == inf ? -1 : minseed[T]) << endl;

  return 0;
}

Measured memory_bytes: 3272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next()) - 1;
		int y = Integer.parseInt(sc.next()) - 1;

		int[] counts = new int[n];
		for (int i = 0; i < n; ++i) {
			for (int j = i + 1; j < n; ++j) {
				int dist = 0;
				if (hasOnlyOnePath(i, j, x, y)) {
					dist = j - i;
				} else {
					dist = Math.min(j - i, Math.abs(x - i) + 1 + Math.abs(j - y));
				}

				++counts[dist];
			}
		}

		for (int d = 1; d < n; ++d) {
			System.out.println(counts[d]);
		}
	}

	static boolean hasOnlyOnePath(int i, int j, int x, int y) {
		if (y <= i) {
			return true;
		} else if (x <= i) {
			return false;
		} else {
			return j <= x;
		}
	}
}


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

int main() {
  int sum = 0;
  for (int i = 0; i < 5; i++) {
    int score;
    cin >> score;
    if (score < 40) score = 40;
    sum += score;
  }

  cout << sum / 5 << endl;

  return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>

int fact(int n){
	int i;
	int fact =1;
	
	for(i=1; i<=n; ++i){
		fact= fact*i;
	}
	return fact;
}

int main(void){
	int n, i, j;
	int p[8];
	int q[8];
	int sump=1; int sumq=1;
	int countp, countq;
	scanf("%d", &n);
	
	for(i=0; i< n; i++){
		scanf("%*c%d", &p[i]);
	}
	for(i=0; i< n; i++){
		scanf("%*c%d", &q[i]);
	}
	
	for(i=0; i< n-1; i++){
		countp=0; countq=0;
		for(j=i+1; j< n; j++){
			if(p[i]>p[j]){
				countp+=1;
				
			}
			if(q[i]>q[j]){
				countq+=1;
								
			}
		}
		if(countp!=0)sump += countp*fact(n-i-1);
		if(countq!=0)sumq += countq*fact(n-i-1);
		
	}
	printf("%d", abs((sump+1)-(sumq+1)));
	
}

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

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

#define rep(i, n) for(size_t i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;



void solve() {
	ULL LessM = 0, MoreM = 0;

	string s; cin >> s;
	ULL ans = 0;
	s.push_back('<');
	rep(i, s.size()) {
		if (s[i] == '<') {
			if (MoreM != 0) {
				ans += LessM * (LessM + 1) / 2;
				ans += MoreM * (MoreM + 1) / 2;
				ans -= min(LessM, MoreM);
				LessM = MoreM = 0;
			}
			LessM++;
		}
		else {
			MoreM++;
		}
	}

	ans += LessM * (LessM - 1) / 2;

	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <cstdlib>

inline int f(int x) {
    return x*x;
}

int get_input(void) {
    int d;
    std::cin >> d;
    if (std::cin.fail()) {
        exit(0);
    }
    return d;
}

long long unsigned int solve(int d){
    long long unsigned int acc = 0;
    for (int i = d; i <= 600-d; i+=d) {
        acc += f(i) * d;
    }
    return acc;
}

int main(void) {
    while(true) {
        std::cout << solve(get_input()) << std::endl;
    }
    return 0;
}
    

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

int max_value(vector<int> &d, int i, int n, int l){
    int ans=0;
    for(int j=0; j<=i; j++){
        //左からj回取り出す
        int get_v=0;
        vector<int> a;
        vector<int>check(n,0);
        for(int k=0; k<j; k++){
            int g = d.at(k);
            get_v+=g;
            a.push_back(g);
            check.at(k) = 1;
            if(k==n-1) break;
        }
        for(int k=0; k<i-j; k++){
            int g=d.at(n-1-k);
            if(check.at(n-1-k) == 1) break;
            get_v+=g;
            a.push_back(g);
            if(k == n-1) break;
        }
        sort(a.begin(), a.end());
        int m=a.size();
        int cnt=0;
        while(cnt<l-i && cnt<m){
            if(a.at(cnt) > 0) break;
            get_v -= a.at(cnt);
            cnt++;
        }
        ans = max(ans, get_v);
    }
    return ans;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> d;
    for(int i=0; i<n;i++){
        int v;
        cin >> v;
        d.push_back(v);
    }
    int ans=0;
    for(int i=0; i<=k; i++){
        //i回取り出す
        int count=max_value(d, i, n, k);
        ans = max(ans, count);
        //cout << i<< ' '<< count << endl;
    }
    cout << ans << endl;
}


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

int main() {
 
  int N, M;
  cin >> N >> M;
 
  vector<int> a(M);
  vector<int> b(M);
 
  for ( int i = 0; i < M; i++ ){
    cin >> a.at(i) >> b.at(i);
  }
 
  vector<int> d(N);
 
  for ( int i = 0; i < N; i++ ){
    for ( int j = 0; j < M; j++){
       if ( a.at(j) == i + 1 || b.at(j) == i + 1){
         d.at(i) += 1;
       }
    }
   
   cout << d.at(i) << endl;
  }
  
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    map<char, int> cnt;
    rep(i, N) rep(j, M) {
        char C; cin >> C;
        cnt[C]++;
    }
    bool ans = true;

    int c4 = 0, c2 = 0, c1 = 0;
    for (auto c : cnt) {
        int n = c.second;
        c4 += n/4;
        n %= 4;
        c2 += n/2;
        n %= 2;
        c1 += n;
    }
    if (N&1 && M&1) {
        if (c1 != 1) ans = false;
        if (c4 < (N-1)*(M-1)/4) ans = false;
        c2 += 2 * (c4 - (N-1)*(M-1)/4);
        if (c2 != (N-1)/2 + (M-1)/2) ans = false;
    } else if (N&1 || M&1) {
        if (N&1) swap(N, M);
        if (c4 < N*(M-1)/4) ans = false;
        c2 += 2 * (c4 - N*(M-1)/4);
        if (c2 != N/2) ans = false;
        if (c1) ans = false;
    } else {
        if (c4 != N*M/4) ans = false;
        if (c2 || c1) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

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

using namespace std;

long long getGcd(long long a, long long b) {
    long long c;

    while (b) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

long long getLcm(long long a, long long b) {
    return a / getGcd(a, b) * b;
}

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

    int n;
    cin >> n;

    long long t;
    cin >> t;

    long long lcm = t;

    for (int i = 1; i < n; ++i) {
        cin >> t;

        lcm = getLcm(lcm, t);
    }

    cout << lcm;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class A1222 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;

	    int res = 0;
	    while(n > 0){
	        int r = n%10;
	        if(r==2) res++;
	        n /= 10;
	    }

	    out << res << endl;
	}
};


int main() {
	A1222 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */

ll f(ll a, ll b) {
    if (a > b) {
        return f(b, a);
    } else if (a == 0) {
        return -b;
    } else {
        return 2 * (b / a) * a + f(b % a, a);
    }
}

/* ---------- Main Function ---------- */

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

    ll N, X;
    cin >> N >> X;

    cout << N + f(X, N - X) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;


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


  int i = 1;
  while(1){
    if( N <= ((2*D + 1) * i) ){
      cout << i << endl;
      break;
    }
    i++;
  }

  return 0;
}


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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

vector<int> vec;
bool f[300001];

bool solve(){
  int n;

  scanf("%d",&n);

  if(n == 1) return false;

  printf("%d:", n);
  
  for(int i=0;i<vec.size();i++){
    if(n % vec[i] == 0 && f[n/vec[i]]){
      printf(" %d",vec[i]);
    }
  }

  puts("");
  
  return true;
}


int main(){

  vector<int> vec2;

  for(int i=2;i<=300000;i++){
    if(i%7 == 1 || i%7 == 6){
      vec2.push_back(i);
      f[i] = true;
    }
  }
  f[1] = true;

  for(int i=0;i<vec2.size();i++){
    bool flag = true;
    int p = vec2[i];
    for(int j=0;vec2[j]*vec2[j] <= p;j++){
      if(p%vec2[j] == 0) flag = false;
    }

    if(flag){
      vec.push_back(p);
    }
  }

  while(solve());
  
  return 0;
}

Measured memory_bytes: 3920