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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(std::string S, std::string T) {
  cout << T << S << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 3632
import sys
from collections import deque

H, W = map(int, sys.stdin.readline().split())
cy, cx = map(int, sys.stdin.readline().split())
gy, gx = map(int, sys.stdin.readline().split())

cy -= 1
cx -= 1
gy -= 1
gx -= 1

grid = []
for _ in range(H):
    grid.append(sys.stdin.readline().strip())

q = deque()
# x, y, 累積移動距離, ブロック通過数, ワープ利用数
q.append((cx, cy, 0))
# visited = {}
visited = [[float("inf") for _ in range(W)] for _ in range(H)]
# visited[(cx, cy)] = 0
visited[cy][cx] = 0
ans = float("inf")
while q:
    x, y, c = q.popleft()
    # if (x, y) in visited and visited[(x, y)] < c:
    if visited[y][x] < c:
        # print("here1")
        continue
    # print(x, y, c, d, e)
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nx = x + dx
        ny = y + dy
        if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#":
            # if (nx, ny) in visited and visited[(nx, ny)] < c + 1:
            if visited[ny][nx] <= c:
                # print("here2")
                continue
            # visited[(nx, ny)] = c
            visited[ny][nx] = c
            if nx == gx and ny == gy:
                continue
            q.appendleft((nx, ny, c))
    for dx in range(-2, 3):
        for dy in range(-2, 3):
            if abs(dx) == 1 and dy == 0 or abs(dy) == 1 and dx == 0:
                continue
            nx = x + dx
            ny = y + dy
            # print("warp", dx, dy)
            if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#":
                # print("warp append")
                # if (nx, ny) in visited and visited[(nx, ny)] < c + 1:
                if visited[ny][nx] < c + 1:
                    # print("here3")
                    continue
                # visited[(nx, ny)] = c + 1
                visited[ny][nx] = c + 1
                if nx == gx and ny == gy:
                    continue
                q.append((nx, ny, c+1))
# print(visited)
if visited[gy][gx] == float("inf"):
    print(-1)
else:
    print(visited[gy][gx])

Measured memory_bytes: 222608
import java.util.*;

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

        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 1001;

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
            min = Math.min(min, a[i]);
        }

        System.out.println(max - min);
    }
}

Measured memory_bytes: 21844
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

vector<pair<int,int>> way={{1,0},{0,1}};
//(*'ω'*)ACほちぃ...
int main(){
    int h,w,r,c,nr,nc;cin>>h>>w;
    vector<string> maze(h);
    for(int i=0;i<h;i++)cin>>maze[i];
    vector<vector<int>> change(h,vector<int>(w,1000));
    vector<vector<int>> visited(h,vector<int>(w,0));
    change[0][0]=0;
    queue<pair<int,int>> q;
    q.push(make_pair(0,0));
    while(!q.empty()){
        auto p=q.front();q.pop();
        r=p.first;c=p.second;
        for(auto wp:way){
            nr=r+wp.first;nc=c+wp.second;
            if(nr>h-1||nc>w-1)continue;
            if(maze[nr][nc]==maze[r][c]){
                change[nr][nc]=min(change[nr][nc],change[r][c]);
            }
            else{
                change[nr][nc]=min(change[nr][nc],change[r][c]+1);
            }
            if(!visited[nr][nc]){
                q.push(make_pair(nr,nc));
                visited[nr][nc]=1;
            }
        }
    }
    int tmp=change[h-1][w-1];
    int ans=(tmp+1)/2;
    if(maze[0][0]=='#'&&maze[h-1][w-1]=='#')ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3736
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    string s;
    cin >> s;

    deque<char> dq;
    for (auto &&i : s) {
        dq.push_back(i);
    }
    bool rev = false;

    int q;
    cin >> q;
    for (int qi = 0; qi < q; qi++) {
        int t;
        cin >> t;

        if (t == 1) {
            rev = !rev;

        } else {
            int f;
            char c;
            cin >> f >> c;

            if ((f == 1) == rev) {
                dq.push_back(c);
            } else {
                dq.push_front(c);
            }
        }
    }

    if (!rev) {
        for (auto i = dq.begin(); i != dq.end(); i++) {
            cout << *i;
        }
    } else {
        for (auto i = dq.rbegin(); i != dq.rend(); i++) {
            cout << *i;
        }
    }
    cout << endl;
}


