akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import io


def main():
    N = int( sys.stdin.readline() )

    XYU_list = []

    for _ in range(N):
        x,y,u = sys.stdin.readline().rstrip().split()
        XYU_list.append( [int(x),int(y),u] )


    diff = float("inf")

    for i in range(4):
        if i <= 1:  # do when we rotate matrix by 0, 90 degree
            ret = checkSafety_UD(XYU_list)
            diff = min(diff, ret)
        
        # do when we rotate matrix by 0, 90, 180, 270 degree
        ret = checkSafety_UR(XYU_list)
        diff = min(diff, ret)

        rotate(XYU_list)


    if diff != float("inf"):
        print( int(diff * 10) )
    else:
        print("SAFE")


def rotate(XYU_list :list):
    for i in range(len(XYU_list)):
        x,y,u = XYU_list[i][0], XYU_list[i][1], XYU_list[i][2]
        
        x2 = -y
        y2 = x
        
        if u == "U":  u2 = "L"
        if u == "D":  u2 = "R"
        if u == "L":  u2 = "D"
        if u == "R":  u2 = "U"
        
        XYU_list[i] = [x2,y2,u2]


def checkSafety_UD(XYU_list :list) -> int:
    check_UD = {}

    for x,y,u in XYU_list:
        if (u == "U") or (u == "D"):
            check_UD.setdefault( x , [] )
            check_UD[x].append( (y,u) )

    for key in check_UD:
        check_UD[key].sort()


    diff_min = float("inf")
    
    for arr in check_UD.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "U") and (arr[i+1][1] == "D"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) / 2 )

    return diff_min


def checkSafety_UR(XYU_list) -> int:
    check_UR = {}

    for x,y,u in XYU_list:
        if (u == "U") or (u == "R"):
            check_UR.setdefault( (x+y) , [] )
            check_UR[ (x+y) ].append( (x,u) )

    for key in check_UR:
        check_UR[key].sort()


    diff_min = float("inf")
    
    for arr in check_UR.values():
        for i in range(len(arr) - 1):
            if (arr[i][1] == "R") and (arr[i+1][1] == "U"):
                diff_min = min( diff_min, (arr[i+1][0] - arr[i][0]) )

    return diff_min


if __name__ == "__main__":
    main()


Measured memory_bytes: 99864
s=input()
q=int(input())
cnt=0
l=''
r=''
for i in range(q):
  k=input()
  if k[0]=='1':
    cnt+=1
  else:
    if k[2]=='1':
      if cnt%2==0:
        l=k[4]+l
      else:
        r+=k[4]
    elif k[2]=='2':
      if cnt%2!=0:
        l=k[4]+l
      else:
        r+=k[4]
if cnt%2==0:
  s=l+s+r
else:
  s=l+s+r
  s=s[::-1]
print(s)

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

public class Main {
	char temp;
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String str = sc.next();
		for(int i = 0; i < a; i++) {
			 temp = str.charAt(i);
			 if('0'>temp || temp >'9') {
				 System.out.println("No");
				 return;
			 }
		}
		if(str.charAt(a) != '-') {
			System.out.println("No");
			return;
		}
		for(int i = a+1; i <= a+b; i++) {
			 temp = str.charAt(i);
			 if('0'>temp || temp >'9') {
				 System.out.println("No");
				 return;
			 }
		}
		System.out.println("Yes");
		
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21972
#include <iostream>

int main(){

    int n = 0,y = 0;
    int k = 0;

    std::cin >> n >> y ;

    for (int a = 0; a <= n; a++ ){
        for(int b = 0; b <= n; b++ ) {
            int l = 0, c = 0;
            l = y - (10000 * a + 5000 * b) ;
            c = n - (a+b);
            if ( l / 1000 == c ){
                if( c < 0) continue;
                std::cout << a << " " << b << " " << c << std::endl; 
                return 0;
            }
        }
    }
    std::cout << "-1 -1 -1";

}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, d, sum, Q;
LL ans;
LL no;
bool b, bb[100001];
string s, t;
LL keta(LL a) {
	LL con = 0;
	while (a != 0) {
		a = a / 10;
		con++;
	}
	return con;
}
int main() {
	cin >> H >> W;
	for (LL i = 1; i <= W; i++) {
		if ((H*i) % W == 0) {
			cout << H*i << endl;
			return 0;
		}
	}
	cout << d << endl;
	return 0;
}



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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k; cin >> n >> k;
	ll a[n];
	for (int i = 0; i<n; i++) cin >> a[i];
	int ptr1 = 0;
	ll prod = 1;
	for (int i = 0; i<k; i++) prod *= a[i];
	for (int i = k; i<n; i++) {
		bool verdict = a[i] > a[ptr1];
		printVerdict(verdict);
		prod = prod / a[ptr1] * a[i];
		ptr1++;
	}
	
}



