akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    A.sort()
    d = A[-1] - A[0]
    if d >= 2:
        return 'No'
    elif d == 0:
        if A[0]*2 <= N or A[0] == N-1:
            return 'Yes'
        else:
            return 'No'
    else:
        K = max(A)
        C = Counter(A)
        y = C[K]
        x = C[K-1]
        if x < K and 2*(K-x) <= y:
            return 'Yes'
        else:
            return 'No'

def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 74008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

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

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int cur=a[0];
  rep(i,1,n){
    cur=gcd(cur,a[i]);
  }
  cout<<cur<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	string in;
	int out=0;
	cin>>in;
	for(int i=0;i<3;i++)
	{
		if(in[i]=='1')
			out=out*10+9;
		else
			out=out*10+1;
	}
	cout<<out<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
	int n,x,count;
	
	while(1)
	{
		count=0;
		
		cin >> n >> x;
		
		if(n==0&&x==0)break;
		
		for(int h=1;h<=n;h++)
		{
			for(int i=h+1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if((h+i+j)==x)
					{
						count++;
					}
				}
			}
		}
		
		cout << count << "\n";
		
	}
		
return 0;
}

Measured memory_bytes: 3092
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000009
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sec second
#define fir first
#define M_PI           3.14159265358979323846  /* pi */
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
const int m = 3000;
int n;
double readd[m], dp[m][m], res = 0;
double go(int i,  int h)
{
	if (i == n)
	{
		if (h > (n / 2) )
			return 1;
		return 0;
	}

	if (dp[i][h] != -1)
		return dp[i][h];

	return dp[i][h] = (readd[i] * go(i + 1, h + 1) + (1 - readd[i]) * go(i + 1, h));

}

void solve()
{
	rep(i, 3000)
	rep(j, 3000)
	dp[i][j] = -1;

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

	cout << fixed << setprecision(10) << go(0, 0) << endl;

	return;
}


