akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m;
    double res=0;
    double p=0.5;
    cout<<(m*1900+100*(n-m))*pow(2,m);
    return 0;
}




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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C'){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
input_data = gets.chomp
s = input_data.to_i
while s != 0 do 
    #21 x 21の２次元配列
    gems = Array.new(21).map{Array.new(21, false)}
    # p gems
    
    s.times do
        g = gets.chomp.split(" ")
        x = g[0].to_i
        y = g[1].to_i
        gems[x][y] = true
    end
    
    input_data = gets.chomp
    r = input_data.to_i
    
    rx = 10
    ry = 10
    
    r.times do
        g = gets.chomp.split(" ")
        news = g[0]
        move = g[1].to_i
        dx = 0
        dy = 0
        if news == 'N'
            dy = 1
        elsif news == 'E'
            dx = 1
        elsif news == 'S'
            dy = -1
        else 
            dx = -1
        end
        move.times do
            rx += dx
            ry += dy
            gems[rx][ry] = false
        end
    end
    
    flag = false
    
    gems.each do |v|
        v.each do |vv|
            if vv
                flag = true
                break
            end
        end
        break if flag 
    end
    
    if flag 
        puts 'No'
    else 
        puts 'Yes'
    end
    input_data = gets.chomp
    s = input_data.to_i
end



Measured memory_bytes: 7000
//IN THE NAME OF LORD
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int              long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             9e18
#define ALL(a)          a.begin(),a.end()
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
int md = 1e9+7;
int add(int a,int b){
    return ((a*b)%md+md)%md;
} 
int mul(int a,int b){
    return ((a+b)%md+md)%md;
} 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
vi g[100005];
int dp[100005][2];
int n;
int color(int src,int par,int c){
    if(dp[src][c]!=-1)
        return dp[src][c];
    dp[src][c]=1;
    for(int i:g[src]){
        if(i==par)
            continue;
        if(c==1)
            dp[src][c] = add(dp[src][c],color(i,src,0));
        else
            dp[src][c] = add(dp[src][c],mul(color(i,src,1),color(i,src,0)));
    }
    
    return dp[src][c];
}
int32_t main()
{
    c_p_c();
    cin>>n;

    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
       
    }
    for(int i=0;i<=n;i++)
        dp[i][0]=dp[i][1]=-1;
    int start=1;
  /*  for(int i=1;i<=n;i++){
        if(g[i].size()==1){
            start=i;
            break;
        }
    }*/
    cout<<mul(color(start,0,0),color(start,0,1));
    

 //cerr << "proc time: " << 1.0 * clock() / CLOCKS_PER_SEC << "s    ";
    return 0;
        
}


Measured memory_bytes: 18936
# -*- coding: utf-8 -*-

import sys
from collections import Counter
from copy import copy

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
D=LIST()

L=[0]

C=Counter(D)
S=[]
for k, v in C.items():
    if v>=3:
        print(0)
        exit()
    elif v>=2:
        L.append(k)
        L.append(24-k)
    else:
        S.append(k)

mx=0
for i in range(1<<len(S)):
    L2=copy(L)
    for j in range(len(S)):
        if i>>j&1:
            L2.append(S[j])
        else:
            L2.append(24-S[j])
    L2.sort()
    L2=L2+[l+24 for l in L2]
    mn=INF
    for i in range(1, len(L2)):
        mn=min(mn, abs(L2[i-1]-L2[i])%24)
    mx=max(mx, mn)
print(mx)


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

