akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1
 
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;
int main(){
	ll N;
	string S[100010];
	cin>>N;
	REP(i,N){
	    string s;
	    cin>>s;
	    sort(ALL(s));
	    S[i]=s;
	}
	sort(S,S+N);
	ll count=1,ans=0;
	REP(i,N){
	    if(i==0)continue;
	    if(S[i]==S[i-1]){
	        count++;
	    }else{
	        if(count>=2){
	            ans+=count*(count-1)/2;
	        }
	        count=1;
	    }
	    if(i==N-1){
	        if(count>=2){
	            ans+=count*(count-1)/2;
	            count=1;
	        }
	    }
	}
	cout<<ans;
}

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

ll gcd(ll x, ll y) {
    if(x%y == 0) {
        return y;
    } else {
        return gcd(y,x%y);
    }
}

ll solve(ll N,ll M, vector<ll> &res) {
    while(res.at(0) % 2 == 0) {
        for(int i = 0; i < N; i++) {
            if(res.at(i) % 2 != 0) return 0;
            else {
                res.at(i) /= 2;
            }
        }
        M /= 2;
    }
    for(int i = 0; i < N; i++) {
        if(res.at(i) % 2 == 0) return 0;
    }

    ll lcm = 1;
    for(int i = 0; i < N; i++) {
        lcm = (lcm * res.at(i)) / gcd(lcm,res.at(i));
        if(lcm > M) return 0;
    }
    return (M/lcm + 1) / 2;
}

int main() {
    ll N,M; cin >> N >> M;
    vector<ll> res(N);
    for(int i = 0; i < N; i++){ 
        cin >> res.at(i);
        res.at(i) /= 2;
    }
    cout << solve(N,M,res) << endl;

}

Measured memory_bytes: 1152
import itertools
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
max_res = -10**9

me_list = list(itertools.product([0, 1], repeat=10))
for i in range(1, 2**10):
    res = 0
    co = [ 0 for o in range(N)]
    for j in range(10):
        if me_list[i][j] == 1:
            for k in range(N):
                co[k] += F[k][j]
    for j in range(N):
        res += P[j][co[j]]
    if res > max_res:
        max_res = res
            
print(max_res)

Measured memory_bytes: 3316
#!/usr/bin/env python

n = input()
a = list(map(int, input().split()))
# print(n)
# print(a)

alice = []
bob = []
a_sorted = sorted(a)
# print(a_sorted)

while len(a_sorted) != 0:
    max = a_sorted.pop()
    # print(max)
    alice.append(max)
    if(len(a_sorted) != 0):
        max = a_sorted.pop()
        bob.append(max)