Measured memory_bytes: 5208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int a;
    while(~scanf("%d",&a))
    {
        if(a<3)
            printf("0\n");
        else
        {
            printf("%d\n",a/3);
        }
    }
    return 0;
}

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

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,m;
string a,b;
map<char,vi> pos;
double arr[200];
void solve()
{
	cin>>n;rep(i,0,n)cin>>arr[i];
	sort(arr,arr+n,greater<double>());
	stack<double> S;
	
	rep(i,0,n)S.push(arr[i]);
	
	while(S.size()!=1)
	{
		double x=S.top();S.pop();
		double y=S.top();S.pop();
		S.push((x+y)/2);
	}
	cout<<fixed<<setprecision(10)<<S.top();
	
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 256
/*   In The Name Of God   */
// Hunt...
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

#define sqr(A) (A) * (A)
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	string s;
	int ans;
	stack<char> t;
	cin >> s;
	ans = s.size();
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S')
			t.push(s[i]);
		if (!t.empty() && s[i] == 'T') {
			t.pop();
			ans -= 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
//#define int long long
using namespace std;

string hoge(string m, char c){
    int h = m.size() / 2;
    int sz = m.size();
    string res = "";
    if(c == 'J'){
        res = m[sz - 1] + m.substr(0, sz - 1);
    }else if(c == 'C'){
        res = m.substr(1, sz - 1) + m[0];
    }else if(c == 'E'){
        rep(i, 0, h){
            swap(m[i], m[(sz + 1) / 2 + i]);
        }
        res = m;
    }else if(c == 'A'){
        res = m;
        reverse(all(res));
    }else if(c == 'P'){
        rep(i, 0, sz){
            int tmp = m[i] - '0';
            if(0 < tmp && tmp <= 9) m[i] = '0' + tmp - 1;
            else if(tmp == 0) m[i] = '9';
        }
        res = m;
    }else if(c == 'M'){
        rep(i, 0, sz){
            int tmp = m[i] - '0';
            if(0 <= tmp && tmp < 9) m[i] = '0' + tmp + 1;
            else if(tmp == 9) m[i] = '0';
        }
        res = m;
    }
    return res;
}

signed main(){
    int n;
    cin >> n;
    rep(x, 0, n){
        string s, m;;
        cin >> s >> m;
        repb(i, s.size() - 1, 0){
            m = hoge(m, s[i]);
        }
        cout << m << endl;
    }
}

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

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

    string s;
    cin >> s;

    int l = 0;
    for(int i = 0; i < (int)s.size(); i++){
        l += (s[i] == 'x');
    }

    if(l > 7){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int n;
vector<ll> a;
ll dp[3005][3005];

int main(){
    cin>>n;
    a.resize(n);
    rep(i,n) cin>>a[i];
    for(int bit = 0; bit < n; bit++) {
        for(int l = 0; l + bit < n; l++) {
            int r = l + bit;
            if((n+l+r)%2==1){
                dp[l][r]=max(a[l]+dp[l+1][r],a[r]+dp[l][r-1]);
            }
            else{
                dp[l][r]=min(-a[l]+dp[l+1][r],-a[r]+dp[l][r-1]);
            }
        }
    }

    cout<<dp[0][n-1]<<endl;
    return 0;
}

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

map<char, int> mp;
char str[100];
int main(){
	scanf("%s", str);
	int n = strlen(str);
	for(int i = 0;i < n;i++){
		if(mp[str[i]] == 1){
			printf("no\n");
			return 0;
		}
		mp[str[i]]++;
	}
	printf("yes\n");
	return 0;
}

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

int y1_no_z1_jou(int y1, int z1)
{
	int sumjoujou = 1;
	for (int i3 = 0; i3 < z1; ++i3) {
		sumjoujou *= y1;
	}
	return sumjoujou;
}

int getmp(int upto, int check) {
	int c_maxp = 0;
	for (int i1 = 2; c_maxp * check <= upto; ++i1) {
		c_maxp = y1_no_z1_jou(check, i1);
	}
	return c_maxp;
}

int main()
{
	int x;
	cin >> x;
	int maxb = sqrt(x);
	int max_power = 1;
	for (int i = maxb; i > 2; --i) {
		int comp = getmp(x, i);
		if (max_power < comp) {
			max_power = comp;
		}
	}
	cout << max_power;
}

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

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		StringBuilder sb = new StringBuilder();
		ArrayList<String> dis = new ArrayList<String>();
		while(true){
			str = br.readLine();
			if(str.equals("-")) break;
			int h = Integer.parseInt(br.readLine());
			for(int i=0 ;i<h ;i++){
				int c = Integer.parseInt(br.readLine());
				sb.append(str);
				str = sb.substring(0,c);
				sb.delete(0,c);
				str = sb.append(str).toString();
				sb.setLength(0);
			}
			dis.add(str);
		}
		for(String s : dis){
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 16888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

long long n, maxW;
int dp[3003][3003];
string s, t;

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

void printSol(int indexS, int indexT)
{
    if(indexS == s.size() || indexT == t.size())
        return;
    if(s[indexS] == t[indexT])
    {
        cout << s[indexS];
        printSol(indexS + 1, indexT + 1);
        return;
    }
    int ans1 = solve(indexS + 1, indexT);
    int ans2 = solve(indexS, indexT + 1);
    if(ans1 > ans2)
        printSol(indexS + 1, indexT);
    else
        printSol(indexS, indexT + 1);
}

int main()
{
    IO;
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    solve(0, 0);
    printSol(0, 0);
    return 0;
}


Measured memory_bytes: 35968
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
using ll = long long;
ll intmax = 100000000000000000;
ll dist(ll sup, ll sdown, ll tup, ll tdown)
{
    // cout << sup << " " << sdown << " " << tup << " " << tdown << " " << endl;
    return min(
        min(
            min(
                max(sdown, tdown),
                max(sup, tup)),
            min(sup, tdown) + sup + tdown),
        min(tup, sdown) + tup + sdown);
}
ll solve(vector<ll> &s, vector<ll> &t, ll x)
{
    auto sit = lower_bound(s.begin(), s.end(), x);
    auto tit = lower_bound(t.begin(), t.end(), x);
    auto spos = sit - s.begin();
    auto tpos = tit - t.begin();
    return dist((spos - 1 >= 0) ? x-s[spos - 1] : intmax,
                (sit==s.end())? intmax : s[spos]-x,
                (tpos - 1 >= 0) ? x-t[tpos - 1] : intmax,
                (tit==t.end())? intmax : t[tpos]-x);
}
int main()
{
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B), x(Q);
    for (int i = 0; i < A; i++)
        cin >> s[i];
    for (int i = 0; i < B; i++)
        cin >> t[i];
    for (int i = 0; i < Q; i++)
        cin >> x[i];
    for (int i = 0; i < Q; i++)
        cout << solve(s, t, x[i]) << endl;
}

Measured memory_bytes: 3712
tbl1 = {
  " " => "101",
  "'" => "000000",
  "," => "000011",
  "-" => "10010001",
  "." => "010001",
  "?" => "000001",
  "A" => "100101",
  "B" => "10011010",
  "C" => "0101",
  "D" => "0001",
  "E" => "110",
  "F" => "01001",
  "G" => "10011011",
  "H" => "010000",
  "I" => "0111",
  "J" => "10011000",
  "K" => "0110",
  "L" => "00100",
  "M" => "10011001",
  "N" => "10011110",
  "O" => "00101",
  "P" => "111",
  "Q" => "10011111",
  "R" => "1000",
  "S" => "00110",
  "T" => "00111",
  "U" => "10011100",
  "V" => "10011101",
  "W" => "000010",
  "X" => "10010010",
  "Y" => "10010011",
  "Z" => "10010000"
}

tbl2 = {
  "00000" => "A",
  "00001" => "B",
  "00010" => "C",
  "00011" => "D",
  "00100" => "E",
  "00101" => "F",
  "00110" => "G",
  "00111" => "H",
  "01000" => "I",
  "01001" => "J",
  "01010" => "K",
  "01011" => "L",
  "01100" => "M",
  "01101" => "N",
  "01110" => "O",
  "01111" => "P",
  "10000" => "Q",
  "10001" => "R",
  "10010" => "S",
  "10011" => "T",
  "10100" => "U",
  "10101" => "V",
  "10110" => "W",
  "10111" => "X",
  "11000" => "Y",
  "11001" => "Z",
  "11010" => " ",
  "11011" => ".",
  "11100" => ",",
  "11101" => "-",
  "11110" => "'",
  "11111" => "?"
}

while (line = gets)
  chs = line.chomp.split("")

  str0 = ""
  for ch in chs
    str0 += tbl1[ch]
  end

  rem = str0.length % 5
  str0 += "0" * (5 - rem) if rem > 0

  str1 = ""
  str0.scan(/[01]{5}/).each do |b|
    str1 += tbl2[b]
  end
  puts str1
end

Measured memory_bytes: 6408
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int r, g, b, n,ans=0;
	cin >> r >> g >> b >> n;
	rep(i,(n / r)+1) {
		rep(j, (n / g)+1) {
			if ((n - r * i - g * j) % b == 0&& n - r * i - g * j>=0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  int x,a;
  cin >> x >> a;
  if(x < a){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, float("inf"))

dp = [float("inf")] * (N + 1)
dp[1] = 0

for i in range(2, N + 1):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]))
        else:
            break

print(dp[N])

Measured memory_bytes: 57184
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;


int main() {
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1 == 0){
        cout << 1 << endl;
        return 0;
    }
    if(x2 == 0){
        cout << 2 << endl;
        return 0;
    }
    if(x3 == 0){
        cout << 3 << endl;
        return 0;
    }
    if(x4 == 0){
        cout << 4 << endl;
        return 0;
    }
    if(x5 == 0){
        cout << 5 << endl;
        return 0;
    }
}


Measured memory_bytes: 3188
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var C = 0;
            var j = 0;
            var b = true;

            int[] s = cin.ReadIntArray(N);
            

            while (b)
            {


                for (var i = 0; i < N; i++)
                {

                    
                    if ((s[i] % 2 == 0)&&(s[i]!=0))
                    {
                        j++;
                    }
                }
                if (j == N)
                {
                    C++;
                    j = 0;
                    for(var i = 0; i < N; i++)
                    {
                        s[i] = s[i] / 2;
                    }

                }else if(j!=N){
                    b = false;
                    break;
                }
                
            }
            WriteLine(C);
            
            
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
	
int partition(int *a, int p, int r){
	int x = a[r];
	int i = p-1;
	int j;
	int tmp;
	for(j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
	}
	tmp = a[i+1];
	a[i+1] = a[r];
	a[r] = tmp;
	return i+1;
}

int main(){
	int i;
	int q;
	int n;
	cin >> n;
	int a[n];
	rep(i, n) scanf("%d", &a[i]);
	q = partition(a, 0, n-1);
	rep(i, n){
		if(i!=0) printf(" ");
		if(i==q)printf("[");
		cout << a[i];
		if(i==q)printf("]");
	}
	cout << endl;
}



Measured memory_bytes: 3524
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean flag = true;
        for(int i = 0; i <= s.length() / 2; i++){
            char c = s.charAt(i);
            char cc = s.charAt(s.length() - 1 - i);
            switch(c){
                case 'p':
                    if(cc != 'q') flag = false;
                    break;
                case 'q':
                    if(cc != 'p') flag = false;
                    break;
                case 'b':
                    if(cc != 'd') flag = false;
                    break;
                case 'd':
                    if(cc != 'b') flag = false;
                    break;
            }
        }
        String ans = flag? "Yes" : "No";
        System.out.println(ans);
    }
}

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

