akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B, C,X;
	cin >> A >> B >> C >> X;

	int ans = 0;
	rep(i, 0, A + 1)rep(j, 0, B + 1)rep(k, 0, C + 1)
	{
		if (500 * i + 100 * j + 50 * k == X)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	
	cout << s1[0] << s2[0] << s3[0] << endl;
	
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>

using namespace std ;
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
     if(n*a<b){
        cout<<n*a<<endl;
     }
     else if(n*a>b){
        cout<<b<<endl;
     }
     else if(n*a==b){
        cout<<b<<endl;
     }

    return 0;
}


Measured memory_bytes: 256
import java.util.Comparator

fun main(args: Array<String>) {
    val (H, W, D) = readLine()!!.split(" ").map{it.toInt()}
    val A = Array(H) {
        readLine()!!.split(" ").map{it.toInt()}
    }

    val B = Array(H * W) {
        val i = it / W
        val j = it % W
        Triple(A[i][j], i, j)
    }.sortedWith(Comparator { a, b -> a.first.compareTo(b.first)})

    val C = Array(H * W) {
        if (it < D) {
            0
        } else {
            val s = B[it - D]
            val t = B[it]
            Math.abs(s.second - t.second) + Math.abs(s.third - t.third)
        }
    }

    for (i in D until C.size) {
        C[i] += C[i - D]
    }

    val Q = readLine()!!.toInt()
    for (i in 1..Q) {
        val (L, R) = readLine()!!.split(" ").map{it.toInt()}

        println(C[R - 1] - C[L - 1])
    }
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,h;
    cin >> h >> n;
    vector<vector<int>> dp(n+1,vector<int>(h+1,1e9));
    dp[0][0] = 0;
    for (int i = 0;i < n;++i) {
        int a,b;
        cin >> a >> b;
        dp[i+1] = dp[i];
        for (int j = 0;j < h+1;++j) dp[i+1][min(h,j+a)] = min(dp[i+1][min(h,j+a)],dp[i][j]+b);
        for (int j = 0;j < h+1;++j) dp[i+1][min(h,j+a)] = min(dp[i+1][min(h,j+a)],dp[i+1][j]+b);
    }
    cout << dp[n][h] << endl;
}

