akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 110
#define INF (1<<29)
typedef pair<int,int> P;
typedef pair<int,P> PP;
 
int H,W;
int dist[MAX][MAX]; 
char field[MAX][MAX];
vector<P> M,Hole;
 
struct State{
    int x,y,cost,m;
    State(){}
    State(int x,int y,int cost,int m) : x(x), y(y), cost(cost), m(m) {}
};
 
bool inField(int y,int x){
    return 0 <= y && y < H && 0 <= x && x < W;
}
 
void init(){
    fill(dist[0],dist[MAX],1);
    const int dx[] = {-1,-1,-1,0,0,1,1,1};
    const int dy[] = {-1,0,1,-1,1,-1,0,1};
    for(int i = 0 ; i < (int)Hole.size() ; i++){
	int x = Hole[i].first, y = Hole[i].second;
	for(int j = 0 ; j < 8 ; j++){
	    int nx = x + dx[j];
	    int ny = y + dy[j];
	    if(!inField(ny,nx)) continue;
	    dist[ny][nx] = max(dist[ny][nx],3);
	    for(int k = 0 ; k < 8 ; k++){
		int nnx = nx + dx[k];
		int nny = ny + dy[k];
		if(!inField(nny,nnx)) continue;
		dist[nny][nnx] = max(dist[nny][nnx],2);
	    }
	}
    }
}
 
int bfs(int sx,int sy,int gx,int gy){
    const int dx[] = {-1,0,0,1};
    const int dy[] = {0,-1,1,0};
    int d[MAX][MAX];
    fill(d[0],d[MAX],INF);
    d[sy][sx] = 0;
    priority_queue<PP,vector<PP>,greater<PP> > Q;
    Q.push(PP(0,P(sx,sy)));
 
    while(!Q.empty()){
	PP p = Q.top(); Q.pop();
	int x = p.second.first, y = p.second.second;
	if(x == gx && y == gy) break;
	for(int i = 0 ; i < 4 ; i++){
	    int nx = x + dx[i];
	    int ny = y + dy[i];
	    if(!inField(ny,nx)) continue;
	    if(field[ny][nx] == '#') continue;
	    if(d[ny][nx] <= d[y][x] + dist[y][x]) continue;
	    Q.push(PP(p.first+dist[y][x],P(nx,ny)));
	    d[ny][nx] = p.first + dist[y][x];
	}
    }
 
    return d[gy][gx];
}
 
void solve(int sx,int sy,int gx,int gy){
    int len = M.size(),ans = INF;
    int d[MAX][MAX][1<<5];
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    for(int k = 0 ; k < 1<<5 ; k++){
		d[i][j][k] = INF;
	    }
	}
    }
    d[sy][sx][0] = 0;
    queue<State> Q;
    Q.push(State(sx,sy,0,0));   
    init();
 
    while(!Q.empty()){
	State S = Q.front(); Q.pop();
	bool ok = true;
	for(int i = 0 ; i < len ; i++){
	    if(!(S.m >> i & 1)){
		ok = false; 
		break;
	    } 
	}
	if(ok && S.x == gx && S.y == gy){
	    ans = min(ans,S.cost);
	    continue;
	}
	if(ok){
	    S.cost += bfs(S.x,S.y,gx,gy);
	    ans = min(ans,S.cost);   
	}else{
	    for(int i = 0 ; i < len ; i++){
		if(S.m >> i & 1) continue;
		State next;
		next.cost = S.cost + bfs(S.x,S.y,M[i].first,M[i].second);
		next.m = S.m | 1<<i; next.x = M[i].first; next.y = M[i].second;
		if(next.cost < d[next.y][next.x][next.m]){
		    d[next.y][next.x][next.m] = next.cost;
		    Q.push(next);
		}
	    }
	}
    }
    cout << ans << endl;
}
 