Measured memory_bytes: 976
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
C = []
D = []
for i in range(M):
    c,d = map(int,input().split())
    C.append(c)
    D.append(d)

for i in range(N):
    ans = float("inf")
    ansidx = 0
    for j in range(M):
        if ans > abs(A[i] - C[j]) + abs(B[i] - D[j]):
            ans = abs(A[i] - C[j]) + abs(B[i] - D[j])
            ansidx = j + 1
    print(ansidx)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
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;}

int main() {
    int n,x;
    cin >> n >> x;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    if(a[0] > x) {
        ans += a[0]-x;
        a[0] = x;
    }
    rep(i,n-1) {
        if(a[i]+a[i+1] > x) {
            int tmp = a[i]+a[i+1]-x;
            a[i+1] -= tmp;
            ans += tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int ans=0;
  int n = s.size();
  priority_queue<int> pq;
  for(int i=0; i<n; i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      ans++;
    }
    else{
      pq.push(ans);
      ans=0;
    }
  }
  
   pq.push(ans);
  
  cout << pq.top() << endl;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int d[5*100000+1];
int main(){
    string s;cin>>s;
    ll cnt = 0;
    ll res = 0;
    bool f = true;
    rep(i,s.size()){
        if(s[i]=='S'){
            cnt++;
        }
        else {
            if(cnt>0){
                res++;
                cnt--;
            }
        }
    }
    ll res1 = s.size()-res*2;
    cout<<res1;
}



Measured memory_bytes: 640
# AtCoder 社は、毎週土曜日にコンテストを開催しています。
# コンテストには ABC と ARC の 2つの種類があり、
# 毎週どちらか一方が開催されます。
# ABC が開催された次の週には ARC が開催され、
# ARC が行われた次の週には ABC が開催されます。
# 先週開催されたコンテストを表す文字列 S が与えられるので、
# 今週開催されるコンテストを表す文字列を出力してください。

# 制約
# Sは'ABC' または'ARC'

# 標準入力から文字列 S を取得する
s = input()

# S をたよりに、今週開催されるコンテストを出力する
next_contest = "ret"
if s == "ABC":
    next_contest = "ARC"
elif s == "ARC":
    next_contest = "ABC"

print(next_contest)


Measured memory_bytes: 8880
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long x = Long.parseLong(in.next());
            long k = Long.parseLong(in.next());
            long d = Long.parseLong(in.next());
            long ans = 0;
            x = Math.abs(x);

            if (x / d >= k) {
                ans = x - k * d;
            } else {
                long k2 = x / d;
                long x2 = x - k2 * d;
                long k3 = k - k2;
                k3 %= 2;
                x2 -= k3 * d;
                ans = Math.abs(x2);
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35692
a, b, c = sorted(map(int, input().split()))

diff1 = c - b
a += diff1
diff2 = c - a
if diff2 % 2 == 0:
    diff2 //= 2
else:
    diff2 += 1
    diff2 //= 2
    diff2 += 1

print(diff1 + diff2)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"math"
)

func fact(n int) int {
	if n == 0 {
		return 1
	}
	return n * fact(n-1)
}

func routepath(f []int, m [][]int, rp float64) float64 {
	var sum float64
	for i, t := range m {
		n_m := make([][]int, len(m))
		copy(n_m, m)
		n_m = append(n_m[:i], n_m[i+1:]...)

		var n_rp float64
		if f != nil {
			x := (f[0] - t[0])
			y := (f[1] - t[1])
			n_rp = math.Sqrt(float64(x * x + y * y))
		}

		if len(n_m) <= 0 {
			sum += n_rp + rp
			continue
		}

		sum += routepath(t, n_m, n_rp + rp)
	}
	return sum
}

func main() {
	var max int
	fmt.Scan(&max)

	var buf [][]int
	for {
		if !(max > len(buf)) {
			break
		}
		raw := make([]int, 2)
		fmt.Scanf("%d %d", &(raw[0]), &(raw[1]))

		buf = append(buf, raw)
	}

	fmt.Printf("%010.8f", routepath(nil, buf, 0) / float64(fact(max)))
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

const int mod = 998244353;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};


int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//input
	int N, K;
	cin >> N >> K;
	vector<int> L(K), R(K);
	rep(i,K) cin >> L[i] >> R[i];
	//dp
	vector<mint> dp(N+5,0), dpsum(N+5,0);
	dp[1] = 1; dpsum[1] = 1;
	for(int i = 1; i < N; i++){
		for(int k = 0; k < K; k++){
			int left = i+1 - R[k];
			int right = i+1 - L[k];
			if(right< 0) continue;
			left = max(left,1);
			dp[i+1] += dpsum[right] - dpsum[left-1];
		}
		dpsum[i+1] = dpsum[i] + dp[i+1];
	}
	//output
	cout << dp[N] << endl;
}

Measured memory_bytes: 6352
def counting_sort(A):
    # init
    bucket = {}
    for i in range(10000):
        bucket[i] = 0

    for a in A:
        bucket[a] += 1



    k = 0
    for i in range(10000):
        for j in range(bucket[i]):
            A[k] = i
            k += 1

n = int(input())
A = list(map(int, input().split()))

counting_sort(A)

print(*A)


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll a,b,c,d;
    string S;
    cin >> a>>b>>c>>d;

    vector<ll> x,y;

    x.push_back(a);
    //x.push_back(a*(-1));
    x.push_back(b);
    //x.push_back(b * (-1));
    y.push_back(c);
    //y.push_back(c * (-1));
    y.push_back(d);
    //y.push_back(d * (-1));

    ll ans = LLINF*(-1);

    REP(i,x.size()){
        REP(j,y.size()){
            ll tmp = x.at(i) * y.at(j);
            ans = max(tmp, ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long ll;

ll a, b, c;

void solve() {
  int cnt = 0;
  if(a == b) cnt++;
  if(a == c) cnt++;
  if(b == c) cnt++;
  string r = (cnt == 1) ? "Yes" : "No";
  cout << r;
}

void input() {
  cin >> a >> b >> c;
}
 
int main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:36777216")

#include <bits/stdc++.h>
using namespace std;
#define LSON            id << 1 , l , mid
#define RSON            id << 1 | 1 , mid + 1 , r
#define ROOT            1 , 1 , n
#define CLR(x , y)      memset(x , y , sizeof(x))
#define LOWBIT(x)       x & (-x)
#define FORN(i , a , n)  for(int i = (a) ; i <= (n) ; ++i)
#define FORP(i , n , a)  for(int i = (n) ; i >= (a) ; --i)
#define CASE(x)		printf("Case %d: ", x)
#define SFD(x)      scanf("%lf" , &x)
#define SFC(x)      scanf(" %c" , &x)
#define SFS(x)      scanf(" %s" , x)
#define SFI(x)      scanf("%d" , &x)
#define SFL(x)      scanf("%lld" , &x)
#define SFI64(x)    scanf("%I64d" , &x)
#define PFF(x)         printf("%f" , x)
#define PFD(x)         printf("%lf" , x)
#define PFI(x)         printf("%d" , x)
#define PFC(x)         printf("%c" , x)
#define PFS(x)         printf("%s" , x)
#define PFI64(x)       printf("%I64d" , x)
#define PFL(x)         printf("%lld" , x)
#define SPACE          printf(" ")
#define PUT            puts("")
#define LPUP(i , j , k) for(int i = j ; i <= k ; ++i)
#define LPDW(i , j , k) for(int i = j ; i >= k ; --i)
#define PB(x)          push_back(x)
#define ALL(A)         A.begin(), A.end()
#define SZ(A)          int((A).size())
#define LBD(A, x)      (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x)      (upper_bound(ALL(A), x) - A.begin())
#define LOCAL
static const double PI = acos(-1.0);
static const double EPS = 1e-8;
static const int INF = 0X3fffffff;
typedef double LL;

/************************Little Pea****************************/

LL t;
int n;
LL p;
LL now;
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("D:\\系统优化\\Desktop\\littlepea\\in.data" , "r" , stdin);
#endif
    cin >> n >> t;
    LL pre = 0;
    LPUP(i , 1 , n)
    {
        cin >> p;
        if(p - pre >= t)
        {
            now += t;
        }
        else
        {
            now += (p - pre);
        }
        pre = p;
    }
    printf("%.0f" , now + t);

#ifndef ONLINE_JUDGE
    fclose(stdin), fclose(stdout);
#endif
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    string s;
    cin >> s;
    if (s == "#") break;
    s += '/';
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b, --c, --d;
    vector<string> v;
    {
      string l;
      for (auto &c : s) {
        if (c == '/') v.emplace_back(l), l.clear();
        if (c == 'b') l += 'b';
        if (isdigit(c)) l += string(c - '0', '.');
      }
    }
    swap(v[a][b], v[c][d]);
    rep(i, v.size()) {
      int s = 0;
      for (auto &c : v[i]) {
        if (c == 'b') {
          if (s) cout << s;
          cout << 'b';
          s = 0;
        } else {
          s++;
        }
      }
      if (s) cout << s;
      cout << "/\n"[i == v.size() - 1];
    }
  }
}



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
int N;
cin >> N;
vector<int>P(N);
REP(i, N) cin >> P.at(i);
int cnt = 1;
int mi = P.at(0);
for(int i = 1; N > i; i++){
  if(P.at(i) <= mi) cnt++;
  mi = min(mi, P.at(i));
}

print(cnt);
}

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

/*
  idea :
  a = n, 2n, 3n, ..., n*n
  b = (n+1)n, (n+1)(n-1), (n+1)(n-2), ..., (n+1)1
  this makes a ascending and b descending

  and this forms :
  ai+bi becomes a pattern : x, x-1, x-2, ..., n*n + (n+1)

  then starting from p1, add the value of 
  a(p1) becomes x+1
  a(p2) becomes x+2
  ...
*/

int main(){
  int n, a[60005], b[60005], p[60005], val[60005];
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> p[i];
    val[p[i]] = p[i] + i-1;
  }

  for(int i=1; i<=n; i++){
    a[i] = i * n + val[i];
    b[i] = (n+1) * ((n+1) - i);
  }

  for(int i=1; i<=n; i++) cout << a[i] << " "; cout << endl;
  for(int i=1; i<=n; i++) cout << b[i] << " "; cout << endl;

  return 0;
}

