akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

  int ans = 0;
  while(1){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        cout << ans << endl;
        return 0;
      }
      a[i] /= 2;
    }
    ans++;
  }

  return 0;
}

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

if K>N*(N-1)//2-(N-1):
    print(-1)
    exit()

is_ban = [[False]*N for _ in range(N)]

for i in range(1, N):
    for j in range(i+1, N):
        if K==0:
            break
        
        is_ban[i][j] = True
        K -= 1

ans = []

for i in range(N):
    for j in range(i+1, N):
        if not is_ban[i][j]:
            ans.append((i, j))
    
print(len(ans))

for u, v in ans:
    print(u+1, v+1)

Measured memory_bytes: 43248
from itertools import product
N = int(input())
STR = ['3','5','7']
cnt = 0
for i in range(10):
    if N<10**i-1:
        break
    else:
        A=list(product(STR,repeat = i+1))
        # Aにiけた未満の３５７の組み合わせを入れる
        for j in A:
            # ３桁かつ３、５、７が一個以上入るかつNより小さい数
            if j.count('3')>=1 and j.count('5')>=1 and j.count('7')>=1 and int(''.join(j))<=N:
                cnt +=1
print(cnt)
    



Measured memory_bytes: 13968
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    vector<int> S = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << S[K-1];
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;
 
int main() {
	// 入力
    float n,m,d;
    cin >> n >> m >> d;
	
	float ans;
	if (d==0) ans = (m-1)*1/n;
	else ans = (m-1)*((1*2*d)+2*(n-2*d))/n/n;
    // cout << ans << endl;
	printf("%10f\n", ans);	// 3
}
 


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  long long rakuda = 0;
  REP(i, n) rakuda ^= a[i];
  cout << (rakuda == 0 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static int[][] dp;




	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		int k =sc.nextInt();
		int[] a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		int[] dp = new int[k+1];				//dp[i] = kがiの時の勝者
		for(int  i = 0;i <= k;i++){
			if(i < a[0]){
				dp[i] = 2;
			}else{
				int sub = 0;
				for(int j = 0;j < N;j++){
					if(i - a[j] >= 0){
						if(dp[i-a[j]] == 2){
							sub = 1;
							break;
						}
					}
				}
				if(sub == 1){
					dp[i] = 1;
				}else{
					dp[i] = 2;
				}

			}
		}
		if(dp[k] == 1){
			System.out.println("First");
		}else{
			System.out.println("Second");

		}


	}


}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 23636
n = int(input())
a = list(map(int,input().split()))
ans = [0] * 9

for i in a:
  if i >= 1 and i <= 399:
    ans[0] += 1
  elif i >= 400 and i <= 799:
    ans[1] += 1
  elif i >= 800 and i <= 1199:
    ans[2] += 1
  elif i >= 1200 and i <= 1599:
    ans[3] += 1
  elif i >= 1600 and i <= 1999:
    ans[4] += 1
  elif i >= 2000 and i <= 2399:
    ans[5] += 1
  elif i >= 2400 and i <= 2799:
    ans[6] += 1
  elif i >= 2800 and i <= 3199:
    ans[7] += 1
  else:
    ans[8] += 1
    
maxv = 0
minv = 0

for i in range(0,8):
  if ans[i] > 0:
    minv += 1
    

maxv = str(minv + ans[8])
if minv == 0:
  minv = 1
minv = str(minv)


#print(ans)
print("".join([minv, " ", maxv]))

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

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int ans = 0;
  for (int i = 1; i < N; i++) {
    int d = A[i - 1] - A[i];
    if (d > 0) {
      ans += d;
      A[i] = A[i - 1];
    }
  }

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

Measured memory_bytes: 4824
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  double a, b, x; cin >> a >> b >> x;
  double rad1 = atan2(2*a*a*b - 2*x, a*a*a);
  double rad2 = atan2(a*b*b, 2*x);

  if (b > a * tan(rad1)) {
    printf("%.8f\n", rad1 * 180 / M_PI);
  } else {
    printf("%.8f\n", rad2 * 180 / M_PI);
  }
}


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