using namespace std;
int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    if (((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d)) cout<<"Yes"; else cout<<"No";
    return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int p[5005], c[5005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i=0; i<n; i++)
        cin >> c[i];

    long long ret = LLONG_MIN;
    for (int i=0; i<n; i++) {
        int u = i;
        vector<long long> path{0};
        do {
            u = p[u];
            path.push_back(path.back() + c[u]);
        } while (u != i);
        if (k / int(path.size() - 1) > 0) {
            if (path.back() > 0)
                ret = max(ret, max(path.back() * (k / int(path.size() - 1)) + *max_element(path.begin(), path.begin() + k % int(path.size() - 1) + 1),
                          path.back() * (k / int(path.size() - 1) - 1) + *max_element(path.begin() + (k / int(path.size() - 1) - 1 == 0), path.end())));
            else if (path.back() == 0)
                ret = max(ret, *max_element(path.begin(), path.end()));
            else
                ret = max(ret, *max_element(path.begin() + 1, path.end()));
        } else {
            ret = max(ret, *max_element(path.begin() + 1, path.begin() + k + 1));
        }
    }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 3724
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int t=sc.nextInt();
			if(t==0)break;
			int n=sc.nextInt();
			for(int i=0;i<n;i++){
				int s=sc.nextInt();
				int f=sc.nextInt();
				t-=(f-s);
			}
			if(t<=0)System.out.println("OK");
			else System.out.println(t);
		}
	}
}
			

Measured memory_bytes: 23568
#include <cstdio>
#include <cstdlib>
#include <queue>

template<typename T>
class TBinaryHeap
{
    std::vector<T> FArray;
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const T& Value)
    {
        std::size_t Index = FArray.size();
        FArray.push_back(Value);
        while(Index > 1){
            std::size_t Parent = Index / 2;
            if(FArray[Index] < FArray[Parent]) break;
            std::swap(FArray[Index], FArray[Parent]);
            Index = Parent;
        }
    }
    void pop()
    {
        FArray[1] = FArray.back();
        FArray.pop_back();

        std::size_t Size = FArray.size();
        std::size_t Index = 1;
        while(Index < Size){
            std::size_t Left = Index * 2;
            std::size_t Right = Left + 1;
            if(Left >= Size) break;
            std::size_t Target = Right >= Size ? Left : FArray[Left] > FArray[Right] ? Left : Right;
            if(FArray[Target] <= FArray[Index]) break;
            std::swap(FArray[Index], FArray[Target]);
            Index = Target;
        }
    }
    const T& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap<int> S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6252
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var n = int.Parse(Console.ReadLine());
		var a = read();
		var b = read();
		var ab = a.Zip(b, (x, y) => new { x, y }).OrderBy(_ => _.y).ThenBy(_ => _.x).ToArray();
		b = ab.Select(_ => _.y).ToArray();

		if (a.OrderBy(x => x).Where((x, i) => x > b[i]).Any()) { Console.WriteLine("No"); return; }

		int c = 0, k = 0;
		for (; c == 0 || k > 0; c++)
			if ((k = Array.BinarySearch(b, ab[k].x)) < 0) k = ~k;
		Console.WriteLine(c != n ? "Yes" : "No");
	}
}


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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end();

ll gcd(ll a, ll b){
   if(b == 0) return a;
   
   return gcd(b, a % b);
}

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}
using namespace std;


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

   int a,b; cin >> a >> b;
   int ans;
   int aux;
   if(a == b){
      ans = a+b;
   }else if(a > b){
      ans = a;
      a--;
      if(a >= b) ans += a;
   }else{
      ans = b;
      b--;
      if(b >= a) ans += b;
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

char page[5][6] = {
  {'a','f','k','p','u','z'},
  {'b','g','l','q','v','.'},
  {'c','h','m','r','w','?'},
  {'d','i','n','s','x','!'},
  {'e','j','o','t','y',' '}  
};


class AOJ0127{
private:
  string code;
public:

  explicit AOJ0127(string code):code(code){}

  string decode(){
    if((int)code.size()%2 != 0)return "NA";
    rep(i,code.size()){
      if(i%2 == 0){
	if(!('1' <= code[i] && code[i] <='6' ))return "NA";
      }
      else{
	if(!('1' <= code[i] && code[i] <='5' ))return "NA";
      }
    }
    string res;
    for(int i=0;i<code.size();i+=2){
      res += page[(code[i+1]-'0')-1][(code[i]-'0')-1]; 
    }
    return res; 
  }
    
};

int main(){
  string s;
  while(cin >> s){
    AOJ0127 ans(s); 
    cout << ans.decode() << endl;
  }
return 0;
}

Measured memory_bytes: 1200
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

int n, q;
vector<vector<int>> g;
vector<int> v;

void dfs(int p, int tot, int now)
{
	v[now] += tot;
	for (int next : g[now])
	{
		if (next == p)continue;
		dfs(now, v[now], next);
	}
}

int main()
{
	cin >> n >> q;
	g.resize(n + 1);
	v.resize(n + 1, 0);
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i, q)
	{
		int p, x; cin >> p >> x;
		v[p] += x;
	}
	dfs(0, 0, 1);
	for (int i = 1; i <= n; ++i)cout << v[i] << " ";
}