int main() {

	fast
	int T;
	T = 1;
	// cin >> T;
	while (T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,h[29];
  cin >> n;
  for(int i=0; i<n; i++) cin >> h[i];
  int sum=1;
  int high=h[0];
  for(int i=1; i<n; i++){
    if(h[i]>=high){
      sum++;
      high=h[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn dsum(x: u32) -> u32{
    let mut x = x;
    let mut res = 0;
    while x > 0{
        res += x%10;
        x /= 10;
    }
    res
}

fn main(){
    let line = read_as_vec::<u32>();
    let (n, a, b) = (line[0], line[1], line[2]);

    let mut ans = 0;
    for i in 1..n+1{
        let digit_sum = dsum(i);
        if a <= digit_sum && digit_sum <= b{
            ans += i;
        }
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	int n;cin>>n;
	vector<int> A;
	vector<int> B;vector<int> C;
	for(int i=0;i<n;i++)
	{
	    int a,b,c;cin>>a>>b>>c;
	    A.push_back(a);
	    B.push_back(b);
	    C.push_back(c);
	}
	vector<int> dp1(n);
	vector<int> dp2(n);
	vector<int> dp3(n);
	dp1[0]=A[0];dp2[0]=B[0];dp3[0]=C[0];
	for(int i=1;i<n;i++)
	{
	    dp1[i]=max(dp2[i-1],dp3[i-1])+A[i];
	    dp2[i]=max(dp1[i-1],dp3[i-1])+B[i];
	    dp3[i]=max(dp2[i-1],dp1[i-1])+C[i];
	}
	cout<<max({dp1[n-1],dp2[n-1],dp3[n-1]});
}

Measured memory_bytes: 2796
# -*- coding: utf-8 -*-
def pop_min_abs(l):
    abs_l = list(map(abs, l))
    l.pop(abs_l.index(min(abs_l)))
    return l



n, l = map(int, input().split())

apples = [l+i-1 for i in range(1,n+1)]
print(sum(pop_min_abs(apples)))


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

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A+1), b(B+1);
    int a_min = 100001, b_min = 100001;
    for (int i = 1; i <= A; i++) {
        cin >> a.at(i);
        a_min = min(a_min, a.at(i));
    }
    for (int i = 1; i <= B; i++) {
        cin >> b.at(i);
        b_min = min(b_min, b.at(i));
    }
    int ret = a_min + b_min;
    int tmp_a, tmp_b, tmp;
    for (int i = 1; i <= M; i++) {
        cin >> tmp_a >> tmp_b >> tmp;
        tmp = a.at(tmp_a) + b.at(tmp_b) - tmp;
        ret = min(ret, tmp);
    }
    cout << ret << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

template<class T>
struct segment_tree {
    using F = function<T(T,T)>;
    int n;
    vector<T> data;
    F f;
    T init_v;

    segment_tree(int n_, T init_v, F f) : f(f), init_v(init_v) {
        n = 1;
        while (n < n_) n *= 2;
        data.assign(2*n-1,init_v);
    }

    //kをaに変更
    void update(int k, T a) {
        k += n-1;
        data[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = f(data[k*2+1],data[k*2+2]);
        }
    }

    //[a,b)のquery,kは節点番号
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return data[k];
        else {
            T vl = query(a,b,k*2+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T get(int a) {return data[a+n-1];}

    void debug(int a, int b) {
        a += n-1; b += n-1;
        for (int i = a; i <= b; i++) {
            cout << data[i] << " ";
        }
        cout << endl;
    }
};

ll f(ll a, ll b) {return max(a,b);}

int main() {
    int n; cin >> n;
    vint h(n), a(n);
    rep(i,n) cin >> h[i];
    rep(i,n) cin >> a[i];
    segment_tree<ll> seg(n+1,0,f);
    rep(i,n) {
        ll value = seg.query(0,h[i]);
        if (seg.get(h[i]) < value+a[i]) seg.update(h[i],value+a[i]);
    }
    cout << seg.query(0,n+1) << endl;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int main(){
FASTIO  
ll k;
cin>>k;
ll ans=0;
for(ll i=1;i<=k;i++){
  for(ll j=1;j<=k;j++){
     for(ll p=1;p<=k;p++){
        ans+=(ll)(__gcd(i,__gcd(j,p)));
     }
  }
}
cout<<ans;
return 0;
}


Measured memory_bytes: 3632
n=int(input())
alist=[]
maxa=0
nextmax=0
maxindex = 573945
for i in range(n):
    tmpa=int(input())
    if tmpa >= maxa:
        nextmax = maxa
        maxa = tmpa
        maxindex = i
    elif tmpa >= nextmax:
        nextmax = tmpa

for j in range(n):
    if j == maxindex:
        print(nextmax)
    else:
        print(maxa)





Measured memory_bytes: 9396
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] S = new int[N];
        for (int i = 0; i < N; i++) {
            S[i] = sc.nextInt();
        }
        System.out.println( solve(N, S) );
    }

    private static int solve(int N, int[] S) {
        boolean[][] dp = new boolean[N + 1][10000 + 1];
        dp[0][0] = true;

        for (int i = 1; i <= N; i++) {
            int s = S[i-1];
            for (int p = 0; p <= 10000; p++) {
                if( p >= s ) {
                    dp[i][p] = dp[i-1][p-s] || dp[i-1][p];
                } else {
                    dp[i][p] = dp[i-1][p];
                }
            }
        }

        int ans = 0;
        for (int i = 0; i <= 10000; i++) {
            if( dp[N][i] && i % 10 != 0 ) {
                ans = Math.max(ans, i);
            }
        }
        return ans;
    }

    private static void showPoints(boolean[] points) {
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i <= 10000; i++) {
            if( points[i] ) {
                result.add(i);
            }
        }
        System.err.println( result );
    }
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin >> v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    for(int j=1;j<n;j++) ans = (ans+v[j])/2;
    cout << ans << endl;
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  cout << a * b / 2.0 << "\n";
  return 0;
}


Measured memory_bytes: 3780
import sys
def SimultaneousEquation():
    for line in sys.stdin:
        a,b,c,d,e,f=map(float,line.split())
        y=(c*d-f*a)/(b*d-e*a)
        x=(c-b*y)/a
        print("{0:.3f} {1:.3f}".format(x,y))
        
    

#testWriteFile()
SimultaneousEquation()

Measured memory_bytes: 7428
#k,sを入力から取得する
k,s = map(int, input().split())

#2重forでx,y,zを探索する。組み合わせを見つけるたびにcntを+1していく
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        
#組数を出力する
print(cnt)

Measured memory_bytes: 2940
#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 FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;

int main() {
  ll H, W;
  cin >> H >> W;
  char s[H][W];
  ll sum = 0;
  REP(i, H) REP(j, W) {
    cin >> s[i][j];
    if (s[i][j] == '#') sum++;
  }

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

  REP(i, H) REP(j, W) {
    if (s[i][j] == '#') {
      REP(d, 4) {
        if (i + dy[d] < 0 || H <= i + dy[d] || j + dx[d] < 0 || W <= j + dx[d])
          continue;
        if (s[i + dy[d]][j + dx[d]] == '#') {
          cnt++;
          break;
        }
      }
    }
  }

  if (sum == cnt)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 256
n, a, b = map(int,input().split())
mod = 10**9 + 7

mod = 10**9 + 7
l = 3*10**5 + 3

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

# print(inv(8,13))

MI = [0] * (l-1) +[inv(M[l-1], mod)]  # i!の逆元
for i in range(l-2, -1, -1):
    MI[i] = MI[i+1] * (i+1) % mod

def C(x, y):  # コンビネーション
    if y < 0 or y > x:
        return 0
    ans = M[x]
    ans = (ans * MI[y]) % mod
    return (ans * MI[x-y]) % mod

ans = pow(2, n, mod)
ans -= 1
m1 = 1
for i in range(n, n-a+1-1, -1):
    m1 = (m1*i) % mod
m1 = (m1 * MI[a]) % mod
m2 = 1
for i in range(n, n-b+1-1, -1):
    m2 = (m2*i) % mod
m2 = (m2 * MI[b]) % mod
ans = (ans-m1) % mod
ans = (ans-m2) % mod
# ans -= 1
print(ans)

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
string ans = "";
int a[10];
int aa[10];
int c[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[10005];
int n, m;
int solve(int rem)
{
    if (rem < 0)
        return -INF;
    if (rem == 0)
        return 0;
    int &ret = dp[rem];
    if (ret != -1)
        return ret;
    for (int i = 0; i < m; ++i)
    {
        ret = max(ret, 1 + solve(rem - c[a[i]]));
    }
    return ret;
}
void trace(int rem)
{
    if (rem == 0)
        return;
    int &ret = dp[rem];
    for (int i = 0; i < m; ++i)
    {
        if (ret == solve(rem - c[a[i]]) + 1)
        {
            ans = ans + char(a[i] + '0');
            trace(rem - c[a[i]]);
            return;
        }
    }
    return;
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        cin >> a[i];
    }
    sort(a, a + m, greater<int>());
    solve(n);
    trace(n);
    sort(all(ans));
    for (int i = sz(ans) - 1; i >= 0; --i)
        cout << ans[i];
    p();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int seg[524288]; 
void update(int k, int a){
	k += 262143; 
	seg[k] = a; 
	while(k > 0){
		k = (k - 1) / 2; 
		seg[k] = max(seg[k * 2 + 1], seg[k * 2 + 2]); 
	}
}
long long query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return 0; 
	if(a <= l && b >= r) return seg[k]; 
	else{
		long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2); 
		long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r); 
		return max(vl, vr); 
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N, Q; cin >> N >> Q; 
	for(int i = 0; i < N; i++){
		int a; cin >> a; update(i, a); 
	}
	update(N, 1145141919); 
	while(Q--){
		int T; cin >> T; 
		if(T == 1){
			int X, V; cin >> X >> V; 
			X--; update(X, V); 
		}else if(T == 2){
			int L, R; cin >> L >> R; L--; 
			cout << query(L, R, 0, 0, 262144) << "\n"; 
		}else if(T == 3){
			int X, V; cin >> X >> V; X--; 
			int ng = X; int ok = N+1; 
			while(ok - ng > 1){
				int mid = (ok + ng) / 2; 
				if(query(X, mid, 0, 0, 262144) >= V) ok = mid; 
				else ng = mid; 
			}
			cout << ok << "\n"; 
		}
	}
}

Measured memory_bytes: 5232
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, l;
string s;

int main(){
    multiset<string> m;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
        cin >> s;
        m.insert(s);
    }

    for(auto it = m.begin(); it != m.end(); ++it){
        cout << *it;
    }


}


//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	int X, Y, Z = 0, A, B, C;
	ll ap, ans = 0;
	cin >> X >> Y >> A >> B >> C;
	vector<pair<ll, int>> V;
	for (int i = 0;i < A;i++) {
		cin >> ap;
		V.push_back({ ap,0 });
	}
	for (int i = 0;i < B;i++) {
		cin >> ap;
		V.push_back({ ap,1 });
	}
	for (int i = 0;i < C;i++) {
		cin >> ap;
		V.push_back({ ap,2 });
	}
	sort(all(V));
	reverse(all(V));
	for (auto i : V) {
		if (i.second == 0) {
			if (X != 0)ans += i.first, X--;
		}
		else if (i.second == 1) {
			if (Y != 0)ans += i.first, Y--;
		}
		else {
			Z++;
			ans += i.first;
		}
		if (X + Y - Z == 0) {
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 10604
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

int main(){
  	string S;
  	cin >> S;
  	int N = S.size();

  	int A[N+1];
    for(int i=0;i<=N;i++){
      A[i] = 0;
    }

    for(int i=0;i<N;i++){
      if(S[i]=='<') A[i+1] = A[i] + 1;
    }

    for(int i=N-1;i>=0;i--){
      if(S[i]=='>') A[i] = max(A[i], A[i+1]+1);
    }

    ll sum = 0;
    for(int i=0;i<=N;i++) sum += A[i];


    cout << sum <<endl;
  	return 0;
}


Measured memory_bytes: 2820
func main() {
    let ints = readInts()
    let a = ints[0]
    let b = ints[1]
    let c = ints[2]
    let d = ints[3]
    var arr: [Int] = []
    arr.append(a * c)
    arr.append(b * c)
    arr.append(a * d)
    arr.append(b * d)
    print(arr.sorted()[3])
}

main()

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}


Measured memory_bytes: 8328
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]:
   if A[i][2]>A[i+1][2]:return 0
 return 1
n=int(input())
f=lambda x,y:(x,int(y))
A=[(*f(*sys.stdin.readline().split()),i)for i in range(n)]
k(A,0,n-1)
print(['Not s','S'][s(A)]+'table')
for e in A:print(*e[:2])


Measured memory_bytes: 20428
N, K = map(int, input().split())
xlist = list(map(int, input().split()))

lpos = 0
rpos = K-1

near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])
bet = abs(xlist[lpos] - xlist[rpos])

ans = bet + near

for i in range(N-K):
    lpos += 1
    rpos += 1

    near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])
    bet = abs(xlist[lpos] - xlist[rpos])

    tmp = bet+near

    if tmp < ans:
        ans = tmp