int main() {

	int h, w, k; cin >> h >> w >> k;
	vector<vector<char>> c(h, vector<char>(w));
	//int totalSum = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
			//if (c[i][j] == '#') totalSum++;
		}
	}
	int ans = 0;
	int n = h + w;
	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<bool> removeI(h, false);
		vector<bool> removeJ(w, false);
		int tmpCnt = 0;
		for (int i = 0; i < h; ++i) {
			if (bit & (1 << i)) {
				removeI[i] = true;
			}
		}
		for (int j = h; j < h + w; j++) {
			if (bit & (1 << j)) {
				removeJ[j - h] = true;
			}
		}
		for (int i = 0; i < h; i++) {
			if (removeI[i]) continue;
			for (int j = 0; j < w; j++) {
				if (removeJ[j]) continue;
				if (c[i][j] == '#') tmpCnt++;
			}
		}
		if (tmpCnt == k) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n;
    string s;
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++)
    {
    if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]==s[3]&&s[4]==s[5])
        {
            cout<<"Yes";
            break;
        }
        else
            cout<<"No";
        break;
    }
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val cnt = mutableMapOf<String, Int>()

    repeat(n) {
        val s = readLine()!!
        cnt[s] = (cnt[s] ?: 0) + 1
    }

    println("AC x ${cnt["AC"] ?: 0}")
    println("WA x ${cnt["WA"] ?: 0}")
    println("TLE x ${cnt["TLE"] ?: 0}")
    println("RE x ${cnt["RE"] ?: 0}")
}

