akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
const int maxn = 1000010;
const int mod = 1e9 + 7;
const int INF = 999999999;
double eps = 1e-8;
typedef long long LL;
typedef pair<string, string> strP;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

int n;
char s[55];
map<strP, LL> mp;
map<int, string> f;

void solve() {
    string t;
    for(int i = 0;i < (1<<n);i++) {
        string a, b, c, d;
        for(int j = 0;j < n;j++) {
            if(i&(1<<j)) a.push_back(s[j]), d.push_back(s[j + n]);
        }
        for(int j = n - 1;j >= 0;j--) {
            if(i&(1<<j)) continue;
            b.push_back(s[j]), c.push_back(s[j + n]);
        }
        f[i] = b;
        mp[strP(c,d)]++;
    }
    LL ans = 0;
    for(int i = 0;i < (1<<n);i++) {
        string a, b;
        for(int j = 0;j < n;j++) {
            if(i&(1<<j)) a.push_back(s[j]);
        }
        b = f[i];
        ans = ans + mp[strP(a,b)];
        //cout << a << " " << b << " " << mp[strP(a, b)] << endl;
    }
    cout << ans << endl;
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        while(cin >> n >> s)
            solve();
    }
    int mark_EOF;
    if(scanf("%d", &mark_EOF) == EOF) return 0;
    return 0;
}


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

int main() {
  string s; cin >> s;
  if (s == "a" or s == "e" or s == "i" or s == "o" or s == "u") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = scanner.nextInt();
		int[] delicious = new int[n];
		int sum = 0;

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

		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				sum += delicious[i] * delicious[j];
			}
		}

		System.out.print(sum);
	}
}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            while(sc.hasNext()) {
                int N=sc.nextInt();
                int M=sc.nextInt();
                if(N+M==0)    break;
                int[] ds = new int[11];
                for(int i=0; i<N; i++) {
                    int d = sc.nextInt();
                    int p = sc.nextInt();
                    ds[p] += d;
                }
                int P = 0;
                for(int p= 10; p >=0; p--) {
                    if(M >= ds[p]) {
                        M -= ds[p];
                    }
                    else {
                        P += (ds[p] - M) * p;
                        M = 0;
                    }
                }
                System.out.println(P);
            }
        }
    }
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B > C+D) cout << "Left" << endl;
  else if(A+B == C+D) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

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

#define sum(l, r) (((r) * ((r) - 1) - (l) * ((l) - 1)) / 2)