Measured memory_bytes: 23424
import numpy as np

a, b, x = map(int, input().split())
if(x >= 0.5*a*a*b):
  t_theta = (2*b)/a - (2*x)/a**3
  print ((180 * np.arctan(t_theta)) / np.pi)
else:
  t_theta = (a*b*b) / (2*x)
  print ((180 * np.arctan(t_theta)) / np.pi)

Measured memory_bytes: 12908
#include<bits/stdc++.h>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define all(n) (n).begin(),(n).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	ll  x = c-a-b;

	if( x > 0  &&  x * x > 4LL * a * b )
		cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3584
using System;

namespace A___On_the_Way
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ');
            var A = int.Parse(read[0]);
            var B = int.Parse(read[1]);
            var C = int.Parse(read[2]);

            if((A <= C && C <= B)||(A >= C && C >= B)) 
            {
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


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

int main(){
	int n,k;
	cin >> n >> k;
	vector<ll> x(n);
	rep(i,n) cin >> x[i];

	ll ans = 1000000000;
	rep(i,n-k+1){
		ll t;
		ll l = abs(x[i]);
		ll r = abs(x[i+k-1]);
		if(x[i]*x[i+k-1] > 0){
			t = max(l,r);
		}else{
			t = min(2*l+r, l+2*r);
		}
		if(t < ans) ans = t;
	}

	cout << ans << endl;

	return 0;
}

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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 2e5 + 10;
const int M = (int) 2e6 + 10;
const int K = (int) 20;
const int INF = (int) 1e9 + 7;
const int mod = (int) 998244353;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;

int W, H, w, h;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> W >> H >> w >> h;
	for (ll x = 0; x <= 5e7; x++) {
		ll pt = -(w * h - 1) * x - 1; 
		ll negatives = (W / w) * (H / h);
		ll total_sum = (W * H - negatives) * x + negatives * pt;
		if (total_sum > 0) {
			cout << "Yes\n";
			for (int i = 1; i <= W; i++) {
				for (int j = 1; j <= H; j++) {
					if (i % w == 0 && j % h == 0) {
						cout << pt << ' ';
					} else {
						cout << x << ' ';
					}
				}
				cout << endl;
			}
			exit(0);
		}
	}
	cout << "No";
	return 0;	
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;


public class Main {
//	入力値
	static Scanner scInputData = new Scanner(System.in);
//	座標情報を保持する
	
//	配列
	static ArrayList<Coordinate> arrCoordinate = new ArrayList<Coordinate>();
	
	public static void main(String[] args) {
		
//		必要なパラメータを用意する処理
//		座標を取得する処理
		getCoordinate();
//		座標を(x, y)順でソートする処理
		compareCoordinate();
//		結果を出力する処理
		putResult();
	}
	
	private static void putResult() {
		for(Coordinate crd : arrCoordinate) {
			System.out.println(crd.getX() + " " + crd.getY());
		}
	}
	
	private static void compareCoordinate() {

		Collections.sort(arrCoordinate, new Comparator<Coordinate> () {//x座標でソート
			public int compare(Coordinate crd1, Coordinate crd2) {
				return Integer.compare(crd1.getX(), crd2.getX());
			}
		}.thenComparing(new Comparator<Coordinate>() { //xが同じ場合、y座標でソート 
			public int compare(Coordinate crd1, Coordinate crd2) {
				return Integer.compare(crd1.getY(), crd2.getY());
			}
		}));
	}
	private static void getCoordinate() {
//		 座標の要素数
		int iCoordinateNum = 0;
		iCoordinateNum = scInputData.nextInt();
		while(arrCoordinate.size() < iCoordinateNum) {
			Coordinate crd = new Coordinate(scInputData.nextInt(), scInputData.nextInt());
			arrCoordinate.add(crd);
		}
	}
//	座標情報を扱うクラス
	static class Coordinate {
		int x, y;
		public Coordinate(int x, int y) {
			this.x = x;
			this.y = y;
		}
		int getX() {
			return x;
		}
		int getY() {
			return y;
		}
	}
}


Measured memory_bytes: 107576
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]
      