Measured memory_bytes: 58096
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    int min = 0;
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        long X = long.Parse(s[0]);
        //long B = long.Parse(s[1]);
        //long K = long.Parse(s[2]);
        Console.WriteLine(GeneratePrime(X));
    }
    public static long GeneratePrime(long min)
    {
        List<long> primeList = new List<long>();

        //primeList.Add(2);
        long num = 2;
        while(true)
        {
            bool isPrime = true;
            for(int i = 0; i < primeList.Count; i++)
            {
                if(num % primeList[i] == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if(isPrime)
            {
                primeList.Add(num);
                if(min <= num)
                {
                    break;
                }
            }
            num++;
        }

        return num;
    }
}


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

using namespace std;

int const maxn = 2e5 + 5;
int a[maxn], b[maxn];

main()
{
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    if (n % 2 == 1)
        cout << b[(n + 1) / 2] - a[(n + 1) / 2] + 1 << '\n';
    else
        cout << (b[n / 2] + b[n / 2 + 1] - a[n / 2] - a[n / 2 + 1]) + 1 << '\n';
    return 0;
}


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

int main(){
	int k,x;
	cin >> k >> x;
	
	if(500*k >= x){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
char buf[1<<20];
int p[2<<17];
int N,K;
int sz;
int ans;
main()
{
	read(0,buf,1<<20);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		K=K*10+k-'0';
	}
	for(int i=0;i<N;i++)
	{
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			p[i]=p[i]*10+k-'0';
		}
	}
	for(int i=1;i<N;i++)p[i]+=p[i-1];
	for(int i=N-1;i>=K;i--)
	{
		p[i]-=p[i-K];
	}
	for(int i=0;i<N;i++)
    {
		if(ans<p[i])ans=p[i];
    }
	printf("%f\n",(ans+K)/2.);
}

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

int main() {
  int N;
  cin >> N;
  string S;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  
  for(int i = 0; i < N; i++){  
    cin >> S;
    if(S == "AC"){
      ac++;
    }
    else if(S == "WA"){
      wa++;
    }
    else if(S == "TLE"){
      tle++;
    }
    else if(S == "RE"){
      re++;
    }
  }
    
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3624
N = int(input())
cities = [int(input()) for i in range(5)]

#print ("N:",N)
#print ("cities:",cities)

ans = 0

people = [N,0,0,0,0,0]
latest = 0

# maybe O(N)
'''
while True:
	if (people[-1] == N):
		break
	else:
		for i in reversed(range(len(cities))):
			tmp = people[i]
			people[i] = max(0, people[i] - cities[i])
			people[i+1] += tmp - people[i]


	ans += 1
'''

critical = (N - 1) // min(cities) 


print (5 + critical)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    int  A,B;
    cin >> A >> B;
    int a = A + B;
    int b = A - B;
    int c = A * B;
    if(a < b) a = b;
    if(a < c) a = c;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    char S[5];
    cin >> S;
    for( int i = 0; i < 5; ++i ){
        if( S[i] == 'A' && S[i+1] == 'C' ){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}




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

    ll x, y;
    cin>>x>>y;

    ll ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }

    cout<<ans;
    return 0;
}








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

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

//逆辺いらないなんてだたのDAGじゃないですかー
int to[100001], ne[100001], he[100001];
int saidai;
void dfs(int u, int c) {
	int k = 1;
	for (int i = he[u]; i; i = ne[i]) {
		if (k == c) k++;
		chmax(saidai, k);
		dfs(to[i], k);
		to[i] = k++;
	}
}

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


	int N = getint();
	int tmp = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[tmp] = b;
		ne[tmp] = he[a];
		he[a] = tmp++;
	}

	dfs(1, 0);

	putint(saidai);
	rep1(i, N) putint(to[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

namespace ABC083 {
	class ABC083_A {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var result = (input[0] + input[1]) - (input[2] + input[3]);
			if (result == 0) Console.WriteLine("Balanced");
			if (result > 0) Console.WriteLine("Left");
			if (result < 0) Console.WriteLine("Right");
		}
	}
}


Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;

		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;
			StringTokenizer tokenizer = new StringTokenizer(line);
			double[] x = new double[4];
			double[] y = new double[4];
			for (int i = 0; i < 4; i++) {
				x[i] = Double.parseDouble(tokenizer.nextToken());
				y[i] = Double.parseDouble(tokenizer.nextToken());
			}
			double a = (x[0] - x[1]) * (x[2] - x[3]);
			double b = (y[0] - y[1]) * (y[2] - y[3]);
			if ((float) a + (float) b == 0)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

Measured memory_bytes: 16960
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll H,W,K;
    cin>>H>>W>>K;
    vector<vector<bool>> st(H,vector<bool>(W));
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            char c;
            cin>>c;
            if(c=='#')st[i][j]=true;
            else st[i][j]=false;
        }
    }
    
    bool initialized=false;
    ll now=1;
    vvll ans(H,vll(W,-1));
    for(ll i=0;i<H;i++){
        bool ini=initialized;
        bool ex=false;
        for(ll j=0;j<W;j++){
            if(st[i][j]){
                if(ex)now++;
                initialized=true;
                ex=true;
            }
            ans[i][j]=now;
        }
        if(!ini && initialized){
            for(ll ii=i-1;ii>=0;ii--){
                for(ll j=0;j<W;j++){
                    ans[ii][j]=ans[ii+1][j];
                }
            }
        }
        if(initialized && !ex){
            for(ll j=0;j<W;j++){
                ans[i][j]=ans[i-1][j];
            }
        }
        if(ex)now++;
    }
    
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
            printf("%d",ans[i][j]);
            if(j!=W-1)printf(" ");
            else printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    int cnt = 0;
    ll ans = 0;
    rep(i, s.length()) {
        if ( s[i] == 'B' ) ++cnt;
        else               ans+=cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	r,g,b,n = readline() |> split |> parseMap
	to = 0
	x = div(n,r)
	if r==1
		for i in 0:div(n,g)
			m = n-g*i
			for j in 0:div(m,b)
				if g*i+b*j<=n
					to += 1
				end
			end
		end
	elseif g == 1
		for i in 0:div(n,r)
			m = n-r*i
			for j in 0:div(m,b)
				if r*i+b*j<=n
					to += 1
				end
			end
		end
	elseif b == 1
		for i in 0:div(n,r)
			m = n-r*i
			for j in 0:div(m,g)
				if r*i+g*j<=n
					to += 1
				end
			end
		end
	else
	for i in 0:x
		m = n-r*i
		y = div(m,g)
		for j in 0:y
			l = m-g*j
			z = div(l,b)
			for k in 0:z
				if r*i+g*j+b*k == n
					to += 1
				end
			end
		end
	end
	end
	println(to)
end
main()


Measured memory_bytes: 138400
#include <bits/stdc++.h>
#define N 1005
#define INF 0x3f3f3f3f 
#define mod 1000000007
using namespace std;
typedef long long ll;
ll ans;
 
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    for(int i=1; i<n; i++) ans+=min((arr[i]-arr[i-1])*a, b);
    cout << ans;
    return 0;
}