int main(){
    int sx,sy,gx,gy;
    cin >> W >> H;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    cin >> field[i][j];
	    if(field[i][j] == 'S'){
		sx = j; sy = i;
	    }else if(field[i][j] == 'G'){
		gx = j; gy = i;
	    }else if(field[i][j] == 'M'){
		M.push_back(P(j,i));
	    }else if(field[i][j] == '#'){
		Hole.push_back(P(j,i));
	    }
	}
    }
    solve(sx,sy,gx,gy);
 
    return 0;
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    map<ll, ll> mp; // mp[累積の値のmod] := そのような値に成る部分数列の数
    ll acc = 0; // 累積の値
    mp[acc]++;
    rep(i, N)
    {
        acc += A[i];
        mp[acc % M]++;
    }
    ll res = 0;
    for (auto& v : mp) {
        res += v.second * (v.second - 1) / 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
INF = 10 ** 12

N, W = map(int, input().split())

items =[] * N

for i in range(N):
    v, w = map(int, input().split())
    items.append([v,w])

dp = [[INF for i in range(W+1)] for j in range(N+1)]

for i in range(W+1):
    dp[0][i] = 0

for i in range(N+1):
    dp[i][0] = 0

for i in range(1,N+1): #1<= i <= N
    for j in range(1, W+1): # 1 <= j <= W
        if j - items[i-1][1] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j - items[i-1][1]] + items[i-1][0])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])


Measured memory_bytes: 25948
S = input()

first_0 = 0
first_1 = 0

for i, s in enumerate(S):
    if i % 2 == 0:
        if s == "0":
            first_1 += 1
        else:
            first_0 += 1
    else:
        if s == "0":
            first_0 += 1
        else:
            first_1 += 1

print(min(first_0, first_1))

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

using namespace std;

int main(){
	int d;
	cin >> d;
	if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
	else if(d == 23) cout << "Christmas Eve Eve" << endl;
	else if(d == 24) cout << "Christmas Eve" << endl;
	else cout << "Christmas" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N; ++N;
    vector<int> ans,b1,b2;
    for (int i=1;N>1;++i){
        ans.emplace_back(i);
        if (N&1LL){
            b1.emplace_back(i);
            --N;
        } else {
            b2.emplace_back(i);
            N>>=1LL;
        }
    }
    reverse(b1.begin(),b1.end());
    for (int x:b2) ans.emplace_back(x);
    for (int x:b1) ans.emplace_back(x);
    cout << ans.size() << '\n';
    cout << ans << '\n';
}

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

int main() {
  int n;  cin >> n;
  int v[100];
  for(int i = 0; i < n; i++) cin >> v[i];
  for(int i = 0; i < n; i++) cout << v[i] << (i == n-1 ? "\n" : " ");

  //---Insertion Sort---//
  for(int j = 1; j < n; j++) {
    //--- key を挿入していく ---//
    int key = v[j];
    //--- k は keyの左隣にあるインデックス ---//
    int k = j - 1;
    //--- key より小さければ右へずらす ---//
    while(k >= 0 && key < v[k]) {
      v[k + 1] = v[k];
      k--;
    }
    //--- ループが終わった段階で一つ左へ行きすぎているので k+1 で調整 ---//
    v[k + 1] = key;
    for(int i = 0; i < n; i++) {
      cout << v[i] << (i == n-1 ? "\n" : " ");
    }
  }
}



Measured memory_bytes: 3064
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n, m; cin >> n >> m;
    vector<int> ac(n , 0), wa(n , 0);
    vector<bool> ok(n, false); 
    rep(i, m) {
        int p; string s; cin >> p >> s;
        --p;
        if(s == "WA" && ok[p] == 0) {
            wa[p] += 1;
        } else {
            ac[p] = 1;
            ok[p] = 1;
        }
    }
    int accnt = 0, wacnt = 0;
    rep(i, n) {
        accnt += ac[i];
        if(ok[i]) wacnt += wa[i];
    }
    cout << accnt << " " << wacnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const int maxn = 100000;