# print(alice)
# print(bob)
print(sum(alice) - sum(bob))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, q, anc[maxn][17], dep[maxn], X[maxn], Y[maxn], A[maxn], B[maxn], sum[maxn], sumCol[maxn], cntCol[maxn], ans[maxn];
vector<pii>que[maxn];
vector<tuple<int, int, int> >adj[maxn];
void dfs(int v, int p)
{
    anc[v][0] = p;
    dep[v] = dep[p] + 1;
    for(int i = 1; i < 17; i++)
        anc[v][i] = anc[anc[v][i - 1]][i - 1];
    for(tuple<int, int, int>aa : adj[v])
    {
        int to, c, w;
        tie(to, c, w) = aa;
        if(to != p)
        {
            sum[to] = sum[v] + w;
            dfs(to, v);
        }
    }
}
int lca(int a, int b)
{
    if(dep[a] > dep[b])
        swap(a, b);
    for(int i = 16; i >= 0; i--)
        if(dep[anc[b][i]] >= dep[a])
            b = anc[b][i];
    if(a == b)
        return a;
    for(int i = 16; i >= 0; i--)
        if(anc[a][i] != anc[b][i])
            a = anc[a][i], b = anc[b][i];
    return anc[a][0];
}
void dfs2(int v, int p)
{
    for(pii p : que[v])
    {
        int i, d;
        tie(i, d) = p;
        ans[i] += d * cntCol[X[i]] * Y[i];
        ans[i] -= d * sumCol[X[i]];
    }
    for(tuple<int, int, int>aa :adj[v])
    {
        int to, c, w;
        tie(to, c, w) = aa;
        if(to != p)
        {
            cntCol[c]++;
            sumCol[c] += w;
            dfs2(to, v);
            cntCol[c]--;
            sumCol[c] -= w;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n >> q;
    for(int i = 0; i < n - 1; i++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        adj[a].pb(make_tuple(b, c, d));
        adj[b].pb(make_tuple(a, c, d));
    }
    dfs(1, 0);
    for(int i = 0; i < q; i++)
    {
        int a, b;
        cin >> X[i] >> Y[i] >> a >> b;
        A[i] = a, B[i] = b;
        if(dep[a] > dep[b])
            swap(a, b);
        int LCA = lca(a, b);
        ans[i] = sum[a] + sum[b] - 2 * sum[LCA];
        if(a == LCA)
            que[a].pb({i, -1}), que[b].pb({i, +1});
        else
        {
            que[LCA].pb({i, -2});
            que[a].pb({i, +1});
            que[b].pb({i, +1});
        }
    }
    dfs2(1, 0);
    for(int i = 0; i < q; i++)
        cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 27384
import sys
#sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from random import randint
d=int(input().rstrip())
c=[int(i)for i in input().split()]
s=[[int(i)for i in input().split()]for _ in range(d)]
last=[0]*26
for i in range(d):
    print((i+4)%26+1)

Measured memory_bytes: 9748
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
constexpr int MAX = 5000000;


struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int S; cin >> S;
	vector dp(701, vector<mint>(S + 1));
	dp[0][0] = 1;
	for (int i = 0; i < 700; i++) {
		for (int j = 0; j <= S; j++) {
			for (int k = 3; j + k <= S; k++) {
				dp[i + 1][j + k] += dp[i][j];
			}
		}
	}
	mint res = 0;
	for (int i = 1; i < 700; i++) res += dp[i][S];
	cout << res.x << "\n";
	return 0;
}

Measured memory_bytes: 14192
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve(Scanner scanner, PrintWriter writer) {
        String s = scanner.next();
        String t = scanner.next();

        // dp[i][j] denote length of longest common subsequence of s[0:i-1] and t[0:j-1]
        int n1 = s.length();
        int n2 = t.length();
        int[][] dp = new int[n1 + 1][];
        //Arrays.fill(dp, new int[n2+1]);
        for (int i = 0; i <= n1; i++) {
            dp[i] = new int[n2+1];
        }

        for (int i = 1; i <= n1; i++) {
            for (int j = 1; j <= n2; j++) {
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }

        //for (int i = 0 ; i <= n1; i++){
        //    writer.println(Arrays.toString(dp[i]));
        //}

        StringBuilder str = new StringBuilder();
        int row = n1;
        int col = n2;
        while (row >= 1 && col >= 1) {
            int cur = dp[row][col];
            int topLeft = dp[row - 1][col - 1];
            int left = dp[row][col - 1];
            int top = dp[row - 1][col];
            if (cur == 0) {
                break;
            } else if (cur - 1 == top && cur - 1 == topLeft && cur - 1 == left) {
                str.append(s.charAt(row - 1));
                --row;
                --col;
            } else if (cur == left) {
                --col;
            } else if (cur == top) {
                --row;
            }
        }

        writer.println(str.reverse().toString());

        //int ans = dp[n1][n2];
        //
        //writer.println(ans);
    }
}


Measured memory_bytes: 83020
N = int(input())
S = list(str(input()))

right_white = S.count('.')
right_black = len(S) - right_white

ans = right_white

left_white=0
left_black=0

for i in range(N):
    if(S[i] == '#'):
        left_black = left_black+1
        right_black = right_black-1
    else:
        left_white = left_white+1
        right_white = right_white-1

    if(ans > (left_black + right_white)):
        ans = (left_black + right_white)

print(ans)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 30+7;

int n,m;
int cnt[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    cin >> n >> m;
    REP(i,0,n-1)
    {
        int k;
        cin >> k;
        REP(j,0,k-1)
        {
            int ai;
            cin >> ai;
            cnt[ai]++;
        }
    }
    int ans = 0;
    REP(i,1,m)
    {
        if (cnt[i] == n) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
c = list(input())
wcount = [0] * n
rcount = [0] * n
for i in range(n):
    if c[i] == 'W':
        wcount[i] = 1
    if c[-(i+1)] == 'R':
        rcount[-(i+1)] = 1
    if i != 0:
        wcount[i] = wcount[i] + wcount[i-1]
        rcount[-(i+1)] = rcount[-(i+1)] + rcount[-i]
ans = n
for i in range(n+1):
    if i == 0:
        W = 0
        R = rcount[0]
    elif i == n:
        W = wcount[-1]
        R = 0
    else:
        W = wcount[i-1]
        R = rcount[i]
    tmp = max(W, R)
    if tmp < ans:
        ans = tmp
print(ans)

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

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  if(l%d==0){
    cout << r/d-l/d+1 << endl;
  }
  else{
    cout << r/d-l/d << endl;
  }

  return 0;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

int main() {
  ll n, m, x, y = 0, z = 0, h, w, sum = 0, Max = -1, Min = 1e9+1;
  string s, t, u;
  bool ok=true;
  cin >> n;
  VI a(n); rep(i,n) cin >> a[i];
  VI b(n);

  if(n%2==0){
    rep(i,n){
      if(a[i]%2==0){
        pri(0); return 0;
      }
      b[a[i]]++;
    }

    for(int i=1; i<n; i+=2){
      if(b[i] != 2){
        pri(0); return 0;
      }
    }
    x = powMod(2,floor(n/2),mod);
    pri(x);
  }
  else{
    rep(i,n){
      if(a[i]%2!=0){
        pri(0); return 0;
      }
      b[a[i]]++;
    }
    if(b[0]!=1){
      pri(0); return 0;
    }
    for(int i=2; i<n; i+=2){
      if(b[i] != 2){
        pri(0); return 0;
      }
    }
    x = powMod(2,floor(n/2),mod);
    pri(x);
  }


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	long long X,Y;
	cin>>X>>Y;
	
	if(Y>=X-1&&Y<=X+1)cout<<"Brown"<<endl;
	else cout<<"Alice"<<endl;
	
	return 0;
}

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

using namespace std;


string s;
string t;
int dp[3010][3010];

int solve(int i, int j){
	if(i == 0 || j == 0)	return dp[i][j] = 0;
	
	if(dp[i][j] != -1)      return dp[i][j];
	
	return dp[i][j] = max(solve(i-1,j),max(solve(i,j-1),(s[i-1] == t[j-1]) + solve(i-1,j-1)));	
}	

string recover(int i, int j){
	if(i == 0 || j == 0){
		return "";
	}
	int val = (s[i-1] == t[j-1]);
	if(dp[i][j] == dp[i-1][j]){
		return recover(i-1,j);
	}else if(dp[i][j] == dp[i][j-1]){
		return recover(i,j-1);
	}else if(dp[i][j] == dp[i-1][j-1] + val){
		return recover(i-1,j-1) + s[i-1]  ;
	}
}

int main(){
	cin >> s >> t;
	for(int i = 1; i <= s.size();i++){
		for(int j = 1; j <= t.size();j++){
			dp[i][j] = max(dp[i-1][j],max(dp[i][j-1],(s[i-1] == t[j-1]) + dp[i-1][j-1]));	
		}
	}
	int i = s.size(), j = t.size();
	string ans;
	while(i != 0 && j != 0){
		int val = (s[i-1] == t[j-1]);
		if(dp[i][j] == dp[i-1][j]){
			i = i-1;
			j = j;
		}else if(dp[i][j] == dp[i][j-1]){
			i = i;
			j = j - 1;
		}else if(dp[i][j] == dp[i-1][j-1] + val){
			ans += s[i-1];
			i = i-1;
			j = j-1;
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 200100

pi t;
ll A[MAXN];
ll nearest[MAXN];
ll N,K;
ll done[MAXN];
vi V;

ll val(ll x, ll y){
	return A[x] + A[y] + K*abs(y-x);
}

int main(){
	cin>>N>>K;
	for (ll i=1;i<=N;++i)cin>>A[i];
	t = mp(1e18,-1);
	for (ll i=N;i>=1;--i){
		nearest[i] = t.s;
		if (K*i + A[i] < t.f){
			t = mp(K*i+A[i], i);
		}
	}
	ll cur = 1;
	V.pb(1);
	while (nearest[cur] != -1){
		done[cur] = 1;
		cur = nearest[cur];
		V.pb(cur);
	}
	done[cur] = 1;
	ll ans = 0;
	ll bestp = A[1] - K;

	for (ll i=1;i<SZ(V);++i){
		ans += bestp + V[i]*K + A[V[i]];
		// cout<<V[i]<<' '<<ans<<'\n';
		bestp = min(bestp, A[V[i]]-K*V[i]);
	}

	bestp = A[1] - K;
	for (ll i=0;i<SZ(V) - 1;++i){
		for (ll j=V[i]+1;j<V[i+1];++j){
			ans += min(bestp + j*K + A[j], val(V[i+1], j));
			bestp = min(bestp, A[j] - K*j);
		}
		bestp = min(bestp, A[V[i+1]]-K*V[i+1]);
	}
	cout<<ans;
}


Measured memory_bytes: 6644
import numpy as np

N, M, X, Y = map(int, input().split())
lst_x = list(map(int, input().split()))
lst_y = [int(y) for y in input().split()]

lst = np.arange(X + 1, Y + 1)
lst = [x for x in lst if x > max(lst_x)]
lst = [y for y in lst if y <= min(lst_y)]

print('War') if len(lst) == 0 else print('No War')


Measured memory_bytes: 12428
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.insert(N+1, 0)
total = 0
for i in range(N+1):
    total += abs(A[i+1] - A[i])
for j in range(1, N+1):
    print(total + abs(A[j + 1] - A[j - 1]) - abs(A[j + 1] - A[j]) - abs(A[j-1] - A[j]))

Measured memory_bytes: 14048
#include <stdio.h>

int main(){
	int jamb;
	int menitb;
	int jamt;
	int menitt;
	int belajar;
	int rumus;
	scanf("%d %d %d %d %d", &jamb,&menitb,&jamt,&menitt,&belajar);
	rumus=((jamt*60)+menitt)-((jamb*60)+menitb)-belajar;
	printf("%d", rumus);
	
	
	return 0;
}

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

int main() {
  int N, sum = 0, a = 0;
  cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++){
      cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end()); 
    reverse(vec.begin(), vec.end()); 

    for (int i = 0; i < N; i += 2) { 
      sum += vec.at(i);
    }

    for (int i = 1; i < N; i += 2){       
      a += vec.at(i);
    }
   cout << sum - a << endl;
}


Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int N = 200005;
  const int INF = 1e16;
  const double PI = acos(-1);



vector<int> adj[N];
    int bvis[N];

int dist[N];

void bfs(int u)
{

    queue<int> q;
    q.push(u);
    dist[u] = 0;
    while(q.size())
    {
        u = q.front(), q.pop();
        for(int &v : adj[u])
        {
            if(!bvis[v])
            {
                dist[v] = dist[u] + 1;
                bvis[v] = 1;
                q.push(v);
            }
        }
    }
}

int ans[N];

int32_t main()
{
       

    IOS


    int n,x,y;
    cin >> n >> x >> y;


    for(int i = 1; i <= n-1; i++)
    {
      adj[i].PB(i+1);
      adj[i+1].PB(i);
    }

    adj[x].PB(y);
    adj[y].PB(x);


    set<pair<int,int>> s;
    map<int,int> mp;

    for(int i = 1; i <= n; i++)
    {
      bfs(i);
      dist[i] = 0;
      for(int j = 1; j <= n; j++)
      {
        int xx = i;
        int yy = j;
        if(xx > yy)swap(xx,yy);
        if(!s.count({xx,yy}))
        {
            mp[dist[yy]]++; 
            s.insert({xx,yy});         
        }
        bvis[j] = false;
        dist[j] = 0;
      }


    }

    for(auto i : mp)
    {

      //trace2(i.first,i.second);
      if(i.first >=1 and i.first <= n - 1)
        {
          ans[i.first] = i.second;
        }
    }
  
    for(int i = 1; i <= n-1; i++)cout << ans[i] << endl;


    // bfs(4);

    // for(int i = 1; i <= n; i++)
    // {
    //   cout << dist[i] << endl;
    // }


  return 0;
} 

Measured memory_bytes: 132992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i,n){
    char c;
    cin >> c;
    s[i] = c - '0';
  }
  int ans = 0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        int p = 0;
        while(s[p] != i && p < n) p ++;
        p ++;
        while(s[p] != j && p < n) p ++;
        p ++;
        while(s[p] != k && p < n) p ++;
        if(p < n) ans ++;
      }//k
    }//j
  }//i
  cout << ans << endl;
}


Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<Int> dist;
vector<vector<pair<Int,Int>>> G;

bool dfs(Int v) {
	
	for (auto e : G[v]) {
		if (dist[e.first] == INF) {//行き先が見探索の場合
			dist[e.first] = dist[v] + e.second;
			if(!dfs(e.first))return false;//1回でもfalseが返ってきたら、falseを返す
		}
		else if (dist[v] + e.second != dist[e.first])return false;//矛盾する場合
	}

	return true;
}

int main() {

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

	Int N, M;
	cin >> N >> M;

	dist.resize(N, INF);
	G.resize(N);

	Int L, R, D;
	for (Int i = 0; i < M; i++) {
		cin >> L >> R >> D;
		L--;
		R--;
		G[L].push_back(make_pair(R, D));
		G[R].push_back(make_pair(L, -D));
	}

	for (Int i = 0; i < N; i++) {
		if (dist[i] == INF) {
			dist[i] = 0;
			if (!dfs(i)) {
				cout << "No" << "\n";
				return 0;
			}
		}
	}

	cout << "Yes" << "\n";
}


Measured memory_bytes: 15616
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end 
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class Edge
  attr_accessor:to,:from,:c
  def initialize(from,to,cost)
    @to=to
    @from=from
    @c=cost
  end
end
class PriorityQueue
  attr_accessor:heap,:n
  def initialize(n)
    @n=0
    @heap=array(2,n,Float::INFINITY)
  end

  def push(x)
    i=@n
    @n+=1
    while i>0
      p=(i-1)/2
      break if @heap[p][0]<=x[0]
      @heap[i]=@heap[p]
      i=p
    end
    @heap[i]=x
  end

  def pop()
    res=@heap[0]
    @n-=1
    x=@heap[@n]
    i=0
    while i*2+1<=@n
      l=i*2+1
      r=i*2+2
      l=r if r<=@n and @heap[r][0]<=@heap[l][0]
      break if @heap[l][0]>=x[0]
      @heap[i]=@heap[l]
      i=l
    end
    @heap[i]=x
    return res
  end
end
V,E,r=get_i
edges=Array.new(V){[]}
E.times do|i|
  s,t,d=get_i
  edges[s].push(Edge.new(s,t,d))
end

pq=PriorityQueue.new(V)
d=array(V,1,Float::INFINITY)
d[r]=0
pq.push([d[r],r])

until pq.n.zero?
  v=pq.pop()
  next if v[0]==Float::INFINITY and v[1]==Float::INFINITY
  if d[v[1]]<v[0]
    next
  else
    next if edges[v[1]].nil?
    edges[v[1]].each do|e|
      if d[e.to]>d[v[1]]+e.c
        d[e.to]=d[v[1]]+e.c
        pq.push([d[e.to],e.to])
      end
    end
  end
end
d.each do|dis|
  if dis==Float::INFINITY
    puts "INF"
  else
    puts dis
  end
end


Measured memory_bytes: 60740
#include<iostream>
#include<string>
using namespace std;
int n;
string s;

int main(){
    cin >> s;
    n = s.length();
    bool is_constructable = true;

    if(s[0] == '0' || s[n-1] == '1'){
        is_constructable = false;
    }
    for(int i = 0; i < n - 1; i++){
        if(s[i] != s[n - 2 - i]){
            is_constructable = false;
        }
    }
    if(!is_constructable){
        cout << "-1" << endl;
        return 0;
    }

    int i = 0;
    while(i < n - 1){
        int j = i;
        while(s[j] == '0'){
            cout << (i+1) << " " << (j+2) << endl;
            j++;
        }
        cout << (i+1) << " " << (j+2) << endl;
        i = j + 1;
    }

        
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define be(x) (x).begin(),(x).end()

void solve(){
    double n;
    cin>>n;
    double a=n/1.08;
    if(ceil(a) == floor(a)){
        int ans=a;
        cout<<ans<<endl;
    }
    else if(floor(round(a)*1.08)==n){
        int ans=round(a);
        cout<<ans<<endl;
    } 
    else if(floor(ceil(a)*1.08)==n){
        int ans=ceil(a);
        cout<<ans<<endl;
    }
    else cout<<":("<<endl;
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
    
    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    
    cout << endl;
}


Measured memory_bytes: 3100
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
n,m=map(int,input().split())
z=n*(n-1)//2
l=[-1]*n
a=[1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[z]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
def f(s):
  return r(int(s)-1)
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  if x!=y:
    s,t=a[x],a[y]
    z-=s*t
    if s<t:
      l[x]=y
      a[y]+=s
    else:
      l[y]=x
      a[x]+=t
  c[i]=z
for x in c[1:]:
  print(x)

Measured memory_bytes: 41040
#include <stdio.h>


int main(void){

	char n;
	int ans=0;
	
	while(1){
	
		scanf("%c",&n);
	
		if(n=='0'){
			break;
		}else if(n=='1'){
		    ans+=1;
		}else if(n=='2'){
		    ans+=2;
		}else if(n=='3'){
		    ans+=3;
		}else if(n=='4'){
		    ans+=4;
		}else if(n=='5'){
		    ans+=5;
		}else if(n=='6'){
		    ans+=6;
		}else if(n=='7'){
		    ans+=7;
		}else if(n=='8'){
		    ans+=8;
		}else if(n=='9'){
		    ans+=9;
		}
		    
		
		while(1){
			scanf("%c",&n);
			
			if(n=='0'){
			}else if(n=='1'){
		    	ans+=1;
			}else if(n=='2'){
			    ans+=2;
			}else if(n=='3'){
			    ans+=3;
			}else if(n=='4'){
			    ans+=4;
			}else if(n=='5'){
			    ans+=5;
			}else if(n=='6'){
			    ans+=6;
			}else if(n=='7'){
			    ans+=7;
			}else if(n=='8'){
			    ans+=8;
			}else if(n=='9'){
			    ans+=9;
			}else{
				break;
			}
		}
		
		printf("%d\n",ans);
		ans=0;
	}
	
	return 0;
}

Measured memory_bytes: 2704
#include <stdio.h>

int main(void){
    int N,K,x,y,min,i;
    scanf("%d %d",&N,&K);
    for(i=0;i<K;i++){
        scanf("%d %d",&x,&y);
        x>y?min=y:(min=x);
        if(min > N-x+1)
            min=N-x+1;
        if(min > N-y+1)
            min=N-y+1;
        min=(min-1)%3;
        if(min == 0)
            puts("1");
        else if(min == 1)
            puts("2");
        else
            puts("3");
    }
    return 0;
}

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

std::vector<std::vector<int>> C;

std::vector<int> row_diff(int i, int j) {
    return {C[j][0] - C[i][0], C[j][1] - C[i][1], C[j][2] - C[i][2]};
}

std::vector<int> col_diff(int i, int j) {
    return {C[0][j] - C[0][i], C[1][j] - C[1][i], C[2][j] - C[2][i]};
}

int main() {
    C.assign(3, std::vector<int>(3));
    std::cin >> C[0][0] >> C[0][1] >> C[0][2];
    std::cin >> C[1][0] >> C[1][1] >> C[1][2];
    std::cin >> C[2][0] >> C[2][1] >> C[2][2];

    auto row_diff01 = row_diff(0, 1);
    auto row_diff12 = row_diff(1, 2);
    auto col_diff01 = col_diff(0, 1);
    auto col_diff12 = col_diff(1, 2);

    bool cond1 = row_diff01[0] == row_diff01[1] && row_diff01[1] == row_diff01[2];
    bool cond2 = row_diff12[0] == row_diff12[1] && row_diff12[1] == row_diff12[2];
    bool cond3 = col_diff01[0] == col_diff01[1] && col_diff01[1] == col_diff01[2];
    bool cond4 = col_diff12[0] == col_diff12[1] && col_diff12[1] == col_diff12[2];

    if (cond1 && cond2 && cond3 && cond4) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
/*
Author: Dynamic JQ

Problem: ARC095 E - Symmetric Grid

Time & Date(start): Apr/23/2018 18:33

Verdict: Coding

Tags: Bruteforce
*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;
const LL LINF = (1LL << 62) + 7;
int n, m;
bool used[15];
LL fo[15][15], fr[15][15];
char d[15][15];

bool check()
{
	vector<LL> sym;
	rep(i, m) if(fo[n][i] == fr[n][i]) sym.push_back(fo[n][i]);
	sort(sym.begin(), sym.end());
	sym.push_back(LINF);
	sort(fo[n], fo[n] + m);
	sort(fr[n], fr[n] + m);
	rep(i, m) if(fo[n][i] != fr[n][i]) return false;
	int pos = 0, cur = 0, cnt = 0;
	rep(i, m) if(fo[n][i] == sym[pos]) cur ^= 1;
	else {
		cnt += cur;
		cur = 0;
		while(fo[n][i] > sym[pos]) pos ++;
		if(fo[n][i] == sym[pos]) cur ^= 1;
	}
	cnt += cur;
	return cnt == (m & 1);
}

bool solve(int id, int beg, LL t)
{
	if(id == n) return check();
	for(int i = (id >= (n >> 1) ? 0 : beg); i < n; i ++)
	if(!used[i]) {
		used[i] = true;
		rep(j, m) fo[id + 1][j] = fo[id][j] * 26 + d[i][j];
		rep(j, m) fr[id + 1][j] = fr[id][j] + d[i][j] * t;
		if(solve(id + 1, i, t * 26LL)) return true;
		used[i] = false;
	}
	return false;
}

int main()
{
	scanf("%d%d", &n, &m);
	rep(i, n) {
		scanf("%s", d[i]);
		rep(j, m) d[i][j] -= 'a'; 
	}
	printf(solve(0, 0, 1LL) ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    REP(i, H) {
        REP(j, W) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> ans;
    REP(i, H-1) {
        REP(j, W) {
            if (a[i][j] % 2 == 1) {
                a[i][j]--;
                a[i+1][j]++;
                ans.push_back({i+1, j+1, i+2, j+1});
            }
        }
    }
    REP(j, W-1) {
        if (a[H-1][j] % 2 == 1) {
            a[H-1][j]--;
            a[H-1][j+1]++;
            ans.push_back({H, j+1, H, j+2});
        }
    }
    cout << ans.size() << endl;
    for (auto& v : ans) cout << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << endl;
}

Measured memory_bytes: 10032
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,m, ans = -1,buf;
	string s;
	bool flag = true;

	cin >> n >> m;

	if (n > 1)
		s.push_back('1');
	else
		s.push_back('0');

	forll(i, 1, n)
		s.push_back('0');

	vector<pair<ll, ll>> a(m);

	forll(i, 0, m)
		cin >> a[i].first >> a[i].second;

	a.push_back({ 4,0 });

	sort(a.begin(), a.end());

	forll(i, 0, m)
	{
		buf = a[i].second;

		if (a[i].first != a[i+1].first)
			s[a[i].first-1] = (char)buf+'0';
		else if (a[i].second != a[i + 1].second)
		{
			flag = false;
			break;
		}
	}

	if (!flag || n > 1 && s[0] == '0')
		cout << ans << endl;
	else
		cout << s << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define INF 0x3f3f3f3f
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
using namespace std;


int main()
{
  ll n;
  cin >> n;
  ll arr[n];
  fr(i,0,n)cin >> arr[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  fr(i,2,n)
  {
      dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
  }
  cout << dp[n-1];
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N, H, W;
    cin >> N >> H >> W;
    int ans = 0;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        if(a >= H && b >= W) { ans++; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
T,A = list(map(int,input().split()))
H = list(map(int,input().split()))
MIN = 9999999
NUM = -1
for i in range(N):
    if abs(A-(T-H[i]*0.006)) < MIN:
        MIN = abs(A-(T-H[i]*0.006))
        NUM = i
print(NUM+1)


Measured memory_bytes: 3060
#include <iostream>
#include <queue>

using namespace std;

struct process {
    string name;
    int time;
};

int main() {
    int elapsed = 0;
    int n, q, time;
    string name;
    queue<process> Q;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> name >> time;
        Q.push(process{name, time});
    }
    while (!Q.empty()) {
        process P = Q.front();
        Q.pop();
        if (P.time > q) {
            P.time -= q;
            Q.push(P);
            elapsed+=q;
        } else {
            elapsed+=P.time;
            cout << P.name << ' ' << elapsed << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 6244
h, w, a, b = map(int, input().split())

row_0 = '0' * a + '1' * (w - a)
row_1 = '1' * a + '0' * (w - a)

for _ in range(b):
    print(row_0)

for _ in range(h - b):
    print(row_1)

Measured memory_bytes: 3956
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N  =sc.nextInt();
        int K = sc.nextInt();
        int num = 0;
        for(int i=0;i<N;i++){
            int h = sc.nextInt();
            if(K<=h)num++;
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 48236
def removeRow(s, i):
  return s[:i] + s[i+1:]

def removeCol(s, j):
  for i in range(len(s)):
    s[i] = s[i][:j] + s[i][j+1:]
  return s

def isWhiteRow(s, i):
  return s[i].count("#") == 0

def isWhiteCol(s, j):
  res = True
  for i in range(len(s)):
    res &= s[i][j] == "."
  return res

H, W = map(int, input().split())
a = [ input() for _ in range(H) ]

while True:
  changed = False
  for i in range(len(a)):
    if isWhiteRow(a, i):
      a = removeRow(a, i)
      changed = True
      break
  for j in range(len(a[0])):
    if isWhiteCol(a, j):
      a = removeCol(a, j)
      changed = True
      break
  if not changed:
    for s in a:
      print(s)
    exit()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
map<string, int> m;
int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		int t, y;
		string x;
		cin >> t >> x;
		if(t == 0) 
		{
			scanf("%d",&y);
			m[x] = y;
		}
		else if(t == 1) printf("%d\n",m[x]);
		else if(t == 2) m.erase(x);
	}
	return 0;
}


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

using namespace std;

int main(){
    long long H, W;

    cin >> H >> W;

    long long w = W/2;
    long long h = H/2;

    if ((H == 1) || (W == 1)){
        cout << 1 << endl;
    }
    else{
        cout << w * h + (W-w) * (H-h) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
        int data;
        struct node *next;
        struct node *prev;
        struct node *head;
        struct node *last;
}stack;
typedef struct {
        stack pair;
        stack area;
}areapair;
void Push_back(stack**, stack**, int);
int Pop_back(stack**, stack**);
main()
{
        int i, ch, count = 0, sum = 0;
        char str[20001];
        stack S1, *p;
        areapair S2;
        S1.head = S1.last = S2.pair.head = S2.pair.last
                = S2.area.head = S2.area.last = NULL;
        scanf("%s", str);
        for(i = 0; str[i]; i++){
                if(str[i] == '\\'){
                        Push_back(&(S1.head), &(S1.last), i);
                }else if(S1.head != NULL && str[i] == '/'){
                        int j = Pop_back(&(S1.head), &(S1.last));
                        int a = i - j;
                        sum += i - j;
                        count++;
                        while(S2.pair.head != NULL && S2.pair.last -> data > j){
                                a += S2.area.last -> data;
                                Pop_back(&(S2.pair.head), &(S2.pair.last));
                                Pop_back(&(S2.area.head), &(S2.area.last));
                                count--;
                        }
                        Push_back(&(S2.pair.head), &(S2.pair.last), j);
                        Push_back(&(S2.area.head), &(S2.area.last), a);
                }
        }
        printf("%d\n%d", sum, count);
        p = S2.area.head;
        while(p != NULL){
                printf(" %d", p -> data);
                p = p -> next;
        }
        putchar('\n');
}
void Push_back(stack **head, stack **last, int data)
{
        stack *p;
        if((p = (stack*)malloc(sizeof(stack))) == NULL){
                fprintf(stderr, "Memory cannot allocate\n");
                exit(0);
        }
        p -> data = data;
        p -> next = NULL;
        p -> prev = *last;
        if(*head == NULL){
                        *head = p;
        }else{
                        (*last) -> next = p;
        }
        *last = p;
}
int Pop_back(stack **head, stack **last)
{
        int pop_data;
        stack *p = *last;
        if(*head == NULL){
                return EOF;
        }
        pop_data = (*last) -> data;
        if((*last) -> prev == NULL){
                *head = NULL;
        }else{
                        (*last) -> prev -> next = NULL;
        }
                *last = (*last) -> prev;
        free(p);
        return pop_data;
}

Measured memory_bytes: 2628
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    s: Chars
    }
    let n = s.len();
    for i in 0..n {
        if i % 2 == 0 && s[i] == 'L' {
            print!("No");
            return
        }
        if i % 2 == 1 && s[i] == 'R' {
            print!("No");
            return
        }
    }
    println!("Yes");
    return
}


Measured memory_bytes: 2200
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,cnt,ans,f[100010];
int main()
{
	int i,s,a,b,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		f[a]++;f[a+1]++;
		if(a)f[a-1]++;
	}
	for(i=0;i<=1e5;i++)ans=max(ans,f[i]);
	printf("%d",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(void) {
    int N;
    cin >> N;

    vector<int> p(N + 1);
    for(int i = 1; i <= N; i++) {
        cin >> p[i];
    }

    int fix_count = 0;

    for(int i = 1; i <= N; i++) {
        if(p[i] == i) {
            continue;
        }

        if(fix_count >= 1 || p[p[i]] != i) {
            cout << "NO" << endl;
            return 0;
        }

        int tmp = p[p[i]];
        p[p[i]] = p[i];
        p[i] = tmp;
        fix_count++;
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    int h, w;
    cin >> h >> w;
    string s[104];
    rep(i, h) cin >> s[i];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < 2; j++) {
            cout << s[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;
    std::cin >> N;
    int n1 = N%10;
    int n10 = ((N-n1)%100)/10;
    int n100 = ((N-n1-10*n10)%1000)/100;
    int n1000 =(N-n1-10*n10-100*n100)/1000;
    if((n1==n10 && n10==n100) || (n10==n100 && n100==n1000)){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define DREP(i,n,N) for(int i=n;i>=N;i--)
#define print(S) cout<<S<<endl;
using namespace std;

int main() {
	int N;
	cin>>N;
	int A[N];
	set<int> st;
	REP(i,0,N){
		cin>>A[i];
		st.insert(A[i]);
	}
	if(st.size()%2){
		print(st.size());
	}else{
		print(st.size()-1);
	}

	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

class Main{
      public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int b = sc.nextInt();
	int a = sc.nextInt();
	if(a-2*b<0||a%2!=0||2*b-a/2<0){
	    System.out.println("No");
	}else{
	    System.out.println("Yes");
	}
	sc.close();
      }
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

using pint = pair<int,int>;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int amax = -1e+6-10, amin = 1e+6+10;
    bool allpos = true, allneg = true;
    REP(i,N) {
        cin >> a[i];
        amax = max(amax,a[i]);
        amin = min(amin,a[i]);
        if ( a[i] < 0 ) allpos = false;
        else if ( a[i] > 0 ) allneg = false;
    }
    
    int imax,imin;
    REP(i,N){
        if ( amax == a[i] ) imax = i;
        if ( amin == a[i] ) imin = i;
    }
    
    vector<pint> ans;
    if ( allpos ){
        for ( int i = 1; i < N; ++i){
            ans.push_back(pint(i-1,i));
        }
    } else if ( allneg ){
        for ( int i = N-1; i >= 1; --i){
            ans.push_back(pint(i,i-1));
        }
    } else {
        if ( abs(amax) >= abs(amin) ){
            REP(i,N){
                //if ( i == imax ) continue;
                ans.push_back(pint(imax,i));
            }
            for ( int i = 1; i < N; ++i){
                ans.push_back(pint(i-1,i));
            }
        } else {
            REP(i,N){
                //if ( i == imin ) continue;
                ans.push_back(pint(imin,i));
            }
            for ( int i = N-1; i >= 1; --i){
               ans.push_back(pint(i,i-1));
           }
        }
    }
    
    
    cout << ans.size() << endl;
    for ( int i = 0; i < ans.size(); ++i){
        cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    }
    
    
    
    
    return 0;
}


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

bool check(const std::vector<int>& count, int h, int m)
{
  int sum = 0;
  for (int c : count) {
    sum += std::min(c, h);
  }
  return sum / m >= h;
}

int main()
{
  std::ios::sync_with_stdio(false);
  int n, m;
  while (std::cin >> n >> m) {
    std::vector<int> count(26);
    std::string s;
    for (int i = 0; i < n; ++ i) {
      std::cin >> s;
      count[s[0] - 'A'] ++;
    }
    int result = 0;
    while (check(count, result + 1, m)) {
      result ++;
    }
    std::cout << result << std::endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		int x = in.nextInt();
		int t = in.nextInt();
		
		if(n % x == 0) System.out.println((n / x) * t);
		else System.out.println((n / x + 1) * t);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] a = new int[abc];
			for (int i = 0; i < abc; i++)
				a[i] = nextInt();
			return a;
		}
	}
}





Measured memory_bytes: 32700