Measured memory_bytes: 3924
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll a, b;
	cin >> a >> b;

	ll M = max(a, b);
	ll m = min(a, b);

	for (ll i = 0; i < M; ++i)
	{
		cout << m;
	}

	cout << endl;

	//system("pause");
}


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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,M;
vector <int > s,g;
vector <int > l,m;




int main()
{

	cin >> N >> M;

	s.resize(M);
	g.resize(M);
	m.resize(N+1);

	REP(i,N+1){
		m[i] = 0;
	}
	REP(i,M){
		cin >> s[i] >> g[i];
		if(s[i] == 1)
			l.push_back(g[i]);
		if(g[i] == N)
			m[s[i]] = 1;
	}
	REP(i,l.size()){
		if(m[l[i]]){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3196
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
int t[MAX_N], x[MAX_N], y[MAX_N];

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

  cin >> N;
  REP(i, N) cin >> t[i] >> x[i] >> y[i];

  int curT = 0, curX = 0, curY = 0;
  for (int i = 0; i < N; i++) {
    int diff = abs(x[i] - curX + y[i] - curY);
    int diffT = (t[i] - curT);
    // ちょうど
    if (diff != diffT &&
        // 偶数か奇数が一致していて少ないときは行けるので除外
        !(((diff % 2) == (diffT % 2)) && diff <= diffT)) {
      cout << "No" << endl;
      return 0;
    }
    curT = t[i], curX = x[i], curY = y[i];
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1408
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = [[0]*w for _ in range(h)]
def dfs(x,y):
    if 0 <= x < h and 0 <= y < w:
        if ans[x][y] != "#":
            ans[x][y] += 1        

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i][j] = '#'
            dfs(i+1, j)
            dfs(i+1, j+1)
            dfs(i+1, j-1)
            dfs(i-1, j+1)
            dfs(i-1, j)
            dfs(i-1, j-1)
            dfs(i, j+1)
            dfs(i, j-1)
for i in range(h):
    for j in range(w):
        ans[i][j]=str(ans[i][j])
        print(ans[i][j],end="")
    print('')



Measured memory_bytes: 9112
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	r := nextInt()
	puts(float64(r) * 2.0 * math.Pi)
}


Measured memory_bytes: 1764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int wa = a + b - c - d;
  string s;
  if (wa > 0) s = "Left";
  else if (wa == 0) s = "Balanced";
  else s = "Right";
  cout << s << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
double n, m;
int main() {
	cin >> n >> m;
	cout << ceil(n / m);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
int n,m,l;
int i,j,k;

scanf("%d %d %d", &n, &m, &l);

int matA[n][m];
int matB[m][l];
long ans[n][l];

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

for (i = 0; i < m; i++)
for (j = 0; j < l; j++)
scanf("%d", &matB[i][j]);

for (i = 0; i < n; i++) {
for (j = 0; j < l; j++) {
ans[i][j]=0;
for (k = 0; k < m; k++) {
ans[i][j] += matA[i][k] * matB[k][j];
}
}
}

for (i = 0; i < n; i++){
for (j = 0; j < l; j++){
if (j != l-1)printf("%ld ", ans[i][j]);
else printf("%ld", ans[i][j]);
}
puts("");
}

return (0);
}

Measured memory_bytes: 768
import numpy as np
n,m = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(n)]

ab = np.array(ab)
ab = sorted(ab, key = lambda x: x[0])

ch = m+0
ans = 0
ax = 0
while ch > 0:
    t_ab = ab[ax]
    if t_ab[1] <= ch:
        num = t_ab[1]
    else:
        num = ch
    ans += t_ab[0]*num
    ax += 1
    ch -= num

print(ans)

Measured memory_bytes: 37908
#include<iostream>
#include<stack>
#include<string>

int main() {
    int a, b;
    std::string input;
    std::stack<int> stackCtn;
    
    while (std::cin >> input)
    {
        if (input[0] == '+') {
            a = stackCtn.top();
            stackCtn.pop();
            b = stackCtn.top();
            stackCtn.pop();
            stackCtn.push(a + b);
        } else if (input[0] == '-') {
            a = stackCtn.top();
            stackCtn.pop();
            b = stackCtn.top();
            stackCtn.pop();
            stackCtn.push(b - a);
        } else if (input[0] == '*') {
            a = stackCtn.top();
            stackCtn.pop();
            b = stackCtn.top();
            stackCtn.pop();
            stackCtn.push(a * b);
        } else {
            try {
                a = std::stoi(input);
            }
            catch(const std::exception& e) {
                std::cerr << e.what() << '\n';
            }
            
            stackCtn.push(a);
        }
    }
    
    a = stackCtn.top();
    stackCtn.pop();

    std::cout << a << std::endl;

    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int maxn=100111;

int n,q,a[maxn],b[maxn],c[maxn],f[maxn];
LL m;
int gf(int x){return x==f[x]?x:f[x]=gf(f[x]);}

int main()
{
	scanf("%d%lld%d",&n,&m,&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d%d",a+i,b+i,c+i);
		a[i]++;b[i]++;
	}
	if(m==n-1)
	{
		for(int i=1;i<=q;i++)if(c[i]==1)
		{
			puts("No");
			return 0;
		}
		puts("Yes");
		return 0;
	}
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=q;i++)if(c[i]==0)f[gf(a[i])]=gf(b[i]);
	for(int i=1;i<=q;i++)if(c[i]==1&&gf(a[i])==gf(b[i]))
	{
		puts("No");
		return 0;
	}
	int cnt=0;
	for(int i=1;i<=n;i++)if(f[i]==i)cnt++;
	if(n+(LL)cnt*(cnt-3)/2<m)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll L, R;
    cin >> L >> R;
    ll ans = 2019;
    if(R - L >= 2019) ans = 0;
    else{
        for (ll i = L; i <= R; ++i){
            for (ll j = L; j <= R; ++j){
                if(j > i) chmin(ans,((i%2019)*(j%2019))%2019);
            }
        }
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf ((int)0x3f3f3f3f)
#define neinf ((int)0xc1c1c1c1)
#define llinf ((ll)0x3f3f3f3f3f3f3f3f)
#define nellinf ((ll)0xc1c1c1c1c1c1c1c1)
#define ull unsigned long long
#define lson root<<1
#define rson root<<1|1
#define uint usigned int
#define Mid int mid=(l+r)>>1;
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Memv(a,b) for(int i=0;i<=b;i++) a[i].clear()
#define ll long long
#define eps 1e-6
#define PB push_back
#define PI acos(-1)
#define lmove(n) (1<<(n))
#define FI first
#define SE second
#define Ceil(x,y) ((x+y-1)/y)
#define EULER_C 0.57721566490153286060651209
using namespace std;
const int MAXN=2e5+10;
const ll mod=1e9+7;
char s[MAXN];
int Next[MAXN][26];
int dp[MAXN];
int first[26];
int ans[MAXN];
int main() {
#ifdef ONLINE_JUDGE
#else
    //freopen("/home/jason/data/out.txt","r",stdin);
    //FREI;
    //FREO;
#endif // ONINLE_JUDGE
    scanf("%s",&s);
    int l=strlen(s);
    Mem(Next,-1);
    Mem(first,-1);
    for(int i=l-1;i>=0;i--){
        dp[i]=(l-i+1);
        first[s[i]-97]=i;
        //cout<<(int)(s[i]-97)<<' '<<first[s[i]-97]<<' '<<s[i]<<endl;
        for(int j=25;j>=0;j--){
            if(Next[i][j]==-1) {
                dp[i]=2,ans[i]=-j-97;
            }
            else if(dp[Next[i][j]]+1<=dp[i]) {
                dp[i]=dp[Next[i][j]]+1,ans[i]=Next[i][j];
            }
        }
        Next[i][s[i]-97]=i;
        if(i) for(int j=0;j<26;j++) {
            Next[i-1][j]=Next[i][j];
        }
    }
    int tmp=inf,id;
    for(int i=25;i>=0;i--){
        //cout<<i<<' '<<first[i]<<' '<<dp[first[i]]<<endl;
        if(first[i]==-1){
            tmp=-1;
            id=i;
        }
        else if(tmp>=dp[first[i]]){
            //cout<<i<<' '<<dp[first[i]]<<endl;
            tmp=dp[first[i]];
            id=i;
        }
    }
    int pos=first[id];
    if(pos==-1){
        putchar(id+97);
        return 0;
    }
    while(true){
        putchar(id+97);
        pos=ans[pos];
        //cout<<pos<<endl;
        if(pos<0) {
            putchar(-pos);
            break;
        }
        id=s[pos]-97;
    }


}


Measured memory_bytes: 22400
using System;

public class Program
{
	public static void Main (string [] args)
	{
		//var ss = new StreamScanner ();
		//---------------------------------
		var res = new int [26];
		while (true) {
			var cr = Console.ReadLine ();
			if (cr == null || cr == "EOF") break;

			foreach (var c in cr.ToLower ()) {
				if (char.IsLetter (c)) res [c - 'a']++;
			}
		}

		for (var i = 0; i < res.Length; i++) {
            Console.WriteLine ((char)(i + 'a') + " : " + res [i]);
		}
		//---------------------------------
	}
}

public class StreamScanner
{
	private readonly char [] _c = { ' ' };
	private int _index = -1;
	private string [] _input = new string [0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader (Console.OpenStandardInput ());

	public T Next<T> ()
	{
		if (_index == _input.Length - 1) {
			_index = -1;
			while (true) {
				string rl = _sr.ReadLine ();
				if (rl == null) {
					if (typeof (T).IsClass) return default (T);
					return (T)typeof (T).GetField ("MinValue").GetValue (null);
				}
				if (rl != "") {
					_input = rl.Split (_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType (_input [++_index], typeof (T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T [] Next<T> (int x)
	{
		var ret = new T [x];
		for (var i = 0; i < x; ++i) ret [i] = Next<T> ();
		return ret;
	}

	public T [] [] Next<T> (int x, int y)
	{
		var ret = new T [y] [];
		for (var i = 0; i < y; ++i) ret [i] = Next<T> (x);
		return ret;
	}
}

Measured memory_bytes: 9136
import sys

a = []
for line in sys.stdin:
    a.append(int(line))
b = [0, 0, 0]
for i in a:
	j = 0
	while j < 3:
		if i > b[j]:
			b.insert(j, i)
			break
		j += 1

for i in b[:3]:
	print i

Measured memory_bytes: 6432
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int mark,max=-1,n;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
    if(l.at(i)>max){
      max=l.at(i);
      mark=i;
    }
  }

  int sum=0;
  for(int i=0;i<n;i++){
    if(i==mark) continue;
    sum+=l.at(i);
  }

  if(max<sum) puts("Yes");
  else  puts("No");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
using ll = long long;


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

int main(){
	ll n,m;cin >> n >> m;
	if(n == 1 && m == 1){
		cout << 1 << endl;
	}else if(n == 1 && m >= 3){
		cout << m-2 << endl;
	}else if(m == 1 && n >= 3){
		cout << n-2 << endl;
	}else if(n>=3 && m>=3){
		cout << (m-2)*(n-2) << endl;
	}else{
		cout << 0 << endl;
	}
}


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

bool dp[111111] = {false};
int val[111];
int main() {
    int n, k; cin>>n>>k;
    for (int i=0;i<n;i++) {
        cin>>val[i];
    }
    for (int i=1;i<=k;i++) {

        for(int j=0;j<n;j++) {
            if (i >= val[j] && !dp[i-val[j]]) {
                dp[i]=true;
            }
        }
    }
    cout << (dp[k]?"First":"Second") <<endl;
}

Measured memory_bytes: 384
n = int(input())
x = list(map(int,input().split()))
print (*x)
for i in range(1,n):
    v = x[i]
    j = i - 1
    while j >= 0:
        if x[j] > v:
            x[j + 1] = x[j]
            x[j] = v
        j += -1
    print (*x)

Measured memory_bytes: 8000
=begin
－－－－－－－－－－－－－－ 
A = 100*A 水
B = 100*B 水
C,D = １回の投入可能砂糖量
E = 100(g)あたりに溶かすことのできる砂糖量
F = ビーカー許容量(水 + 砂糖 = 総質量)
sugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙)
water = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙)
sum = water[i]とsugar[j]の総質量
pos = water[i] に溶かせる砂糖量
con = sugar[j]*100 / (sugar[j] + water[i])  の砂糖濃度(%)
ans = 答え
－－－－－－－－－－－－－－
=end

A,B,C,D,E,F = gets.split.map(&:to_i);

tmp = {};
tmp[:waters] = [];
(0..30).each{|i|
  (0..30).each{|j|
    x = (100*A*i) + (100*B*j);
    tmp[:waters] << x if x <= F;
  }
}
tmp[:waters].sort!.uniq!;

tmp[:sugars] = []
(0..F).each{|i|
  (0..F).each{|j|
    y = C * i + D * j;
    tmp[:sugars] << y if y <= F;
  }
}
tmp[:sugars].sort!.uniq!;

sum_ans = 0;
sugar_ans = 0;
dif = -1;
con = 0.0;

tmp[:waters].each{|w|
  pos = w / 100 * E;
  tmp[:sugars].each{|s|
    sum = w + s;
    next if pos < s || F < sum
    
    con = (s*100) / (s + w).to_f;
    if dif < con
      sum_ans = sum;
      sugar_ans = s;
      dif = con;
    end
  }
}

puts "#{sum_ans} #{sugar_ans}"

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

int main() {
  int N;
  cin >> N;
  
  bool isFour = false;
  for (int i=0; i<N; i++) {
    string s;
    cin >> s;
    if (s == "Y")
      isFour = true;
  }
  cout << (isFour ? "Four" : "Three") << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){

    int n, k;
    string s;
    
    cin >> n >> s >> k;
    
    string temp = s.substr(k-1, 1);

    string result;
    for(int i=0; i<s.size(); i++) {
        if(s.substr(i,1) != temp) {
            result += "*";
        }
        else result += s.substr(i,1);
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int SIZE=55;
const int dr[]={-1,-1,-1,0,0,1,1,1};
const int dc[]={-1,0,1,-1,1,-1,0,1};
	int H,W;
	char M[SIZE][SIZE];
	int count(int x,int y){
		int sum=0,r,c;
		for(int i=0;i<8;i++){
			r=x+dr[i];
			c=y+dc[i];
			if(r>=0&&r<H&&c>=0&&c<W&&M[r][c]=='#')sum++;
		}
		return sum;
	}
	int main(){
		cin>>H>>W;
		for(int i=0;i<H;i++)cin>>M[i];
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++){
				if(M[i][j]=='.')M[i][j]='0'+count(i,j);
			}
		for(int i=0;i<H;i++){
			cout<<M[i]<<endl;
		}
		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int MAX = 100005;
int P[MAX], Y[MAX];
vector<int> yd[MAX];
int main()
{
    int N, M;
    cin >> N >> M;
    rep(i, M)
    {
        cin >> P[i] >> Y[i];
        yd[P[i]].push_back(Y[i]);
    }
    rep(i, N)
    sort(yd[i + 1].begin(), yd[i + 1].end());
    rep(i, M)
    {
        printf("%06d", P[i]);
        printf("%06d\n", lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1);
    }
    return 0;
}


Measured memory_bytes: 7808
n, m = gets.split.map(&:to_i)
graph = Array.new(n + 1) { [] }

m.times do
  a, b = gets.split.map(&:to_i)
  graph[a] << b
  graph[b] << a
end

dist = []
dist[1] = 0
queue = [1]

while queue.any?
  v = queue.shift

  graph[v].each do |i|
    next if dist[i]

    dist[i] = dist[v] + 1
    queue << i
  end
end

puts dist[n] == 2 ? :POSSIBLE : :IMPOSSIBLE

Measured memory_bytes: 23368
#include<stdio.h>
#define X 10000

void countingSort(int A[],int B[], int n){
  int i;
  int C[X+1];

  for(i=0;i<=X;i++){
    C[i] = 0;
  }

  for(i=0;i<n;i++){
    C[A[i]]++;
  }

  for(i=1;i<=X;i++){
    C[i] += C[i-1];
  }

  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }
}

int main(){

  int n,i;

  scanf("%d",&n);

  int A[n],B[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  countingSort(A,B,n);

  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 17400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String input = scn.nextLine();
		int a = Integer.valueOf(input.split(" ")[0]).intValue();
		int b = Integer.valueOf(input.split(" ")[1]).intValue();
		int N = 2;
		int myCoins = 0;

		for(int i = 0;i < N;i++) {
			if(a == b) {
				myCoins += a;
				a--;
			}
			else if(a > b) {
				myCoins += a;
				a--;
			}
			else {
				myCoins += b;
				b--;
			}
		}

		System.out.println(myCoins);
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b; cin>>a>>b;
  
  if(a>=13){
    cout<<b;
  }else if(a>=6 and a<=12){
    cout<<b/2;
  }else{
    cout<<0;
  }
    
  return 0;
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]
H[0] = H[0] - 1
for i in range(1,N):
    if H[i] - H[i-1] > 0:
        H[i] = H[i] -1

if H == sorted(H):
    print("Yes")
else: 
    print("No")
        


Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int N = Integer.parseInt(W);
		W = in.readLine();
		String[] S = W.split(" ");

		String ans ="";
		for(int i=0;i<N;i++){
			ans+=S[0].substring(i,i+1);
			ans+=S[1].substring(i,i+1);
		}

		System.out.println(ans);



	}


}


Measured memory_bytes: 22484
use std::io;

fn main() {
    let v = read_line();
    if v[0] == v[1] && v[0] != v[2] { return println!("Yes"); }
    if v[1] == v[2] && v[0] != v[2] { return println!("Yes"); }
    if v[0] == v[2] && v[0] != v[1] { return println!("Yes"); }
    println!("No");
}

fn read_line() -> Vec<i32> {

    let input_str = get_input();
    let vec: Vec<&str> = input_str.trim().split_whitespace().collect();

    let mut int_vec: Vec<i32> = Vec::new();
    for v in vec {
        int_vec.push(to_i(v));
    }

    int_vec
}

fn to_i(s: &str) -> i32 {
    let input_num: i32 = match s.trim().parse() {
        Ok(num) => num ,
        Err(_)  => panic!("input wrong number."),
    };
    input_num
}

fn get_input() -> String {
    let mut input_str = String::new();
    io::stdin().read_line(&mut input_str)
        .expect("Failed to read line")
        ;
    input_str
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int main(){
  char buf[1024];
  int N,M;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &M);

  printf("%d\n", N-M+1);

  return 0;

}


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

int main() {
	string s;
	cin >> s;
	
	stringstream ss;
	for (int i = 0; i < s.length(); i++) {
		ss << "x";
	}
	string ans = ss.str();

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

Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    // 入力
    val pw = PrintWriter(System.out)
    //入手
    val (b, c) = readLine()!!.split(" ")
    if (b.toInt() % 2 == 0 || c.toInt() % 2 == 0) {
        pw.println("Even")
    } else {
        pw.println("Odd")
    }
    pw.flush()
}

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


int main() {
    int k; cin >> k;
    string s; cin >> s;
    int n=s.size();
    if(n<=k){
        cout << s << endl;
        return 0;
    }
    else {
        cout << s.substr(0,k) << "..." << endl;
    }
}

Measured memory_bytes: 3600