int n;
int a[maxn], dp[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i) dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
		if(i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	
	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
n = int(input())
d,x = map(int,input().split())

a = [int(input()) for _ in range(n)]

sum = x

for i in range(n):
  if d%a[i] == 0:
    sum += d//a[i]
  else:
    sum  += d//a[i] +1

print(sum)


Measured memory_bytes: 9080
#include <iostream>
#include <limits.h>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int main(void)
{
  int test = 1;
  int i,j,k,l;
  int n;
  int min = INT_MAX;
  int rep = INT_MIN;
  int a;
  scanf("%d",&n);
  rep(i,n) {
    scanf("%d",&a);
    if(a - min > rep) rep = a - min;
    if(min > a) min = a;
  }
  printf("%d\n",rep);
  return 0;
}

Measured memory_bytes: 3224
def main():
    from collections import deque
    import sys

    input = sys.stdin.readline
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    c = [input().rstrip() for _ in range(h)]
    cw -= 1
    ch -= 1
    dw -= 1
    dh -= 1
    c[ch] = c[ch][:cw] + "=" + c[ch][cw + 1 :]
    bfs = deque([[cw, ch]])
    warp_before = set()
    warp_after = set()

    for cnt in range(1000000):  # ワープ回数のカウント
        while bfs:  # ワープせずに歩いてどこまで行けるか
            for _ in range(len(bfs)):
                now_x, now_y = bfs.popleft()
                for next_x, next_y in zip([1, 0, -1, 0], [0, 1, 0, -1]):
                    x, y = now_x + next_x, now_y + next_y
                    if 0 <= x < w and 0 <= y < h:
                        if x == dw and y == dh:
                            print(cnt)
                            exit()
                        c_next = c[y][x]
                        if c_next == "#":  # 壁の隣マスの座標をwarp_beforeに加える
                            warp_before.add((now_x, now_y))
                        if c_next == ".":  # 走査済マーク
                            c[y] = c[y][:x] + "=" + c[y][x + 1 :]
                            bfs.append([x, y])
        else:
            if not warp_before:
                print(-1)
                exit()
            for now_x, now_y in warp_before:
                # 壁の隣マスの座標を中心に5*5マスの範囲で、壁の外側の未到達マスの座標をwarp_afterに加える
                if c[now_y][now_x] == "=":
                    for next_y in range(-2, 3):
                        for next_x in range(-2, 3):
                            x, y = now_x + next_x, now_y + next_y
                            if 0 <= x < w and 0 <= y < h:
                                warp_after.add((x, y))
            for x, y in warp_after:
                # 壁の外側の未到達マスの座標のゴール判定・走査済マーク「=」を付けてbfsに格納
                if c[y][x] == ".":
                    if x == dw and y == dh:  # 終了(ゴール)判定
                        print(cnt + 1)
                        exit()
                    c[y] = c[y][:x] + "=" + c[y][x + 1 :]
                    bfs.append([x, y])
            warp_before = set()
            warp_after = set()


if __name__ == "__main__":
    main()

Measured memory_bytes: 223456
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int a,b;cin>>a>>b;
  int p = a/b, q = a%b;
  double r = (double)a/b;
  cout<<fixed;
  cout<<p<<" "<<q<<" "<<r<<endl;
}



Measured memory_bytes: 3284
a, b, c, d = gets.chomp.split('').map(&:to_i)

if a + b + c + d == 7
  puts "#{a}+#{b}+#{c}+#{d}=7"
elsif a + b + c - d == 7
  puts "#{a}+#{b}+#{c}-#{d}=7"
elsif a + b - c + d == 7
  puts "#{a}+#{b}-#{c}+#{d}=7"
elsif a + b - c - d == 7
  puts "#{a}+#{b}-#{c}-#{d}=7"
elsif a - b + c + d == 7
  puts "#{a}-#{b}+#{c}+#{d}=7"
elsif a - b + c - d == 7
  puts "#{a}-#{b}+#{c}-#{d}=7"
elsif a - b - c + d == 7
  puts "#{a}-#{b}-#{c}+#{d}=7"
elsif a - b - c - d == 7
  puts "#{a}-#{b}-#{c}-#{d}=7"
end


Measured memory_bytes: 1916
import heapq
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

li=[]
heapq.heappush(li,(-a[0]-b[0]-c[0],0,0,0))

ans=[]
used=set()

for _ in range(k):
    value,i,j,l=heapq.heappop(li)
    ans.append(-value)
    
    if i<x-1 and (i+1,j,l) not in used:
        heapq.heappush(li,(-a[i+1]-b[j]-c[l],i+1,j,l))
        used.add((i+1,j,l))
    if j<y-1 and (i,j+1,l) not in used:
        heapq.heappush(li,(-a[i]-b[j+1]-c[l],i,j+1,l))
        used.add((i,j+1,l))
    if l<z-1 and (i,j,l+1) not in used:
        heapq.heappush(li,(-a[i]-b[j]-c[l+1],i,j,l+1))
        used.add((i,j,l+1))
        
for i in ans:
    print(i)

Measured memory_bytes: 5104
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i =0; i < n ;i++)
#define reps(s, i, n) for(int i =s; i < n ;i++)
using namespace std;
long long e[300005], w[300005];