Measured memory_bytes: 39424
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <iostream>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;
int main() {
    string s,t;
    cin >> s >> t;
    int m = s.length();
    int n = t.length();
    bool ok = true;
    for (int i = 0; i < m; i++){
        if (s[i] != t[i]) {
            ok = false;
        }
    }
    if (m + 1 != n) {
        ok = false;
    }
    if(ok){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

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

int main(){
	int Array [3];
	for (int i=0; i<3; i++){
		cin >> Array[i];
	}
	
	swap(Array[0], Array[1]);
	swap(Array[0], Array[2]);
	
	for (int i=0; i<3; i++){
	cout << Array[i] << " ";
	}	
}

Measured memory_bytes: 256
// finish date: 2019/06/29

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 998244353;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

//最大公約数
ll gcd(ll a, ll b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (a < b) {
        swap(a, b);
    }
    ll r = 1; //0以外であれば何でも
    while (r != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;
    ll cntB = B - (B / C + B / D - B / ((C * D) / gcd(C, D)));
    ll cntA = A - (A / C + A / D - A / ((C * D) / gcd(C, D)));

    cout << cntB - cntA << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll res=1;a%=mod;for(;b;b>>=1){if(b&1) res=res*a%mod;a=a*a%mod;}return res;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N=4e5+10;
string s,bs,es;
int main()
{

    sync;
    cin>>s;
    int q;
    cin>>q;
    int cnt=0;
    while (q--)
    {
        int t,f;
        char c;
        cin>>t;
        if(t==1)
        {
           cnt++;
        }else
        {
            cin>>f>>c;
            if(f==1)
            {
                if(cnt%2)
                {
                    es+=c;
                }
                else
                {
                    bs=c+bs;
                }
            }else
            {
                if(cnt%2)
                {
                    bs=c+bs;
                }
                else
                {
                    es+=c;
                }
            }
        }
    }
    if(cnt%2)
    {
        reverse(es.begin(),es.end());
        reverse(s.begin(),s.end());
        reverse(bs.begin(),bs.end());
        cout<<es<<s<<bs<<endl;
    }else
        cout<<bs<<s<<es<<endl;
    return 0;
}

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

using namespace std;

int gcd(int a, int b){
    if (a < b){
        int c = b;
        b = a;
        a = c;
    }
    while (true){
        int _b = a%b;
        if (_b == 0)  return b;
        else {
            a = b;
            b = _b;
        }
    }
}

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

    vector<int> memo1(n, 0);
    vector<int> memo2(n, 0);

    int v = a[0];
    for (int i=0; i<n; i++){
        v = gcd(a[i], v);
        memo1[i] = v;
    }
    v = a[n-1];
    for (int i=n-1; i>=0; i--){
        v = gcd(a[i], v);
        memo2[i] = v;
    }

    int ans = 0;
    for (int i=0; i<n; i++){
        int _ans;
        if (i == 0)  _ans = memo2[1];
        else if (i == n-1)  _ans = memo1[n-2];
        else {
            _ans = gcd(memo1[i-1], memo2[i+1]);
        }
        ans = max(ans, _ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{


    ll k,b,m,q;
    long long int c,d,t,i,j,a,f,n;
    vector<ll> v;
    map<char,ll> ma,sa;
    vector<string> st,et;
    string s;
    cin>>a>>b;
    f = 0;
    for(i=0; i<a; i++)
    {
        cin>>s;
        st.push_back(s);
    }
    for(i=1;i<=b+2;i++){
        cout<<"#";
    }
    cout<<endl;
    for(i=0;i<st.size();i++){
        cout<<"#"<<st[i]<<"#"<<endl;
    }
for(i=1;i<=b+2;i++){
        cout<<"#";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,a[100010],d[100010],nxt[100010],id[100010];
long long k,ans[100010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),d[i]=i,id[i]=i;
	scanf("%d %lld",&m,&k);
	for(int i=1,w;i<=m;i++) scanf("%d",&w),swap(id[w],id[w+1]);
	for(;k;k>>=1){
		if(k&1){
			for(int i=1;i<=n;i++) nxt[i]=d[id[i]];
			for(int i=1;i<=n;i++) d[i]=nxt[i];
		}
		for(int i=1;i<=n;i++) nxt[i]=id[id[i]];
		for(int i=1;i<=n;i++) id[i]=nxt[i];
	}
	for(int i=1;i<=n;i++) ans[i]=a[d[i]]-a[d[i]-1];
	for(int i=1;i<=n;i++) printf("%lld.0\n",ans[i]+=ans[i-1]);
}

Measured memory_bytes: 3840
import sys
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]

dp = [10 ** 18] * N
dp[0] = 0

for i in range(N):
    if i + 1 < N:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(L[i] - L[i + 1]))
        
    if i + 2 < N:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(L[i] - L[i + 2]))
    
print(dp[-1])

Measured memory_bytes: 14104
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	string S;
	cin >> S;

	int a = 0;
	int b = N - 1;
	int kotae = 0;
	while (a < b) {
		while (a < N && S[a] == 'R') a++;
		while (b >= 0 && S[b] == 'W') b--;
		if (a < b) {
			kotae++;
			a++;
			b--;
		}
	}
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<map>

int main(){

    size_t n;
    std::cin >> n;

    std::map<size_t, size_t> m;

    for(size_t i = 0; i < n; i++){
        size_t in;
        std::cin >> in;
        m[in]++;
    }

    size_t cnt = 0;

    for(const auto& e : m){
        if(e.second % 2 == 1){
            cnt++;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

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

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template<typename T>
void dump_vec(vector<T> vec) {
    rep(i, vec.size()) {
        cout << i << ": " << vec[i] << endl;
    }
}

void out_route(p_i s, p_i t, bool forward = true) {
    assert(t.first - s.first > 0);
    assert(t.second - s.second > 0);
    if (forward) {
        rep(i, t.first - s.first) {
            cout << 'R';
        }
        rep(i, t.second - s.second) {
            cout << 'U';
        }
    } else {
        rep(i, t.first - s.first) {
            cout << 'L';
        }
        rep(i, t.second - s.second) {
            cout << 'D';
        }

    }
    
    return;
}

// --- notice ---
// intの和はllにしろ

int main() {
    int s_x, s_y, t_x, t_y;
    cin >> s_x >> s_y >> t_x >> t_y;

    p_i start(s_x, s_y);
    p_i end(t_x, t_y);
    out_route(start, end);
    out_route(start, end, false);

    cout << 'D';

    out_route(p_i(s_x, s_y - 1), p_i(t_x + 1, t_y));
    cout << 'L';
    cout << 'U';
    out_route(p_i(s_x - 1, s_y), p_i(t_x, t_y + 1), false);

    cout << 'R' << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int q;
	
	scanf("%d", &q);
	while (q-- > 0){
		int c, a, n;
		int team = 0;
		
		scanf("%d %d %d", &c, &a, &n);
		while (c > 0 && a > 0 && n > 0){
			team++;
			c--;
			a--;
			n--;
		}
		while (c > 1 && a > 0){
			team++;
			c -= 2;
			a--;
		}\
		while (c > 2){
			team++;
			c -= 3;
		}
		printf("%d\n", team);
	}
	
	return 0;
}

Measured memory_bytes: 600
X, N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  num = float("inf")
  for i in range(1, 101):
    if abs(i-X) < abs(num-X) and not i in p:
      num = i
  if abs(0-X) <= abs(num-X) and abs(0-X) <= abs(101-X):
    print(0)
  elif abs(101-X) < abs(num-X):
    print(101)

  else:	
    print(num)
else:
  print(X)

Measured memory_bytes: 61948
#include<cstdio>
using namespace std;
typedef long long ll;
ll a[60],div,ans;
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",a+i);
	for(int flag=0,p;!flag;){
		if(a[p=1]<n)flag=1;
		for(int i=2;i<=n;++i)
			if(a[i]>a[p]&&a[i]>=n)flag=0,p=i;
		if(!flag){
			ans+=(div=a[p]/n);a[p]%=n;
			for(int i=1;i<=n;++i)
				if(i!=p)a[i]+=div;
		}
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		//Console.WriteLine(maxCap(0));
		//Console.WriteLine(maxCap(45));
		//Console.WriteLine(maxCap(90));
		
		
		double l = 0.0;
		double r = 90.0;
		for(int t=0;t<200;t++){
			double c = (l + r) / 2;
			double cap = maxCap(c);
			if(cap >= X){
				l = c;
			} else {
				r = c;
			}
		}
		Console.WriteLine((l + r) / 2.0);
		
		
	}
	
	double maxCap(double ang){
		ang *= Math.PI / 180.0;
		
		double left = A * Math.Sin(ang);
		double right = B * Math.Cos(ang);
		//Console.WriteLine("{0} {1}",left, right);
		if(right >= left){
			double s = A * A * Math.Tan(ang) / 2.0;
			return (double) (A * B - s) * A;
		} else {
			double s = B * B * Math.Tan(Math.PI/2.0 - ang) / 2.0;
			return s * A;
		}
	}
	
	
	
	int A,B,X;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1]; X = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
typedef long long ll;
#define int ll
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
using namespace std;
int MOD = 1000000007;
 
signed main(){

    int x,y,s;
    while(1){
        cin >> x >> y >> s;
        if(x == 0)break;
        int ans = 0;
        for(int a = 1;a < s;a++){
            for(int b = 1;b < s;b++){
            if(a*(100+x)/100 + b*(100+x)/100 == s){
                ans = max(ans,a*(100+y)/100 + b*(100+y)/100);
            }}
        }
        cout << ans << endl;

    }
    return 0;
}

// g++ -std=c++14 icpc2014_a.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc034.contest.atcoder.jp/tasks/agc034_b



Measured memory_bytes: 2996
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

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

int main()
{
    fast;
    int s,w;cin>>s>>w;
    if(w>=s)
    	cout<<"unsafe";
    else
    	cout<<"safe";

    
}





Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
int n;
char maps[5005][5005];
int mem[3000][2];
bool han(int xx,int yy){
  if(xx>5000 || 0>xx || yy>5000 || 0>yy)return false;
  else return true;
}
int main(void){
  scanf("%d",&n);
  while(n!=0){
    memset(maps,0,sizeof(maps));
    memset(mem,0,sizeof(mem));
    int i,x,y;
    for(i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      mem[i][0]=x;
      mem[i][1]=y;
      maps[x][y]=1;
    }
    int j,ans=0,p,q,a,b,s;
    for(i=0;i<n;i++){
      for(j=i;j<n;j++){
	x=mem[i][0];
	y=mem[i][1];
	p=mem[j][0];
	q=mem[j][1];
	b=p-x;
	a=y-q;
	if(han(p+a,q+b) && maps[p+a][q+b]==1){
	  if(han(x+a,y+b) && maps[x+a][y+b]==1){
	    s=a*a+b*b;
	    ans=(s>ans)?s:ans;
	  }
	}
	if(han(p-a,q-b) && maps[p-a][q-b]==1){
	  if(han(x-a,y-b) && maps[x-a][y-b]==1){
	    s=a*a+b*b;
	    ans=(s>ans)?s:ans;
	  }
	}
      }
    }
    printf("%d\n",ans);
    scanf("%d",&n);
  }
  return 0;
}

Measured memory_bytes: 25524
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

axor=[0]*n
bxor=[0]*n

for i in range(n-1):
    axor[i] = a[i] ^ a[i+1]
    bxor[i] = b[i] ^ b[i+1]

axor[-1] = a[0] ^ a[-1]
bxor[-1] = b[0] ^ b[-1]

def MP(it):
    n = len(it)
    res = [0]*(n+1)
    res[0] = -1
    j = -1
    for i in range(n):
        while j >= 0 and it[i] != it[j]:
            j = res[j]
        j += 1
        res[i+1] = j
    return res

mp = MP(bxor)
shift = [1]*(n+1)
for i in range(n):
    shift[i+1] = i+1 - mp[i+1]
txt = axor + axor
head = 0
ans = list()
start = 0
while head < n:
    for i in range(start,n):
        if bxor[i] != txt[head+i]:     
            start = max(0,i - shift[i])
            head += shift[i]
            break
    else:
        x = b[0] ^ a[head]
        ans.append([head, x])
        start = i+1 - shift[i+1]
        head += shift[i+1]


for k,x in ans:
    print(k,x)

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

int main() {
	int N;
	double x[10], count = 0;
	string u[10];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY") count += x[i];
		else count += 380000 * x[i];
	}
	printf("%5f\n", count);
}

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

public class Main {

	void submit() {
		int n = nextInt();
		
		int c0 = 0;
		int c1 = 0;
		int c2 = 0;
		
		for (int i = 0; i < n; i++) {
			int x = nextInt();
			if (x % 4 == 0) {
				c2++;
			} else if (x % 2 == 0) {
				c1++;
			} else {
				c0++;
			}
		}
		
		if (c0 > c2 + 1) {
			out.println("No");
			return;
		}
		
		if (c0 == c2 + 1) {
			out.println(c1 == 0 ? "Yes" : "No");
			return;
		}
		
		out.println("Yes");
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


Measured memory_bytes: 35860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll x;
	cin>>x;
	FOR(a,-3000,3000)FOR(b,-3000,3000){
		if(a*a*a*a*a-b*b*b*b*b==x){
			cout<<a<<' '<<b<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3612
import java.util.Scanner;

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

        final int[] array = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = scanner.nextInt();
        }

        int prev = array[1];
        for (int i = 2; i <= n; i++) {
            if (prev + array[i] < l) {
                prev = array[i];
                continue;
            }

            System.out.println("Possible");
            for (int j = 1; j < i - 1; j++) {
                System.out.println(j);
            }

            for (int j = n - 1; j >= i; j--) {
                System.out.println(j);
            }

            System.out.println(i - 1);
            return;
        }

        System.out.println("Impossible");
    }
}


Measured memory_bytes: 65740
n = int(input())
b = list(map(int, input().split()))
a = [0] * n
a[0] = b[0]
for i in range(n - 1):
    if a[i] <= b[i]:
        pass
    else:
        a[i] = b[i]
    a[i + 1] = b[i]

print(sum(a)) 

Measured memory_bytes: 8992
#include <iostream>
using namespace std;
#define LL long long

#include <cmath>
void _140() {
    int n;
    cin >> n;
    int b[100];
    LL sum = 0;
    for (int i = 0; i < n - 1; ++i) {
        cin >> b[i];
        if (i == 0) {
            sum += b[i];
        } else {
            sum += min(b[i - 1], b[i]);
        }
    }
    sum += b[n - 2];

    cout << sum << endl;
}

void _141() {
    int n, k, q;
    cin >> n >> k >> q;
    int a[100000];
    int point[100000] = {0};
    for (int i = 0; i < q; ++i) {
        cin >> a[i];
        point[a[i] - 1]++;
    }

    for (int i = 0; i < n; ++i) {
        if (k + point[i] - q > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
 }

#include <vector>
#include <algorithm>
void _142() {
    int n;
    cin >> n;
    int a;
    vector<pair<int, int> > list;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        list.push_back(make_pair(a, i + 1));
    }

    sort(list.begin(), list.end());
    for (int i = 0; i < n; ++i) {
        cout << list[i].second;
        if (i == n - 1)
            cout << endl;
        else
            cout << " ";
    }
}

#include <string>
void _143() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    char prev_color = s[0];
    int count = 1;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] != prev_color) {
            count++;
            prev_color = s[i];
        }
    }
    cout << count << endl;
}

void _144() {
    LL n;
    cin >> n;
    LL m = floor(sqrt(n));

    LL result = 0;
    for (LL i = m; m > 0; --i) {
        if (n % i == 0) {
            result = i + n / i - 2;
            break;
        }
    }
    cout << result << endl;
}

#include <iomanip>
#include <cmath>
void _145() {
    int n;
    cin >> n;
    int x[8], y[8];
    vector<int> points;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        points.push_back(i);
    }

    int curr_x, curr_y;
    double sum = 0;
    int count = 0;
    do {
        double distance = 0;
        curr_x = x[points[0]];
        curr_y = y[points[0]];
        // cout << points[0] << endl;
        for (int i = 1; i < n; ++i) {
            // cout << curr_x << " " << curr_y << endl;
            // cout << x[points[i]] << " " << y[points[i]] << endl;
            // cout << (pow(x[points[i]] - curr_x, 2)) << " " << ((y[points[i]] - curr_y)) << endl;
            // cout << ((x[points[i]] - curr_x) ^ 2 + (y[points[i]] - curr_y) ^ 2) << endl;
            distance += sqrt(pow(x[points[i]] - curr_x, 2) + pow(y[points[i]] - curr_y, 2));
            curr_x = x[points[i]];
            curr_y = y[points[i]];
            // cout << distance << endl;
            // cout << endl;
        }
        // cout << distance << endl;
        sum += distance;
        count++;
    } while (next_permutation(points.begin(), points.end()));

    cout << fixed << setprecision(10);
    cout << sum / count << endl;

}

int main()
{
    _145();

    return 0;
}



Measured memory_bytes: 256
use std::collections::{HashMap, VecDeque};
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
struct Main {
    k: usize,
    a: Vec<Vec<i64>>,
}
impl Main {
    fn invoke(&mut self) {
        for i in 1..10 {
            let a = self.a[i - 1].clone();
            let mut new_a = vec![];
            for &v in a.iter() {
                let num_str = v.to_string();
                let num_chars = num_str.chars();
                let last_num = num_chars.clone().last().unwrap() as i64 - 48;
                let new_chars: Vec<char> = if last_num == 0 {
                    vec!['0', '1']
                } else if last_num == 9 {
                    vec!['8', '9']
                } else {
//                    println!("{}, {}, {}", last_num - 1, last_num, last_num + 1);
                    vec![last_num - 1, last_num, last_num + 1]
                        .iter()
                        .map(|&n| std::char::from_digit(n as u32, 10).unwrap())
                        .collect::<Vec<char>>()
                };
                for &c in new_chars.iter() {
                    let new_num_chars = num_chars.clone();
                    let mut new_num_chars_vec = new_num_chars.collect::<Vec<char>>();
                    new_num_chars_vec.push(c);
                    let mut new_num_str = "".to_string();
                    for &num_char in new_num_chars_vec.iter() {
                        new_num_str.push(num_char);
                    }
                    let new_num: i64 = new_num_str.parse().unwrap();
                    new_a.push(new_num);
                }
            }
            self.a[i] = new_a;
        }
//        println!("{:?}", self.a);
        let res = self.a.iter().flat_map(|a_one| a_one).collect::<Vec<_>>();
        println!("{}", res[self.k - 1]);
    }
}
fn main() {
    let k: usize = read();
    Main {
        k: k,
        a: vec![(1..10).collect::<Vec<i64>>(); 10],
    }
        .invoke()
}

Measured memory_bytes: 8572
# coding: utf-8
import math
a, b, x = map(int, input().split())
if x >= a**2*b/2:
    ans = 90 - math.degrees(math.atan2(a**3, (2*a**2*b-2*x)))
else:
    # ans = 90 - math.degrees(math.atan2(2*x, (a**2*b-2*x)))
    # ans = 90 - math.degrees(math.asin((2*x*a) / (b*math.sqrt(4*x**2 + a**2*b**4))))
    ans = 90 - math.degrees(math.asin(2*x/math.sqrt(a**2*b**4 + 4*x**2)))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

signed main() {
  int x,a,b,n;cin>>x>>a>>b>>n;
  int ans = x;
  for(int i=0;i<n;++i) {
    string s;cin>>s;
    if (s == "nobiro") ans += a;
    if (s == "tidime") ans += b;
    if (s == "karero") ans = 0;
    ans = max(ans, 0LL);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>


using namespace std;

int dp(int x,int y){
    if(y==0) return 1;
    return x*dp(x,y-1);
}

int main() {
    int n;
    cin>>n;
    int t=0;
    int a=n;
    while(a>0){
        a=(a-a%10)/10;
        t=t+1;
    }
    int ans=0;
    if(t>=4){
        for(int i=3;i<=t-1;i++){
            ans=ans+dp(3,i)-3*dp(2,i)+3;
        }
    }
    stack<int> s;
    s.push(3);
    s.push(5);
    s.push(7);
    int b,c;
    b=dp(10,t-1);
    c=dp(10,t);
    while(s.size()!=0){
        a=s.top();
        s.pop();
        if(a>=b && a<=n){
            int d[8];
            for(int i=0;i<=7;i++){
                d[i]=0;
            }
            for(int i=0;i<=t-1;i++){
                d[a%10]=1;
                a=(a-a%10)/10;
            }
            if(d[3]==1 && d[5]==1 && d[7]==1){
                ans++;
            }
        }else if(a<b){
            s.push(10*a+3);
            s.push(10*a+5);
            s.push(10*a+7);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int n;
    cin>>n;
    /*{P1,P2,,,P(n-1),Pn}={2,3,,,n,1}のとき
    {M1,M2,,,M(n-1),Mn}={1,2,,,n-1,0}
    これが最大*/
    cout<<(long long)(n-1)*n/2<<endl;
    return 0;
}

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

int main()
{
    
 int n;
 cin>>n;
 int a[10][n];
 for(int i=0;i<n;i++)
 {cin>>a[0][i]>>a[1][i]>>a[2][i];

 }
 int dp[n][3];
dp[0][0]=a[0][0] ;
dp[1][0]=a[1][0] ;
dp[2][0]= a[2][0];
for(int j=1;j<n;j++)
{
dp[0][j]=a[0][j]+max(dp[1][j-1],dp[2][j-1]);
dp[1][j]=a[1][j]+max(dp[0][j-1],dp[2][j-1]);
dp[2][j]=a[2][j]+max(dp[1][j-1],dp[0][j-1]);


}
cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<endl;
}

Measured memory_bytes: 3712
N=int(input())
l=[0]*5
for i in range(N):
    s=input()
    if s[0]=="M":
        l[0]+=1
    elif s[0]=="A":
        l[1]+=1
    elif s[0]=="R":
        l[2]+=1
    elif s[0]=="C":
        l[3]+=1
    elif s[0]=="H":
        l[4]+=1
from itertools import combinations
t=list(combinations(range(5),3))
a=0
for i in range(10):
    a+=l[t[i][0]]*l[t[i][1]]*l[t[i][2]]
print(a) 

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());

            var P = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var min = int.MaxValue;
            var count = 0;
            foreach(var i in Enumerable.Range(0, N))
            {
                if (P[i] < min)
                {
                    count++;
                    min = P[i];
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 35676
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int kyo = sc.nextInt();
		int iin = sc.nextInt();
		int kyohi[] = new int[kyo];
		int cnt[] = new int[kyo];
		int kijun[] = new int[iin];
		for(int i = 0; i < kyo; i++){
			kyohi[i] = sc.nextInt();
			cnt[i] = 0;
		}
		for(int i = 0; i < iin; i++){
			kijun[i] = sc.nextInt();
		}
		for(int j = 0; j < iin; j++){
			for(int k = 0; k < kyo; k++){
				if(kyohi[k] <= kijun[j]){
					cnt[k] = cnt[k] + 1;
					break;
				}
			}
		}
		int max = cnt[0];
		int soe = 1;
		for(int i = 1; i < kyo; i++){
			if(max < cnt[i]){
				max = cnt[i];
				soe = i + 1;
			}
		}
		System.out.println(soe);
	}
}

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

int main() {
	ll n,d;
	cin>>n>>d;
	d=d*d;
	ll f=0;
	for(ll i=0;i<n;i++) {
	    ll x,y;
	    cin>>x>>y;
	    x=x*x;
	    y=y*y;
	    if(d>=(x+y))
	    f++;
	}
	cout<<f<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

template<typename T>
struct Point {
	T x, y;
	Point(T x=0, T y=0):x(x), y(y) {}
	Point(std::pair<T, T> p): x(p.first), y(p.second) {}
	Point& operator+= (const Point &o){ x += o.x; y += o.y; return *this; }
	friend Point operator+ (Point a, const Point &b) { a += b; return a; }
	Point& operator-= (const Point &o){ x -= o.x; y -= o.y; return *this; }
	friend Point operator- (Point x, const Point &y) { x -= y; return x; }
	Point& operator*= (const T &a) { x *= a, y *= a; return *this; }
	friend Point operator* (const T a, Point x) { x *= a; return x; }
	Point& operator/= (const T &a) { x /= a, y /= a; return *this; }
	friend Point operator/ (Point x, const T a) { x /= a; return x; }
	T dot(const Point &o) const { return x*o.x+y*o.y; }
	T det(const Point &o){ return x*o.y-y*o.x; }
	// complex product
	Point cp(const Point &o) {
		complex<T> p = complex<T>(x, y) * complex<T>(o.x, o.y);
		return Point(p.real(), p.imag());
	}
	bool operator< (const Point &o) { return x<o.x || (x==o.x && y<o.y); };
};

typedef Point<double> P;
double dist2(P a, P b){
	return (a-b).dot(a-b);
}

vector<P> circles_intersections(P x1, double r1, P x2, double r2){
	P z = x2-x1;
	double d2 = dist2(z, P());
	double cos = (r1*r1 + d2 - r2*r2)/(2*r1*sqrt(d2));
	if(cos<-1 || 1<cos) return {};
	P p(r1*cos, r1*sqrt(1-cos*cos));
	vector<P> r{p, P(p.x, -p.y)};
	for(P &t: r){
		t = t.cp(z) / sqrt(d2) + x1;
	}
	return r;
//	double a = (d2 + r1*r1 - r2*r2)/2;
//	double b2 = d2 * r1*r1 - a*a;
//	double c = d2;
//	if(abs(b2) < 1e-10){
//		return {P(a * z.x / c, a * z.y / c) + x1};
//	}
//	if(b2 < 0) return vector<P>();
//
//	double b = sqrt(b2);
//	return {P((a * z.x + z.y * b) / c,
//			  (a * z.y - z.x * b) / c) + x1,
//		   P((a * z.x - z.y * b) / c,
//			 (a * z.y + z.x * b) / c) + x1};
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<double> X(N), Y(N), C(N);
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i] >> C[i];

	double lb = 0, ub = 1000000;
	double eps = 1e-8;
	for(int l=0; l<100; l++){
		double med = (lb+ub)/2;
		bool ok = false;
		vector<P> candidates;
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				if(i==j) continue;
				vector<P> is = circles_intersections(P(X[i], Y[i]), med/C[i]-eps, P(X[j], Y[j]), med/C[j]-eps);
				for(P p: is){
					candidates.push_back(p);
				}
			}
			candidates.push_back(P(X[i], Y[i]));
		}

		for(P p: candidates){
			int cnt = 0;
			for(int k=0; k<N; k++){
				if(C[k]*sqrt(dist2(P(X[k], Y[k]), p)) <= med) cnt++;
			}
			if(cnt >= K){
				ok = true;
				debug(med, cnt, K, p.x, p.y);
			}
		}

		if(ok){
			ub = med;
		} else {
			lb = med;
		}
	}

	cout << setprecision(10) << lb << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll h, w, d;
  cin >> h >> w >> d;
  
  map<ll, P> m;
  for (ll i = 0; i < h; i++){
    for (ll j = 0; j < w; j++){
      ll a;
      cin >> a;
      
      m[a] = P(i, j);
    }
  }


  vector<vector<ll>> accsum(d, vector<ll>(h*w/d + 1, 0));

  for (ll i = 0; i < d; i++){
    for (ll j = 1; j < h*w/d + 1; j++){
      P p = m[i + d*(j-1)];
      P q = m[i + d*j];
      accsum[i][j] = accsum[i][j-1] + abs(p.first - q.first) + abs(p.second - q.second);
    }
  }
  

  ll q;
  cin >> q;
  for (ll i = 0; i < q; i++){
    ll l, r;
    cin >> l >> r;
    
    cout << accsum[l % d][r / d] - accsum[l%d][l/d] << endl;
  }

  return 0;
}


Measured memory_bytes: 19312
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
PII p[1000010];
vector<PII> up,down;
int n;
string s;
void solve()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        int res=0,tmp=0;
        for(char ch:s)
        {
            if(ch=='(')res++;
            if(ch==')')res--;
        }
        if(res>=0)
        {
            res=0;
            for(int i=0;i<s.size();i++)
            {
                if(s[i]=='(')res++;
                if(s[i]==')')res--;
                tmp=min(tmp,res);
            }
            up.pb({tmp,res});
        }
        if(res<0)
        {
            res=0;
            for(int i=s.size()-1;i>=0;i--)
            {
                if(s[i]=='(')res--;
                if(s[i]==')')res++;
                tmp=min(tmp,res);
            }
            down.pb({tmp,res});
        }
    }
    sort(all(up),greater<PII>());
    sort(all(down),greater<PII>());
    int res_up=0,res_down=0;
    for(PII it:up)
    {
        if(res_up+it.fi<0)
        {
            cout<<"No";
            return;
        }
        res_up+=it.se;
    }
    for(PII it:down)
    {
        if(res_down+it.fi<0)
        {
            cout<<"No";
            return;
        }
        res_down+=it.se;
    }
    if(res_up==res_down)cout<<"Yes";
    else cout<<"No";
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
    solve();
    return 0;
}

Measured memory_bytes: 19080
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (a - b >= 0)cout << "delicious" << endl;
	else if (a - b + x >= 0)cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,i;
    cin>>n>>i;
    cout<<n-i+1<<endl;
}

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