Measured memory_bytes: 4356
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
#define endl "\n"
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;

int32_t main() {
    fastio
    int n;
    cin>>n;

    vector<int> vec(n);
    for(auto& it : vec) cin>>it;
    vector<ll> v1(n), v2(n);
    map<ll, ll> mp1, mp2;
    for(int i = 0; i<n; ++i) {
        v1[i] = vec[i]+i;
        v2[i] = i-vec[i];
        mp1[v1[i]]++;
        mp2[v2[i]]++;
    }

    sort(all(v1)); sort(all(v2));

    ll ans = 0;
    for(auto& it : mp1) {
        ans += it.second * mp2[it.first];
    }
    cout<<ans<<endl;
}

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

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

	int main() {
		int N, i;
		long long L[100];
		cin >> N;
		for (i = 0; i < 100; i++) {
			L[i] = 0;
		}
		L[0] = 2;
		L[1] = 1;

		for (i = 2; i <= N; i++) {
			L[i] = L[i - 2] + L[i - 1];
		}
		cout << L[N] << endl;

	}


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

template<typename C>
inline void out_vector(const C& v){
  bool isFirst = true;
  for(const auto& e : v){
    if(isFirst) { isFirst = false; }
    else { cout << " "; }
    
    cout << e;
  }
  cout << endl;
}


int main() {
  string s;
  cin >> s;
  
  auto len = s.size();
  int p = len;
  vector<string> ss;
  string prev;
  for(int i = 0; i < len; i++){
    string h = s.substr(i, 1);
    if(h == prev){
      h = s.substr(i, 2);
      if(h == prev) {
        ss.pop_back();
        h = h + h;
      } else {
        i++;
      }
    }
    //cout << h << endl;
    ss.push_back(h);
    prev = h;
  }
  
  //out_vector(ss);
  cout << ss.size() << endl;
}

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

#include <cmath>
#include <cstring>
#include <iostream>

using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
//#define x first
//#define y second
#define pb push_back
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const double eps = 1e-10;
double add(double a, double b)
{
    if(fabs(a+b) < eps*(fabs(a) + fabs(b))) return 0;
    return a+b;
}

struct P{
    double x, y;
    P() {}
    P(double x, double y) : x(x), y(y) {}
    P operator + (P p) { return P(add(x, p.x), add(y, p.y)); }
    P operator - (P p) { return P(add(x, -p.x), add(y, -p.y)); }
    P operator * (double d) { return P(x*d, y*d); }
    double dot(P p) { return  add(x*p.x, y*p.y); }
    double det(P p) { return  add(x*p.y, -y*p.x); }
};

//determine whether q on Seg_p1p2
bool on_seg(P p1, P p2, P q)
{
    return (p1-q).det(p2-q) == 0 && (p1-q).dot(p2-q) <= 0;
}

P intersection(P p1, P p2, P q1, P q2)
{
    return p1+(p2-p1)*((q2-q1).det(q1-p1) / (q2-q1).det(p2-p1));
}

int n, v, x, y;
const int MAX_N = 55;
const double g = 9.8;
int l[MAX_N], bo[MAX_N], r[MAX_N], to[MAX_N];

double calc(double vy, double t)
{
    return vy*t - g*t*t/2.0;
}