int main(){
  string s;
  cin >> s;
  if(s == "ABC")cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3628
def print_ans(s):
    """Print substring of s, odd_th char

    Parameters
    --------------
    Examples
    >>> print_ans("a")
    a
    >>> print_ans("ab") 
    a
    >>> print_ans("aibc")
    ab

    """
    for i in range(0,len(s),2):
        print(s[i],end="")

if __name__ == '__main__':
    s = input()
    print_ans(s)



Measured memory_bytes: 47192
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
const int MAX=2e5+5;

vi nb[MAX];
bool vs[MAX];

P dfs(int v, int d){
  	vs[v]=true;
	int l=sz(nb[v]);
	int mv=v;
	int md=d;
	rep(i,l){
		int u=nb[v][i];
		if(vs[u])continue;
		P p=dfs(u,d+1);
		int pd=p.second;
		int pv=p.first;
		if(pd>md){
			mv=pv;
			md=pd;
		}
	}
	P q=make_pair(mv,md);
	return q;
}

int main(){
	int N;
	cin>>N;
	rep(i,N-1){
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		nb[u].push_back(v);
		nb[v].push_back(u);
	}
	
	rep(i,N)vs[i]=false;
	P p=dfs(1,0);
//  	cout<<p.first<<" "<<p.second<<endl;
	int v=p.first;
	rep(i,N)vs[i]=false;
	p=dfs(v,0);
//  	cout<<p.first<<" "<<p.second<<endl;
	int d=p.second;
	
	if(d%3==1) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
}

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

int main() {
    string s;
    cin >> s;
    int r, l;
    l = stoi(s) / 100;
    r = stoi(s) % 100;

    if (1 <= l & l <= 12 & r <= 12 & 1 <= r) cout << "AMBIGUOUS" << endl;
    else if (r <= 12 & 1 <= r) cout << "YYMM" << endl;
    else if (1 <= l &l <= 12)  cout << "MMYY" << endl;
    else  cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int,int> p;
     
     
    int main(void)
    {
      int n, m;
      cin >> n >> m;
      vector<int> a(m, 0);
      vector<int> b(m, 0);
      vector<int> count(n, 0);
      for (int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        count[a[i]-1]++;
        count[b[i]-1]++;
      }
     
      for(int i: count){
        cout << i << endl;
      }
     
     
      return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)


class UnionFind{

private:
    vector<int> rank,p;

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

  public:
      UnionFind(){};
      UnionFind(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i = 0; i < size; i++){
          makeSet(i);
        }
      }

    bool same(int x, int y){
      return  find(x) == find(y);
    }

    void unite(int x, int y){
      link(find(x), find(y));
    }

    int find(int x){
      if(x != p[x]) p[x] = find(p[x]);
      return p[x];
    }

private:
    void link(int x, int y){
      if(rank[x] > rank[y]){
        p[y] = x;
      }else{
        p[x] = y;
        if(rank[x] == rank[y]) rank[y]++;
      }
    }

};




int main(){
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i,n)cin >> p[i],p[i]--;

    UnionFind uf = UnionFind(n);

    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        uf.unite(a,b);
    }

    vector<vector<int> > v(n);
    rep(i,n){
        v[uf.find(i)].push_back(i);
    }

    int ans = 0;

    rep(i,n){
        int a[100000] = {};
        rep(j,v[i].size()){
            a[p[v[i][j]]]++;
        }
        rep(j,v[i].size()){
            if(a[v[i][j]]) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 7296
#include<iostream>

using namespace::std;

int main(int) {
  int D;
  cin >> D;
  if (D == 25) cout << "Christmas";
  else if(D == 24) cout << "Christmas Eve";
  else if(D == 23) cout << "Christmas Eve Eve";
  else if(D == 22) cout << "Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int sum = 0;
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      sum += a[i];
    }
    int minDiff = 1000000000;
    int minDiffIdx = 0;
    for (int i = 0; i < N; i++) {
      int diff = Math.abs(a[i]*N-sum);
      if (minDiff > diff) {
        minDiff = diff;
        minDiffIdx = i;
      }
    }
    System.out.println(minDiffIdx);
  }
}