int main(){   
    int N;
    string s;
    cin >> N;
    cin >> s;
    rep(i, N){
        if(s[i]=='E'){
            e[i+1] = e[i] +1;
            w[i+1] = w[i];
        } 
        else{
            w[i+1] = w[i] + 1;
            e[i+1] = e[i];
        }
    }

    long long ans =999999999;

    for(int i =1; i <=N; i++){
        ans = min(ans,  (e[N]- e[i] + w[i-1] ));
        //cout << e[N]- e[i]  << " ";
        //cout <<w[i-1] << endl;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5380
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        void solve(Scanner sc, PrintWriter out) {
            int x = nint(sc);
            int y = nint(sc);
            if (x % y == 0){
                out.println(-1);
            }else{
                out.println(x);
            }

        }
    }

    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return String.valueOf(sc.next());
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k, n;
    cin >> k >> n;
    ll arr[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    ll maxi = k + arr[0] - arr[n - 1];
    for (ll i = 1; i < n; i++)
    {
        maxi = max(maxi, arr[i] - arr[i - 1]);
    }
    cout << k - maxi << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int a, b;
    char op;

    while (1)
    {
        cin >> a >> op >> b;
        switch (op)
        {
        case '+':
            OP(a + b);
            break;
        case '-':
            OP(a - b);
            break;
        case '*':
            OP(a * b);
            break;
        case '/':
            OP(a / b);
            break;
        case '?':
            return 0;
        }
    }
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
double d;
/**********************************************/

signed main(){
    cin >> d;
    printf("%.12f\n", max((double)((int)d+1), sqrt(2)*d));
}



Measured memory_bytes: 3280
# soundhound2018-summer-qualA - F
def main():
    a, b = list(map(int, input().rstrip().split()))
    if a + b == 15:
        print("+")
    elif a * b == 15:
        print("*")
    else:
        print("x")


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
import Data.List

data RecItem = RecItem {
    riStart :: Int
  , riEnd :: Int
  , riChannel :: Int
  } deriving (Show)

data EventType = ETStart | ETEnd
                           deriving (Eq, Ord)

data Event = Event {
    evTime :: Int
  , evType :: EventType
} deriving (Eq, Ord)

calc :: [RecItem] -> Int -> Int
calc ris numC =
  countPara $ sort $ concat [eventList ris c | c <- [1 .. numC]]

eventList :: [RecItem] -> Int -> [Event]
eventList ris c = 
  concat [[Event s ETStart, Event e ETEnd] |
          RecItem s e _ <- foldr gen [] $ sortOn riStart $ filter ffilt ris]
  where 
    ffilt (RecItem s e c') = c == c'
    gen ri [] = [ri]
    gen ri1@(RecItem s1 e1 _) ris2@((RecItem s2 e2 c) : ris)
      | e1 == s2  = RecItem s1 e2 c : ris
      | otherwise = ri1 : ris2

countPara :: [Event] -> Int
countPara evs = f 0 0 evs
  where f cur vMax [] = vMax
        f cur vMax ((Event t ETStart) : evs) = f (cur + 1) vMax' evs
          where vMax' = if cur == vMax then vMax + 1 else vMax
        f cur vMax ((Event t ETEnd)   : evs) = f (cur - 1) vMax evs

main :: IO ()
main = do
  x <- getLine
  let [numRI, numC] = [read w | w <- words x]
  ris <- readData numRI
  putStrLn $ show $ calc ris numC

readData :: Int -> IO [RecItem]
readData n = do
  ris <- f n []
  return $ reverse ris
  where
    f :: Int -> [RecItem] -> IO [RecItem]
    f n acc | n == 0 = return acc
            | otherwise = do
                    x <- getLine
                    let [s, e, c] = [read w | w <- words x]
                    f (n - 1) (RecItem s e c : acc)


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

using namespace std;

int main() {
    int n, k; cin >> n >> k;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int  x;
        cin >> x;
        if (x >= k) res++;
    }
    cout << res;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int a,p;cin>>a>>p;
  cout<<(3*a+p)/2<<endl;
}

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


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

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

	int r;

	cin >> r;

	cout << r * r << endl;

}


Measured memory_bytes: 256
n=gets.split
x=[0,2,5,3]
y=[0,4,5,1]
m=->r,d{r.map{|i|n[i]}.rotate(d).map.with_index{|v,i|n[r[i]]=v}}
gets.chop.chars{|c|m[(c<?F||?V<c)?x:y,c>?R?1:-1]}
puts n[0]

Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    rep(i,50001){
        int tmp = i * 1.08;
        if(tmp == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> board(H, vector<char>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> board.at(i).at(j);
    }
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (board.at(i).at(j) == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }
     
  for (int i = 0; i < H; i++) {
    if (row[i]) {
      for (int j = 0; j < W; j++) {
         if (col[j]) {
         	cout << board[i][j];
       	 }
      }
      cout << endl;
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define f first
#define s second
#define endl '\n'
#define sq(x) (x)*(x)*1ll
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_multiset;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//      tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef pair<int,int> pii;



int main () {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//        freopen("test_input.txt", "r", stdin);
        int a = 0, b= 0;
        string str; cin >> str;
        for (const auto w: str)
                a += w == 'A', b += w == 'B';

        if (a && b) cout << "Yes";
        else cout << "No";
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

int ans=1010,n,m;
char s[1010],t[1010];

int main(){
	scanf("%s",s);n=strlen(s);
	scanf("%s",t);m=strlen(t);
	for(int i=0;i<n-m+1;i++){
		int res=0;
		for(int j=0;j<m;j++) if(s[i+j]!=t[j]) res++;
		ans=min(ans,res);
	}cout<<ans;
}


Measured memory_bytes: 3760
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> as;
vector<int> bs;

ll solve(const int N) {
    if (N % 2 == 0) {
        ll a1 = as[N / 2 - 1];
        ll a2 = as[N / 2];
        ll b1 = bs[N / 2 - 1];
        ll b2 = bs[N / 2];
        // printf("a1: %lld, a2: %lld, b1: %lld, b2: %lld\n", a1, a2, b1, b2);
        return ((b1 + b2) - (a1 + a2)) + 1;
    } else {
        ll avg1 = as[N / 2];
        ll avg2 = bs[N / 2];
        // printf("avg1: %lld, avg2: %lld\n", avg1, avg2);
        return (avg2 - avg1) + 1LL;
    }
}

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

    as.resize(N);
    bs.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i] >> bs[i];
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 4828
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        
        var n = long.Parse(Console.ReadLine());
        var list = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(x => x).ToList();
        var ans = new List<long>();
        
        for(var i = 0;i < n - 1;i++){
            if(list[i] == list[i + 1]){
                ans.Add(list[i]);
                i++;
            }
        }
        if(ans.Count < 2){
            Console.WriteLine(0);
        }else{
            Console.WriteLine(ans[0] * ans[1]);
        }
        
    }
}


Measured memory_bytes: 24288
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
dp = [[[0]*(k+2*(n+1)) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(i+1):
        for l in range(k+1):
            dp[i+1][j+1][l+2*(j+1)] += dp[i][j][l]
            dp[i+1][j+1][l+2*(j+1)]%=mod
            dp[i+1][j][l+2*j] += dp[i][j][l]*(j*2+1)
            dp[i+1][j][l+2 * j] %= mod
            if j!= 0:
                dp[i+1][j-1][l+(j-1)*2] += dp[i][j][l]*j*j
                dp[i+1][j-1][l+(j-1)*2]%=mod



print(dp[n][0][k]%mod)



Measured memory_bytes: 96220
def det(a,b):
    return a[0]*b[1] - a[1]*b[0]
cnt = 1
while True :
    n = int(input())
    if n==0:
        break
    dots = []
    std = list(map(int,input().split()))
    for i in range(n-1):
        dots.append(list(map(int,input().split())))
    #print(dots)
   
    dots2 = []
    for dot in dots:
        dot[0] -= std[0]
        dot[1] -= std[1]
        dots2.append(dot)
    #print(dots2)
    area = 0
    for i in range(n-2):
        area += det(dots2[i],dots2[i+1])
    area /= 2
    area = abs(area)
    #print(std)
    print("{} {}".format(cnt,area))
    cnt +=1
    input()


Measured memory_bytes: 5612
# coding: utf-8
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(n):
    judge = input()
    if judge == "AC":
        AC += 1
    elif judge == "WA":
        WA += 1
    elif judge == "TLE":
        TLE += 1
    else:
        RE += 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))


Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e15;

using Weight=int;
struct Edge{
  int src,dst;
  Weight weight;
  Edge():src(0),dst(0),weight(0){}
  Edge(int s,int d,Weight w):src(s),dst(d),weight(w){}
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

vector<vector<int>> Dij(Graph&g,int s){
    using state = pair<int,pair<int,int>>;//始点からの距離、ノード、(使用＝１,未使用＝０)
    priority_queue<state,vector<state>,greater<state>> pq;
    vector<vector<int>> dis(g.size(),vector<int>(2,INF));
    dis[s][0]=0;

    pq.push({0,{s,0}});
    while(!pq.empty()){
      int d=pq.top().first;
      int v=pq.top().second.first;
      int ticket=pq.top().second.second;
      pq.pop();

      if(dis[v][ticket]<d)continue;
      rep(i,g[v].size()){
        Edge &e=g[v][i];

        if(dis[e.dst][ticket]>dis[v][ticket]+e.weight){
          dis[e.dst][ticket]=dis[v][ticket]+e.weight;
          pq.push({dis[e.dst][ticket],{e.dst,ticket}});
        }

        if(ticket)continue;

        rep(j,g[e.dst].size()){
          if(dis[v][0]<dis[g[e.dst][j].dst][1]){
            dis[g[e.dst][j].dst][1]=dis[v][0];
            pq.push({dis[g[e.dst][j].dst][1],{g[e.dst][j].dst,1}});
          }
        }
      }
    }
    return dis;
}

signed main(){
  int n,m;
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    Graph g(n);
    rep(i,m){
      int a,b,c;cin>>a>>b>>c;
      a--;b--;
      g[a].emplace_back(a,b,c);
      g[b].emplace_back(b,a,c);
    }
    vector<vector<int>> ans=Dij(g,0);
    cout<<min(ans[n-1][0],ans[n-1][1])<<endl;
  }

 return 0;
}



Measured memory_bytes: 3144
#Union Find

#木の根を求める
def find(x,par):
    if par[x] == x:
        return x
    else:
        return find(par[x],par)

#xとyの属する集合の併合
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    
    if x != y:
        #xとyの属している集合が異なる時
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x]==rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y,par):
    return find(x,par) == find(y,par)
n,k,L = map(int,input().split())
rpar = [] #親
tpar = []
rrank = [0]*n#木の深さ
trank= [0]*n

#初期化
for i in range(n):
    #par[i]:i rank[i]:0
    rpar.append(i)
    tpar.append(i)


for i in range(k):
    x,y = map(int,input().split())
    unite(x-1,y-1,rpar,rrank)
for i in range(L):
    x,y = map(int,input().split())
    unite(x-1,y-1,tpar,trank)

num = []
d = {}
for i in range(n):
    num.append(find(i,rpar)+find(i,tpar)*10**6)
    if num[-1] in d:
        d[num[-1]] += 1
    else:
        d[num[-1]] = 1
res = ''
for i in range(n):
    if i != 0:
        res += ' '
    
    res += str(d[num[i]])

print(res)

Measured memory_bytes: 42044
N=int(input())
K=int(input())
s=str(N)
N=len(s)

dp=[[[0]*2 for j in range(K+1)] for i in range(N+1)]
dp[0][0][0]=1

for i in range(N):
    for j in range(K+1):
        for k in range(2):
            cd=int(s[i])
            for nd in range(10):
                ni=i+1
                nj=j
                nk=k
                if nd!=0:nj+=1
                if nj>K:continue
                if k==0:
                    if nd>cd:continue
                    if nd<cd:nk=1
                dp[ni][nj][nk]+=dp[i][j][k]
print(dp[N][K][0]+dp[N][K][1])


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 5;

class LinearSieve {
    public:
        vector<int> lp, pr;
        LinearSieve() {}
        LinearSieve(int n) {
            lp.resize(n + 1);
            lp[0] = -1, lp[1] = -1;
            init(n);
        }

        void init(int x) {
            FOR (i, 2, x + 1) {
                if (lp[i] == 0) {
                    lp[i] = i;
                    pr.push_back(i);
                }
                for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && (ll)i * pr[j] <= x; ++j) {
                    lp[i * pr[j]] = pr[j];
                }
            }
        }

        bool isPrime(int x) { return lp[x] == x; }

        vector<int> factorList(int x) {
            vector<int> res;
            while (x != 1) {
                res.push_back(lp[x]);
                x /= lp[x];
            }

            return res;
        }

        vector<pair<int, int> > factorize(int x) {
            vector<int> p = factorList(x);
            if (p.size() == 0) return {};
            vector<pair<int, int> > res(1, make_pair(p[0], 0));
            rep (i, p.size()) {
                if (res.back().first == p[i]) {
                    res.back().second++;
                } else {
                    res.emplace_back(p[i], 1);
                }
            }

            return res;
        }
};