print(ans)


Measured memory_bytes: 14844
n = int(input())

s = ""
for i in range(n):
    s += input()

print("AC x " + str(s.count("AC")))
print("WA x " + str(s.count("WA")))
print("TLE x " + str(s.count("TLE")))
print("RE x " + str(s.count("RE")))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

void bubble_sort(vector<pair<char,int>> A, vector<pair<char,int>> &B){
  // bubble sort
  int N = A.size();
  for (int i=0;i<N;i++){
    for (int j=N-1;j>=i+1;j--){
      if (A[j].second < A[j-1].second) swap(A[j], A[j-1]);
    }
  }
  rep(i,N) B.push_back(A[i]);
  return;
}

void selection_sort(vector<pair<char,int>> A, vector<pair<char,int>> &B){
  // selection sort
  int N = A.size();
  for (int i=0;i<N;i++){
    int minj = i;
    for (int j=i;j<N;j++){
      if (A[j].second < A[minj].second) minj = j;
    }
    swap(A[i], A[minj]);
  }
  rep(i,N) B.push_back(A[i]);
  return;
}

bool is_stable(vector<pair<char,int>> A, vector<pair<char,int>> A_sorted){
  int N = A.size();
  bool stable = true;
  for (int i=0;i<N-1;i++){
    if (A[i].second == A[i+1].second){
      for (int a=0;a<N;a++){
        for (int b=a+1;b<N;b++){
          if (A[i]==A_sorted[b] && A[i+1]==A_sorted[a]){
            stable = false;
            break;
          }
        }
        if (!stable) break;
      }
      
    }
    if (!stable) break;
    
  }

  return stable;
}