int cmp(double lb, double ub, double a)
{
    return a<lb+eps ? -1 : (a>ub-eps ? 1 : 0);
}

bool check(double qx, double qy)
{
    double a = g*g/4.0, b = g*qy - v*v, c = qx*qx + qy*qy;
    double D = b*b - 4.0*a*c;
    if(D<0 && D>-eps) D = 0;
    if(D < 0 ) return false;
    for(int d=-1; d<=1; d+=2) {
        double t2 = (-b+d*sqrt(D)) / (2.0*a);
        if(t2 <= 0) continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + g*t*t/2.0) /  t;

        double yt = calc(vy, x / vx);
        if(yt < y-eps) continue;

        bool ok = true;
        REP(i, 0, n) {
            if(l[i] >= x) continue;
            if(r[i]==x && y<=to[i] && bo[i]<=yt) ok = false;

            int yl = cmp(bo[i], to[i], calc(vy, l[i]/vx));
            int yr = cmp(bo[i], to[i], calc(vy, r[i]/vx));
            int xh = cmp(l[i], r[i], vx*(vy/g));
            int yh = cmp(bo[i], to[i], calc(vy, vy/g));
            if(xh==0 && yh>=0 && yl<0) ok = false;
            if(yl*yr <= 0) ok = false;
        }
        if(ok) return true;
    }
    return false;
}

int main()
{
#ifdef ANONYM
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
#endif

    scanf("%d%d%d%d", &n, &v, &x, &y);
    REP(i, 0, n) {
        scanf("%d%d%d%d", &l[i], &bo[i], &r[i], &to[i]);
        r[i] = min(r[i], x);
    }
    bool ok = check(x, y);
    REP(i, 0, n) {
        ok |= check(l[i], to[i]);
        ok |= check(r[i], to[i]);
    }
    puts(ok ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3164
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	map<ll, ll> mpA, mpB;

	rep(i, n) mpA[a[i]]++;
	rep(i, n) mpB[-b[i]]++;

	ll cnt = 0, min1 = LINF, min2 = LINF;
	for(auto i : mpA){
		cnt += i.sc;
		if (cnt >= (n + 1) / 2) chmin(min1, i.fs);
		if (cnt >= n / 2 + 1) chmin(min2, i.fs);
	}

	cnt = 0;
	ll max1 = -LINF, max2 = -LINF;
	for(auto i : mpB){
		cnt += i.sc;
		if (cnt >= (n + 1) / 2) chmax(max1, -i.fs);
		if (cnt >= n / 2 + 1) chmax(max2, -i.fs);
	}

	if (n & 1) co(max1 - min1 + 1);
	else
		co(max1 + max2 - min1 - min2 + 1);

	return 0;
}


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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }
UINT luin() { UINT x; scanf("%llu", &x); return x;}


int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int X = in();
    int Y = in();

    bool bOK = false;
    for (int i = 0; i <= X; ++i) {
        int j = X - i;
        if ( Y == 2 * i + 4 * j) {
            bOK = true;
            break;
        }
    }

    printf(bOK ? "Yes" : "No");

    return 0;
}







Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r, l+4038);
  int ans = 2018;
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      int x = i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	public static void main(String[] args) throws Exception {
		long N = Long.parseLong(br.readLine());
		
		if(N % 2 == 0)
			pw.println(N);
		else
			pw.println(N*2);
		
		pw.close();
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans=0;
  
  for (int i=0; i<N-2; i++){
    if(S[i]=='A'&& S[i+1]=='B' &&S[i+2]=='C'){
      ans++;
    }
  }
  cout << ans << endl;
}

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