template<typename T>
T modpower(T a, T n, T mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T mod) {
    return modpower(a, mod - 2, mod);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    LinearSieve ls = LinearSieve(N);
    int n;
    cin >> n;
    ll res = 0;
    map<int, int> mp;
    vector<ll> a(n);
    
    rep (i, n) {
        cin >> a[i];
        auto v = ls.factorize(a[i]);
        rep (j, v.size()) {
            mp[v[j].first] = max(mp[v[j].first], v[j].second);
        }
    }
    ll l = 1;
    for (auto p : mp) {
        rep (i, p.second) {
            l *= p.first;
            l %= MOD;
        }
    }
    rep (i, n) {
        ll tmp = l * modinv(a[i], MOD);
        res += tmp;
        res %= MOD;
    }
    cout << res << endl;
    
    return 0;
}



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

using namespace std;

int main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;

	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x1 - (y2 - y1);
	y4 = y1 + (x2 - x1);

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 103455

int cant[tam];
int vis[tam];
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;
    cin>>n>>m;
    forr(i,1,n+1)
        cant[i]=1;
        vis[1]=1;
    int iz,der;
    forr(i,0,m)
    {
        cin>>iz>>der;
        
        if (vis[iz])
            vis[der]=1;
        cant[iz]--;
        if (cant[iz]==0)
            vis[iz]=0;
        cant[der]++;
    }
    int c=0;
    forr(i,1,n+1)
    {
        //cout<<cant[i]<<" "<<vis[i]<<endl;
        if (vis[i] && cant[i]>0)
            c++;
    }
    cout<<c<<endl;
}
// PLUS ULTRA!!

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char ch[11];
	int i;
	for (i=1; i<=10; i++) cin >> ch[i];
	int p;
	p=int((ch[6]-'0')*10)+int(ch[7]-'0');
	if (p>4) cout << "TBD" << endl;
	else cout << "Heisei" << endl;
	return 0; 
} 

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2144
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,Q = LI()
    q = LIR(n)
    q.sort(key = lambda x:x[2])
    d = IR(Q)
    ans = [-1]*(Q+1)
    f = [0]*Q
    for s,t,x in q:
        l = bisect.bisect_left(d,s-x)
        r = bisect.bisect_left(d,t-x)
        while l < r:
            while ans[l] != -1:
                l = f[l]
            if r <= l:
                break
            ans[l] = x
            f[l] = r
            l += 1
    for i in ans[:-1]:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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