Measured memory_bytes: 21844
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int,input().split()))
L = [i for i in range(0,102) if i not in P]

if X in L:
    ANS = X
else:
    L.append(X)
    L = sorted(L)
    n = L.index(X)
    if (L[n+1]-L[n] < L[n] - L[n-1]):
        ANS = L[n+1]
    else:
        ANS = L[n - 1]

print(ANS)

Measured memory_bytes: 9244
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> dat(n);
    for (int i = 0; i < n; i++)
    {
        cin >> dat[i].first >> dat[i].second;
    }
    sort(dat.begin(), dat.end());
    bool ok = false;
    for (int i = 0; i < n; i++)
    {
        if (dat[i].second <= t)
        {
            cout << dat[i].first << endl;
            ok = true;
            break;
        }
    }
    if (!ok)
        cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    int w[n];
    rep(i,n) cin >> w[i];
    int sum1 = 0;
    int sum2 = 0;
    int ans = 0 , value = 10000;
    for(int i=0;i<n;i++){
        sum1 += w[i];
        sum2 = 0;
        for(int j=i+1;j<n;j++){
            sum2 += w[j];
        }
        ans = abs(sum2-sum1);
        if(ans < value){
            value = ans;
        }
    }
    cout << value << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {


	int n;
	scanf("%d", &n);

	if (n / 100 == 9) {
		n = n % 100 + 100;
	}
	else if (n / 100 == 1) {
		n = n % 100 + 900;
	}
	if ((n / 10)%10 == 9) {
		n = n -90 + 10;
	}
	else if ((n / 10) % 10 == 1) {
		n = n - 10 + 90;
	}
	if (n  % 10 == 9) {
		n -= 8;
	}
	else if (n % 10 == 1) {
		n +=8;
	}
	printf("%d", n);
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for(int i = 0; i < N; i++)
            a[i] = sc.nextInt();
        for(int i = 0; i < N; i++)
            b[i] = sc.nextInt();
        sc.close();
        long sum1 = 0;
        long sum2 = 0;
        for(int i = 0; i < N; i++){
            if(a[i] > b[i]){
                sum1 += (a[i]-b[i]);
            } else {
                sum2 += (b[i]-a[i])/2;
            }
        }
        if(sum1 <= sum2)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}