long long hano(int x){
	long long ret = x;
	ret *= x;
	ret *= x;
	ret *= x;
	ret *= x;
	return ret;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	long long x;
	cin>>x;
	vector<long long> v;
	for(int i=-3000;i<=3000;i++){
		for(int j=-3000;j<=3000;j++){
			if(hano(i) - hano(j) == x){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <math.h>


using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int temp;
    int back;
    int increasing=0;
    int count = 0;

    cin>>back;
    
    for (int i = 0; i < N - 1; i++) {
        cin>>temp;
        if (increasing == 0) {
            if (back < temp) {
                increasing = 1;
            }
            else if(back > temp){
                increasing = -1;
            }
        } else if (increasing == 1 && back > temp) {
            count++;
            increasing = 0;
        } else if(increasing == -1 && back < temp){
            count++;
            increasing = 0;
        }
        back = temp;
    }
    count++;
    cout << count << endl;
    return 0;
}


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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;

template<typename T>
void chmin(T& a,T b){a=min(a,b);}
template<typename T>
void chmax(T& a,T b){a=max(a,b);}


#define PRO "YES"
#define SHUMI "NO"
#define fin "\n"

int main(){
    string s;
    cin>>s;
    int N=s.size();
    vector<int> cnt(N);
    int g=0,p=0;
    for(int i=0;i<N;i++){
        if(s[i]=='g')g++;
        else p++;
        cnt[i]=g-p;
    }
    int res=0;
    int y=114514;
    for(int i=N-1;i>=0;i--){
        y=min(y,cnt[i]);
        if(s[i]=='g'&&y>1){
            res++;
            y-=2;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<numeric>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rep(i, n) for(int i=0; i<n; i++)
#define COUT(a) cout << a << endl;
#define PB push_back

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

ll H, W;
vector<char> answer;
vector<vector<char>> field;


int main() {
    ll N;
    cin >> N;
    vector<ll> x(N), y(N), h(N);

    rep(i, N){
        cin >> x[i] >> y[i] >> h[i];
    }

    ll Cx = 0, Cy = 0, H = 1;

    bool isInvalid = false;

    rep(i, 101){
        rep(j, 101){
            ll _H = -1;
            isInvalid = false;
            
            rep(k, N){
                if (h[k]>0){
                    ll tmp = h[k] + abs(x[k]-i) + abs(y[k]-j);
                    if (_H >= 0 && _H != tmp) {
                        isInvalid = true;
                        break;
                    }
                    if (_H < 0){
                        _H = tmp;
                    }
                }else{
                    if (_H > 0){
                        if (h[k] != max(_H - abs(x[k]-i) - abs(y[k]-j), (ll)0) )
                        {
                            isInvalid = true;
                            break;
                        }
                    }
                }
            }
            if ( _H < 0 || isInvalid) continue;
            Cx = i;
            Cy = j;
            H = _H;
        }
    }

    cout << Cx << " " << Cy << " " << H << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 


int main() {
  fastio;
  ld a,b,x;
  cin>>a>>b>>x;
  ld volume = a*a*b;
  ld ans = 0;
  cout<<fixed;
  if(x == volume / 2) {
    ans = atan(b / a) * 180 / PI;
  } else if(x>volume/2) {
    ld t = (2*x - volume) / (a*a) ;
    ans = atan((b-t)/a) * 180 / PI;
  } else {
    ld t = (volume -2.0*x)/(a*b);
    ans = atan(b/(a-t)) * 180 / PI;
  }
  cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















int main(){
    int n, t;
    scanf("%d %d", &n, &t);
    pair<int, int> v[3000];
    int max_a = 0;
    for(int i = 0; i < n; i++){
        scanf("%d %d", &v[i].first, &v[i].second);
        max_a = max(max_a, v[i].first);
    }
    sort(v, v + n);
    int dp[6000] = {}, tmp[6000] = {};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < t; j++){
            tmp[j + v[i].first] = dp[j] + v[i].second;
        }
        for(int j = 0; j < t + max_a; j++){
            dp[j] = max(dp[j], tmp[j]);
        }
    }
    printf("%d\n", *max_element(dp, dp + t + max_a));
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

odd = 'RUD'
even = 'LUD'

S = rs()

for i, c in enumerate(S):
	if i % 2 == 0:
		if c not in odd:
			print('No')
			exit()
	else:
		if c not in even:
			print('No')
			exit()
print('Yes')


Measured memory_bytes: 38384
// ABC156A - 

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

int main() {
	int N, R;
	int rate;

	cin >> N >> R;
	if (N >= 10) {
		cout << R << endl;
	} else {
		cout << R + 100 * (10 - N) << endl;
	}
}


Measured memory_bytes: 256
n,m=map(int,input().split())
A=list(map(int,input().split()))
a=sorted(A)
bc=[]
for _ in range(m):
    x=list(map(int,input().split()))
    bc.append(x)
bc.sort(key=lambda x:x[1],reverse=True)
i=0
j=0
k=0
while a[i]<bc[j][1]:
    a[i]=bc[j][1]
    i+=1
    k+=1
    if bc[j][0]==k:
        j+=1
        k=0
    if i>=n or j>=m:
        break
print(sum(a))

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

int main() {
	int n;
	cin>>n;
	int ans=1;
	for(int i=2;i<=n;i++){
		for(int j=2;j<i;j++){
			int z=i;
			while(z%j==0) z/=j;
			if(z==1){
				ans=max(ans,i);
			}
		}
	}
	cout<<ans;
}

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

int main() {
    int n, min, max, outputNumber;
    long long sum;

    cin >> n;
    cin >> outputNumber;

    min = outputNumber;
    max = outputNumber;
    sum = outputNumber;

    for (int i = 1; i < n; i++) {
        cin >> outputNumber;
        if (outputNumber < min) {
            min = outputNumber;
        }

        if (outputNumber > max) {
            max = outputNumber;
        }

        sum += outputNumber;
    }
    cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 3104
#include <stdio.h>
#define MAX_LEVEL 50

/*
レベルLバーガーの層の数
X_0 = 1
X_L = 2*X_L-1 + 3
X_L = 4*2^L - 3
レベルLバーガーのパティの数
X_0 = 1
P_L = 2*P_L-1 + 1
P_L = 2*2^L - 1
*/

typedef unsigned long long ull;
typedef struct {
    ull layer_num;
    ull patty_num;
} hamburger_data;


hamburger_data hamburger[MAX_LEVEL + 1];


void init_hamburger(int level) {
    if(level == 0) {
        hamburger[level].layer_num = 1;
        hamburger[level].patty_num = 1;
        return;
    }
    init_hamburger(level - 1);
    hamburger[level].layer_num = 2 * hamburger[level - 1].layer_num + 3;
    hamburger[level].patty_num = 2 * hamburger[level - 1].patty_num + 1;
}


hamburger_data eat_patty(int level, hamburger_data ret) {
    if(ret.layer_num == 0) {
        return ret;
    }
    if(ret.layer_num >= hamburger[level].layer_num) {
        ret.layer_num -= hamburger[level].layer_num;
        ret.patty_num += hamburger[level].patty_num;
        return ret;
    }
    ret.layer_num -= 1;

    ret = eat_patty(level-1, ret);

    if(ret.layer_num == 0) {
        return ret;
    }
    ret.layer_num -= 1;
    ret.patty_num += 1;

    ret = eat_patty(level-1, ret);

    if(ret.layer_num == 0) {
        return ret;
    }
    ret.layer_num -= 1;

    return ret;
}

int main() {
    int N;
    ull X;
    scanf("%d %lld", &N, &X);
    hamburger_data ret = {X, 0};
    init_hamburger(N);
    ret = eat_patty(N, ret);
    printf("%lld\n", ret.patty_num);
}

Measured memory_bytes: 128
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a,b,c
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) a,b,c
    do i=1,b
        if(mod(a*i,b)==c)then
            write(*,*)'YES'
            stop
        end if
    enddo

  
    write(*,*) 'NO'

  
    stop
end program sample
  



Measured memory_bytes: 2848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  // 通らない入力は来ない
  for (ll a = 1; a <= 200; ++a) for (ll b = -200; b <= 200; ++b) {
    if (pow_(a, 5) - pow_(b, 5) == n) {
      cout << a << " " << b << endl;
      return;
    }
  }
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 0119c
int n, a, b, c;
int l[10];
int ans = 1<<21;
void dfs(int A, int B, int C, int po, int index){
    if (index==n){
        if (A!=0 and B!=0 and C!=0) chmin(ans, abs(A-a) + abs(B-b) + abs(C-c) + po*10 - 30);
        return;
    }

    dfs(A+l[index], B, C, po+1, index+1);
    dfs(A, B+l[index], C, po+1, index+1);
    dfs(A, B, C+l[index], po+1, index+1);
    dfs(A, B, C, po, index+1);
}

int main(){
    cin >> n >> a >> b >> c;
    rep(i, n) cin >> l[i];
    dfs(0, 0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> pint;

const ll INF=1000100010001000;
vector<pint> vp[100001];
ll ds[100001];
bool used[100001];
int main(){
    ll n,m,l,r,d;
    cin>>n>>m;
    rep(i,m){
        cin>>l>>r>>d;
        --l,--r;
        vp[l].pb(mp(d,r));
        vp[r].pb(mp(-d,l));
    }
    rep(i,n) ds[i]=INF;
    rep(i,n){
        if(used[i]) continue;
        queue<ll> q;q.push(i);
        used[i]=true;ds[i]=0;
        while(!q.empty()){
            ll pi=q.front();q.pop();
            rep(i,vp[pi].size()){
                ll nx=vp[pi][i].second;
                if(!used[nx]){
                    used[nx]=true;
                    ds[nx]=ds[pi]+vp[pi][i].first;
                    q.push(nx);
                }
                else{
                    if(ds[nx]!=ds[pi]+vp[pi][i].first){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


  int dp[101][101];

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    string s;
    cin >> s;

    set<int> ss(s.begin(),s.end());

    if(s.size() == ss.size())
    {
      cout << "yes";
    }
    else
    {
      cout << "no";
    }


    return 0;   
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

const int INF = 1e18;

// idx, (未処理, 偶数左, 奇数, 偶数右)
const int VARI = 5;
int dp[200010][VARI];

signed main() {
  int N;
  cin >> N;
  vec<int> v(N);
  rep (i, N) {
    cin >> v[i];
  }

  const int one = 0; // 左のゼロ区間
  const int two = 1; // 右のゼロ区間
  const int three = 2; // 左の偶数区間
  const int four = 3; // 右の偶数区間
  const int five = 4; // 奇数区間

  // 初期化
  fill(dp[0], dp[N+1], INF);
  dp[0][one] = 0;
  dp[0][two] = 0;
  dp[0][three] = 0;
  dp[0][four] = 0;
  dp[0][five] = 0;

  // DP
  rep (i, N) {
    // 左のゼロ区間
    chmin(dp[i+1][one], dp[i][one] + v[i]);

    // 左の偶数区間
    int cost1 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][two], min(dp[i][two], dp[i][one]) + cost1);

    // 奇数
    int cost3 = 1 - (v[i] % 2);
    int mi = min({dp[i][two], dp[i][three], dp[i][one]});
    chmin(dp[i+1][three], mi + cost3);

    // 右の偶数区間
    int cost2 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][four], min({dp[i][three], dp[i][four], dp[i][one], dp[i][two]}) + cost2);


    // 未処理右
    int mi2 = min({dp[i][two], dp[i][four], dp[i][three], dp[i][five], dp[i][one]});
    chmin(dp[i+1][five], mi2 + v[i]);
  }

  int ans = INF;
  rep (i, VARI) {
    chmin(ans, dp[N][i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vi p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  int now = 0;
  int a, b;
  vi v;
  rep(i, n) v.push_back(i + 1);
  do {
    now++;
    bool sp = true, sq = true;
    rep(i, n) {
      if(p[i] != v[i]) sp = false;
      if(q[i] != v[i]) sq = false;
    }
    if(sp) a = now;
    if(sq) b = now;
  } while(next_permutation(all(v)));
  cout << abs(a - b) << endl;
}

Measured memory_bytes: 256