akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

void kazoeru(vector<string> hoge,vector<string> kakunin){
    int n=hoge.size();
    
    for(int i=0;i<n;i++){
        cout<<hoge.at(i);
        if(i<n-1) cout<<" ";
    }
    
    cout<<endl;
    
    string safe="Stable";
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int a=0;a<n;a++){
                for(int b=a+1;b<n;b++){
                    if(kakunin.at(i).at(1)==kakunin.at(j).at(1) && kakunin.at(i)==hoge.at(b) && kakunin.at(j)==hoge.at(a)) safe="Not stable";
                }
            }
        }
    }
    
    cout<<safe<<endl;
}

int main(){
    int n;
    cin>>n;
    vector<string> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    vector<string> fuga=hoge;
    vector<string> kakunin=hoge;
    
    bool flag=true;
    
    while(flag){
        flag=false;
        
        for(int i=n-1;i>0;i--){
            if(hoge.at(i).at(1)<hoge.at(i-1).at(1)){
                string pre=hoge.at(i);
                hoge.at(i)=hoge.at(i-1);
                hoge.at(i-1)=pre;
                
                flag=true;
            }
        }
    }
    
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(fuga.at(minj).at(1)>fuga.at(j).at(1)){
                minj=j;
            }
        }
        
        string pre=fuga.at(i);
        fuga.at(i)=fuga.at(minj);
        fuga.at(minj)=pre;
    }
    
    kazoeru(hoge,kakunin);
    kazoeru(fuga,kakunin);
    
    return 0;
}


Measured memory_bytes: 3208
package main