int main(){
  int N; cin >> N;
  vector<pair<char,int>> A(N);
  rep(i,N) cin >> A[i].first >> A[i].second;
  
  vector<pair<char,int>> Ab, As;

  bubble_sort(A,Ab);
  rep(i,N){
    cout << Ab[i].first << Ab[i].second;
    if (i<N-1) cout << " ";
  }
  cout << endl;
  cout << (is_stable(Ab, A)? "Stable" : "Not stable") << endl;

  selection_sort(A,As);
  rep(i,N){
    cout << As[i].first << As[i].second;
    if (i<N-1) cout << " ";
  }
  cout << endl;
  cout << (is_stable(As, A)? "Stable" : "Not stable") << endl; 

  return 0;
}


Measured memory_bytes: 3108
n = int(input().strip())
red = [list(map(int, input().split())) for i in range(n)]
blue = [list(map(int, input().split())) for j in range(n)]

for i in range(n):
    '''
    kagi_r = [min(red[i][0], red[i][1]), max(red[i][0], red[i][1])]
    kagi_b = [min(blue[i][0], blue[i][1]), max(blue[i][0], blue[i][1])]
    red[i] = red[i] + kagi_r
    blue[i] = blue[i] + kagi_b
    '''
red.sort(key=lambda x: (x[0], x[1]), reverse=True)
blue.sort(key=lambda x: x[1])
flg_r = [0]*n
cnt = 0