int main(void) {
  ll B;
  while (cin >> B, B) {
    for (ll w = 65000; w >= 0; w--) {
      ll l = 0, h = B + 1;
      while (h - l > 1) {
        ll m = (l + h) / 2;
        if (sum(m, m + w) >= B) h = m;
        else l = m;
      }
      if (sum(h, h + w) == B) {
        cout << h << " " << w << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <cstring>

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int n;
string s, t;

int main() {
    cin >> s >> t;

    rep(i,s.length()) if (s[i] != t[i]) n++;

    cout << n << endl;

    return 0;
}

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

int main(){
    long long int N,A,B,C,D,E; cin>>N>>A>>B>>C>>D>>E;
    long long int ans=0;
    ans=(N-1)/min({A,B,C,D,E})+5;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import math
a,b,c,d= list(map(int, input().split()))
c_kakudo=c*30+(0.5*d)
d_kakudo=d*6
kakudo=abs(c_kakudo-d_kakudo)
rad=(kakudo*math.pi)/180
ans=math.sqrt((a**2)+(b**2)-2*a*b*math.cos(rad))
print(ans)

Measured memory_bytes: 9388
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func Input_int() int {
	stdin.Scan()
	out,err := strconv.Atoi(stdin.Text())
	if err != nil{
		panic(err)
	}
	return out
}

func main(){
	stdin.Split(bufio.ScanWords)
	A,B := Input_int(),Input_int()
	if A==B || (A+1)==B || A==(B+1){
		fmt.Println(A+B)
	}else if A>B{
		fmt.Println(A*2-1)
	}else{
		fmt.Println(B*2-1)
	}
}

Measured memory_bytes: 640
# 初期入力
import sys
input = sys.stdin.readline
X,N = (int(i) for i in input().split())
if N !=0:
    p = list(map(int, input().split()))
elif N ==0:
    p=[-1]
p.sort()
#
ans =[]
for i in range(-1,102):
    if i not in p:
        ans.append((abs(i-X),i))
ans.sort()
print(ans[0][1])

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

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

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

// 500, 45min

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
ll A[MAX_N] = {};
ll bit_cnt[64] = {};    // 各ビットの 1 の数
ll to_zero[64] = {};    // 各ビットの 1 を 0 にできるやつの数

signed main()
{
    cin >> N;
    REP(i, N) {
        scanf("%lld", &A[i]);
        for(ll j = 0; j < 64; ++j) {
            ll res = ((A[i] >> j) & 1);
            if(res == 1) { bit_cnt[j]++; }
        }
        for(ll j = 0; j < 64; ++j) {
            ll res = ((A[i] >> j) & 1);
            if(res == 1) {
                to_zero[j]++;
                break;
            }
        }
    }
    // 各ビットを上位から見ていく
    ll ans = 0;
    for(ll i = 63; i >= 0; --i) {
        if(bit_cnt[i] % 2 != 0) {
            if(to_zero[i] <= 0) {
                printf("-1\n");
                return 0;
            }
            to_zero[i]--;
            bit_cnt[i]--;
            for(ll j = i-1; j >= 0; --j) { bit_cnt[j]++; }
            ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
for i in range(N):
    if A[i] >= 2:
        ans += A[i]//2
        A[i] -= (A[i]//2)*2
    if i != N-1:
        if A[i] == 1 and A[i+1] >= 1:
            A[i] = 0
            A[i+1] -= 1
            ans += 1
print(ans)



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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    vector<int> A(2), B(2);
    REP(i, 2) cin >> A[i];
    REP(i, 2) cin >> B[i];
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    int sumA = 0, sumB = 0;

    sumA += A[0] / 10 * c + A[1] / 20 * d + A[0] * a + A[1] * b;
    sumB += B[0] / 10 * c + B[1] / 20 * d + B[0] * a + B[1] * b;

    if(sumA == sumB)
        cout << "even" << endl;
    else 
        cout << (sumA > sumB ? "hiroshi" : "kenjiro") << endl;

    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    map<ll, ll> mp0;
    map<ll, ll> mp1;
    map<ll, bool> used;
    int n;
    cin>>n;
    ll ans=0;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp0[i-a[i]]++;
        mp1[a[i]+i]++;
        used[a[i]+i]=false;
        //cout<<mp0[i-a[i]]<<" "<<mp1[i+a[i]]<<endl;
    }
    for(int i=0;i<n;i++){
        if(!used[a[i]+i]) ans+=mp1[i+a[i]]*mp0[i+a[i]];
        used[a[i]+i]=true;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 50544
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

  vt<int> L(N);
  rep(i,N)
    std::cin >> L[i];

  int ma = *std::max_element(L.begin(),L.end());
  int total = accumulate(L.begin(),L.end(),0) - ma;

  std::cout << (total > ma ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
def v():
    W,H,N=tuple(map(int,sys.stdin.readline().split()))
    lx,ux,ly,uy=0,W,0,H
    for _ in [0]*N:
        x,y,a=tuple(map(int,sys.stdin.readline().split()))
        if a==1 and lx<x:lx=x
        elif a==2 and ux>x:ux=x
        elif a==3 and ly<y:ly=y
        elif a==4 and uy>y:uy=y
    if lx<ux and ly<uy:print((ux-lx)*(uy-ly))
    else:print(0)
if __name__=='__main__':v()


Measured memory_bytes: 3064
import heapq

nv, ne, r = map(int, input().split(' '))
vertices = [[] for i in range(nv)]
for i in range(ne):
    s, t, w = map(int, input().split(' '))
    vertices[s].append((t, w))

q = []
heapq.heappush(q, (0, r))

dist = [float('inf')] * nv
dist[r] = 0

while len(q):
    u = heapq.heappop(q)[1]

    for t, w in vertices[u]:
        alt = dist[u] + w
        if alt < dist[t]:
            dist[t] = alt
            heapq.heappush(q, (alt, t))

[print(d) if d < float('inf') else print("INF") for d in dist]

Measured memory_bytes: 93064
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    loop {
        let _ = stdin.read_line(&mut buf);
        let vec : Vec<i64> = buf.split_whitespace().map(|a| i64::from_str(a).unwrap()).collect();
        buf.clear();

        let (x, y) = (vec[0], vec[1]);
        if x == 0 && y == 0 { break; }

        if x < y {
            println!("{} {}", x, y);
        }
        else {
            println!("{} {}", y, x);
        }
    }
}



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

typedef long long ll;
const ll INF = 1001001001001001001;

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a+2), t(b+2);
    // 番兵みたいな要素
    s[0] = -2 * INF, s[a + 1] = 2 * INF;
    t[0] = -2 * INF, t[b + 1] = 2 * INF;
    for(int i = 1; i <= a; ++i){
        cin >> s[i];
    }
    for(int i = 1; i <= b; ++i){
        cin >> t[i];
    }
    for(int i = 0; i < q; ++i){
        ll x;
        cin >> x;
        int s_id = lower_bound(s.begin(), s.end(), x) - s.begin();
        int t_id = lower_bound(t.begin(), t.end(), x) - t.begin();
        ll res = INF;
        ll x1 = s[s_id] - x;
        ll x2 = x - s[s_id - 1];
        ll y1 = t[t_id] - x;
        ll y2 = x - t[t_id - 1];
        cerr << x1 << " " << x2 << " " << y1 << " " << y2 << " ";
        res = min(res, max(x1, y1));
        res = min(res, max(x2, y2));
        res = min({res, 2 * x1 + y2, x1 + 2 * y2});
        res = min({res, 2 * x2 + y1, x2 + 2 * y1});
        cout << res << endl;
    }
}

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

int main() {
    int l[10];
    int v1, v2;
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
                l, l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 7, l + 8, l + 9, &v1, &v2) != EOF) {
        int sum = 0;
        for (int i = 0; i < 10; i++) {
            sum += l[i];
        }
        double meetTime = (double)sum / (v1 + v2);
        sum = 0;
        for (int i = 0; i < 10; i++) {
            sum += l[i];
            if (meetTime * v1 <= sum) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    double r;cin>>r;
    cout<<r*r<<endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import product

a, b, c, d, e, f = map(int, input().split())

max_conc = 0
res = [100*a, 0]
for w1, w2 in product(range(0, f+1, 100*a), range(0, f+1, 100*b)):
    if w1 + w2 > f or w1 == w2 == 0:
        continue
    for s1 in range(0, f-w1-w2+1, c):
        s2 = (min(f-w1-w2, (w1 + w2) // 100 * e) - s1) // d * d
        if s2 < 0:
            continue
        conc = (s1 + s2) / (w1 + w2 + s1 + s2) * 100
        if conc > max_conc:
            max_conc = conc
            res = [w1 + w2 + s1 + s2, s1 + s2]

print(' '.join(map(str, res)))


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K, S;
    cin >> N >> K >> S;
    vector<int> res(N);

    rep(i, K) { res[i] = S; }
    for(int i = K; i < N; i++) {
        if(S == 1e9)
            res[i] = 1;
        else
            res[i] = 1e9;
    }
    rep(i, N) { cout << res[i] << (i == N - 1 ? "\n" : " "); }
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a,odd,even;

main() {
    cin >> n;
    rep(i,n) {
        cin >> a;
        if (a%2) odd++;
        else even++;
    }
    if (odd%2) ct("NO")
    else ct("YES")
}



Measured memory_bytes: 256
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
x = 0
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if a <= x:
        continue
    x = b-1
    count+=1
print(count)

Measured memory_bytes: 20072
#![allow(dead_code)]

mod reader {
    use std;

    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);

    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }
}

#[macro_use]
mod misc {
    #[macro_export]
    macro_rules! bind_from_vec((
                               $ ( $ variable : ident ) , + = $ vector : expr
                               ) => {
                               let mut v = $ vector . clone (  ) . into_iter (
                                ) ; $ (
                               let $ variable = v . next (  ) . unwrap (  ) ;
                               ) + } ;);
}

use reader::*;
use misc::*;

fn main() {
    use std::cmp;

    bind_from_vec!(a , b = read_to_vec :: < i32 > (  ));

    println!("{}" , if a == b { a + b } else {
             cmp :: max ( a , b ) + cmp :: max ( a , b ) - 1 });
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
using namespace std;
int main() {
	int A[3];
	int K;
	cin >> A[0] >> A[1] >> A[2] >> K;
	int mx = max({A[0], A[1], A[2]});
	int mult = pow(2, K);
	int rest = 0;
	if (mx == A[0])
		rest = A[1] + A[2];
	else if (mx == A[1])
		rest = A[0] + A[2];
	else
		rest = A[0] + A[1];
	cout << mx * mult + rest << endl;
	//cin >> K;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


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

    ll ans = 1,p;
    cin >> p;
    ll min_p = p;
    for(int i=1;i<N;i++){
        cin >> p;
        if(p < min_p) ans++;
        min_p = min(min_p,p);
    }

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


Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n, ans = 0, cnt = 0;
	cin >> n;
	long long a[100001];
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		ans += abs(a[i]);
		if(a[i] < 0)
		{
			cnt++;
		}
		a[i] = abs(a[i]);
	}
	sort(a,a+n);
	if(cnt % 2)
		ans -= 2*a[0];
	cout << ans << endl;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec d(n);
    init(d);
    sort(all(d));
    print(d[n / 2] - d[n / 2 - 1]);

    return 0;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e5+3; //AREGLAAAAAAAAR!!!!
int a[MAXN],b[MAXN];
int main(){
	int n;
	ri(n);
	FOR(i,0,n){
		ri(a[i]);
	}
	int k=0,k2=n-1;
	
	for(int i=n-1; i>=0; i-=2){
		int i2=i-1;
		if(!i) i2=0;
		b[k]=a[i];
		b[k2]=a[i2];
		k++;
		k2--;
	}
	FOR(i,0,n) cout<<b[i]<<" ";
	cout<<endl;
}


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

using namespace std;


int N,K;
vector<bool> B;



int main()
{

	int ans = 0;
	cin >> N;
	cin >> K;
	

	B = vector<bool>(N);

	string input;
	cin >> input;

	int change_count = 0;

	for (int i = 0; i < N; i++) {
		B.at(i) = (input.at(i) == 'R');

		if (i > 0) {
			if (B.at(i) != B.at(i - 1)) {
				change_count++;
			}
			else {
				ans++;
			}
		}
	}


	ans += min(change_count, K * 2);


	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func swap(a int, b int) (int, int) {
	return b, a
}

func GCD(a int, b int) int {
	if b > a {
		a, b = swap(a, b)
	}
	if b == 0 {
		return a
	} else {
		return GCD(a%b, b)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	ans := 0
	K := nextInt()
	for a := 1; a <= K; a++ {
		for b := 1; b <= K; b++ {
			for c := 1; c <= K; c++ {
				tmp := GCD(a, b)
				ans += GCD(tmp, c)
			}
		}
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 1784
import sys


N, A, B, C, D = map(int, input().split())

S = {i : s for i, s in enumerate(input(), 1)}

stay_B = False
if S[B-1] == '.':
  continuous_empty = 2
else:
  continuous_empty = 1

while B != D:
  if S[B+1] == '.':
    B += 1
    continuous_empty += 1
    if continuous_empty == 3:
      stay_B = True
  else:
    if S[B+2] == '.':
      B += 2
      continuous_empty = 1
    else:
      print("No")
      sys.exit()
    
# D < C のときはAがBを追い越さなくてはならないので3連続空白地帯が必要
if (D > C) or stay_B or (continuous_empty == 2 and S[D+1] == '.'):
  while A != C:
    if S[A+1] == '.':
      A += 1
    else:
      if S[A+2] == '.':
        A += 2
      else:
        print("No")
        sys.exit()

  print("Yes")
  
else:
  print("No")


Measured memory_bytes: 27488
import itertools as itr
inf = int(1e9)
n, w = list(map(int, input().split()))
warr = [0]*(n+1)
varr = [0]*(n+1)
for i in range(n):
    wi, vi = list(map(int, input().split()))
    warr[i+1] = wi
    varr[i+1] = vi
vm = max(varr)    
vmax = int(n*vm)+1
dp = [[inf]*vmax for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
ans = 0
for i, j in itr.product(range(1,n+1), range(1,vmax)):
    jv = j-varr[i]
    if jv <0:
        jv = 0
    dp[i][j] = min(dp[i-1][jv] + warr[i], dp[i-1][j])
    if j > ans and dp[i][j] <= w:
        ans = j
  
print(ans)

Measured memory_bytes: 122928
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;

int main()
{
	int n; cin>>n;
	vvi dp(n,vi(n,INFTY));
	rep(i,n)
		dp[i][i]=0;
	rep(i,n){
		int r,k; cin>>r>>k;
		rep(j,k){
			int t; cin>>t;
			dp[r-1][t-1]=1;
		}
	}
	
	rep(k,n) rep(i,n) rep(j,n)
		dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
	
	int p; cin>>p;
	rep(i,p){
		int s,d,v; cin>>s>>d>>v;
		if(dp[s-1][d-1]<v)
			cout<<dp[s-1][d-1]+1<<endl;
		else
			cout<<"NA"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}

void solve()
{
     ll n;
     cin>>n;
     vector<ll> a(n+1),b(n+1),c(n+1);
     ll i;
     for(i=1;i<=n;i++)
          cin>>a[i]>>b[i]>>c[i];
     vector< vector<ll> > dp(n+1,vector<ll> (3,0));
     dp[1][0]=a[1];
     dp[1][1]=b[1];
     dp[1][2]=c[1];
     for(i=2;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][1],dp[i-1][0])+c[i];
     }
     ll ans=0;
     for(i=0;i<3;i++)
          ans=max(ans,dp[n][i]);
     cout<<ans;
     
}

int main()
{
    ios;
    ll t;
//    cin>>t;
  t=1;
    while(t--)
        solve();
}

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10 = 1024, X11 = 2048, X12 = 4096, X13 = 8196, X14 = 16392, X15 = 32786, X16 = 65536, X17 = 131072, X18 = 262144, X19 = 524288, X20 = 1048576;

class UnionFind {
private:
    vector<int> p, rank;
    int N;
    int findSet2(int i, bool* A){A[i] = 1;return (p[i] == i) ? i : (p[i] = findSet2(p[i], A));}
public:
    UnionFind(int N) {
        rank.assign(N, 0);
        p.assign(N, 0);
        for (int i = 0; i < N; i++) p[i] = i;
        this->N = N;
    }

    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }

    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }

    void unionSet(int i, int j) {
        if (!isSameSet(i, j)) {
// if from different set
            int x = findSet(i), y = findSet(j);
            if (rank[x] > rank[y]) p[y] = x;
// rank keeps the tree short
            else {
                p[x] = y;
                if (rank[x] == rank[y]) rank[y]++;
            }
        }
    }


    int numDisjointSets(){
        set<int> s;
        bool* visited = new bool[this->N];
        memset(visited, 0, sizeof(bool)*this->N);
        for (int i = 0; i < N; ++i) {
            if(!visited[i])s.insert(findSet2(i, visited));
        }
        return s.size();
    }

    int maxElements(){
        int mx = 0;
        map<int, int> m;
        for (int i = 0; i < N; ++i) {
            m[findSet(i)] ++;
        }
        set<pair<int, int>> s;
        for(auto p : m){
            s.insert({p.second, p.first});
        }
        return s.rbegin()->first ;
    }


};

vector<int> v;
void _() {
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            if(4*i + 7*j<=1300)v.emplace_back(4*i+7*j);
        }
    }
    int a;
    cin >> a;
    cout << (contains(v,a)?"Yes":"No");

}


int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const ll inf = 1e18;

int main()
{

    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);

    ll n;
    cin >> n;

    ll sum = 0, sumsq = 0;

    for (int i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        sum += a;
        sumsq += a * a;
    }
    ll ans = inf;

    for (ll x = -100; x <= 100; ++x) {
        ll val = sumsq - 2 * x * sum + n * x * x;
        ans = min(ans, val);
    }
    cout << ans << '\n';

}


Measured memory_bytes: 256
import math

a,b = map(int,input().split())
alow = math.ceil((a)/0.08)
ahigh = math.floor((a+1)//0.08)

blow = math.ceil((b)/0.1)
bhigh = math.floor((b+1)//0.1)

if alow < blow:
    if blow <= ahigh <= bhigh:
        print(blow)
    else:
        print(-1)

elif blow < alow:
    if alow  <= bhigh <= ahigh:
        print(alow)
    else:
        print(-1)

elif alow == blow:
    print(alow)

Measured memory_bytes: 3064
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(1, in, out);

//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for(int qq = 0; qq < q; qq++) {
            String s = in.next(), t = in.next();
            int n = s.length(), m = t.length();
            int[][] dp = new int[n + 1][m + 1];

            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= m; j++) {
                    if(s.charAt(i - 1) == t.charAt(j - 1)) {
                        dp[i][j] = 1 + dp[i - 1][j - 1];
                    }
                    else {
                        dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                    }
                }
            }
            StringBuilder sb = new StringBuilder();
            int i = n, j = m;
            while(i > 0 && j > 0) {
                if(s.charAt(i - 1) == t.charAt(j - 1)) {
                    sb.append(s.charAt(i - 1));
                    i--;
                    j--;
                }
                else {
                    if(dp[i - 1][j] >= dp[i][j - 1]) {
                        i--;
                    }
                    else {
                        j--;
                    }
                }
            }
            out.println(sb.reverse().toString());
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

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

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

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

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

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




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

int main() {
    int D,G,p[11],c[11];
    int nmin=0;
    cin >> D >> G;
    for (int i=0; i<D; i++) {
        cin >> p[i] >>c[i];
        nmin += p[i];
    }
    
    for (int mask=0; mask < (1<<D); mask++) {
        int num=0 ,point=0 ,rest_max=-1;
        
        for (int i=0; i<D; i++) {
            if (mask>>i & 1) {
                point += 100*(i+1) *p[i] +c[i];
                num += p[i];
            }else{
                rest_max =i;
            }
        }
        
        int rest_point = (100*(rest_max+1));
        if (point < G) {
            int need = (G - point + (rest_point-1) )/rest_point;
            if (need > p[rest_max]) continue;
            num += need;
        }
        
        nmin = min(nmin, num);
    }
    
    cout << nmin << endl;
    
    return 0;
}


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

int main()
{
    int x;
    
    cin >> x;
    
    if(x < 1200) {
        cout << "ABC\n";
    } else {
        cout << "ARC\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

ans = None
for i in range(N, -1, -1):
    for j in range(N-i, -1, -1):
        k = N - j - i
        if 10000 * i + 5000 * j + 1000 * k == Y:
            ans = (i, j, k)
            break
    else:
        continue
    break

if ans is not None:
    print(' '.join(map(str, ans)))
else:
    print(-1, -1, -1)


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

	string a;
	string b;
	
	int i=0;
	int ans=0;
	
	cin>>a>>b;
	
	if(a.size()>b.size())ans=0;
	if(a.size()==b.size())ans=1;
	if(a.size()<b.size())ans=2;
	
	if(ans==1){
	
		for(i=0;i<a.size();i++){
			if(a[i]>b[i]){
				ans=0;
				break;
			}
			//if(a[i]==b[i])ans=1;
			if(a[i]<b[i]){
				ans=2;
				break;
			}
		}	
	
	}

        if(ans==0)cout<<"GREATER";
        if(ans==1)cout<<"EQUAL";
        if(ans==2)cout<<"LESS";



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector <int> xcity(N);
    for(int i=0; i<N; i++) {
        cin >> xcity.at(i);
    }
    xcity.push_back(X);
    sort(xcity.begin() , xcity.end());
    
    vector <int> ycity(M);
    for(int i=0; i<M; i++) {
        cin >> ycity.at(i);
    }
    ycity.push_back(Y);
    sort(ycity.begin() , ycity.end());
    
    if (xcity.at(N) < ycity.at(0)) {
        cout << "No War" <<endl;
    }
    else {
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

vector<int> Eratosthenes(const int N){
    vector<bool> is_prime(N + 1);
    for(int i = 0; i <= N; i++)
    {
        is_prime[i] = true;
    }
    vector<int> p;
    for(int i = 2; i <= N; i++)
    {
        if(is_prime[i])
        {
            for(int j = 2 * i; j <= N; j += i)
            {
                is_prime[j] = false;
            }
            p.emplace_back(i);
        }
    }
    return p;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1, 0);
    REP(i, n){
        for(int j = i; j <= n; j += i)a[j]++;
    }
    ll ans = 0;
    REP(i, n){
        ans += a[i] * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int x, k;
    cin >> k >> x;
    if (500*k>=x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;

    for(int i = 0; i<=n; i++) {
      for(int j = 0; j<=m; j++) {
        count = ( i * m ) + ( j * n ) - ( 2 * i * j );
        if(count == k) {
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}

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

int main()
{
    int n,count=0;
    cin >> n;
    long a[n];
    for(long i=0;i<n;i++){
        cin >> a[i];
    }

    for(long i=0;i<n-2;i++){
        for(long j=i+1;j<n-1;j++){
            if(a[i]==a[j])    continue;
            for(long k=j+1;k<n;k++){
                if(a[i]==a[k] || a[j]==a[k])    continue;
                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i]) count++;
            }
        }
    }

    cout << count <<"\n";

    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define ll long long
#define lll __int128_t
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdll pair<ld, pll >
#define ppp pair<pii, pii >
#define F first
#define S second
#define pb push_back
#define pp pop_back

const int P = 1000000007;

using namespace std;

vector<lll> c(4), d;
map<ll, lll> dp;

ll dfs(ll n){
	
	if(n == 0) return 0;
	if(dp[n]) return dp[n];

	dp[n] = n*c[3];
	for(ll i=0; i<3; i++){
		ll k = 0;
		while((n-k)%d[i]) k++;
		dp[n] = min(dp[n], dfs((n-k)/d[i])+k*c[3]+c[i]);
		k = 0;
		while((n+k)%d[i]) k++;
		dp[n] = min(dp[n], dfs((n+k)/d[i])+k*c[3]+c[i]);
	}

	return dp[n];
}

int main(){

	d = {2, 3, 5};

	int t;
	cin >> t;

	for(;t--;){
		lll n;
		ll tmpn;
		vector<ll> tmpc(4);
		cin >> tmpn; n = tmpn;
		for(int i=0; i<4; i++){
			cin >> tmpc[i];
			c[i] = tmpc[i];
		}
		dp.clear();
		cout << dfs(n) << '\n';	
	}

	return 0;
}


Measured memory_bytes: 4604
#include<stdio.h>
int main(void)
{
  int a[3],b[3],i,j,jud=0,c[4];
  for(i=0;i<3;i++)
  {
    scanf("%d%d",&a[i],&b[i]);
    c[i]=0;
  }
  c[3]=0;
  for(i=0;i<3;i++)
  {
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  for(i=0;i<4;i++)
  {
    if(c[i]==0 || c[i]==3) jud=-1;
  }
  if(jud==0) printf("YES");
  else printf("NO");
  return 0;
}

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

int n;
string s;

bool match(int index, string pattern) {
	if (index + pattern.size() > s.size()) return false;
	for (int i = 0; i < pattern.size(); i++) {
		if (s[index + i] != pattern[i])
			return false;
	}
	return true;
}

int change() {
	string after = "Hoshina", before = "Hoshino";
	for (int i = 0; i < s.size(); i++) {
		if (match(i, before)) {
			for (int j = 0; j < before.size(); j++) {
				s[i + j] = after[j];
			}
		}
	}
	return 0;
}

int main(){
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		getline(cin, s);
		change();
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 0;
		for (int i = 1; i <= n; i++) {
			count += i;
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 21844
h1, m1, h2, m2, m = map(int, input().split())

if m2 < m1:
    mm = m2 - m1
else:
    mm = m2 - m1

t = (h2 - h1) * 60 + mm

if t < m:
    print(0)
else:
    print(t - m)

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

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

  int a[31] = {0};
  for(int i = 1; i <= 31; i+=7){
    a[i] = 6;
  }
  for(int i = 2; i <= 31; i+=7){
    a[i] = 7;
  }
  for(int i = 3; i <= 31; i+=7){
    a[i] = 1;
  }

  for(int i = 4; i <= 31; i+=7){
    a[i] = 2;
  }
  for(int i = 5; i <= 31; i+=7){
    a[i] = 3;
  }
  for(int i = 6; i <= 31; i+=7){
    a[i] = 4;
  }
  for(int i = 7; i <= 31; i+=7){
    a[i] = 5;
  }

  if(a[X] == 6){cout << "fri" << endl;}
  if(a[X] == 7){cout << "sat" << endl;}
  if(a[X] == 1)cout << "sun" << endl;
  if(a[X] == 2)cout << "mon" << endl;
  if(a[X] == 3)cout << "tue" << endl;
  if(a[X] == 4)cout << "wed" << endl;
  if(a[X] == 5)cout << "thu" << endl;

  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
using node = tuple<ll, ll>;
const int inf = numeric_limits<int>::max();

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


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

ll dp[3005][3005];

void solve(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    for(int i=n-1;i>=0;--i){//更新順に注意
        for(int j=i+1;j<=n;++j){
            if((n-(j-i))%2==0) dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
            else dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
        }
    }
    cout<<dp[0][n]<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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

const int N=100005;
const long long MOD=1e9+7;
int n,m,a[N];
long long dp[N][105];
char str[N];

long long dfs(int x,int s,int limit)
{
	if(x==n+1)
	{
		dp[x][s]=(s==0);
		return dp[x][s];
	}
	if(!limit&&dp[x][s]>-1) return dp[x][s];
	int rb;
	long long res=0;
	if(limit) rb=a[x]; else rb=9;
	for(int i=0;i<=rb;i++)
	{
		res=(res+dfs(x+1,(s+i)%m,(limit&&(i==rb))))%MOD;
	}
	if(!limit) dp[x][s]=res;
	return res;
}

int main()
{
	scanf("%s%d",str,&m),n=strlen(str);
	for(int i=1;i<=n;i++) a[i]=str[i-1]-'0';
	memset(dp,-1,sizeof(dp));
	printf("%lld\n",(dfs(1,0,1)+MOD-1)%MOD);
}

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

using namespace std;

int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    long long mul = 1LL * a * b - 1;
    if (a > b) swap(a, b);
    long long ans = a-1;
    long long le = a-1, ri = b-1;
    while (le < ri) {
      long long mid = (le + ri + 1) >> 1;
      long long k = (mid + a + 1) / 2;
      long long c = min(max(k - a, 1LL), mid);
      bool ok = 1;
      for (int i = -2; i <= 2; ++i) {
        long long d = c + i;
        if (d <= 0 || d > mid) continue;
        long long x = a + d, y = mid + 1 - d;
        if (x * y > mul) {
          ok = 0;
          break;
        }
      }
      if (ok)
        le = mid;
      else
        ri = mid-1;
    }
    ans += ri;
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 256