n, m = map(int, input().split())
e = [list(map(int,input().split())) for i in range(m)]
e.reverse()

uf = UnionFind(n)
score = n*(n-1)//2 
ans = [score]
for ce in range(m-1):
    u, v = e[ce][0]-1, e[ce][1]-1
    if uf.getRoot(u) != uf.getRoot(v):
        xu = uf.getSize(u)
        xv = uf.getSize(v)
        uf.merge(u, v)
        score -= xu * xv
    ans.append(score)
ans.reverse()

for i in range(m):
    print(ans[i])

Measured memory_bytes: 34552
import java.util.*;
import java.math.BigDecimal;

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

		// 整数の入力
		int a = sc.nextInt();//最もこれに近い整数を求める
		int b = sc.nextInt();//整数の数

		List<Integer> list = new ArrayList<>();
		
		for (int i = 0; i < b; i++) {
			list.add(sc.nextInt());
		}
		
		int index = 0;
		boolean flag = true;
		
		while (flag && -100 <= index && index <= 100) {
			a -= index;
			if (list.indexOf(a) == -1) {
				System.out.println(a);
				flag = false;
			} else {
				if (index >= 0) {
					index++;
				} else {
					index--;
				}
				if (index != 1) {
					index *= -1;
				}
				
			}
		}
	}
}

Measured memory_bytes: 35848
import math
import collections
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if n == 1:
        return factor
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor

n = int(input())
kai = [0 for _ in range(n+1)]
MOD = 10**9 + 7
l = []

for i in range(1, n+1):
    l.extend(trial_division(i))
c = collections.Counter(l)

s = 1
for key, value in c.items():
    s *= (value + 1)
    s %= MOD

print(s)

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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

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

	int v[n];

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

	sort(v, v+n);

	int rmid = n/2;
	int lmid = rmid-1;

	if(v[lmid]==v[rmid]){
		cout<<0<<endl;
		return 0;
	}

	cout<<v[rmid]-v[lmid]<<endl;
    
    return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
int main() 
{
	int a, b, c, k;
	scanf("%d%d%d%d", &a, &b, &c, &k);

	bool flag = false;
	for (int q1 = 0; q1 <= k; ++q1)
	{
		for (int q2 = 0; q2 <= k; ++q2)
		{
			for (int q3 = 0; q3 <= k; ++q3)
			{
				if (q1 + q2 + q3 <= k)
				{
					if (a * pow(2, q1) < b * pow(2, q2) && b * pow(2, q2) < c * pow(2, q3))
					{
						flag = true;
						goto here;
					}
				}
			}
		}
	}

	here:;

	if (flag)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}

	return 0;
}

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