struct UnionFind {
  vector<int> par; //par[i]:=iの親番号

  UnionFind(int N) : par(N) {
    rep(i, N) par[i]=i;
  }

  int root(int x) { //xが属する木の根を得る
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { //併合
    int rx=root(x);
    int ry=root(y);
    if (rx==ry) return;
    par[rx]=ry;
  }

  bool same(int x, int y) { //x, yが属する木が同じならtrue
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main() {
  int n,q; cin>>n>>q;

  UnionFind uf(n);
  vector<int> res;
  rep(i, q) {
    int com,x,y; cin>>com>>x>>y;
    if (com==0) uf.unite(x, y);
    else res.push_back(uf.same(x, y));
  }
  rep(i, (int)(res.size())) {
    cout<<res[i]<<endl;
  }
}



Measured memory_bytes: 3364
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n; cin >> n;
  string s; cin >> s;
  int r = 0, b = 0;
  for (char c : s) r += (c == 'R'), b += (c == 'B');
  puts(r > b ? "Yes" : "No");
  return 0;
}


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"
#define llevel 20
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
const int N=3002;
ll dp[N][N];
int _runtimeTerror_()
{
	ll n,s,i,j;
	cin>>n>>s;
	ll ans=0,a[n];
	for(i=0;i<n;++i)
		cin>>a[i];
	mem1(dp);
	dp[0][0]=0;
	for(i=0;i<n;++i)
	{
		for(j=s;j>=0;--j)
		{
			if(i>0)dp[i][j]=dp[i-1][j];
		}
		if(a[i]==s)
		{
			ans=(ans+(n-i)*(i+1))%MM;
			continue;
		}
		for(j=s;j>0;--j)
		{
			if(j+a[i]<s && dp[i][j]!=-1)
			{
				if(dp[i][j+a[i]]==-1)++dp[i][a[i]+j];
				dp[i][j+a[i]]+=dp[i][j];
				dp[i][j+a[i]]%=MM;
			}
			else if(j+a[i]==s && dp[i][j]!=-1)
			{
				ans+=dp[i][j]*(n-i)%MM;
				ans%=MM;
			}
		}
		if(dp[i][a[i]]==-1)++dp[i][a[i]];
		dp[i][a[i]]=(dp[i][a[i]]+i+1)%MM;
	}
	cout<<ans%MM<<endl;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}


Measured memory_bytes: 70656
import java.util.*;

public class Main {
	final int INF = 1 << 24;
	C [][] pass;
	int ans;
	String [][] data;
	char [][] map;
	String [] store;
	boolean [] used;
	HashMap<Character, Character> change;

	class C{
		int pos ,ind;
		public C(int pos, int ind) {
			this.pos = pos;    this.ind = ind;
		}
	}

	private void dfs(int deep){
		if(deep == 9){
			ans++;
			return;
		}
		for(int j = 0; j< 9; j++){
			if(used[j]) continue;
			for(int i=0; i < 4; i++){
				store[deep] = data[j][i];
				if(check(deep)){
					used[j] = true;
					dfs(deep+1);
					used[j] = false;
				}
			}
		}
		return ;
	}

	private boolean check(int deep){
		for(int i = 0 ;  i <= 3; i += 3){
			C to = pass[deep][i];
			if(to == null) continue;
			//System.out.println("A= " + store[deep] + " " + store[to.pos] + " " + deep);
			if(store[deep].charAt(i) != change.get(store[to.pos].charAt(to.ind))){
				return false;
			}
		}
		return true;
	}

	private void doit() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		pass = new C[9][4];
		passCreate();
		change = new HashMap<Character, Character>();
		change.put('R', 'r');
		change.put('G', 'g');
		change.put('B', 'b');
		change.put('W', 'w');
		change.put('r', 'R');
		change.put('g', 'G');
		change.put('b', 'B');
		change.put('w', 'W');
		while(n-- > 0){
			data = new String[9][4];
			for(int i =0; i < 9; i++){
				String str = sc.next();
				for(int j =0; j < 4; j ++){
					char [] work = new char[4];
					for(int k =0; k < 4; k++){
						work[k] = str.charAt((k+j) % 4);
					}
					data[i][j] = new String(work);
				}
			}
			ans = 0;
			map = new char[9][9];
			store = new String[9];
			used = new boolean[9];
			for(int i = 0; i < 9; i++)	Arrays.fill(map[i], '*');
			dfs(0);
			System.out.println(ans);
		}
	}

	private void passCreate(){
		pass[1][3] = new C(0,1);
		pass[2][3] = new C(1,1);
		pass[3][0] = new C(0,2);
		pass[4][0] = new C(1,2);
		pass[4][3] = new C(3,1);
		pass[5][0] = new C(2,2);
		pass[5][3] = new C(4,1);
		pass[6][0] = new C(3,2);
		pass[7][0] = new C(4,2);
		pass[7][3] = new C(6,1);
		pass[8][0] = new C(5,2);
		pass[8][3] =  new C(7,1);
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a;
  cin >> a;
  cout << (int)ceil(a / 2.0) << endl;
  return 0;
}


Measured memory_bytes: 256
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " Fun.id in
  let ans = ref 0 in
  let m = ref IntMap.empty in
  for i = n - 1 downto 0 do
    ans := !ans + Option.value ~default:0 (IntMap.find_opt (as_.(i) + i) !m);
    m :=
      IntMap.add (i - as_.(i))
        (1 + Option.value ~default:0 (IntMap.find_opt (i - as_.(i)) !m)) !m
  done;
  Printf.printf "%d\n" !ans



Measured memory_bytes: 23852
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   
    int n = sc.nextInt();
    String s = sc.next();
    String ss = "";

    char abc[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    //メモ　Aが０

    for(int i = 0 ; i < s.length() ; ++i){
      for(int j = 0 ; j < abc.length ; ++j){
        if(s.charAt(i) == abc[j]){
          if(j+n>=26){
            ss += abc[j+n-26];
          }else{
            ss += abc[j+n];
            break;
          }
          
        }
      }
    }
   System.out.println(ss);
  }
}

Measured memory_bytes: 56672