Measured memory_bytes: 42540
#include <iostream>
#include <cstdio>
#include <iterator>
#include <algorithm>
#include <map>
#include <string>
#include <vector>

using namespace std;



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

  int n; cin >> n;
  if(n % 2 != 0){
    cout << n/2 + 1;
  }else{
    cout << n/2;
  }
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
#import math
# from itertools import product, accumulate, combinations, product
import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())


def run():
    N, *A = mapread()
    A.sort()
    i = bisect.bisect_right(A, -EPS)
    cache = []
    if i <= N-1:
        if i < 1:
            i = 1
        ans = A[i-1]
        for k in range(i, N-1):
            cache.append((ans, A[k]))
            ans -= A[k]
        cache.append((A[N-1], ans))
        ans = A[N-1] - ans
        for k in range(0, i-1):
            cache.append((ans, A[k]))
            ans -= A[k]
        print(ans)
        for x, y in cache:
            print(f'{x} {y}')
    elif i > N-1:
        ans = A[-1]
        for i in range(N-1):
            cache.append((ans, A[i]))
            ans -= A[i]
        print(ans)
        for x, y in cache:
            print(f'{x} {y}')


if __name__ == "__main__":
    #print(math.gcd(0, 10))
    run()


Measured memory_bytes: 23200
import sys