import (
	"fmt"
)

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

	l := make([]int, 87)
	l[0] = 2
	l[1] = 1
	for i := 2; i < len(l); i++ {
		l[i] = l[i-1] + l[i-2]
	}

	fmt.Println(l[n])
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
using namespace std;
int maxv=0;
int main(){
	int n,k;
	cin>>n>>k;
	int num[n+1];
	for(int i=1;i<=n;i++)	
		cin>>num[i];
	for(int f=1;f<=n;f++)
		for(int r=n;r>f;r--){
			int sumk=f+(n-r+1);
			if(sumk>k)
				continue;
			int remain=k-sumk;
			int sum=0;
			priority_queue<int> pq;
			for(int i=1;i<=f;i++)
				pq.push(num[i]);
			for(int i=r;i<=n;i++)
				pq.push(num[i]);
			while(pq.top()>0 || pq.size()>remain){
				if(pq.empty())
					break;
				sum+=pq.top();
				pq.pop();
			}
			maxv=max(maxv,sum);
		}
	for(int f=1;f<=n;f++){
		int sumk=f;
		if(sumk>k)
			continue;
		int remain=k-sumk;
		int sum=0;
		priority_queue<int> pq;
		for(int i=1;i<=f;i++)
			pq.push(num[i]);
		while(pq.top()>0 || pq.size()>remain){
			if(pq.empty()) 
				break;
			sum+=pq.top();
			pq.pop();
		}
		maxv=max(maxv,sum);
	}
	for(int r=n;r>=1;r--){
		int sumk=n-r+1;
		if(sumk>k)
			continue;
		int remain=k-sumk;
		int sum=0;
		priority_queue<int> pq;
		for(int i=r;i<=n;i++)
			pq.push(num[i]);
		while(pq.top()>0 || pq.size()>remain){
			if(pq.empty())
				break;
			sum+=pq.top();
			pq.pop();
		}
		maxv=max(maxv,sum);
	}
	cout<<maxv;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#define PB push_back
#define MP make_pair
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
struct node {
	int id; ll d;
	node(int id=0,ll d=0): id(id),d(d) {}
	friend bool operator <(node A,node B) { return A.d<B.d; }
};
priority_queue<node> que;
map<ll,int> mp;
int n,sz[N];
ll d[N];
vector< pair<int,int> > E;
vector<int> son[N];
ll dfs(int u) {
	ll tot=0;
	for(int i=0;i<son[u].size();++i) tot+=dfs(son[u][i])+sz[son[u][i]];
	return tot;
}
int main() {
	rd(n);
	for(int i=1;i<=n;++i) {
		rd(d[i]),mp[d[i]]=i;
		que.push(node(i,d[i]));
		sz[i]=1;
	}
	while(que.size()>1) {
		int u=que.top().id; que.pop();
		mp.erase(d[u]);
		ll t=d[u]-(n-sz[u]*2ll);
		if(!mp.count(t)) {
			printf("-1");
			return 0;
		}
		int f=mp[t];
		E.PB(MP(f,u));
		son[f].PB(u);
		sz[f]+=sz[u];
	}
	int rt=que.top().id;
	if(dfs(rt)!=d[rt]) {
		printf("-1");
		return 0;
	}
	for(int i=0;i<E.size();++i) printf("%d %d\n",E[i].first,E[i].second);
	return 0;
}

Measured memory_bytes: 16880
import java.util.*;
     
    public class Main {
        public static void main(String[] args) {
            Scanner s = new Scanner(System.in);
            int n = s.nextInt();
            int m = s.nextInt();
            int correct = 0;
            int penalty = 0;
            int [] a = new int[n+1];
            for(int i = 0; i<m; i++){
                int problem = s.nextInt();
                String status = s.next();
                if(a[problem] == -1){
                    continue;
                }
                if(status.equals("WA")){
                    a[problem]++;
                }else{
                    correct++;
                    penalty = penalty + a[problem];
                    a[problem] = -1;
                }
            }
            System.out.println(correct);
            System.out.println(penalty);
        }
    }

Measured memory_bytes: 64716
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = INT_MAX/3;

int main(){
    int n;
    int x;

    cin >> n;
    int m = INF;
    int M = -INF;
    ll S = 0ll;
    for (int i=0;i<n;i++){
        cin >> x;
        m = min(m, x);
        M = max(M, x);
        S += x;
    }

    cout << m << " " << M << " " << S << endl;
    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(10) ;
  int n,d,cnt=0;
  cin >> n >> d;
  int a[n][d];
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double w=0.0;
      for(int k=0;k<d;k++){
        w+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
      }
      if((double)sqrt(w)==(int)sqrt(w))cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3656
<?php
// スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $n, $m);

$data = array();
for ($i = 0; $i < $m; $i++) {
  $data[] = fscanf(STDIN, "%d %d");
}

for ($i = 0; $i < $m; $i++) {
  $data[$i][2] = $i;
}

//多次元配列のソート
foreach ($data as $key => $value) {
  $sort[$key] = $value[1]; //yearでソート
}

array_multisort($sort, SORT_ASC, $data);

$ans_data = array();
for ($i = 1; $i <= $n; $i++) {
  $ans_data[$i] = 1;
}

for ($i = 0; $i < $m; $i++) {
  $id_first = sprintf('%06d', $data[$i][0]);
  $id_last = sprintf('%06d', $ans_data[$data[$i][0]]);
  $data[$i][3] = $id_first. $id_last;
  $ans_data[$data[$i][0]]++;
}

//多次元配列のソート
foreach ($data as $key => $value) {
  $sort[$key] = $value[2]; //元のindexでソート
}

array_multisort($sort, SORT_ASC, $data);

foreach ($data as $a) {
  echo $a[3]."\n";
}

?>


Measured memory_bytes: 124384
import sys
input = lambda: sys.stdin.readline().strip()

def main():
    X = int(input())
    for diff in range(-200,200):
        for a in range(-200,200):
            b = a-diff
            if (a**5 - b**5) == X:
                break
        else:
            continue
        break
    print(a,b)

main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

template<class T>
struct slidingWindowAggregation {
    using F = function<T(T,T)>;
    F f;
    T d;
    stack<pair<T,T>> st1, st2;
    slidingWindowAggregation(F f, T d) : f(f), d(d) {}
    T fold_all() { 
        if(st1.size() && st2.size()) return f(st1.top().second, st2.top().second); 
        if(st2.size()) return st2.top().second;
        if(st1.size()) return st1.top().second;
        return d;
    }
    void push(T x) { 
        const T rui = st2.size() ? f(st2.top().second, x) : x;
        st2.push({x, rui}); 
    }
    void pop() {
        if(st1.empty()) {
            T rui = d;
            while(st2.size()) {
                T t; tie(t, ignore) = st2.top(); st2.pop();
                rui = f(rui, t);
                st1.push({t, rui});
            }
        }
        st1.pop();
    }
};

int main(void) {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    // dp[i回投げた][最後に当てたのがj]
    // dp[i][j] = max(dp[i-1][k]) + (i+1)*j j-m<=k<=j-1
    vector<vector<ll>> dp(k, vector<ll>(n, -INF));
    REP(i, n) dp[0][i] = a[i]; 
    FOR(i, 1, k) {
        auto f = [&](ll l, ll r) { return max(l, r); };
        slidingWindowAggregation<ll> swag(f, -INF);
        REP(j, n) {
            dp[i][j] = swag.fold_all() + (i+1)*a[j];
            swag.push(dp[i-1][j]);
            if(j >= m) swag.pop();
        }
        dump(i, dp[i]);
    }

    ll ret = 0;
    REP(i, n) chmax(ret, dp[k-1][i]);
    cout << ret << endl;

    return 0;
}

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

const int M = 1e9 + 7;

int main() {

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

  long long n, k;
  cin >> n >> k;

  long long ans = 0;
  for (long long i = k; i <= n + 1; ++i) {
    long long l = (i * (i - 1)) / 2;  
    long long r = (n * (n + 1)) / 2 - ((n-i) * (n-i+1)) / 2;
    l %= M;
    r %= M;
    ans = (ans + (r - l + 1 + M)) % M;
  }

  cout << ans << '\n';
}



Measured memory_bytes: 3616
import java.util.Scanner;

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

        int n = sc.nextInt();

        int[] A = new int[n];

        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }

        int count = 0;

        for (int i = 0; i < A.length - 1; i++) {

            boolean judge = false;
            int min_j = i;

            for (int j = i; j < A.length; j++) {
                if (A[j] < A[min_j]) {
                    min_j = j;
                    judge = true;
                }
            }

            int tmp = A[i];
            A[i] = A[min_j];
            A[min_j] = tmp;

            if (judge == true) {
                count++;
            }
        }

        for (int i = 0; i < A.length - 1; i++) {
            System.out.print(A[i] + " ");
        }
        System.out.println(A[A.length - 1]);

        System.out.println(count);

        sc.close();
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, m; cin >> n >> m; std::vector<long> li(2 * m + 1, 0);
	std::vector<long> a(n); for(int i = 0; i < n; i++) cin >> a[i];
	
	std::vector<std::vector<int>> vec(m + 1);
	for(int i = 0; i < n - 1; i++){
		if(a[i] < a[i + 1]){
			li[a[i] + 1]++;
			li[a[i + 1]]--;
		}else{
			li[a[i] + 1]++;
			li[a[i + 1] + m]--;
		}
		
		vec[a[i + 1]].push_back(i);
	}
	for(int i = 0; i < 2 * m - 1; i++) li[i + 1] += li[i];
	for(int i = 0; i < m; i++) li[i] += li[i + m];
	
	long pos = 0;
	for(int i = 0; i < n - 1; i++){
		pos += std::min((a[i + 1] + m - a[i]) % m, 1 + (a[i + 1] + m - 1) % m);
	}
	
	long mi = pos;
	for(int i = 1; i < m; i++){
		pos -= li[i];
		
		for(auto v : vec[i]){
			pos -= 1 + (a[v + 1] + m - i) % m;
			pos += (a[v + 1] + m - a[v]) % m;
		}
	
		mi = std::min(mi, pos);
	}
	
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

int main () {
    int n, d, x;
    std::cin >> n >> d >> x;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    int ans = x;
    for (int i = 0; i < n; i++) {
        int cnt = 0;
        while((cnt)*a[i] + 1 <= d) {
            ans++;
            cnt++;
        }
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int n = readint;
    int[] a;

    int[string] db; // name -> int
    for (int i = 0; i < n; i++) {
        auto ax = readln.split;
        string material = ax[0];
        int price = ax[1].to!int;

        db[material] = i;
        a ~= price;
    }

    auto uf = new UnionFind(n);
    int m = readint;
    for (int i = 0; i < m; i++) {
        auto ss = readln.split;
        // s と t は自由に交換可能
        int s = db[ss[0]];
        int t = db[ss[1]];

        // rs, rt の集合の最安値を更新
        int rs = uf.root(s);
        int rt = uf.root(t);
        uf.unite(s, t);
        a[uf.root(s)] = min(a[rs], a[rt]);
    }

    int ans = 0;
    foreach (i; 0..n) {
        ans += a[uf.root(i)];
    }
    writeln(ans);
}


class UnionFind {
    private int[] _data;
    private int[] _nexts; // 次の要素。なければ -1
    private int[] _tails; // 末尾の要素

    this(int n) {
        _data  = new int[](n + 1);
        _nexts = new int[](n + 1);
        _tails = new int[](n + 1);

        _data[] = -1;
        _nexts[] = -1;
        for (int i = 0; i < _tails.length; i++)
            _tails[i] = i;
    }

    int root(int a) {
        if (_data[a] < 0) return a;
        return _data[a] = root(_data[a]);
    }

    bool unite(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) return false;
        // ra に rb を繋げる
        _data[ra] += _data[rb];
        _data[rb] = ra;

        // ra の末尾の後ろに rb を繋げる
        _nexts[_tails[ra]] = rb;
        // ra の末尾が rb の末尾になる
        _tails[ra] = _tails[rb];
        return true;
    }

    bool isSame(int a, int b) {
        return root(a) == root(b);
    }

    /// a が属する集合のサイズ
    int groupSize(int a) {
        return -_data[root(a)];
    }

    /// a が属する集合の要素全て
    void doEach(int a, void delegate(int) fn) {
        auto node = root(a);
        while (node != -1) {
            fn(node);
            node = _nexts[node];
        }
    }
}



Measured memory_bytes: 3476
n,x,y = gets.chomp.split.map(&:to_i)

nums=[*(1..n)]
ans_list = Array.new(n-1, 0)

nums.combination(2) do |a,b|
    if a<=x && y<=b
        d=1+(x-a)+(b-y)
    elsif a<=x && x<b
        d=[b-a, (y-b+1)+(x-a)].min
    elsif a<y && y<=b
        d=[b-a, (b-y+1)+(a-x)].min
    elsif x<a && b<y
        d=[b-a,(y-b)+(a-x)+1].min        
    else
        d=b-a
    end
    ans_list[d-1]+=1
end

puts ans_list

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

ll a[2000010] = {};
ll sum[200010] = {};
int main() {
	ll N; cin >> N;

	ll s = 0;
	repe(i, 1, N) {
		cin >> a[i];
		sum[i] = a[i] + sum[i - 1];
		s += a[i];
	}

	ll minV = 100000000000000000;
	//repe(i, 1, N - 1) {
	//	ll x = sum[i];
	//	ll y = sum[N] - sum[i];
	//	minV = min(minV, abs(x - y));
	//}

	ll xsum = 0;
	repe(i, 1, N - 1) {
		xsum += a[i];
		minV = min(minV, abs(xsum * 2 - s));
	}
	cout << minV << endl;

	return 0;
}

Measured memory_bytes: 4352
import numpy as np
X, Y, Z, K = map(int, input().split())
x = np.array(list(map(int, input().split())))
y = np.array(list(map(int, input().split())))
z = np.array(list(map(int, input().split())))
l = x.reshape((1,-1)) + y.reshape((-1,1))
l = l.reshape(-1,)
l = np.sort(l)[::-1]
l = l[:K]
l = l.reshape((1,-1)) + z.reshape((-1,1))
l = l.reshape(-1,)
l = np.sort(l)[::-1]
l = l[:K]
for k in range(K):
    print(l[k])

Measured memory_bytes: 59364
n, q = gets.split.map(&:to_i)
a = (n-1).times.map{gets.split.map(&:to_i)}
p, x = q.times.map{gets.split.map(&:to_i)}.transpose
node = Array.new(n, 0)
a.sort! { |a, b| a[1] <=> b[1] }

(0..(q-1)).each do |i|
  node[p[i] - 1] += x[i]
end

(0..(n-2)).each do |i|
  node[a[i][1] - 1] += node[a[i][0] - 1]
end

puts node.join(' ')

Measured memory_bytes: 37952
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define maxn 200010
#define inf 1000000007
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
struct P{
    int x,y;
}a[maxn];
ll ans=1999999999999999999ll;
void solve1()
{
    int mn1=inf,mx1=-inf,mn2=inf,mx2=-inf;
    for(int i=1;i<=n;i++)
    {
        mn1=min(mn1,a[i].x);mx1=max(mx1,a[i].x);
        mn2=min(mn2,a[i].y);mx2=max(mx2,a[i].y);
    }
    ans=min(ans,1ll*(mx1-mn1)*(mx2-mn2));
}
bool cmp(P a,P b)
{
    if(a.x!=b.x)  return a.x<b.x;
    return a.y<b.y;
}
int mn1[maxn],mn2[maxn],mx1[maxn],mx2[maxn];
void solve2()
{
    sort(a+1,a+n+1,cmp);
    mn1[n+1]=mn2[n+1]=inf;
    mx1[n+1]=mx2[n+1]=-inf;
    for(int i=n;i>=1;i--)
    {
        mn1[i]=min(mn1[i+1],a[i].x);mx1[i]=max(mx1[i+1],a[i].x);
        mn2[i]=min(mn2[i+1],a[i].y);mx2[i]=max(mx2[i+1],a[i].y);
    }
    int MN1=inf,MX1=-inf,MN2=inf,MX2=-inf;
    for(int i=1;i<=n;i++)
    {
        int mnn1=min(a[i].y,min(MN1,mn1[i+1]));
        int mxx1=max(a[i].y,max(MX1,mx1[i+1]));
        int mnn2=min(a[i].x,min(MN2,mn2[i+1]));
        int mxx2=max(a[i].x,max(MX2,mx2[i+1]));
        ans=min(ans,1ll*(mxx1-mnn1)*(mxx2-mnn2));
        MN1=min(MN1,a[i].y);MX1=max(MX1,a[i].y);
        MN2=min(MN2,a[i].x);MX2=max(MX2,a[i].x);
    }
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  a[i].x=read(),a[i].y=read();
    for(int i=1;i<=n;i++)
      if(a[i].x>a[i].y)  swap(a[i].x,a[i].y);
    solve1();
    solve2();
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;

    int i = 0;
    while (i < n)
    {
        string a = s.substr(i);
        string b = t.substr(0, n - i);
        if (a == b)
            break;

        i++;
    }

    cout << 2 * n - (n - i) << endl;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(cin >> N) {
        vi a(N);
        rep(i, N)cin >> a[i];
        sort(all(a));

        ll sm = a[0], ans = N;
        for(int i = 1; i < N; ++i) {
            if(sm * 2 < a[i])ans = N - i;
            sm += a[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

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

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 75056
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int MAX_N = 1121;
const int MAX_K = 15;
const int MAX_P = 188;

bool isP[MAX_N];
vector<int> P; // size:187

int T[MAX_K][MAX_P][MAX_N];

void make() {
  fill(isP, isP+MAX_N, true);
  isP[0] = isP[1] = false;
  for(int i = 2; i < MAX_N; ++i) {
    if(isP[i]) {
      P.push_back(i);
      for(int j = i*2; j < MAX_N; j += i) isP[j] = false;
    }
  }
}

int rec(int k, int p, int n) {
  int &res = T[k][p][n];
  if(res == -1) {
    res = 0;
    for(int i = p; i < P.size() && n-P[i] >= 0; ++i) {
      res += rec(k-1, i+1, n-P[i]);
    }
  }
  return res;
}

int main() {
  make();
  for(int i = 0; i < MAX_K; ++i) {
    for(int j = 0; j < MAX_P; ++j) {
      for(int k = 0; k < MAX_N; ++k) {
	if(i == 0 && k == 0) T[i][j][k] = 1;
	else if(i == 0 || k == 0) T[i][j][k] = 0;
	else T[i][j][k] = -1;
      }
    }
  }
  int n, k;
  while((cin >> n >> k) && (n || k)) {
    cout << rec(k, 0, n) << endl;
  }
  return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    int a,b;
    a=N/K;
    b=N%K;
    if(b!=0){
        cout<<1<<endl;}else{cout<<0<<endl;}
    
    return 0;
}


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

using namespace std;

struct edge {
    int to;
    long long cost;
};

const int NMAX = 100000 + 5;
vector<edge> tree[NMAX];
long long dist[NMAX];// 始点と各点の距離

void dfs(int v, int p, long long d) {// pは親。ループ防止用。
    dist[v] = d;
    for (auto e:tree[v]) {
        if (e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        --a, --b;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int Q, K;
    cin >> Q >> K;
    --K;

    dfs(K, -1, 0);
    while (Q--) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 14336
input = gets.chomp
input = input.split("/")

# 数値変換できなかったときの処理が無い
year = input[0].to_i
month = input[1].to_i
day = input[2].to_i

if year >= 2019 && month >= 5
  puts "TBD"
else
  puts "Heisei"
end

Measured memory_bytes: 1788
s=gets.chomp
t=s.delete("x")
def r?(s)
  t=s.dup
  while true
    case t.size
    when 0,1
      return true
    else
      unless t.slice!(0).eql?(t.slice!(-1))
        return false
      end
    end
  end
end
unless r?(t)
  puts -1
  exit
end

i=0
f=0
l=s.size-1
while true
  if f==l
    puts i
    exit
  end
  if s[f]==s[l]
    if f+1==l
      break
    else
      f+=1
      l-=1
      next
    end
  elsif s[f].eql?("x")
    (f+=1;i+=1) while s[f].eql?("x")
    break if f+1==l
  elsif s[l].eql?("x")
    (l-=1;i+=1) while s[l].eql?("x")
    break if f+1==l
  end
end
puts i

Measured memory_bytes: 89228
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int main()
{
    KAKA
    ll n,x,t;
    cin>>n>>x>>t;
    ll div = n/x;
    if(n % x) div++;
    cout<<(div * t)<<"\n";
}

Measured memory_bytes: 3600
import sys
import collections
import itertools

input = sys.stdin.readline


def main():
    N, C = [int(x) for x in input().split()]
    D = [[int(x) for x in input().split()] for _ in range(C)]
    c = [[int(x) for x in input().split()] for _ in range(N)]

    A = [[] for j in range(3)]

    for j in range(N):
        for i in range(N):
            A[(i + j) % 3].append(c[j][i])

    one = collections.Counter(A[0])
    two = collections.Counter(A[1])
    three = collections.Counter(A[2])

    ans = float("inf")
    for x, y, z in itertools.permutations(range(C), 3):
        tmp = 0
        for k in one.keys():
            tmp += D[k - 1][x] * one[k]
        for k in two.keys():
            tmp += D[k - 1][y] * two[k]
        for k in three.keys():
            tmp += D[k - 1][z] * three[k]

        ans = min(ans, tmp)

    print(ans)




if __name__ == '__main__':
    main()


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

using namespace std;

int ara[20000];
int main()
{
    int n ;
    cin >> n;
    for(int i = 0; i<n; i++)
    {
        int a;
        cin >> a;
        ara[a]++;
    }
    int f = 0;
    for(int i = 0; i<10007; i++)
        while(ara[i]--){
            if(f) printf(" ");
            cout << i ;
            f = 1;
        }
    cout << endl;
    return 0;
}

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

int main() {
  int N, T, s_1, s_2, min = 10000;
  cin >> N;
  int W[N];
  
  for (int k = 0; k < N; k++)
    cin >> W[k]; //W[i-1] = Wi
  
  for (T = 1; T < N; T++) {
    s_1 = 0;
    s_2 = 0;
    for (int k = 0; k < T; k++)
      s_1 += W[k];
    for (int k = T; k < N; k++)
      s_2 += W[k];
    if (abs(s_1 - s_2) < min)
      min = abs(s_1 - s_2);
  }
  cout << min;
  return 0;
}

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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];

  vector<int> hs(n, -1);
  for (int x : xs) {
    if (hs[0] < x) {
      hs[0] = x;
    } else {
      int l = 0;
      int r = n - 1;
      while (r - l >= 2) {
        int m = (r + l) / 2;
        if (hs[m] < x) {
          r = m;
        } else {
          l = m;
        }
      }
      hs[r] = x;
    }
  }

  int answer = n - count(hs.begin(), hs.end(), -1);
  cout << answer << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K;cin>>K;
    string S; cin>>S;

    if(S.size()<=K){
        cout<<S;
    }
    else{
        S=S.substr(0,K);
        cout<<S<<"...";
    }
    return 0;
}

Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    x,y = list(map(int, input().split()))
    r = 0
    ax = abs(x)
    ay = abs(y)
    if ax == ay:
        if x*y < 0:
            return 1
        return 0
    r = 0
    if ax < ay:
        r += ay-ax
        if x < 0:
            r += 1
        if y < 0:
            r += 1
    else:
        r += ax - ay
        if x > 0:
            r += 1
        if y > 0:
            r += 1
    return r


print(main())


Measured memory_bytes: 7832
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] B = GetInts(N - 1);

		int[] A = Enumerable.Repeat(int.MaxValue / 2, N).ToArray();
		for(int i = 0; i < N - 1; i++)
		{
			A[i] = Math.Min(A[i], B[i]);
			A[i + 1] = Math.Min(A[i + 1], B[i]);
		}

		Console.WriteLine(A.Sum());
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 13396
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int n;
  sc.scan(n);

  if (n == 25)
    writeln("Christmas");
  else if (n == 24)
    writeln("Christmas Eve");
  else if (n == 23)
    writeln("Christmas Eve Eve");
  else if (n == 22)
    writeln("Christmas Eve Eve Eve");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, tmp, r1=0, r2=0;
    set<ll> a;
    cin >> n;
    rep(i, n){
        cin >> tmp;
        if(a.find(tmp) == a.end()){
            a.insert(tmp);
        }else{
            if(r1 < tmp){
                r2 = r1;
                r1 = tmp;
            }else if(r2 <= tmp && tmp <= r1){
                r2 = tmp;
            }
            a.erase(tmp);
        }
    }

    cout << r1*r2 << endl;

    return 0;
}

Measured memory_bytes: 4992
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        if (int.Parse(ab[0]) % int.Parse(ab[1]) == 0)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 11092
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int main(){
    int N;
    R(N);
    VI A(N),B(N);
    REP(i,N)R(A[i],B[i]);
    sort(ALL(A));
    sort(ALL(B));
    int mid1=(N-1)/2;
    if(N&1)W(B[mid1]-A[mid1]+1);
    else{
        W((B[mid1+1]+B[mid1])-(A[mid1+1]+A[mid1])+1);
    }
    return 0;
}


Measured memory_bytes: 4796
#include<stdio.h>
int main()
{
	int x,y,z;
	scanf("%d %d %d",&x,&y,&z);
	int num=0;
	int t=x-z;
	while(t-z>0)
	{
		if(t-y-z<0)
		break;
		else t-=(y+z);
		num++;
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int l = sc.nextInt();

        String[] s = new String[n];

        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        sc.close();

        Arrays.sort(s);

        String ans = "";

        for (int i = 0; i < n; i++) {
            ans = ans + s[i];
        }

        System.out.println(ans);

    }
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(ll i= 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll dp[n][n];
    for(ll i= 0; i < n; i++){
        for(ll j = 0; j < n - i; j++){
                ll k = j + i;
                ll x, y, z;
                if(j + 2 <= k){
                    x = dp[j + 2][k];
                } else x = 0;
                if(j + 1 <= k - 1){
                    y = dp[j + 1][k - 1];
                } else y = 0;
                if(j <= k - 2){
                    z = dp[j][k - 2];
                } else z = 0;
                
    
                dp[j][k] = max(a[j] + min(x, y), a[k] + min(y, z)); 
                
        }
    }
    // for(ll  i= 0; i < n; i++){
    //     for(ll j= 0; j < n; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << 2 * dp[0][n - 1] - sum << endl;
    
}

Measured memory_bytes: 70528
# pythonリストの逆順
# 組み込み関数reversed()を使う。

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

# print("{}".format(numbers))
for i, number in enumerate(reversed(numbers)):
    if i == n - 1:
        print("{}".format(number))
    else:
        print(number, end=" ")



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

using namespace std;

int main() {
    string s, t = "WE";
    int n, min_count = 300001;
    cin >> n >> s;
    vector<int> west, east;

    west.push_back(0);
    east.push_back(0);

    for (int i = 0; i < n; ++i) {
        if(s[i] == t[0]) {
            west.push_back(west[i]+1);
            east.push_back(east[i]);
        } else {
            east.push_back(east[i]+1);
            west.push_back(west[i]);
        }
    }


    for (int i = 1; i <= n; ++i) {
        int sum = west[i-1] + east[n] - east[i];
        min_count = min(min_count, sum);
    }

    cout << min_count << endl;
    return 0;
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  REP(i, m) cin >> a[i];
  int num[] = {INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  sort(ALLr(a));
  vector<int> dp(n+1, -INF);
  dp[0] = 0;
  FORe(i, 1, n){
    REP(j, m){
      if(i - num[a[j]] < 0) continue;
      chmax(dp[i], dp[i-num[a[j]]]+1);
    }
  }
  string ans;
  int l = dp[n];
  REP(i, l){
    REP(j, m){
      if(n - num[a[j]] < 0) continue;
      if(dp[n-num[a[j]]] == dp[n]-1){
        ans += (char)a[j] + '0';
        n -= num[a[j]];
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int abs(int x){
    if(x>=0)return x;
    else return (-x);
}


int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    if(abs(x)==abs(y))printf("1");
    else if(x>0 &&y>0){
        if(x<y)printf("%d",y-x);
        else printf("%d",x-y+2);
    }else if(x>0 && y<0){
        if(abs(x)>abs(y))printf("%d",abs(x)-abs(y)+1);
        else printf("%d",abs(y)-abs(x)+1);
    }else if(x<0 && y>0){
        if(abs(x)>abs(y))printf("%d",abs(x)-abs(y)+1);
        else printf("%d",abs(y)-abs(x)+1);
    }else if(x<0 && y<0){
        if(abs(x)>abs(y))printf("%d",y-x);
        else printf("%d",x-y+2);
    }else if(x==0){
        if(y>0)printf("%d",y);
        else printf("%d",1-y);
    }else{
        if(x>0)printf("%d",x+1);
        else printf("%d",-x);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

typedef long double R;
R m, n, x;

template<int N>
struct Comb{
	R C[N][N];
	Comb(){
		memset(C, 0, (int)sizeof(C));	
		for(int i = 0; i < 50; i++){
			C[i][0] = C[i][i] = 1;
			for(int j = 1; j < i; j++) C[i][j] = C[i-1][j-1] + C[i-1][j];
		}
	}
	R operator()(int n, int r){
		if(n < 0 || r < 0 || r > n) return 0;
		return C[n][r];
	}
};
Comb<50> C;

R solve(R l, R r, R x){
	R res = 0;
	REP(i, x+1){	// i回左に行く
		R sum = C(x, i);
		REPS(j, x){	// j回目の遷移
			REP(k, j){ // 既に j - 1 回中 k 回左に遷移している
				R w = pow(l, k) * pow(r, j-1-k);
				sum -= w*(l) * C(j-1,     k) * C(x-j, i-k  );	// j回目に右に行く
			}
		}
		res += pow(l, i) * pow(r, x-i) * sum;
	}
	return res;
}

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	R ans = 1;
	REP(i, 2){
		cin >> m >> n >> x;
		ans *= solve(m/(n+m), n/(n+m), x);
	}
	printf("%.11f\n", (double)ans);
	return 0;
}

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

int main(){
  int n;
  string s;
  cin>> n >> s;
  
  string ans="Yes";
  if (n%2==1){
    cout<< "No" << endl;
    return 0;
  }
  int h=n/2;
  for (int i=0; i<n/2; i++){
    if (s[i]!=s[i+h]) {
      ans="No";
      break;
    }
  }
  
  cout<< ans <<endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))
mi = A[0]
ma = 0
for i in range(1, N):
    mi = min(mi, A[i - 1])
    ma = max(ma, A[i] - mi)

num = 0
mi = A[0]
for i in range(1, N):
    mi = min(mi, A[i - 1])
    if A[i] - mi == ma:
        num += 1

print(num)




Measured memory_bytes: 14680
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, tmp, sum = 0;
    cin >> n;
    
    while (n--) {
        cin >> tmp;
        while (~tmp & 1) ++sum, tmp >>= 1;
    }
    
    cout << sum << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std;
int main(){
	
	string s  , m; 
	cin>> s ; 
	for(int i= 0 ; i < (int)s.length() ; ++i){
		m+='x' ; 
	}
	cout<<m<<endl;
}
	


Measured memory_bytes: 256
n,m=map(int,input().split())
a = [int(input()) for _ in range(m)]

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
NG=[False]*n
for i in range(m):
    NG[a[i]-1]=True

for i in range(1,n+1):
    if NG[i-1]==False:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[-1])

"""
#DP問題
"""


Measured memory_bytes: 8612
#include<cstdio>
#include<iostream>
using namespace std;
const long long mod=1e9+7;
long long inv[10010];
long long mul[10010];
long long ksm(long long x,long long p){
	long long ret=1;
	while(p){
		if(p&1) ret=ret*x%mod;
		x=x*x%mod;p/=2;
	}
	return ret;
}
long long get_inv(long long x){return ksm(x,mod-2);}
void pred(){
	long long s=1;
	for(int i=1;i<=10000;i++) s=s*i%mod,mul[i]=s;
	inv[10000]=get_inv(s);
	for(int i=9999;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
long long calc(long long n,long long m){return mul[n]*inv[m]%mod*inv[n-m]%mod;}
int a[200010],b[200010];
long long dp[4010][4010];
int main(){
	int n;
	scanf("%d",&n);
	pred();
	for(int i=1;i<=n;i++) scanf("%d%d",a+i,b+i);
	for(int i=1;i<=n;i++) dp[2000-a[i]][2000-b[i]]++;
	for(int i=1;i<=4000;i++) dp[0][i]+=dp[0][i-1],dp[i][0]+=dp[i-1][0];
	for(int i=1;i<=4000;i++)
		for(int j=1;j<=4000;j++)
			dp[i][j]=(dp[i][j]+dp[i-1][j])%mod+dp[i][j-1]%mod,dp[i][j]%=mod;
	long long ans=0;
	for(int i=1;i<=n;i++){
		ans=(ans+dp[a[i]+2000][b[i]+2000]%mod-calc(a[i]+b[i]+a[i]+b[i],a[i]+a[i])%mod)%mod;
		ans%=mod;
	}
	ans=(ans%mod+mod)%mod;
	printf("%lld",get_inv(2)%mod*ans%mod);
	return 0;
}

Measured memory_bytes: 127360