akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sum_up(x)  (x*(x+1))/2
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b

using namespace std;

void base()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/*
bool prime[100001];
void sieve(int n)
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int power(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

double float_sq(double n)
{
    double x = n;
    double y = 1;
    double e = 0.000001;
    while (x - y > e)
    {
        x = (x + y) / 2;
        y = n / x;
    }
    return x;
}

int int_sq(int x)
{
    if (x == 0 || x == 1)
        return x;
    int start = 1, end = x, ans;
    while (start <= end)
    {
        int mid = (start + end) / 2;
        if (mid*mid == x)
            return mid;
        if (mid*mid < x)
        {
            start = mid + 1;
            ans = mid;
        }
        else
            end = mid-1;
    }
    return ans;
}*/

int32_t main()
{
    base();
    int q;
    cin>>q;
    int arr[q];
    int Sort[q+1];
    for(int i=0;i<q;i++){
        cin>>arr[i];
        Sort[arr[i]-1]=i+1;
    }
    for(int i=0;i<q;i++){
        cout<<Sort[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 2432
from collections import deque
import numpy as np
import copy

def bfs(maze, sy, sx, H, W):
    queue = deque([[sy, sx]])
    visited = [[-1 for _ in range(W)] for _ in range(H)]
    visited[sy][sx] = 0
    di = [-1, 0, 1, 0]
    dj = [0, -1, 0, 1]
    while queue:
        y, x = queue.popleft()
        for dir in range(4):
            new_y, new_x = y+di[dir], x+dj[dir]
            if new_x >= W or new_y >= H:
                pass
            elif new_x < 0 or new_y < 0:
                pass
            elif maze[new_y][new_x] == "." and \
                visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    return visited

H, W = map(int, input().split())
MAZE = [input() for _ in range(H)]
ans = 0
tmp = 0
for i in range(H):
    for j in range(W):
        if MAZE[i][j] == "#":
            continue
        tmp = np.max(bfs(MAZE, i, j, H, W))
        ans = max(ans, tmp)
print(ans)

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

int main(int argc, char const *argv[])
{
	int N, K;
	cin >> N >> K;
	vector<int> nums(N);
	for(int i = 0; i < N; i++){
		cin >> nums[i];
	}
	
	sort(nums.begin() , nums.end());

	int res = 0;
	for(int i = N - K; i < N; i++){
		res += nums[i];
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappushpop

"""
・f(x) = （最上段の左端座標） -> 最小コスト
・g = newf とすると、g(x) = |x-l| + min_{x-w_{n-1}<=y<=x+w_n}f(y)
・常に [A0,B0] 上で定数、[A_i,A_{i-1}]で傾き-i、[B_{i-1},B_i]で傾きiの下に凸な折れ線
heapqで(A,B)の形で関数を持つ
・1段目の長方形で、A = [l], B = [l] からスタート（f(x) = |x - l|）
"""

N = int(readline())
m = map(int,read().split())
L,R = zip(*zip(m,m))

A = [-L[0]]; B = [L[0]]
addA = 0
addB = 0
min_f = 0
for n in range(1,N):
    p = R[n-1] - L[n-1]; q = R[n] - L[n]
    # まず、f(x) = min_{x-p <= y <= x+q} f(y) へと更新
    addA += (-q); addB += p
    a = -A[0] + addA
    b = B[0] + addB
    x = L[n]
    # x で座標を2回切り替えるようにする
    if x <= a:
        # 左に2つ入れたあと、右に1つうつす
        min_f += a - x
        heappush(A,-x + addA)
        y = -heappushpop(A,-x + addA) + addA
        heappush(B, y - addB)
    elif x >= b:
        # 右に2つ入れたあと、左に1つうつす
        min_f += x - b
        heappush(B, x - addB)
        y = heappushpop(B, x - addB) + addB
        heappush(A, -y + addA)
    else:
        # 左右に1つずつ入れる
        heappush(A, -x + addA)
        heappush(B, x - addB)

print(min_f)

Measured memory_bytes: 28128
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
#define endl '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define mm(X) memset((X), 0, sizeof((X)))
#define deb(x) cout<<#x<<" "<<x<<endl;



void solve() {
	int n; cin >> n;
	int a[n];
	rep(i, 0, n) cin >> a[i];
	int dp[n];
	if (n == 2) {
		cout << abs(a[0] - a[1]);
		return;
	}
	dp[n - 1] = 0; dp[n - 2] = abs(a[n - 1] - a[n - 2]);
	for (int i = n - 3; i >= 0; i--) {
		dp[i] = min(abs(a[i] - a[i + 1]) + dp[i + 1], abs(a[i] - a[i + 2]) + dp[i + 2]);
	}
	cout << dp[0];
}

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

	// int tc; cin >> tc;
	// for (int t = 1; t <= tc; t++) {
	//cout << "Case #" << t  << ": ";
	solve();
	// }
}

Measured memory_bytes: 4352
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int N=sc.nextInt();
		int A=sc.nextInt();
		pw.println(N%500<=A?"Yes":"No");
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
     
int main() {
	string S,T,U;
  	int A,B;
  	cin >> S >> T >> A >> B >> U;
	if ((S==U)&&(T!=U)){
    cout << (A-1) << " " << B;
    }else if ((S!=U)&&(T==U)){
    cout << A << " " << (B-1); 
    }else if ((S!=U)&&(T!=U)){
    cout << A << " " << B;
    }else{
    cout << (A-1) << " " << (B-1) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		final String s = sc.next();
		final String[] sList = s.split("");

		System.out.print(sList[0] + (sList.length - 2) + sList[sList.length - 1]);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

int main(){

    int n,k;
    cin >> n >> k;

    vector<int> s;

    while(n != 0){

        s.push_back(n % k);
        n /= k;

    }

    int keta = s.size();
    cout << keta << endl;
    


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    }
}

class Solver {
    public String solve(String N){
        long number = 0;
        for(char c: N.toCharArray()){
            number += Character.getNumericValue(c);
        }

        return number % 9 == 0 ? "Yes" : "No";
    }
}


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

int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	vector<string> s(n);
	for(int i=0;i<n;i++)
		cin>>s[i];
	int p=pow(2,n+m);
	int ans=0;
	for(int t=0;t<p;t++)
	{
		vector<int> row,col;
		for(int i=0;i<n;i++)
			if((t>>i)&1)
				row.push_back(i);
		for(int i=n;i<m+n;i++)
			if((t>>i)&1)
				col.push_back(i-n);
		vector<string> copy(n);
		for(int i=0;i<n;i++)
			copy[i]=s[i];
		for(int i=0;i<row.size();i++)
			for(int j=0;j<m;j++)
				copy[row[i]][j]='R';
		for(int i=0;i<col.size();i++)
			for(int j=0;j<n;j++)
				copy[j][col[i]]='R';
		int cnt=0;
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++)
				if(copy[i][j]=='#')
					cnt++;
		if(cnt==k)
			ans++;
	}
	cout<<ans;
	return 0;
	
}

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

int main(){
	int k;
	string s;
	cin >> k >> s;
	int size = s.size();
  	int i;
	if(size<=k){cout << s << endl;}
	else {
		for(i=0;i<k;i++){
			cout << s.at(i);
		}
		cout << "..." << endl;
	}
/*	
for(i=0;i<n;i++){
		
	}
*/	

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define se second
#define Mod 1000000007


int main(){
    ll i,j;

    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++) cin>>a[i];

    bool dp[k+1];

    dp[0]=1;

    for(i=1;i<=k;i++){
        dp[i]=0;
        ll f=1;
        for(j=0;j<n;j++){
            if(i-a[j]>=0){
                if(dp[i-a[j]]==1) f=0; 
            }
        }
        if(f==1) dp[i]=1;
    }

    if(dp[k]==0) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

}




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ld long double
#define F first
#define S second
#define ms(x,y) memset(x,y,sizeof(x))
#define F1(i,n) for(int i=1;i<=n;++i)
#define F0(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
const int MAX=4e4,P=1e9+7;
int a[MAX],r[MAX],b[MAX];
long long gb(int a[],int h1,int t2){
    if (h1==t2)
        return 0;
    int t1=(h1+t2)/2,h2=t1+1;
    long long ans=gb(a,h1,t1)+gb(a,h2,t2);
    int i=h1,j=h2,k=i-1;
    while (i<=t1&&j<=t2){
        if (a[i]<=a[j])
            r[++k]=a[i++];
        else{
            r[++k]=a[j++];
            ans+=t1-i+1;
        }
    }
    while (i<=t1)
        r[++k]=a[i++];
    while (j<=t2)
        r[++k]=a[j++];
    for (int l=h1;l<=t2;l++)
        a[l]=r[l];
    return ans;
}
int main()
{
    LL n,k;
    cin>>n>>k;
    F1(i,n){
        cin>>a[i];
        b[n+i]=b[i]=a[i];
    }
    LL c1=gb(a,1,n),c2=gb(b,1,2*n);
    cout<<(k*(k+1)/2%P*c1%P+k*(k-1)/2%P*(c2-c1*3)%P)%P<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;

struct complex
{
	double num,inum;
	complex(double A=0.0,double B=0.0){num=A,inum=B;}
};
complex operator !(const complex &A){return complex(A.num,-A.inum);}
complex operator +(const complex &A,const complex &B){return complex(A.num+B.num,A.inum+B.inum);}
complex operator -(const complex &A,const complex &B){return complex(A.num-B.num,A.inum-B.inum);}
complex operator *(const complex &A,const complex &B){return complex(A.num*B.num-A.inum*B.inum,A.num*B.inum+A.inum*B.num);}
struct Fast_Fourier_Transform
{
	#define size 140005
	#define pi 3.141592653589793238462643383
	
	int N,rev[size];
	complex *W,w[2][size];
	
	void prepare(int n)
	{
		if(N==n)return;
		int i,k,x,y;N=n;
		for(i=0;i<n;++i)
		{
			for(x=i,y=0,k=1;k<n;x>>=1,k<<=1)(y<<=1)|=x&1;
			rev[i]=y;
		}
		for(i=0;i<n;++i)
		{
			w[0][i]=complex(cos(2*pi*i/n),sin(2*pi*i/n));
			w[1][i]=complex(cos(2*pi*i/n),-sin(2*pi*i/n));
		}
	}
	void work(complex *A,int n)
	{
		if(n==1)return;
		int i,j,k,l,t;
		complex x,y;
		for(i=0;i<n;++i)if(i<rev[i])swap(A[i],A[rev[i]]);
		for(i=1;i<n;i<<=1)
		for(j=0,t=n/(i<<1);j<n;j+=i<<1)
		for(k=l=0;k<i;++k,l+=t)
		{
			x=W[l]*A[j+k+i];
			y=A[j+k];
			A[j+k]=y+x;
			A[j+k+i]=y-x;
		}
	}
	
	void DFT(complex *A,int n){prepare(n);W=w[0];work(A,n);}
	void IDFT(complex *A,int n)
	{
		prepare(n);W=w[1];work(A,n);
		for(int i=0;i<n;++i)A[i].num/=n,A[i].inum/=n;
	}
	
	void mult(int n,int *a,int *b,int *c,int p)
	{
		int i,j,k;
		static complex f[size],g[size],t[size],r[size];
		for(i=0;i<n;++i)
		{
			f[i]=complex(a[i]>>15,a[i]&32767);
			g[i]=complex(b[i]>>15,b[i]&32767);
		}
		DFT(f,n);DFT(g,n);
		for(i=0;i<n;++i)
		{
			int j=i?n-i:0;
			t[i]=( (f[i]+!f[j])*(!g[j]-g[i]) + (!f[j]-f[i])*(g[i]+!g[j]) )*(complex){0,0.25};
			r[i]=(!f[j]-f[i])*(!g[j]-g[i])*(complex){-0.25,0} +(complex){0,0.25}*(f[i]+!f[j])*(g[i]+!g[j]);
		}
		IDFT(t,n);IDFT(r,n);
		for(i=0;i<n;++i)c[i]=( (((long long)(t[i].num+0.5))%p<<15) + (long long)(r[i].num+0.5) + (((long long)(r[i].inum+0.5))%p<<30) )%p; 
	}
	
	#undef size
	#undef pi
}FFT;

int N,n,m,a,b,i,j,k,ans;
int f[100005],g[100005],fac[100005],fac_inv[100005];
char A[100005],B[100005];

#include <string.h>
#define p 998244353

int Power(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=(long long)a*a%p)if(b&1)ans=(long long)ans*a%p;
	return ans;
}

int main()
{
	scanf("%s",A+1);n=strlen(A+1);
	scanf("%s",B+1);
	for(i=1;i<=n;++i)
	if(A[i]=='1')
	{
		if(B[i]=='1')++a;
		else ++b;
	}
	for(fac[0]=i=1;i<=n;++i)fac[i]=(long long)fac[i-1]*i%p;
	for(i=0;i<=n;++i)fac_inv[i]=Power(fac[i],p-2);
	
	m=a+b;
	for(i=0;i<=a;++i)g[i]=(long long)fac_inv[i+1]%p;
	f[0]=1;
	for(N=1;N<=a;N<<=1);N<<=1;
	for(k=b;k;k>>=1)
	{
		if(k&1)FFT.mult(N,f,g,f,p);
		FFT.mult(N,g,g,g,p);
		for(i=a+1;i<N;++i)f[i]=g[i]=0;
	}
	
	for(i=0;i<=a;++i)ans=(ans+(long long)f[i]%p)%p;
	
	ans=(long long)ans*fac[m]%p*fac[b]%p*fac[a]%p;
	printf("%d\n",ans);
}

Measured memory_bytes: 14080
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define pb push_back
using namespace std;
typedef long long LL;
const int maxn = 105;
int N, W;
LL w1, x, y;
vector<LL> V[4];
LL sumv[4][maxn];
LL ans = 0;
int main()
{
    cin>>N>>W;
    cin>>w1>>y;
    V[0].pb(y);
    for(int i = 1; i < N; i++){
        cin>>x>>y;
        V[x-w1].pb(y);
    }
    for(int i = 0; i <= 3; i++) sort(V[i].begin(), V[i].end());
    for(int i = 0; i <= 3; i++) reverse(V[i].begin(), V[i].end());
    for(int i = 0; i <= 3; i++){
        sumv[i][0] = 0;
        for(int j = 0; j < V[i].size(); j++){
            sumv[i][j+1] = sumv[i][j] + V[i][j];
        }
    }
    for(int i = 0; i <= V[0].size(); i++)
        for(int j = 0; j <= V[1].size(); j++)
            for(int k = 0; k <= V[2].size(); k++){
                if(i*w1 + j*(w1+1) + k*(w1+2) > W) break;
                int p = (W - (i*w1 + j*(w1+1) + k*(w1+2)))/(w1+3);
                p = min(p, (int)V[2].size());
                ans = max(ans, sumv[0][i] + sumv[1][j] + sumv[2][k] + sumv[3][p]);
            }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, D: int):
    while True:
        C -= B
        if C <= 0:
            print(YES)
            exit()
        A -= D
        if A <= 0:
            print(NO)
            exit()
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0, a[1005];

	cin >> N;
	rep(i,N) cin >> a[i];

	rep(i,N-1){
		if( a[i] == a[i+1] ){
			ans++;
			a[i+1] = -1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=1e2+5,mod=1e9+7;
int n;
int a[maxn],f[maxn][maxn][maxn];
void upd(int &x,int y){
	x=(x+y)%mod;
}
int main(){
	read(n);
	rep(i,1,2*n-1)read(a[i]);
	sort(a+1,a+2*n-1+1);
	a[0]=a[1];a[2*n]=a[2*n-1];
	f[n][a[n]!=a[n-1]][a[n]!=a[n+1]]=1;
	per(i,n,2)rep(l,0,2*n-1)rep(r,0,2*n-1){
		int fl=(a[i-1]!=a[i-2]),fr=(a[2*n-i+1]!=a[2*n-i+2]);
		rep(k,0,l-1)upd(f[i-1][k+fl][r+fr+1],f[i][l][r]);
		upd(f[i-1][l+fl][r+fr],f[i][l][r]);
		rep(k,0,r-1)upd(f[i-1][l+fl+1][k+fr],f[i][l][r]);
	}
	int ans=0;
	rep(l,0,2*n-1)rep(r,0,2*n-1)upd(ans,f[1][l][r]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    auto s = readln.chomp;

    long Ans = 0;
    auto X = new long[s.length + 1];
    int left = 0, right = 0;
    foreach (i; 0 .. s.length) {
        (s[i] == '(' ? left : right)++;
        Ans += X[left - right];
        X[left - right]++;
    }
    writeln(Ans);

}

Measured memory_bytes: 1988
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll a,b,n;

ll f(ll i){
    return a*i/b-a*(i/b); 
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  cin >> a >> b >> n;
  cout << f(min(b-1,n)) << endl;
  
}  


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





//Dinic O(EV^2)
#define MAX_V 10200
struct edge{ 
	int to, cap, rev;
	edge(int a, int b, int c) :to(a), cap(b), rev(c){}
};

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap){
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}
//sからの最短距離をbfsで計算
void bfs(int s){
	memset(level, -1, sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()){
		int v = que.front(); que.pop();
		for (int i = 0; i<G[v].size(); i++){
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}
//増加パスをdfsで探す
int dfs(int v, int t, int f){
	if (v == t)return f;
	for (int &i = iter[v]; i<G[v].size(); i++){
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to, t, min(f, e.cap));
			if (d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t){
	int flow = 0;
	for (;;){
		bfs(s);
		if (level[t]<0)return flow;
		memset(iter, 0, sizeof(iter));
		int f;
		while ((f = dfs(s, t, INF))>0){
			flow += f;
		}
	}
}

int h,w;
char a[100][100];
int n;


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

	cin>>h>>w;
	rep(y, h)rep(x, w)cin >> a[y][x];

	int sy,sx,gy,gx;
	rep(y, h)rep(x, w){
		if (a[y][x] == 'S')sy = y, sx = x;
		else if (a[y][x] == 'T')gy = y, gx = x;
	}
	if (sy==gy || sx==gx){
		cout<<-1<<endl;
		return 0;
	}
	n = h*w;

	rep(y, h)rep(x, w){
		if (a[y][x]=='.')continue;

		int idx = y*w+x;
		int cost = a[y][x] == 'S' ? INF : 1;
		add_edge(idx, n + y, cost);
		add_edge(n + y, idx, INF);

		add_edge(idx, n + h + x, cost);
		add_edge(n + h + x, idx ,INF);
	}
	cout << max_flow(sy*w+sx, gy*w+gx)<<endl;



	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> d(n);
    REP(i, n) cin >> d[i];
    int m;
    cin >> m;
    vector<int> t(m);
    REP(i, m) cin >> t[i];

    map<int, int> mp1, mp2;
    REP(i, m) mp1[t[i]]++;
    REP(i, n) mp2[d[i]]++;
    int sum = 0;
    for(auto x : mp1){
        sum += max(x.second - mp2[x.first], 0);
    }

    cout << (sum == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end(), greater<int>());
    int ans=0;

    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]<a[j]+a[k]){
                    if(a[j]<a[j]+a[k]){
                        if(a[k]<a[i]+a[j]){
                            ans++;
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n,ma,mb;
  cin>>n>>ma>>mb;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  int dp[n+1][401][401];
  for(int i=0;i<n+1;i++){
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        dp[i][j][k]=(int)1e9;
      }
    }
  }
  dp[0][0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        if(dp[i][j][k]==(int)1e9) continue;
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }
  int ans=-1;
  for(int i=1;i<=400;i++){
    for(int j=1;j<=400;j++){
      if(dp[n][i][j]==(int)1e9) continue;
      if(i*mb==j*ma){
        if(ans<0) ans=dp[n][i][j];
        else ans=min(ans,dp[n][i][j]);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[1<<12];
const ll INF = (1ll<<60);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 1<<12) dp[i] = INF;
    dp[0] = 0;

    ll N, M;
    cin >> N >> M;

    REP(i, M){
    	ll a, b;
    	cin >> a >> b;
    	ll code = 0;
    	REP(j, b){
    		ll c;
    		cin >> c;
    		c--;
    		code += (1<<c);
    	}
    	dp[code] = min(dp[code], a);
    }

    REP(S, 1<<N){
    	for(int T=S;T>0;T=(T-1)&S){
    		for(int U=S;U>0;U=(U-1)&S){
    			if((T|U)==S) dp[S] = min(dp[S], dp[T]+dp[U]);
    		}
    	}
    }
    cout << (dp[(1<<N)-1]==INF ? -1 : dp[(1<<N)-1]) << endl;
    return 0;
}

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

int main(){
  int n,m=0;
  cin >> n;
  vector<int> a(n+1),b(n+1,0);
  for(int i=1;i<=n;i++){
    cin >> a.at(i);
  }
  for(int i=n;i>=1;i--){
    int c = 0;
    for(int j=2*i;j<=n;j+=i){
      c += b.at(j);
    }
    b.at(i) = (a.at(i) + c)%2; 
  }
  for(int i=1;i<=n;i++){
    m += b.at(i);
  }
  cout << m << endl;
  for(int i=1;i<=n;i++){
    if(b.at(i) == 1){
      printf("%d ",i);
    }
  }
  if(m != 0){
    cout << endl;
  }
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int n;
  long long unsigned int sum;

  while (scanf("%d", &n), n){
    vector<int> vec;
    for (int i=0; i<n; i++){
      int x;
      scanf("%d", &x);
      vec.push_back(x);
    }
    sort(vec.begin(), vec.end());
    sum = 0;
    for (int i=0; i<n-1; i++){
      sum += vec[i]*(n-1-i);
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 3320
#include<iostream>

using namespace std;

int main()
{
	int N, s1, s2, s3;

	while(cin >> N)
	{
		while(N--)
		{
			cin >> s1 >> s2 >> s3;
			if(s1*s1 + s2*s2 == s3*s3 || s1*s1 + s3*s3 == s2*s2 || s3*s3 + s2*s2 == s1*s1)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1124
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
	//s=long p=short
    string s,p;
	int answer = 0;
	cin >>s;
	cin >>p;
	int lenp,lens;
	lenp = p.size();
	lens = s.size();
	// check if p[0]~p[lenp-1] = s[i]~s[i+lenp-1] or s[i]~s[i+lenp-lens-1]
	for(int i = 0; i<lens; i++){
		if (answer == 1){
			break;
		}
		if(i+lenp-1<lens){
			for(int j=0; j<lenp;j++){
				if(s[i+j]!=p[j]){
					break;//if one charcter is wrong,break it.
				}
				if(j ==lenp-1 && s[i+j]==p[j]){
				 answer = 1;
				 //if all charcter is wrong ans =1
				}
				
			}//no loop check end
		}
		else{//loop check start
			if (answer == 1){
				break;
			}
			for(int j=0;j<lenp;j++){
				if(i+j<lens){
					if(s[i+j] != p[j]){
						break;
					}
				}
				else{
					if(s[i+j-lens] != p[j]){
						break;
					}
					if(s[i+j-lens] == p[j] && j==lenp-1){
						answer = 1;
						
					}
				}
			}
		}	
	}
	if(answer == 1){
		cout << "Yes" <<"\n";
	}
	else{
		cout << "No" <<"\n";
	}
	return 0;
} 

Measured memory_bytes: 1168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 26;
	static int MOD = 998244353;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] c = new int[n-1], s = new int[n-1], f = new int[n-1];
			for (int i = 0; i < n-1; i++) {
				c[i] = in.nextInt();
				s[i] = in.nextInt();
				f[i] = in.nextInt();
			}

			for (int i = 0; i < n-1; i++) {
				int now = s[i];
				for (int j = i; j < n-1; j++) {
					now += c[j];

					if (j >= n-2) {
						break;
					}
					now = s[j+1] + f[j+1] * Math.max((now - s[j+1] + f[j+1] -1)/f[j+1], 0);
				}
				out.println(now);
			}
			out.println(0);
		}
	}




	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}
}

Measured memory_bytes: 21716
inputList = list(map(int, input().split(' ')))
A = inputList[0]
B = inputList[1]
C = inputList[2]
D = inputList[3]
answer = 0
if D <= A:
    answer = 0
elif C <= A <= D <= B:
    answer = (D-A)
elif C <= A and B <= D:
    answer = (B-A)
elif A <= C and D <= B:
    answer = (D-C)
elif A <= C <= B <= D:
    answer = (B-C)
print(answer)


Measured memory_bytes: 3064
#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) {
	int n;
	cin >> n;
	
	map<ll, ll> mp;
	ll sum = 0LL;
	for(int i = 0; i < n; ++i) {
		ll a;
		cin >> a;
		mp[a]++;
		sum += a;
	}
	
	int Q;
	cin >> Q;
	
	vector<ll> res;
	for(int i = 0; i < Q; ++i) {
		ll b, c;
		cin >> b >> c;
		
		if( mp[b] > 0 ) {
			sum += (c - b) * mp[b];
			ll tmp = mp[b];
			
			mp[b] = 0;
			mp[c] += tmp;
		}
		
		res.push_back(sum);
	}
	
	for(auto& ans : res) {
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 9752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{  
  int n;
  cin >> n;
  int ans = 0;
  int a[n];
  for(int i = 0 ; i < n ; i++)
    cin >> a[i];
  ans = a[0];
  for(int j = 0 ; j < n - 1; j++){
		ans += max(0 , a[j + 1] - a[j]);
  }
  cout << ans << endl;
  return 0;
  	
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int a,b;
	string s;
	cin >> a >> b >> s;
	
	if(s.size()!=a+b+1){
		cout << "No" << endl;
		return 0;
	}
	for(int i=0;i<s.size();i++){
		if(i!=a){
			if(s[i]<'0' || '9'<s[i]){
				cout << "No" << endl;
				return 0;
			}
		}else{
			if(s[i]!='-'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;			
	return 0;
}


Measured memory_bytes: 256
import math

n  = int(input())
ps = []
ds = []
a  = 1
b  = 1

for _ in range(0, n):
	x, y = [int(x) for x in input().split()]
	ps.append((x, y))

for i in range(1, n):
	a *= i
	b *= i

b *= n

for i in range(0, n):
	for j in range(0, n):
		if i != j:
			dx = ps[i][0] - ps[j][0]
			dy = ps[i][1] - ps[j][1]
			ds.append(math.sqrt(dx * dx + dy * dy) * a)

print(sum(ds) / b)


Measured memory_bytes: 38384
#include <stdio.h>
int main()
{
    int N,n1,n2;
    while (scanf("%2d",&N)!=EOF);
    {
        n1 = N/10;
        n2 = N%10;
        if (n1==9||n2==9)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	int n;
	string s;
	int left = 0;
	int right = 0;
	int count = 0;
	int dp[101] = {};
	
	cin >> n;
	cin >> s;
	FOR(i, 0, s.size() - 1) {
		if (s[i] == '(') {
			dp[i] = 1;
		}
		else {
			dp[i] = -1;
		}
	}
	
	FOR(i, 0, s.size() - 1) {
		if (dp[i] == 1) {
			FOR(t, i+1, s.size() - 1) {
				if (dp[t] == -1) {
					dp[i] = 0;
					dp[t] = 0;
					break;
				}
			}
		}
	}
	FOR(i, 0, s.size() - 1) {
		if (dp[i] == 1) {
			right++;
		}
		else if (dp[i] == -1) {
			left++;
		}
	}

	FOR(i, 1, left) {
		cout << '(';
	}
	cout << s;
	FOR(i, 1, right) {
		cout << ')';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    l = "abcdefghijklmnopqrstuvwxyz"
    ans = ""

    while N > 0:
        ans = l[N % 26 - 1] + ans
        N = (N-1) // 26

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut v = read_vec::<usize>();
    let mut alice = 0;
    let mut bob = 0;
    v.sort();
    v.reverse();
    for i in 0..n {
        if i % 2 == 0 {
            alice += v[i];
        } else {
            bob += v[i];
        }
    }
    let ans = alice - bob;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int A, B;
  cin >> A >> B;
  for(int n=0;n<10001;n++){
    int za = n*8/100;
    int zb = n*10/100;
    if(A==za&&B==zb){
      cout << n << endl;
      return 0;
    }
  }
    cout << -1 << endl;
    return 0;
}

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

int main(){
    int n ;
    cin >> n ;
    int p = n/1.08 -1 ;
    while (1)
    {
        int q = p*1.08 / 1;
        if (q == n)
        {
            cout << p << endl ;
            break ;
        }else if (q > n)
        {
            cout << ":(" << endl ;
            break;
        }
        
        p++ ;
    }
    
    
    
}

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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        var N = cin.next();
        var A = N[0];
        var B = N[1];
        var C = N[2];
        var ret = "No";
        if(A == C)
        {
            ret = "Yes";
        }
        Console.WriteLine(ret);
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

#define ll long long
using namespace std;
const int mod = 1e9 + 7, N = 3007;

int dp[N][N];
string s, t;

int solve(int i, int j) {
    if (i >= s.size() || j >= t.size())return 0;
    int &ret = dp[i][j];
    if (~ret)return ret;
    if (s[i] == t[j])return ret = solve(i + 1, j + 1) + 1;
    else {
        return ret = max(solve(i + 1, j), solve(i, j + 1));
    }
}

void Build(int i, int j) {
    if (i >= s.size() || j >= t.size())return;
    if (solve(i, j) == solve(i + 1, j + 1) + 1 and s[i] == t[j]) {
        printf("%c", s[i]);
        Build(i + 1, j + 1);
    }
    else if (solve(i, j) == solve(i + 1, j))Build(i + 1, j);
    else Build(i, j + 1);
}


int main() {

    memset(dp, -1, sizeof dp);
    cin >> s >> t;
    solve(0, 0);
    Build(0, 0);
    return 0;
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

vi to[MX];
vi co[MX];

int n;
int t[MX];

int tfs(int v, int p=-1) {
  int res = 1;
  rep(i,sz(to[v])) {
    int u = to[v][i];
    if (u == p) continue;
    int r = tfs(u,v);
    res += r;
  }
  return t[v] = res;
}
P cfs(int v, int p=-1) {
  P res(INF,v);
  int mx = n-t[v];
  rep(i,sz(to[v])) {
    int u = to[v][i];
    if (u == p) continue;
    mins(res,cfs(u,v));
    maxs(mx,t[u]);
  }
  return min(res,P(mx,v));
}

ll ans;
void dfs(int v, ll d=0, int p=-1) {
  ans += d*2;
  rep(i,sz(to[v])) {
    int u = to[v][i], c = co[v][i];
    if (u == p) continue;
    dfs(u,d+c,v);
  }
}

int main() {
  scanf("%d",&n);
  rep(i,n-1) {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    --a; --b;
    to[a].pb(b); co[a].pb(c);
    to[b].pb(a); co[b].pb(c);
  }
  tfs(0);
  int r = cfs(0).se;
  dfs(r);
  tfs(r);
  int dc = INF;
  rep(i,sz(to[r])) {
    int u = to[r][i];
    if (t[u]*2 == n) {
      dc = co[r][i];
      break;
    } else {
      mins(dc,co[r][i]);
    }
  }
  ans -= dc;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 20864
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int main()
{
    abdelrahman010
    int a , b;
    cin >> a >> b;
    for(int i = 1;;i++)
        if((i * 8) / 100 == a && i / 10 == b)
            return cout << i , 0;
        else if((i * 8) / 100 > a && i / 10 > b)
            break;
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
di = {}
d = {}
for i in range(len(a)):
    di[i] = a[i]
    d[a[i]] = i
ss = ''
for i in s:
    k = d[i] + n
    k %= 26
    ss += di[k]
print(ss)

Measured memory_bytes: 40540
import sys
import bisect
from collections import defaultdict

ans=0
#n=int(input())
n,m=map(int,input().split())
l=[0]*(n)
r=[0]*(n)
a=[0]*(n+3)
for i in range(m):
    x,y=map(int,input().split())
    a[x]+=1
    a[y+1]+=-1
for i in range(n):
    a[i+1]+=a[i]
ans=a.count(m)

print(ans)

Measured memory_bytes: 47616
import math
while True:
    n=int(input())
    if n==0:
        break
    elif n>=4:
        dp=[0]*n
        dp[0]=1
        dp[1]=2
        dp[2]=4
        for i in range(3,n):
            dp[i]=dp[i-1]+dp[i-2]+dp[i-3]
        print(int(math.ceil(dp[n-1]/10/365)))
    else:
        print(1)


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,r=0,b=0;
string a;
cin>>n>>a;
for(int i=0;i<n;i++){
	if(a[i]=='R')
	r++;
	else
	b++;
}
if(r>b)
cout<<"Yes";
else
cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long int 
#define fi first
#define se second
#define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
#define int long long int
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
int32_t main()
{
  string n;
  cin>>n;
  int sum=0;
  forn(i,n.size())
  {
    sum+=n[i]-'0';
  }
  //cout<<sum;
  if(sum%9==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>
#include <stack>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e14, cnt;


ll a[10000001],b[10000001];
int main(){
	ll n;
	cin>>n;

	for(ll i=1; i<=n; i++){
		for(ll j=i; j<=n; j+=i) {
			a[j]++;
		}
	}
	
	for(ll i=1; i<=n; i++) {
		sum+=a[i]*i;
	}
	cout<<sum;
}
	

Measured memory_bytes: 81716