akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

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

    sort(a.begin(),a.end());

    ll diameter = a.back();
    a.push_back(INF);
    bool odd = (bool)(diameter&1);
    ll radius = diameter/2 + (odd ? 1 : 0 );

    bool first = true;

    if(a[0] != radius){
        cout << "Impossible" << endl;
        return 0;
    }
    int prev = radius - 1;
    for(int i = 0; i < n; i++){
        int count = 0;
        while(a[i] == a[i+1]){
            count++;
            i++;
        }
        if(first){
            first = false;
            
            if(odd){
                if(count > 1){
                    cout << "Impossible" << endl;
                    return 0;
                }
            }else{
                if(count > 0){
                    cout << "Impossible" << endl;
                    return 0;
                }
            }
        }else{
            if(count < 1){
                cout << "Impossible" << endl;
                return 0;
            }
        }
        if(prev+1 != a[i]){
            cout << "Impossible" << endl;
            return 0;
        }
        prev = a[i];
    }

    cout << "Possible" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        Console.WriteLine(string.Join("\n", Enumerable.Range(0, n).Select(x => new Tuple<int, string[]>(x + 1, Console.ReadLine().Split())).OrderBy(x => x.Item2[0]).ThenByDescending(x => int.Parse(x.Item2[1])).Select(x => x.Item1)));
    }
}


Measured memory_bytes: 13792
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
   int a,b,d,r;
   double f;
   cin>>a>>b;
  d=a/b;
  r=a%b;
  f=double(a)/double(b);
    cout<<fixed<<setprecision(5)<<d<<" "<<r<<" "<<f<<endl;
    return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,s.size()/2) if(s[i]!=s[s.size()-1-i]) ans++;
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
int n;
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	cout << n*(n+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fi(i,a,b) for(lli i=a;i<b;i++)
#define pb push_back
#define mp make_pair

int main() {
// 	cout<<"GfG!";
    lli t=1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int x=ceil((double)n/(double)2);
        double y=(double)x/(double)n;
        cout<<setprecision(10)<<y;
        
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>

using namespace std;

int main(){
	int n;
	int a[50];
	int cnt=0;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i] != i+1)cnt++;
	}
	if(cnt > 2)cout << "NO" << endl;
	else cout << "YES" << endl;
	
	return 0;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int n, a[200000], r[200001];