for i in range(n):
    for j in range(n):
        if flg_r[j]:
            continue
        if red[j][0] < blue[i][0] and red[j][1] < blue[i][1]:
            flg_r[j] = 1
            cnt += 1
            break

print(cnt)



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

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

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

  int sum = 0;
  int min_abs = 1000;
  int min_abs_raw = 1000;

  for (int i = 1; i <= N; i++)
  {
    sum += L + i - 1;
    if (chmin(min_abs, abs(L + i - 1)))
      min_abs_raw = L + i - 1;
  }
  sum -= min_abs_raw;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int answer=0;
    int count=0;
    while(count<=100)
    {
		if(a%2!=0||b%2!=0||c%2!=0)
		    break;
		else
		{
              int x=a;
              int y=b;
              int z=c;
              a=(y/2+z/2);
              b=(x/2+z/2);
              c=(x/2+y/2);
              count++;
              answer++;
		}
	}
	if(count>100)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<answer<<endl;
	}
}


Measured memory_bytes: 256
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
    if b-w*t<a-v*t:
        print('NO')
    else:
        print('YES')
else:
    if b+w*t>a+v*t:
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 9172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            Dictionary<double, long> prices = new Dictionary<double, long>();
            prices.Add(0.25, inputLongArray[0]);
            prices.Add(0.5, inputLongArray[1]);
            prices.Add(1.0, inputLongArray[2]);
            prices.Add(2.0, inputLongArray[3]);

            Dictionary<double, long> tanka = new Dictionary<double, long>();
            tanka.Add(0.25, inputLongArray[0] * 4);
            tanka.Add(0.5, inputLongArray[1] * 2);
            tanka.Add(1.0, inputLongArray[2]);
            tanka.Add(2.0, inputLongArray[3] / 2);
            var sort = tanka.OrderBy(x => x.Value);

            Dictionary<double, long> lowPrices = new Dictionary<double, long>();
            foreach(var item in sort) {
                lowPrices.Add(item.Key, prices[item.Key]);
            }

            // 整数の入力
            double n = long.Parse(Console.ReadLine());

            long money = 0;
            foreach (var price in lowPrices) {
                if(n >= price.Key) {
                    var count = (int)(n / price.Key);
                    var nedan = count * price.Value;
                    money += nedan;
                    n = n % price.Key;
                }
            }
            Console.WriteLine(money);

        }
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int long long ll;
static const int N=100;
static const int white=0;
static const int gray=1;
static const int black=2;

int n,d[N],f[N],tt;
int color[N],nt[N];
int mp[N][N];

int next(int u){
    
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(mp[u][v]!=0)return v;
    }
    return -1;
}


void dfs_visit(int r){
    
   
    stack<int> s;
    s.push(r);
    color[r]=gray;
    d[r]=++tt;
    while(!s.empty()){
        int u=s.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==white){
            d[v]=++tt;
            color[v]=gray;
            s.push(v);
            }
        }else{
            color[u]=black;
            f[u]=++tt;
            s.pop();
        }
    }
}



void dfs(){

    rep(i,n){color[i]=white;nt[i]=0;}
    tt=0;
    
    for(int i=0;i<n;i++){
        if(color[i]==white){
            dfs_visit(i);
        }
    }
    rep(i,n){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    
}

int main(){
    cin>>n;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            mp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        rep(j,b){
            int c;
            cin>>c;
            mp[a-1][c-1]=1;
        }
    }
    
    dfs();
    
    return 0;
}