input = sys.stdin.readline

P = 2019

def main():
    S = input().rstrip()

    n = len(S)
    counts = [0] * P
    counts[0] += 1
    T = 0
    d = 1
    for s in reversed(S):
        T = (T + (d * int(s)) % P) % P
        d = (d * 10) % P
        counts[T] += 1

    ans = 0
    for c in counts:
        ans += c*(c-1)//2  # cC2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9352
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;


int main() {

	int K, X;
	cin >> K >> X;
	if (K * 500 >= X) cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  char a,b;cin >> a >> b;
  if(a<b){
    cout << '<' << endl;
  }else if(a==b){
    cout << '=' << endl;
  }else{
    cout << '>' << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int min = 1001;
      
      for(int i=0;i<N;i++){
        int c = sc.nextInt();  int t = sc.nextInt();
        if(t<=T){min = Math.min(c,min);}
      }
      if(min==1001){System.out.println("TLE");}
      else{System.out.println(min);}
    }
}

Measured memory_bytes: 22996
h, w = map(int, input().split())
A = [[] for _ in range(h)]
for i in range(h):
    A[i] = list(input())
flag = True
while flag:
    flag = False
    for i, a in enumerate(A):
        if not '#' in a:
            flag = True
            A.pop(i)
            break
    for j in range(len(A[0])):
        a = []
        for i in range(len(A)):
            a.append(A[i][j])
        if not '#' in a:
            flag = True
            for i, a in enumerate(A):
                A[i].pop(j)
            break