namespace ConsoleApp15
{
    class Class312
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double rsum = 0;
            for(int i = 0; i < n; i++)
            {
                rsum += 1 / A[i];
            }
            double ans = 1 / rsum;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long


/// 9 50

int p[200010];
int inf=1e9;

int main()
{
        ios_base::sync_with_stdio(false);
            cin.tie(NULL);

           int n,k,inv=0,res=0;
           set<int> s;

           cin>>n>>k;
           for(int i=0;i<n;i++){
            cin>>p[i];
            if(i<k) s.insert( p[i] );
           }
           p[n]=-1;
           for(int i=0;i<k-1;i++){
            if( p[i] > p[i+1] ) inv++;
           }
          // if( inv==0 ) res--;
           int l=0,r=k-1;
           bool sorted=false;
           while(true){
             //   cout << l << " " << r << " " << inv << " pp " <<endl;
                if( r>=n ) break;
                if( inv == 0 ){
              //      cout << l << " " <<r << " hhee " <<endl;
                    sorted=true;
                    s.insert( p[r+1] );
                    s.erase( p[l] );
                    if( p[l+1]<p[l] ) inv--;
                    if( p[r+1]<p[r] ) inv++;
                    l++;
                    r++;
                    continue;
                }
                s.insert( p[r+1] );
                int a = *( s.begin() );
                int b = *prev( s.end() );
                if( p[l]!=a || p[r+1]!=b ){
           //         cout << l << " " <<r << " " << p[l] << " " <<a  << " a a "<<endl;
                   res++;  /// ako naletimo na novi segment, povecaj sve i idemo dalje. problem: kad je taj sljedeci segment sortiran, pa ga ne treba brojati. smisliti rjesenje i za to
                }
                s.erase( p[l] );
                    if( p[l+1]<p[l] ) inv--;
                    if( p[r+1]<p[r] ) inv++;
                l++,r++;
           }
        //   cout<<sorted << " waa "<<endl;
            if(sorted)res++;
            cout<<res<<endl;

            return 0;
}































Measured memory_bytes: 10368
# ??????????????????
def bubble_sort(ary, len)
  swp = 0
  (0...len-1).each {|n|
    (0...len-1-n).each{|j|
      if ary[j+1].to_i < ary[j].to_i
        ary[j], ary[j+1] = ary[j+1], ary[j] # swap????????????
        swp += 1
      end
    }
  }
  return ary, swp
end

# main
len = gets.to_i
ary = gets.split(' ') # ????§????????????????????????§???????????°?????????
sorted_ary, swp = bubble_sort(ary, len)
puts sorted_ary.join(' ') # ????§????????????????????????§??????
puts swp

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int X;

int main(void){
    
    scanf("%d", &X);
    int ans = 1;
    for(int i = 2; i <= X; ++i){
        int num = i;
        while(num <= X){
            num *= i;
            if(num <= X) ans = max(ans, num);
        }
    }
    printf("%d\n", ans);
    
    return 0;
}

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

int main(){
    long long k;
    cin>>k;
    if(k%2==0 || k%5==0){
        cout<<-1<<endl;
        return 0;
    }
    long long a=7%k;
    for(int i=1;i<=k;i++){
        if(a==0) {
            cout<<i<<endl;
            return 0;
        }
        a=(a*10+7)%k;
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3636
def knapsack(items, budget)
	table = (0..1).map{ Array.new(budget+1, 0) }
	for i in 0..items.size-1
		c, v = items[i]
		for j in 0..budget
			x = table[0][j]
			y = (j >= c ? table[0][j-c] + v : 0)
			table[1][j] = x > y ? x : y
		end
		table << table.shift
	end
	table[0][-1]
end

loop {
	n = gets.to_i
	break if n == 0
	a = gets.split.map &:to_i
	sum = a.inject(:+)
	p sum - 2 * knapsack(a.zip(a), sum/2)
}

Measured memory_bytes: 9124