int main(){
	cin >> n;
	r[0] = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		r[i+1] = r[i]+a[i];
	}
	
	sort(r, r+n+1);
	
	Int ans = 0, cnt = 0;
	for(int i = 1; i < n+1; i++){
		if(r[i] == r[i-1]) cnt++;
		else{
			for(int i = 1; i <= cnt; i++){
				ans += i;
			}
			cnt = 0;
		}
	}
	for(int i = 1; i <= cnt; i++){
		ans += i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll Q, H, S, D, N;
vector<pair<ll, double> > v1, v2;
typedef pair<ll, double> P;

void solve() {
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    ll ans;
    if (N % 2 == 0) {
        ans += N / 2 * v1[0].first;
    } else {
        ans += (N - 1) / 2 * v1[0].first;
        ans += v2[0].first;
    }
    cout << ans << endl;
}

int main() {
    cin >> Q >> H >> S >> D >> N;
    v1.emplace_back(P(Q * 8, 0.25));
    v1.emplace_back(P(H * 4, 0.5));
    v1.emplace_back(P(S * 2, 1));
    v1.emplace_back(P(D, 2));

    v2.emplace_back(P(Q * 4, 0.25));
    v2.emplace_back(P(H * 2, 0.5));
    v2.emplace_back(P(S * 1, 1));
    solve();
    return 0;
}

Measured memory_bytes: 256
i, o, _, j, l, _, _ = map(int, input().split())
if i >= 1 and j >= 1 and l >= 1:
    print((max(6 + ((i - 1) // 2 + (j - 1) // 2 + (l - 1) // 2) * 4, (i // 2 + j // 2 + l // 2) * 4) + 2 * o) // 2)
else:
    print((((i // 2 + j // 2 + l // 2) * 4) + 2 * o) // 2)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, m;
    cin >> n >> m;
    vector< vector<bool> > g(n, vector<bool>(n, false));
    int a, b;
    rep (i, m)
    {
        cin >> a >> b;
        --a; --b;
        g[a][b] = true;
        g[b][a] = true;
    }

    vs32 v(n);
    rep (i, n) v[i] = i;

    int ans = 0;
    do {
        bool ok = true;
        rep (i, n - 1)
        {
            a = v[i];
            b = v[i + 1];
            if (!g[a][b]) ok = false;
        }
        if (ok)
        {
            ++ans;
        }
    } while (next_permutation(v.begin() + 1, v.end()));

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

typedef struct{
	int x;
	int y;
} set;

int main (void)
{
	set data[3000];
	int i,j=0;

	for(i=0;i<3000;i++){
		scanf("%d %d", &data[i].x, &data[i].y);
		if(data[i].x==0 && data[i].y==0) break;
		j=j+1;
	}

	for(i=0;i<j;i++){
		if(data[i].x<data[i].y){
			printf("%d %d\n", data[i].x, data[i].y);
		} else {
			printf("%d %d\n", data[i].y, data[i].x);
		}
	}

	return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int L,R;

int main(){
  cin >> L >> R;
  ll ans = 2018;
  if(R-L>=2019){
    cout<< 0 <<endl;
    return 0;
  }
  for(ll i=L;i<R;i++){
    for(ll j=i+1;j<=R;j++){
      ans = min(ans,(i*j)%2019);
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int N = 1e5+10;
const ll INF = 1e15;

using namespace std;

vector<pair<int,ll>> Graph[N];
vector<ll> d;

void dijkstra (int k, int n)
{
    d.assign(n+1,INF);
    d[k]=0;
    set<int> q;
    q.insert(k);
    while (!q.empty())
    {
        int v=*q.begin();
        q.erase(q.begin());
        for (auto e: Graph[v])
        {
            int to=e.ff;
            ll len=e.ss;
            if (d[to]>d[v]+len)
            {
                d[to]=d[v]+len;
                q.insert(to);
            }
        }
    }
}

main()
{
    fast;
    int n,a,b,q,k,i;
    ll c;
    cin>>n;
    for (i=0;i<n-1;i++)
    {
        cin>>a>>b>>c;
        Graph[a].pb(mp(b,c));
        Graph[b].pb(mp(a,c));
    }
    cin>>q>>k;
    dijkstra(k,n);
    int x,y;
    while (q--)
    {
        cin>>x>>y;
        cout<<d[x]+d[y]<<endl;
    }
}

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

long long mod = 1000000007LL;

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, k; cin >> n >> k;
	long long arr[n];
	for(int i = 0;i < n;i++){
		cin >> arr[i];
	}
	
	sort(arr,arr+n);
	
	long long ans = 0;
	for(int i = 0;i < n - k;i++){
		ans += arr[i];
	}
	cout << ans;
}


Measured memory_bytes: 1792
n = int(input())
*l, = map(int,input().split())
def calc(l,even):
  ans = 0
  l1 = l[:]
  s = 0
  for i in range(n):
    s += l1[i] 
    if i%2 == even and s<=0: 
      ans += -s+1 
      s = 1
    elif i%2 != even and s>=0: 
      ans += s+1
      s = -1
  return ans
print(min([calc(l,0),calc(l,1)]))

Measured memory_bytes: 14332
import itertools as it
N, M, X = map(int, input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]
# print(f'book={book}')
combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
    # print(comb)
    bag = [0] * (M + 1)
    for i in range(N):
        if comb[i] == 0:
            continue
        else:
            for j in range(M + 1):
                bag[j] += book[i][j]
    # print(f'bag={bag}')
    if min(bag[1:]) < X:
        continue
    else:
        prices.append(bag[0])
if len(prices) == 0:
    print(-1)
else:
    print(min(prices))


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B,C,D=0,E=0,F=INF,N,M;
    cin >> N >> A >> B;
    C=max(A,B);
    D=min(A,B);
    A=C+N;
    B=D+N;
    if(C<=B)Out(0);
    else Out(C-B);
}
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define PB push_back
#define fst first
#define sec second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ms(a,x) memset(a,x,sizeof(a))
typedef long long LL;
#define pi pair < int ,int >
#define MP make_pair

using namespace std;
const double eps = 1E-8;
const int dx4[4]={1,0,0,-1};
const int dy4[4]={0,-1,1,0};
const int inf = 0x3f3f3f3f;
const int N=1E4+7;

int n,k;

struct node
{
	int x,y;
}d_pos[N];

pair<int,int>a[123456];

int main()
{
	LL ans=-1;
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>d_pos[i].x>>d_pos[i].y;
	}
	int nn=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			a[nn++]=make_pair(d_pos[i].x,d_pos[j].y);
		}
	}

	for (int i=1;i<=nn;i++)
	{
		for (int j=1;j<=nn;j++)
		{
			if (j!=i)
			{
				int res=0;
				int mi_x=min(a[i].first,a[j].first);
				int ma_x=max(a[i].first,a[j].first);
				int mi_y=min(a[i].second,a[j].second);
				int ma_y=max(a[i].second,a[j].second);
				for (int k=1;k<=n;k++)
				{
					int t_x=d_pos[k].x,t_y=d_pos[k].y;
					if (mi_x<=t_x&&t_x<=ma_x&&mi_y<=t_y&&t_y<=ma_y) res++;
				}
				if (res>=k)
				{
					LL fuck=1LL*(ma_x-mi_x)*(ma_y-mi_y);
					//ans=min(ans,fuck);
					if (ans==-1) ans=fuck;
					else ans=min(ans,fuck);
				}
			}
		}
	}
	//cout<<ans<<endl;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
    string S;
    cin >> S;

    set<char> st;
    for (int i = 0; i < S.length(); i++) {
        st.insert(S.at(i));
    }

    if (S.length() == st.size()) {
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353


def resolve():
    n = int(input())
    A = []
    for _ in range(n):
        a = float(input())
        a = round(a * 10 ** 9 + 0.1)
        A.append(a)

    L = [[0] * 25 for _ in range(45)]
    D = []
    for a in A:
        tmp = a
        ex2 = ex5 = 0
        while tmp % 2 == 0:
            tmp //= 2
            ex2 += 1
        tmp = a
        while tmp % 5 == 0:
            tmp //= 5
            ex5 += 1
        L[ex2][ex5] += 1
        D.append((ex2, ex5))

    res = 0
    check = [[False] * 25 for _ in range(45)]
    for i in range(45):
        for j in range(25):
            if L[i][j] == 0:
                check[i][j] = True
                continue
            for k in range(18 - i, 45):
                for l in range(18 - j, 25):
                    if check[k][l]:
                        continue
                    if k == i and l == j:
                        res += L[i][j] * (L[k][l] - 1) // 2
                    else:
                        res += L[i][j] * L[k][l]
            check[i][j] = True
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 95404
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def LCM(a, b):
    return a * b // math.gcd(a, b)


def main():
    N, M = in_nn()
    a = in_nl()

    lcm = 1
    for i in range(N):
        lcm = LCM(lcm, a[i])
        if lcm > M * 2:
            print(0)
            exit()

    for i in range(N):
        if lcm // a[i] % 2 == 0:
            print(0)
            exit()

    lcm = lcm // 2
    q = M // lcm
    if q % 2 == 0:
        ans = q // 2
    else:
        ans = q // 2 + 1

    print(ans)


if __name__ == '__main__':
    main()


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



int main() {
  int A,B; cin >> A >> B;
  int ans = (A-1) * (B-1);
  cout << ans << endl;




  return 0;
}


Measured memory_bytes: 3420
import math

N = int(input())
a_li = list(map(int, input().split()))
mid_1 = math.ceil(sum(a_li) / N)
mid_2 = sum(a_li) // N
ans_1 = 0
ans_2 = 0
for a in a_li:
    ans_1 += (a - mid_1) ** 2
for a in a_li:
    ans_2 += (a - mid_2) ** 2
print(min(ans_1, ans_2))


Measured memory_bytes: 61924
#include <bits/stdc++.h>
using namespace std;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll H, W, N; cin >> H >> W >> N;
    map<pair<int, int>, ll> mp;

    for(int l=0; l<N; l++){
        int a, b; cin >> a >> b;
        for(int i=0; i<3; i++) for(int j=0; j<3; j++){
            if(a-i <= 0 || b-j <= 0 || H-1 <= a-i || W-1 <= b-j) continue;

            mp[{a-i, b-j}]++;
        }
    }

    vector<ll> ans(10, 0);
    ans[0] = (H-2)*(W-2);
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        ans[itr->second]++;
        ans[0]--;
    }

    for(int i=0; i<10; i++) cout << ans[i] << endl;

}

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

double solve(vector<vector<double>> &dp, vector<double> &p, int i, int h){
        if(h < 0){
        return 0;
    }
    if(i<h){
        return 0;
    }

    if(i==0){
        return 1;
    }
    if(dp[i][h] != -1){
        return dp[i][h];
    }
    dp[i][h] = p[i]*solve(dp, p, i-1, h-1) + (1-p[i])*solve(dp, p, i-1, h);
    // cout<<temp<<endl;
    return dp[i][h];
}

int main(){
    int n;
    cin>>n;
    vector<double> p(n+1, 0.0);
    for(int i = 1; i <= n;++i){
        scanf("%lf", &p[i]);
    }
    double ans = 0;
    vector<vector<double>> dp(n+1, vector<double> (n+1, -1));
    // solve(p, n, n/2 + 1);
    for(int i = n/2+1; i <= n; ++i){
        // cout<<solve(p, n, i)<<endl;
        ans += solve(dp, p, n, i);
    }
    printf("%0.10lf", ans);
    return 0;
}


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

#include <cstdio>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

void solve(long long N, long long M) {
    vector<pair<int, int>> ans;
    if (N % 2 == 1) {
        for (int l = 1, r = N - 1; l < r; l++, r--) {
            ans.emplace_back(l, r);
        }
    } else {
        bool flag = false;
        for (int l = 1, r = N - 1; l < r; l++, r--) {
            if (!flag && r - l <= N / 2) {
                r--;
                flag = true;
            }
            ans.emplace_back(l, r);
        }
    }
    rep(i, M) { printf("%d %d\n", ans[i].first, ans[i].second); }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b;
    Scd2(a,b);

    int tmp = b;
    while( b ){
        a *= 10;
        b /= 10;
    }
    a += tmp;

    bool ans = 0;
    Repe(i,1000,1){
        if( i*i == a ){
            ans++;
            break;
        }
    }
    YesNo(ans);

    return 0;
}



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

int main() {
    int x;
    cin >> x;
    unsigned long long por = 1;
    vector<unsigned long long> ans;
    for(int i = 1; i <= 100; i++) {
        for(int k = 2; k <= 10; k++) {
            ans.push_back(pow(i,k));
        }
    }
    for(int i = 0; i < ans.size(); i++) {
        //cerr << "VI " << ans[i] << endl;
        if (ans[i] <= x)
            por = max(por,ans[i]);
    }
    cout << por << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define zeros(x) ((x) & (-x))
#define inf 1e18

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, a, b, Lvl[100005], Depth[100005], TT[100005];
vector<ll> V[100005];

ll DFS(ll x, ll lvl=1, ll last=-1)
{
    ll maxim = lvl;
    TT[x] = last;
    for (auto i : V[x])
    {
        if (i == last) continue;
        maxim = max(maxim, DFS(i, lvl+1, x));
    }

    Lvl[x] = lvl;
    Depth[x] = maxim;
    return maxim;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>a>>b;
    for (ll i=1; i<n; i++)
    {
        ll x, y;
        cin>>x>>y;
        V[x].push_back(y);
        V[y].push_back(x);
    }

    DFS(b);
    ll target = Lvl[a]/2 + 1 + Lvl[a]%2;

    for (ll i=Lvl[a]; i>target; i--)
        a = TT[a];
    cout<<Depth[a] - 2;
    return 0;
}

Measured memory_bytes: 14720
#include <iostream>
#include <string>
#include <vector>

#define llint long long int

llint gcd(llint a, llint b){
  if(a>b) std::swap(a, b);

  if(b%a == 0) return a;
  else return gcd(a, b%a);
}
llint lcm(llint a, llint b){return a*b/gcd(a,b);}

llint count(llint st, llint ed, llint d){
  llint a = (ed/d) - (st/d);
  llint b = (st%d) ? 0 : 1;
  return a+b;
}

int main(void){

  llint a, b, c, d;
  std::cin >> a >> b >> c >> d;

  llint ret = b-a+1;
  ret = ret - count(a, b, c) - count(a, b, d) + count(a, b, lcm(c,d));

  std::cout << ret << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int x=0;
	int n;
	cin>>n;
	char s[n];
	int ans=-100;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,x);
		cin>>s[i];
		if(s[i]=='I')
		x++;
		else
		x--;
		ans=max(ans,x);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000007
using namespace std;

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


int main() {

	int n, m,x;
	int c = 0;
	
	cin >> n >> m >> x;
	int sum = m;

	for (int i = 0; i < m; i++) {
		int a = 0;
		cin >> a;
		if (x < a) {
			break; 
		}
		else { c += 1; }
	}

	cout << min(c, m-c) << endl;
	
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n, m;
    cin >> n >> m;
    int A[n];
    int sum=0;
 
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        sum += A[i]; // 総投票数   
    }
    
    int cnt=0;
    rep(i, n) {
        if (A[i] < double(sum)/4.0/double(m)) continue;
        else cnt++;
    }
    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define rsort(a) sort(all(a)); reverse(all(a))
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
void maxi(int &a, int b) {if(a<b) a = b;}
void mini(int &a, int b) {if(a>b) a = b;}
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
const int MOD = 1e9+7;
//ll fact[N];






void solve()
{
    int n;
    cin>>n;
    vi a(n), b(n);
    cin>>a;
    cin>>b;
    reverse(all(b));

    int c = -1;

    rep(i,n) {
        if(a[i] == b[i]) {
            c = a[i];
            break;
        }
    }


    int l = 0, r = -1;

    rep(i,n) {
        if(a[i] == c && b[i] == c) {
            l = i;
            break;
        }
    }

    rrep(i,n) {
        if(a[i] == c && b[i] == c) {
            r = i;
            break;
        }
    }

    rep(i,n) {
        if(a[i]!=c && b[i]!=c && l<=r) {
            swap(b[i],b[l]);
            l++;
        }
    }

    if(l<=r) {
        cout<<"No";
    }
    else {
        cout<<"Yes\n";
        cout<<b;
    }
}

int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}








ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}
/*
ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

int dp[105][100005];
int v[105], w[105];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int N, W;
   cin >> N >> W;

   rep(i, 0, N) { cin >> v[i] >> w[i]; }

   rep(i, 0, N) rep(j, 0, W + 1) {
      if (j >= w[i]) {
         dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      } else {
         dp[i + 1][j] = dp[i][j];
      }
   }
   cout << dp[N][W] << endl;
   return 0;
}


Measured memory_bytes: 7480
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()

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

    int a, b;
    cin >> a >> b;
    cout << max(max(a + b, a - b), a * b) << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define PI			3.14159265
#define OO			1e9
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
//#define endl		"\n"
#define all(v) ((v).begin()), ((v).end())
#define boom main
#define cn(n)  scanf("%d", &n)
#define cnl(n)  scanf("%lld", &n)
#define F(i, a, b) for(int i=a; i<=b; i++)
#define rep(i, n) for(int i=0; i<n; i++)
#define Fill(ar, val) memset(ar, val, sizeof(ar))
#define bit(n) (1<<(n))

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

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main()
{
	fast();
	int a, b, T;
	cin >> a >> b >> T;
	int ans = 0;
	int tm = 0;
	while (tm + a <= T)
		ans += b, tm += a;

	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll d[n][2];
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<2;j++)
		cin>>d[i][j];
	}
	ll f=0;
	for(ll i=0;i<n-2;i++)
	{
		if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1])
		{
		f=1;
		break;
		}
	}
	if(f)
	cout<<"Yes"<<"\n";
	else
	cout<<"No"<<"\n";
	

	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define sc scanf
using namespace std;
const int N=3e5+5;
typedef unsigned long long ull;
typedef long long ll;
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll w,h,x,y;
int main(){
    cin>>w>>h>>x>>y;
    double ans=0;
    //if(x*h==w*y||(w-x)*h==w*y||x==0&&y==0||x==w&&y==0||x==0&&y==h||x==w&&y==h){
        int d=0;
        if(2ll*x==w&&2ll*y==h)d=1;
        printf("%.9lf %d\n",h*w*1.0/2,d);
        return 0;
   // }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    ll dp[n+2][k+2];
    memset(dp,0,sizeof(dp));
    for(ll j=0;j<=k;j++)
    {
        if(j<=a[1])
        dp[1][j]=1;
        else
            dp[1][j]=0;
    }
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<=k;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                if((j-1-a[i])>=0)
                    dp[i][j]=(mod+((dp[i][j-1]+dp[i-1][j])%mod)-dp[i-1][j-1-a[i]])%mod;
                else
                    dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
            }
        }
    }
    cout<<dp[n][k]<<endl;
    return 0;
}


Measured memory_bytes: 83040
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn = 5e3 + 10;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl
int a[maxn],b[maxn];
ll dp[maxn],dp2[maxn];
int main() {
    //freopen(".in", "r", stdin);
    int n,k;
    int cnt=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]<k) b[++cnt]=a[i];
    }
    dp[0]=1;
    dp2[0]=1;
    for(int i=1;i<=cnt;i++)
    {
        for(int j=k;j>=b[i];j--)
        {
            dp[j]=(dp[j]+dp[j-b[i]])%19260817;
            dp2[j]=(dp2[j]+dp2[j-b[i]])%111111111;
        }
    }
    int ans=0;
    for(int i=1;i<=cnt;i++)
    {
        bool flag=false;
        for(int j=b[i];j<=k;j++) dp[j]=(dp[j]-dp[j-b[i]]+19260817)%19260817;
        for(int j=b[i];j<=k;j++) dp2[j]=(dp2[j]-dp2[j-b[i]]+111111111)%111111111;
        for(int j=k-b[i];j<=k-1;j++) if(dp[j]!=0&&dp2[j]!=0) flag=true;
        for(int j=k;j>=b[i];j--) dp[j]=(dp[j]+dp[j-b[i]])%19260817;
        for(int j=k;j>=b[i];j--) dp2[j]=(dp2[j]+dp2[j-b[i]])%111111111;
        if(flag==false) ans++;
    }
    printf("%d\n",ans);
    return 0;
}




Measured memory_bytes: 384
K = int(input())
x, y = map(int, input().split())

nowx, nowy = 0, 0
ans = []

def ok():
    global ans, x, y
    ans.append((x, y))
    print(len(ans))
    for (x, y) in ans:
        print(x,y)
    exit(0)
        


while(abs(nowx - x) + abs(nowy - y) >= 2*K):
    if x - nowx >= K:
        nowx += K
    elif nowx - x >= K:
        nowx -= K
    elif y - nowy >= K:
        nowy += K
    else:
        nowy -= K
    ans.append((nowx, nowy))

if (abs(nowx - x) + abs(nowy - y)) % 2 == 1 and K % 2 == 0:
    print(-1)
    exit(0)

    
if (abs(nowx - x) + abs(nowy - y)) == K:ok()
    
if (abs(nowx - x) + abs(nowy - y)) % 2 == 1:
    if abs(nowx+K - x) + abs(nowy - y) < 2*K:nowx += K
    elif abs(nowx-K - x) + abs(nowy - y) < 2*K:nowx -= K
    elif abs(nowx - x) + abs(nowy+K - y) < 2*K:nowy += K
    elif abs(nowx - x) + abs(nowy-K - y) < 2*K:nowy -= K
    ans.append((nowx, nowy))
    
if (abs(nowx - x) + abs(nowy - y)) == K:ok()

rest = K*2 - (abs(nowx-x) + abs(nowy-y))
rest //= 2
xgo, ygo = 1, 1

if nowx != x:
    xgo = (x - nowx) // abs(nowx - x)
if nowy != y:
    ygo = (y - nowy) // abs(nowy - y)

if abs(nowx-x) >= abs(nowy-y):
    nowx += xgo * (K - rest)
    nowy -= ygo * rest
    ans.append((nowx, nowy))
    
else:
    nowy += ygo * (K - rest)
    nowx -= xgo * rest
    ans.append((nowx, nowy))

ok()

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

#define   REP(i, n) for(int i = 0;            i <  (int)(n); i++)
#define  CREP(i, n) for(int i = 1;            i <= (int)(n); i++)
#define  RREP(i, n) for(int i = (int)(n) - 1; i >= 0;        i++)
#define RCREP(i, n) for(int i = (int)(n);     i >  0;        i++)

#define INF std::numeric_limits<int>::max()
#define N_MAX 8

using ll = long long;

int N;
int A, B, C;
int takes[N_MAX];

int dfs(int cnt, int a, int b, int c) {
    if(cnt == N) {
        if(std::min({a, b, c}) > 0) {
            return std::abs(a - A) + std::abs(b - B) + std::abs(c - C) - 30;
        }
        else {
            return INF - 10;
        }
    }

    int ret0 = dfs(cnt + 1, a, b, c);
    int ret1 = dfs(cnt + 1, a + takes[cnt], b, c) + 10;
    int ret2 = dfs(cnt + 1, a, b + takes[cnt], c) + 10;
    int ret3 = dfs(cnt + 1, a, b, c + takes[cnt]) + 10;
    return std::min({ret0, ret1, ret2, ret3});
}

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

    std::cin >> N >> A >> B >> C;
    REP(i, N) {
        std::cin >> takes[i];
    }

    std::cout << dfs(0, 0, 0, 0) << std::endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin()  ;v.end()
#define endl "\n"

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}
int main(){
    fast();
    int n;cin>>n;
    map<ll,ll>freq;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        freq[(i+1)-arr[i]]++;
    }
    ll cnt=0;
    for(int i=0;i<n;i++){
        cnt+=freq[arr[i]+i+1];
    }
    cout<<cnt;
}

Measured memory_bytes: 27924
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int b[] = new int[m];
		for(int i = 0; i < m; i++){
			b[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < n; i++){
			int tmp = c;
			for(int j = 0; j < m; j++){
				int s = sc.nextInt();
				tmp += s*b[j];
			}
			if(tmp > 0)ans++;
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int check(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a[i]>b[i])return 1;
        if(b[i]>a[i])return -1;
    }
    return 0;
}
class data{
public:
    ll v,d,p;
    data(){}
    data(ll vv, ll dd, ll pp){
        v=vv;  d=dd; p=pp;
    }
};

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}

int main()
{
    Fastio();
    int n; cin>>n;
    ll a[n],b[n],c[n];
    ll dp[n+1][5];
    memset(dp,0,sizeof(dp));
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=n-1; i>=0; i--){
        for(int y=0; y<3; y++){
            ll res1,res2,res0;
            res0=res1=res2=-1e9;
            res0=dp[i+1][0]+a[i];
            res1=dp[i+1][1]+b[i];
            res2=dp[i+1][2]+c[i];
            if(y==0){
                dp[i][y]=max(res1,res2);
            }
            if(y==1){
                dp[i][y]=max(res0,res2);
            }
            if(y==2){
                dp[i][y]=max(res0,res1);
            }
        }
    }
    cout<<max(dp[0][0],max(dp[0][1],dp[0][2]))<<'\n';


    return 0;
}


Measured memory_bytes: 6528
n = int(input())
s = str(input())
l = []
left, right = 0, 0
for c in s:
    if c == ')':
        if l == []:
            left += 1
        else:
            l.pop()
    else:
        l.append(1)
right = len(l)
print('(' * left + s + ')' * right)

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

using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end());
	int m;
	cin >> m;
	vector<ll> b(m), c(m);
	for(int i = 0; i < m; ++i){ cin >> b[i]; }
	for(int i = 0; i < m; ++i){ cin >> c[i]; }
	vector<ll> integral(n + 1);
	for(int i = 0; i < n; ++i){
		integral[i + 1] = integral[i] + a[i];
	}
	for(int i = 0; i < m; ++i){
		const int p = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
		if(integral[p] >= c[i]){
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}
	}
	return 0;
}

Measured memory_bytes: 10176
/*
g++ -std=c++11 -o2 -Wall ABC093D.cpp -o ./out/ABC093D.out
./out/ABC093D.out
*/

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

typedef long long ll;

int q;
ll a, b;

int main(){
//    freopen("./input/input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> q;
    for (int i = 0; i < q; ++i) {
      cin >> a >> b;
      if (a > b) {
        swap(a, b);
      }
      auto check = [&](int _mid)->bool{
        for (int j = _mid/2-2; j <= _mid/2+2; ++j) {
          if (j < 0 || b-a < j) continue;
          if ((a+j)*(a+_mid-j) >= a*b) return false;
        }
        return true;
      };
      ll mid;
      ll lb, ub;
      lb = 0;
      ub = b-a+1;
      while (ub-lb > 1) {
        mid = (lb+ub)/2;
        if (check(mid)) {
          lb = mid;
        } else {
          ub = mid;
        }
      }
      cout << a*2-2+lb << "\n";
//      cout << a << " " << lb << "\n";
    }
}


Measured memory_bytes: 384
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w;
    cin>>n>>w;
    int wi[n+1];
    ll val[n+1];
    for(int i=1;i<=n;++i)
    cin>>wi[i]>>val[i];

    ll dp[n+1][w+1];
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=w;++j)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(j-wi[i]>=0)
            dp[i][j]=max(dp[i-1][j-wi[i]]+val[i],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    return 0;
}

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

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

  int n; cin >> n;
  int low = 1, high = n;

  ll res = 0;
  while (low <= high) {
    ll mid = low + (high - low) / 2;

    ll pow = mid * mid;

    if (pow <= n) {
      res = max(res, pow);
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }

  cout << res << "\n";
}


Measured memory_bytes: 3672
unittest
{
	assert( [ "2", "1 2 1 2 2 1" ].solve == 2 );
	assert( [ "3", "1 1 2 2 3 3 3 2 1" ].solve == 1 );
	assert( [ "3", "1 1 2 2 2 3 3 3 1" ].solve == 3 );
}



import std.algorithm;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	as[] -= 1;
	
	// インラインDP
	// dp[ (iターン目) ][ 残したカード1枚目の数字 ][ 残したカード2枚目の数字 ] = 最大得点
	auto dp = new long[][]( n, n );
	foreach( ref dpp; dp ) dpp[] = long.min;					// -2000未満にしておけば絶対0以上にならないので無視できる
	auto z = 0L;												// 全体加算値
	auto mm = 0L;												// 全体最大値
	auto ms = new long[ n ];									// 部分最大値
	ms[] = long.min;
	auto queue = DList!( Tuple!( long, long, long ) )();		// 更新キュー
	
	// 最初のカード2枚を処理
	dp[ as[ 0 ] ][ as[ 1 ] ] = 0;
	dp[ as[ 1 ] ][ as[ 0 ] ] = 0;
	ms[ as[ 0 ] ] = 0;
	ms[ as[ 1 ] ] = 0;
	as.popFrontN( 2 );
	
	// 途中のカードを3枚ずつ処理
	foreach( i; 0L .. n - 1 )
	{
		if( as[ 0 ] == as[ 1 ] && as[ 1 ] == as[ 2 ] )
		{
			// 次の3枚が全て同値の場合
			// 全てのx,yについて dp[ i+1 ][ x ][ y ] = dp[ i ][ x ][ y ] +1 が最適になるので、全体加算値に+1する
			z++;
		}
		else
		{
			foreach( j; 0 .. 3 )
			{
				auto a = as[ j ];
				auto b = as[ 0 + ( j <= 0 ) ];
				auto c = as[ 1 + ( j <= 1 ) ];
				
				// 前ターンのx,yを両方を残す場合
				// dp[ i+1 ][ x ][ y ] = dp[ i ][ x ][ y ] になるので、処理不要
				
				// 前ターンのx,yの片方を残す場合
				// dp[ i+1 ][ x ][ a or b or c ] = dp[ i ][ x ][ ? ].reduce!max になるので、部分最大値を使って更新する
				// また、捨て札y,b,cが全て同値の場合は+1する
				foreach( x; 0L .. n )
				{
					auto v = ms[ x ];
					if( b == c ) v = max( v, dp[ x ][ b ] + 1 );
					queue.insertBack( tuple( x, a, v ) );
				}
				
				// 前ターンのx,yのどちらも残さない場合
				// dp[ i + 1 ][ a or b or c ][ a or b or c ] = dp[ i + 1 ][ ? ][ ? ].reduce!max になるので、全体最大値を使って更新する
				// また、捨て札x,y,c or x,y,bが全て同値の場合は+1する
				queue.insertBack( tuple( a, b, max( mm, dp[ c ][ c ] + 1 ) ) );
				queue.insertBack( tuple( a, c, max( mm, dp[ b ][ b ] + 1 ) ) );
			}
		}
		
		// DPテーブルと最大値を更新
		while( !queue.empty )
		{
			auto x = queue.front[ 0 ];
			auto y = queue.front[ 1 ];
			auto v = queue.front[ 2 ];
			queue.removeFront;
			
			dp[ x ][ y ] = max( dp[ x ][ y ], v );
			dp[ y ][ x ] = max( dp[ y ][ x ], v );
			ms[ x ] = max( ms[ x ], v );
			ms[ y ] = max( ms[ y ], v );
			mm = max( mm, v );
		}
		as.popFrontN( 3 );
	}
	
	// 最後のカード1枚を処理
	return max( mm, dp[ as[ 0 ] ][ as[ 0 ] ] + 1 ) + z;
}


Measured memory_bytes: 36152
program main
  implicit none
  integer(8) i,kill,N
  integer(8),allocatable :: A(:),B(:)
  read(*, *) N
  allocate(A(N+1))
  allocate(B(N))
  read(*, *) (A(i), i = 1,N+1)
  read(*, *) (B(i), i = 1,N)
  kill = 0
  do i = 1,N
    if (A(i) < B(i)) then
      kill = kill + A(i)
      kill = kill + min(A(i+1),B(i)-A(i))
      A(i+1) = A(i+1)-min(A(i+1),B(i)-A(i))
    else
      kill = kill + B(i)
    end if
  end do      
  write(*, *) kill
end program main


Measured memory_bytes: 2304
#include<stdio.h>
int main()
{
    int a,b,i,r;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        r=a+b;
        for(i=0;r!=0;i++)
            r/=10;
        printf("%d\n",i);
    }
    return 0;
}

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

int N, K;
int a[102];
int dp[100002];

int rec(int k){
    if(dp[k] != -1) return dp[k];

    int can_win = 0;
    for(int n=0;n<N;n++){
        if(a[n] <= k){
            if(!rec(k - a[n])) can_win = 1;
        }
    }
    return dp[k] = can_win;
}

int main(){
    cin >> N >> K;
    for(int n=0;n<N;n++) cin >> a[n];
    for(int k=0;k<=K;k++) dp[k] = -1;
    dp[0] = 0;

    if(rec(K)){
        cout << "First" << "\n";
    }
    else{
        cout << "Second" << "\n";
    }

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    int ans = 10000;
    rep(i,0,N-2){
        string ss = S.substr(i,3);
        int v = atoi(ss.c_str());
        ans = min(ans, abs(753-v));
    }
    print(ans);

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, i, j, k, a, b, ans;
	cin >> n;
	vector<string> s(n + n);
	for (i = 0; i < n; i++) {
		cin >> s[i];
		s[i] = s[i] + s[i];
		s[i + n] = s[i];
	}

	ans = 0;
	for (i = 0; i < n; i++) {
		bool valid = true;
		vector<string> ss(n);
		for (j = 0; j < n; j++) ss[j] = s[j].substr(i, n);
		for (j = 0; j < n; j++) {
			for (k = 0; k < n; k++) {
				if (ss[j][k] != ss[k][j]) valid = false;
			}
		}

		if (valid) ans += n;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>

using namespace std;

bool fall(const string& S, const string& T, char left, char right, int start, int width){
    int l = 0, r = width + 1;
    for(int i=S.size()-1;i>=0;i--){
        if(r <= l+1) return true;
        if(T[i] == right) l = max(0, l-1);
        if(T[i] == left) r = min(width+1, r+1);
        if(S[i] == left) ++l;
        if(S[i] == right) --r;
    }
    return (start <= l || r <= start);
}

int main(){
    int H, W, N; cin >> H >> W >> N;
    int sr, sc; cin >> sr >> sc;
    string S, T; cin >> S >> T;
    cout << (fall(S, T, 'L', 'R', sc, W) || fall(S, T, 'U', 'D', sr, H) ? "NO": "YES") << endl;
}

Measured memory_bytes: 776