for a in A:
    temp = ''.join(a)
    print(temp)

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

int n, m;
int a[56], b[56];
int graph[9][9];

bool seen[9];
int ans = 0;

void dfs(int node) {
    for (int i = 1; i <= n; i++) {
        if (!seen[i]) break;
        if (i == n) {
            ans++;
            return;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (graph[node][i] == 1 && !seen[i]) {
            seen[i] = true;
            dfs(i);
            seen[i] = false;
        }
    }
}

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

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) graph[i][j] = 0;
    }
    for (int i = 0; i < m; i++) {
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }

    for (int i = 1; i <= n; i++) seen[i] = false;
    seen[1] = true;
    dfs(1);

    cout << ans << endl;
}


Measured memory_bytes: 3644
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
var n=Arr.shift()-0;
for(var i=0;i<n;i++){
    var arr=Arr[i].split(" ").map(Number);
    var s=arr[0];
    var g=arr[1];
    var ans=[s];
    var plus=1;
    if(s<g){
        do{
            s++;
            ans.push(s);
        }while(s!=g)
    }
    else if(s>g && s<=5){
        do{
            s--;
            ans.push(s);
        }while(s!=g)
    }
    else if(s>g && s>=6){
        do{
            s+=plus;
            if(s==10){
                s=5;
                plus=-1;
                
            }
            if(s==0){
                plus=1;
            }
            ans.push(s);
        }while(s!=g);
    }
    console.log(ans.join(" "));
}



Measured memory_bytes: 15120
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
 int count=0;
int l,r,d,i;
  cin>>l>>r>>d;
  for( i=l;i<=r;i++)
  {
    if(i%d==0)
      count++;
  }
cout<<count;
 return 0;
}
  


Measured memory_bytes: 3564
main :: IO ()
main = do
  [s1,s2,t1,t2] <- map (read . (:[])) <$> getLine :: IO [Int]
  putStrLn $ solve (s1*10+s2) (t1*10+t2)

solve :: Int -> Int -> String
solve x y
  | (x == 0 || x >= 13) && (y >= 1 && y <= 12) = "YYMM"
  | (y == 0 || y >= 13) && (x >= 1 && x <= 12) = "MMYY"
  | (x >= 1 && x <= 12) && (y >= 1 && y <= 12) = "AMBIGUOUS"
  | otherwise = "NA"


Measured memory_bytes: 508
#include <iostream>

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b&&b==c&&c==a)cout << "No" << endl;
	else if(a==b||b==c||c==a)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;

    int d[100];
    rep(i, n){
        cin >> d[i];
    }

    sort(d, d+n);

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

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

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans;

    if (N > K) N %= K;
    ans = min(N, K - N);
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<list>
using namespace std;

int main() {

	int N;
	cin >> N;

	if (N % 2 == 0) {
		cout << N << endl;
	}
	else {
		cout << 2 * N << endl;
	}

	return 0;
}