int main(){
  ll n,k; cin >> n >> k;
  vector<pair<ll, ll>> ab(n);
  rep(i,n){
    cin >> ab.at(i).first >> ab.at(i).second;
  }

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

  ll count = 0;
  rep(i,n) {
    count += ab.at(i).second;
    if(count >= k) {
      cout << ab.at(i).first << endl;
      break;
    }
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> sol;
    for(int i = 1;i<=100;i++)
    {
        if(a%i == 0 && b%i == 0)
        {
            sol.push_back(i);
            //cout << i << " " ;
        }
    }
    cout << sol[sol.size() - k ];
return 0;    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0,n=0,m=0, maxy = 0, mini = 9999, counter = 0, s = 0, endp = 0, checker = 0;
std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001];
long long int iremono2[100001],check[100001];
std::vector<unsigned long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input, one, two;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
int main()
{
	cin >> a >> b;
	if (a*b % 2 == 0) {
		cout << "Even" << endl;	
	}
	else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    const S: string[] = (await sc.getLine()).split('');
    S.sort();
    if (S.join('') === 'abc') {
      console.log('Yes');
    } else {
      console.log('No');
    }

    sc.close();
  }
  solve();
}


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

string S,C;
int ans = 0;

int main()
{
    cin >> S;

    ans += S[0] - '0';
    for(int i = 0; i < S.size() - 1; i++)ans += 9;
    for(int i = 1; i < S.size(); i++)if(S[i] != '9')
    {
        printf("%d\n",ans - 1);
        return 0;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

string ret[] = { "","","","Three","Four" };
int main() {
	int N;
	cin >> N;
	vector<string> x(N);
	cin >> x;
	sort(ALL(x));
	cout << ret[distance(x.begin(), unique(ALL(x)))]<<endl;

	return 0;
}


Measured memory_bytes: 256
def decode(s):
    ret = []
    for line in s.split('/'):
        a = ''
        for c in line:
            if c == 'b':
                a += 'b'
            else:
                a += '.'*(ord(c)-ord('0'))
        ret.append(list(a))
    return ret

def encode(s):
    ret = []
    for line in s:
        x = ''.join(line)
        x = x.split('b')
        a = ''
        for i in range(len(x)-1):
            if len(x[i])>0:
                a += str(len(x[i]))
            a += 'b'

        if len(x[len(x)-1])>0:
            a += str(len(x[len(x)-1]))
        ret.append(a)

    return '/'.join(ret)

def main():
    while True:
        s = input()
        if s == '#':
            break
        a,b,c,d = map(int,input().split())

        f = decode(s)
        f[a-1][b-1] = '.'
        f[c-1][d-1] = 'b'
        print(encode(f))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7692
n = int(input())
num = [int(i) for i in input().split()]

cont=0
ans=1

for j in num:
    if j == 0: cont+=1

if cont > 0: print(0)
else:
    for i in num:
        ans=ans*i
        if ans>1e18:
            ans=-1
            break
    print(ans)


Measured memory_bytes: 21672
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n,m;cin>>n>>m;
  string s;cin>>s;
  vl ans;
  ll i=0;
  reverse(s.begin(),s.end());
  bool finish=false;
  while(true){
    ll MAX=0;
    for(ll j=1;j<=m;j++){
      if(i+j==n){
        ans.push_back(j);
        finish=true;
        break;
      }
      if(s[i+j]=='0')MAX=max(MAX,j);

    }
    if(finish){
      break;
    }
    if(MAX==0){
      cout<<-1<<endl;
      return 0;
      //break;
    }
    ans.push_back(MAX);
    i+=MAX;
  }
  reverse(ans.begin(),ans.end());
  rep(i,ans.size()){
    cout<<ans[i];
    if(i!=ans.size()-1)cout<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1480
using System;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			int tmp = arr.Last();

			for (int i = n - 1; i > 0; i--)
			{
				if (arr[i - 1] <= tmp)
				{
					tmp = arr[i - 1];
				}
				else if (arr[i - 1] - 1 <= tmp)
				{
					tmp = arr[i - 1] - 1;
				}
				else
				{
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}
}


Measured memory_bytes: 30300
//██████╗ ██╗   ██╗██╗      ██████╗ ███████╗
//██╔══██╗██║   ██║██║      ██╔══██╗██╔════╝
//██████╔╝██║   ██║██║█████╗██║  ██║█████╗
//██╔══██╗██║   ██║██║╚════╝██║  ██║██╔══╝
//██║  ██║╚██████╔╝██║      ██████╔╝███████╗
//╚═╝  ╚═╝ ╚═════╝ ╚═╝      ╚═════╝ ╚══════╝

#include <iostream>
#include <random>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <chrono>
#include <cstdio>
#include <map>
#include <memory.h>


// #pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define sqr(x) ((x) * (x))

typedef long long ll;
typedef  double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;

#define next ajksdslk
#define prev aklsfjk

mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());

template<typename T1, typename T2> inline bool upmax(T1& a, T2 b) { return (a < b ? (a = b, true) : false); }
template<typename T1, typename T2> inline bool upmin(T1& a, T2 b) { return (b < a ? (a = b, true) : false); }

const int maxn = (int) 5e6 + 100;
const int maxlog = 21;
const int base = 998244353;
const ld eps = (ld) 1e-9;
const ld PI = acos(-1.);
//const int pp = 41;
const int inf = 2e9;
const ll llinf = 1e18;

vector<pii> g[maxn];
int n;
int cl[maxn];


void dfs(int v, int color = 0, int p = -1) {
  int cnt = 1;
//  cout << v << " " << colo?r << " " << p << endl;
  for (auto t  : g[v]) {
    int to, id;
    tie(to, id) = t;
    if (to == p) continue;
    if (color == cnt) cnt ++;
    cl[id] = cnt;
    dfs(to, cnt, v);
    cnt ++;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifdef LOCAL
  freopen ("input.txt", "r", stdin);
#endif
  cin >> n;
  for (int i = 1; i < n; i ++) {
    int a, b; cin >> a >> b;
    g[a].eb(b, i);
    g[b].eb(a, i);
  }
  dfs(1);
  int ans = 0;
  for (int i = 1; i < n; i ++) {
    upmax(ans, cl[i]);
  }
  cout << ans << "\n";
  for (int i = 1; i < n; i ++) {
    cout << cl[i] << "\n";
  }



  return 0;
}

Measured memory_bytes: 124672
main(n){for(;scanf("%d",&n)*n;){int p[201]={0},m[]={n,n},i=n,c,t=1;for(i=n;i--;p[c]=1)scanf("%d",&c);for(i=1;m[t^1];t^=!i++)p[i]==t?--m[t],p[i]=2,t^=1:0,i%=2*n;printf("%d\n%d\n",*m,m[1]);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pi;
const ll INF = (1ll << 60);

int main(){
  ll A,B,C,D,E,F;cin>>A>>B>>C>>D>>E>>F;
  bool b[F+1]; REP(i, F+1)b[i]=false;
  b[0]=true;
  REP(i,F+1) {
    if(i>=C) if(b[i-C]) b[i]=true;
    if(i>=D) if(b[i-D]) b[i]=true;
  }
  vi p; REP(i,F+1)if(b[i])p.push_back(i);
  pi ans = {100*A,0};
  REP(a,30) REP(b,30) for(ll i : p){
    ll sum = 100*a*A+100*b*B+i;
    if(sum<=F && i*(100+E)<=E*sum) if(i*(ans.first)>=sum*ans.second) ans={sum,i};
  }
  cout<<ans.first<< ' ' <<ans.second<<endl;

}


Measured memory_bytes: 256
N,M=map(int,input().split())
Xa={}
ans=0
for i in range(N):
    V,S=map(int,input().split())
    if V in Xa :
        Xa[V] += S
    else :
        Xa[V]=S
Xb=sorted(Xa.items())
for i in range (len(Xb)) :
    M -= Xb[i][1]
    ans += Xb[i][0]*Xb[i][1]
    if M <= 0 :
        ans -= abs(M)*Xb[i][0]
        break
 
print(ans)

Measured memory_bytes: 23000
import sys
# readline = sys.stdin.readline
read = sys.stdin.read
from itertools import accumulate
from copy import deepcopy
def main():
    maxa2 = 10**5
    p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)]
    p[0] = p[1] = False
    p[2] = p[3] = p[5] = True
    for is1 in range(3, maxa2, 2):
        for is2 in range(is1 ** 2, maxa2, is1):
            p[is2] = False
    p2 = deepcopy(p)
    for i, pe in enumerate(p):
        if pe:
            i2 = ((i + 1) / 2)
            if i2 % 1 != 0:
                p2[i] = False
                continue
            elif not p[int(i2)]:
                p2[i] = False
    p2a = tuple(accumulate(p2))

    q = int(input())
    m = map(int, read().split())
    lr= zip(m, m)
    for l, r in lr:
        print(p2a[r] - p2a[l-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 102536
n = int(input())

button = list()

for x in range(n):
    button.append(int(input())-1)

now = 0
count = 0

while True:
    if now == 1:
        print(count)
        break

    if count >= n:
        print(-1)
        break

    count += 1
    now = button[now]


Measured memory_bytes: 7084
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    println(problem060b(a, b, c))
}

fun problem060b(a: Int, b: Int, c: Int): String {
    val list = mutableListOf<Int>()
    var count = 1
    while (true) {
        list.add(a * 1)
        if (list.sum() % b == c) {
            return "YES"
        }
        count++
        if (list.sum() % b == 0) break
    }
    return "NO"
}

Measured memory_bytes: 31644
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int x;
  cin >> x;

  if (x < 1200) pr("ABC");
  else pr("ARC");


  return 0;
}


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

Measured memory_bytes: 256
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
import heapq
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, X, Y = map(int, input().split())

def dijkstra_heap(s,edge):
    d = [10**20] * N
    used = [True] * N #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
# n,w = map(int,input().split()) #n:頂点数　w:辺の数

edge = [[] for i in range(N)]

for i in range(1, N-1):
    edge[i].append([1, i+1])
    edge[i].append([1, i-1])
edge[0].append([1, 1])
edge[N-1].append([1, N-2])
edge[X-1].append([1, Y-1])
edge[Y-1].append([1, X-1])

dd = defaultdict(int)
for i in range(N):
    dists = dijkstra_heap(i, edge)
    for j in dists[i+1:]:
        dd[j] += 1

for k in range(1, N):
    print(dd[k])


Measured memory_bytes: 91484
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <boost/multiprecision/cpp_int.hpp> 
using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   998244353
#define    inf  9223372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(x==0)return 0;if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}



int main()
{       io 
int testcases=1;     //   cin>>testcases;
while(testcases--)
{


cpp_int c=1;

bool z=false;

int n;
cin>>n;

cpp_int a[n];

for(int i=0;i<n;i++)
{cin>>a[i];
if(a[i]==0)
z=true;
}

if(z)
cout<<0;

else
{
	bool f=true;
	
	for(int i=0;i<n;i++)
	{
		c=c*a[i];
		if(c>1000000000000000000)
		{
			f=false;
			break;
		}
	}
	if(f)
	cout<<c;
	else
	cout<<-1;
}











}return 0;}

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

int main() {
  int A,B;
  cin >> A >> B;
  
  int count = 0;
  
  for (int i=A; i<=B; i++){
    // iは５桁の整数
    //[a,b,c,d]=[10^5の位,10^4の位，10の位，1の位]
    int a,b,c,d;
    a = i/10000;
    b = (i%10000)/1000;
    c = (i%100)/10;
    d = i%10;
    
    if( a==d && b==c) count ++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
N = list(map(int,input().split()))
N.sort()
if N[0]>=4:
    print(0)
else:
    if N ==[1,1]:
        print(1000000)
    elif N==[1,2]:
        print(500000)
    elif N == [1,3]:
        print(400000)
    elif N == [2,2]:
        print(400000)
    elif N == [2,3]:
        print(300000)
    elif N ==[3,3]:
        print(200000)
    else:
        if N[0]==1:
            print(300000)
        elif N[0]==2:
            print(200000)
        else:
            print(100000)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i,n)cin >> a[i];

    int ans = 0;
    rep(i,n-1){
        ans = max(ans, a[i+1] - a[i]);
    }
    ans = max(ans, a[0] + k - a[n-1]);

    ans = k - ans;

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


Measured memory_bytes: 1024
x = int(input())

if x >= 400 and x <= 599:
  print(8)
elif x >= 600 and x <= 799:
  print(7)
elif x >= 800 and x <= 999:
  print(6)  
elif x >= 1000 and x <= 1199:
  print(5)
elif x >= 1200 and x <= 1399:
  print(4)
elif x >= 1400 and x <= 1599:
  print(3)
elif x >= 1600 and x <= 1799:
  print(2)
elif x >= 1800 and x <= 1999:
  print(1)        



Measured memory_bytes: 9120
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt
  val S = readLine.split(" ").map(_.toInt)
  val q = readInt()
  val T = readLine.split(" ").map(_.toInt)
  var count = 0

  def linearSearch(n: Int, key: Int): Boolean = {
    var i = 0
    val appended = S :+ key
    while (appended(i) != key) i += 1
    if (i == n) false else true
  }

  for (e <- T) {
    if (linearSearch(n, e)) count += 1
  }

  println(count)
}



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

int main() {
    int n, m;
    cin >> n >> m;
    int ans = (n-m)*100 + m*1900;
    rep(i, m) ans *= 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;


string Main(string S)
{
    int N = S.length();
    REP(i, N) {
        if(i%2) { // odd
            if(S[i] == 'R') return "No";
        }
        else {
            if(S[i] == 'L') return "No";
        }
    }
    return "Yes";
}

int main(void){
    string S;
    cin >> S;
    cout << Main(S) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod2 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

int main()
{
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(i%2==0 and v[i]%2==1)
            ans+=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  ll a, b, x;
  cin >> a >> b >> x;
  ll anser;
  if (a > 0)
    anser = (b / x) - ((a - 1) / x);
  else
    anser = (b / x) + 1;
  cout << anser << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int H, N;
    cin >> H >> N;
    int hp = H;
    int A;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        hp -= A;
    }
    if (hp <= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace agc015_a
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long ret = ((x[0] - 1) * x[2] + x[1]) - ((x[0] - 1) * x[1] + x[2]) + 1;
            Console.WriteLine(Math.Max(0, ret));
        }
    }
}

Measured memory_bytes: 13268
//default library
#include <stdio.h>
#include <string.h>
//extra library


//default define
#define ll long long int
#define fl(i,a,n) for(int i = a; i < (n); i++)
#define fls(i,a,s) for(int i = a; s[i] != '\0'; i++)
#define endl puts("")
#define kill return 0

//extra define


//declare function


//main code
int main() {
	int t,check = 0;
	scanf("%d", &t);
	for(int i = 0; i < t; i++){
		int a,b;
		scanf("%d %d", &a, &b);
		if(a == b){
			check++;
		}else{
			check = 0;
		}
		if(check == 3){
			puts("Yes");
			kill;
		}
	}
	puts("No");
    return 0;
}

//functions




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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,k;cin >>n>>k;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    ll cnt=0;
    ll cnt2=0;
    for (int i = 0; i < n-1; ++i) {
        for (int j =i+1; j < n; ++j) {
            if(a[i]>a[j])cnt++;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(a[i]>a[j]){
                cnt2++;
            }
        }
    }
    ll ans;
    ll now;
    ans=cnt*k%mod;
    now=k*(k-1)/2%mod;
    now*=cnt2;
    now%=mod;
    ans+=now;
    ans%=mod;
    cout <<ans <<endl;
}


Measured memory_bytes: 3632