Measured memory_bytes: 3112
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CLinearApproximation solver = new CLinearApproximation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLinearApproximation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            for (int i = 0; i < n; i++) {
                a[i] -= i;
            }
            Arrays.sort(a);

            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += Math.abs(a[i] - a[n / 2]);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 48016
using System.IO;
using System.Linq;
using static System.Console;
namespace Partition
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var array = ReadLine().Split(' ').Select(int.Parse).ToArray();

            var part = Partition(array, 0, n - 1);
            var sw = new StreamWriter(OpenStandardOutput()) {AutoFlush = false};
            SetOut(sw);
            for (var i = 0; i < part; i++) Write(array[i] + " ");
            Write("[" + array[part] + "]");
            for(var i = part+1;i<array.Length;i++) Write(" " + array[i]);
            WriteLine();
            Out.Flush();
        }

        private static int Partition(int[] array, int begin, int end)
        {
            var x = array[end];
            var i = begin - 1;
            for (var j = begin; j < end; j++)
            {
                if (array[j] <= x)
                {
                    i++;
                    var tmp = array[i];
                    array[i] = array[j];
                    array[j] = tmp;
                }
            }

            var tmp2 = array[i + 1];
            array[i + 1] = array[end];
            array[end] = tmp2;
            return i + 1;
        }
    }
}


Measured memory_bytes: 25564
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	long long n;
	long long sol;

	scanf("%lld", &n);

	sol = n / 500 * 1000;
	n %= 500;

	sol += n / 5 * 5;

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split(' '))
S = []
for i in range(M):
  X = list(map(int,input().split(' ')))
  s = tuple(X[1:])
  S.append(s)
P = list(map(int,input().split(' ')))
num = 0
for i in range(1<<N):
  Flag = True
  for j in range(M):
    numON = 0
    for k in S[j]:
      if (i >> k-1) & 1:
        numON += 1
    if numON % 2 != P[j]:
      Flag = False
      break
  if Flag:
    num += 1
print(num)  

Measured memory_bytes: 3064
io = DATA.eof? ? STDIN : DATA
n,m=io.gets.split.map(&:to_i)
ab=m.times.map{io.gets.split.map(&:to_i)}
class UnionFind
  attr_reader :parent, :size
  def initialize(n)
    @parent = Array.new(n+1){|i|i}
    @size = Array.new(n+1,1)
  end
  def root(x)
    return x if @parent[x] == x
    @parent[x] = root(@parent[x])
  end
  def merge(x,y)
    x,y = root(x),root(y)
    return if x==y
    x,y = y,x if @size[x] < @size[y]
    @size[x] += @size[y]
    @parent[y] = x
  end
  def same(x,y)
    root(x) == root(y)
  end
  def size(x)
    @size[root(x)]
  end
end
uf = UnionFind.new(n)
ab.each {|a,b|uf.merge(a,b)}
puts (1..n).map{|k| uf.size(k)}.max

__END__


Measured memory_bytes: 31912
import itertools

def distance(a, b):
    return ( (a[0] - b[0])**2 + (a[1] - b[1])**2 )**0.5


N = int(input())
z = []

for i in range(0, N):
    z.append(list(map(int, input().split())))
    
d = [ [] for k in range(0, N) ]
for i in range(0, N):
    for j in range(0, N):
        d[i].append( distance(z[i], z[j]) )

seq = tuple( (k for k in range(0, N)) )
per = list(itertools.permutations(seq))
result = 0

for n in range(0, len(per)):
    summation = 0
    for l in range(0, N-1):
        summation = summation + d[per[n][l]][per[n][l+1]]
    result = result + summation

s = 1
for j in range(1, N+1):
    s = s * j

print(result/s)