Measured memory_bytes: 256
while True:
    n = input()
    if n == 0: break
    P = set(tuple(map(int, raw_input().split())) for i in range(n))
    ans = 0
    for xi, yi in P:
        for xj, yj in P:
            q = (xj - yj + yi, yj + xj - xi)
            r = (xi - yj + yi, yi + xj - xi)
            if q in P and r in P:
                ans = max(ans, pow(xi - xj, 2) + pow(yi - yj, 2))
    print ans

Measured memory_bytes: 5256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
#include <inttypes.h>

int LCS(std::string s,std::string t){
    int n,m,c[1001][1001]={0};
    n=s.size();
    m=t.size();
    int maxlen=0;
    for(int i=1;i<=n;i++){
        c[i][0]=0; 
    }
    for(int i=1;i<=m;i++){
        c[0][i]=0;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=std::max(c[i-1][j],c[i][j-1]);
            }
            maxlen=std::max(maxlen,c[i][j]);
        }
    }
    return maxlen;
}
int main(){
	int N;
    
    std::cin >> N;
    std::string s1,s2;
    for(int i=0;i<N;i++){
        std::cin >> s1 >> s2;
        std::cout << LCS(s1,s2) <<std::endl;
    }
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  rep(i, S.size()){
    S.at(i) = 'x';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    rep2(i,1,n-1){
        int min_n = min({p[i-1],p[i],p[i+1]});
        int max_n = max({p[i-1],p[i],p[i+1]});
        if ( (p[i]!=min_n) && (p[i]!=max_n)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

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

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 2e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 127;
const int inf = 2e9;

int n;

void read() {
    cin >> n;
}

void solve() {
    set<int> ans;
    for (int i = 2; i * i <= n; ++i) {
        int x;
        for (x = 1; n % (x * i) == 0; x *= i);

        if (n / x % i == 1) {
            ans.insert(i);
        }

        if (i * i != n) {
            for (x = 1; n % (x * n / i) == 0; x *= (n / i));

            if (n / x % i == 1) {
                ans.insert(n / i);
            }
        }
    }
    for (int i = 2; i * i <= n - 1; ++i) {
        if ((n - 1) % i == 0) {
            ans.insert(i);
            if (i * i != n - 1) {
                ans.insert(n / i);
            }
        }
    }
    cout << ans.size() + 1 + (n > 2);
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
c_ = [list(map(int,input().split())) for i in range(n)]

# print(c_)
cc_ = []
for i in range(n):
    cc_.append(c_[i][0])
# print(cc_)

import numpy as np
import itertools
l_ = np.arange(n).tolist()

res_ = []
resList = []
flag = False
flag3 = True
if n == 1:
    for i in range(m):
        if c_[0][i+1] < x:
            # print(c_[0][i+1])
            flag3 = False
    print(cc_[0] if flag3 else -1)
else:
    for i in range(1,n+1):
        c = list(itertools.combinations(l_, i))
        for j in c:
            res_ = []
            flag2 = True
            for l in range(m):
                res = 0
                sum_money = 0
                for k in range(len(j)):
                    res += c_[j[k]][l+1]
                    sum_money += c_[j[k]][0]
                # print(res,sum_money)
                if res < x:
                    flag2 = False
            if flag2:
                resList.append(sum_money)
                flag = True
    # print(resList)
    print(min(resList) if flag else -1)


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int a,b;
  cin >> a >> b;
  if(a * 500 >= b) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

int main()
{
	int n, d, a;
	cin >> n >> d >> a;

	vector<pair<int,int>> v(n);
	for (auto& i : v) {
		cin >> i.first >> i.second;
	}

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

	long long ret = 0;
	int sum = 0;
	queue<pair<int, int>> q;
	for (int i = 0; i < n; ++i)
	{
		while (!q.empty()) {
			pair<int,int>& f = q.front();
			if (f.first < v[i].first) {
				sum -= f.second;
				q.pop();
			}
			else {
				break;
			}
		}

		v[i].second -= sum;
		if (0 < v[i].second) 
		{
			int num = (v[i].second + a - 1) / a;
			ret += num;
			int dmg = num * a;
			sum += dmg;
			q.push(pair<int,int>(v[i].first + 2 * d, dmg));
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 2688