Measured memory_bytes: 8052
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> S InnerProd_L(int n, S a[], T b[]){
  int i;
  S res = 0;
  for(i=(0);i<(n);i++){
    res += a[i] * b[i];
  }
  return res;
}
int N;
int M;
int C;
int B[20];
int A[20];
int main(){
  int KL2GvlyY;
  int res = 0;
  rd(N);
  rd(M);
  rd(C);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(M);Lj4PdHRW++){
      rd(B[Lj4PdHRW]);
    }
  }
  for(KL2GvlyY=(0);KL2GvlyY<(N);KL2GvlyY++){
    {
      int Q5VJL1cS;
      for(Q5VJL1cS=(0);Q5VJL1cS<(M);Q5VJL1cS++){
        rd(A[Q5VJL1cS]);
      }
    }
    if(InnerProd_L(M,A,B)+ C > 0){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190928-1

// --- original code ---
// int N, M, C;
// int B[20], A[20];
// {
//   int res = 0;
//   rd(N,M,C,B(M));
//   rep(N){
//     rd(A(M));
//     if(InnerProd(M,A,B) + C > 0) res++;
//   }
//   wt(res);
// }


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

int main(void) {
    int N,M,maxval;
    string s;
    cin >> N;

    unordered_map<string,int> mp;

    for(int i=0;i<N;i++) {
        cin >> s;
        mp[s]++;
    }
    cin >> M;
    for(int i=0;i<M;i++) {
        cin >> s;
        mp[s]--;
    }

    maxval = 0;
    for(auto m:mp) {
        if(maxval < m.second) {
            maxval = m.second;
        }
    }

    cout << maxval << endl;
    return 0;
}


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

int main(){
  int k,s;
  cin>>k>>s;
  int ans=0;
  for (int x=0;x<=k;x++){
    for (int y=0;y<=k;y++){
      int z=s-x-y;
      if (z>=0 && z<=k) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        h: usize, w: usize, a: usize, b: usize,
    }
    for i in 0..h {
        for j in 0..w {
            let flip = (i < b) ^ (j < a);
            puts!("{}", if flip { "1" } else { "0" });
        }
        puts!("\n");
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 9468
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    for(char& c : s){
        int i = ((c - 'A') + n) % 26;
        c = 'A' + i;
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
$h, $w = gets.split.map(&:to_i)
mat=Array.new($h){gets.chomp.split("")}.transpose

def compression(mat)
  mat.each_with_index do |v,i|
    if v.all?{|a| a=="."}
      mat.delete_at(i)
      compression(mat)
    end
  end
  return mat
end

puts compression(compression(mat).transpose).map(&:join)


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


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

int d=0;

map<long long ,int>mp;

rep(i,N){
int a;
cin>>a;
if(mp[a])d++;

mp[a]++;
}
int ans;
if(d%2==1){
    ans=N-d-1;
}
else{
    ans=N-d;
}

cout<<ans<<endl;

return 0;
}
/*

*/


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

using namespace std;

#define w(x)    int x; cin>>x; while(x--)
#define endl 	"\n"
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define rep(i,n) for (i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (i = k; i >= n; --i)
typedef long long ll;
#define mk(arr,n,type)   type *arr=new type[n]
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void b_v_r()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    b_v_r();
    int x[5],ans;
    for(int i=0;i<5;i++)
    {
        cin>>x[i];
        if(x[i]==0)
            ans = (i+1);
    }    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3548
#include<iostream>
using namespace std;
int main(){
int n,a,b,ans=0;cin>>n>>a>>b;
for(int i=1;i<n+1;i++){
int j=i,s=0;
while(j){
s+=j%10;
j/=10;
}
if(a<=s&&s<=b) ans+=i;
}
cout<<ans<<endl;
}


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

#include<iostream>
#include<iomanip>
#include<math.h>
#include<string.h>


using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define INF 1000000007
#define ull unsigned long long
#define PI 3.141592653589793238
#define pb push_back
#define max3(x, y, z) Max(x, Max(y, z))
#define min3(x, y, z) Min(x, Min(y, z))
#define mp make_pair
#define pre(a,b) cout << fixed << setprecision(a) << b  //a for precision b for answer
#define MAX 1e18
#define all(x) (x).begin(), (x).end()
#define lb lower_bound //lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘x’.
#define ub upper_bound //upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘x’.
#define maxe *max_element
#define mine *min_element
#define acc(x) accumulate(x.begin(), x.end(), 0)
#define dst distance
#define sz(x) (int)x.size()

template <typename T>
inline T const& Max (T const& a, T const& b)
{ 
	return a < b ? b:a; 
}

template <typename T>
inline T const& Min (T const& a, T const& b) { 
   return a < b ? a:b; 
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}

ll SieveOfEratosthenes(int n) 
{  
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    {  
        if (prime[p] == true) 
        {   
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    /*for (int p=2; p<=n; p++) 
       if (prime[p]) 
          cout << p << " "; */
    return prime[n + 1];
}

int main()
{
	IOS;
	int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n][3];
    int ans[n];
    dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
    ans[0] = max3(dp[0][0], dp[0][1], dp[0][2]);
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
        ans[i] = max3(dp[i][0], dp[i][1], dp[i][2]);
    }
    cout << ans[n - 1] << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b<c) cout<<a+b+1+b;
    else if(a+b==c) cout<<b+c;
    else if(a+b>c) cout<<c+b;
}

Measured memory_bytes: 3580
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int count = 0;
        for(int i=0;i<3;i++){
            if(S.charAt(i)=='o') count++;
        }
        System.out.print(700+count*100);
    }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		
		if (a >= 3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}
		sc.close();
	}

}

Measured memory_bytes: 21204
from collections import defaultdict

N = input()
nums = list(map(int, input().split()))

nums_dict = defaultdict(int)
sum_nums = sum(nums)

for num in nums:
    nums_dict[num] += 1

M = int(input())

for i in range(M):
    original, replaced = map(int, input().split())

    if original not in nums_dict:
        print(sum_nums)
        continue

    total_change = (replaced - original) * nums_dict[original]
    sum_nums += total_change

    print(sum_nums)

    nums_dict[replaced] += nums_dict[original]
    del nums_dict[original]

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

enum Area_t {
    LINE_1X, LOOP_XY, LINE_YZ
};

Area_t area_of(int i, int X, int Y) {
    if (i < X) {
        return LINE_1X;
    } else if (i <= Y) {
        return LOOP_XY;
    } else {
        return LINE_YZ;
    }
}

int calc_dist_in_loop(int a, int b, int X, int Y) {
    int d = b - a;
    return min(d, Y - X + 1 - d);
}

int calc_dist(int a, int b, int X, int Y) {
    Area_t area_a = area_of(a, X, Y);
    Area_t area_b = area_of(b, X, Y);

    if (area_a == LINE_YZ || area_b == LINE_1X) {
        return b - a;
    } else if (area_a == LINE_1X && area_b == LINE_YZ) {
        return X - a + b - Y + 1;
    } else if (area_a == LOOP_XY && area_b == LOOP_XY) {
        return calc_dist_in_loop(a, b, X, Y);
    } else if (area_a == LINE_1X) {
        return X - a + calc_dist_in_loop(X, b, X, Y);
    } else {
        return b - Y + calc_dist_in_loop(a, Y, X, Y);
    }
}

int main() {
    // get values from input
    int N, X, Y;
    cin >> N >> X >> Y;

    // main procedure

    map<int, int> distance_count;
    for (int i = 1; i < N; ++i) {
        distance_count[i] = 0;
    }

    for (int a = 1; a <= N-1; ++a) {
        for (int b = a+1; b <= N; ++b) {
            int distance = calc_dist(a, b, X, Y);
            distance_count[distance]++;
        }
    }

    // output
    for (int i = 1; i < N; ++i) {
        WRITE_N(distance_count[i]);
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

//最大公約数
//O(log max(a,b))
template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	return GCD(b, (T)(a % b));
}

//最大公約数(複数)
//O(nlog max(a_i))?
template<class T>
T GCD(vector<T> v) {
	for (int n = 1; n < v.size(); n++) {
		v[n] = GCD(v[n], v[n - 1]);
	}
	return v[v.size() - 1];
}

//最小公倍数
template<class T>
T LCM(T a, T b) {
	return a * b / GCD(a, b);
}

//最小公倍数(複数)
template<class T>
T LCM(vector<T> v) {
	for (int n = 1; n < v.size(); n++) {
		v[n] = LCM(v[n], v[n - 1]);
	}
	return v[v.size() - 1];
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N, M;
	cin >> N >> M;
	VLL A(N);
	for (ll n = 0; n < N; n++) {
		cin >> A[n];
		A[n] /= 2;
	}
	ll g = GCD(A);
	for (ll n = 0; n < N; n++)A[n] /= g;
	ll l = LCM(A);
	for (ll n = 0; n < N; n++) {
		ll k = l / A[n];
		if (k % 2 == 0) {
			cout << 0 << "\n";
			return 0;
		}
	}
	ll p = (M / g) / l;
	cout << (p + 1) / 2 << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	int k = S.size();
	sort(all(S));
	auto r = unique(all(S));
	S.erase(r, S.end());
	if (S.size() == k) puts("yes");
	else puts("no");
	return 0;
}


Measured memory_bytes: 256