akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String[] strArray = br.readLine().split(" ");
			if (strArray[1].equals("?")) {
				break;
			}
			long a = Long.parseLong(strArray[0]);
			long b = Long.parseLong(strArray[2]);
			String op = strArray[1];
			switch (op) {
				case "+":
				System.out.println(a + b);
				break;
				case "-":
				System.out.println(a - b);
				break;
				case "*":
				System.out.println(a * b);
				break;
				case "/":
				System.out.println(a / b);
				break;
			}
		}
	}
}

Measured memory_bytes: 24208
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		int[] map = new int[N+1];
		for(int i=1;i<=N;i++) {
			map[i] = cin.nextInt();
		}
		int res = 0;
		for(int i=1;i<=N;i++) {
			if (map[map[i]] == i) {
				res++;
			}
		}
		System.out.println(res/2);
	} 
}

Measured memory_bytes: 53036
#include<stdlib.h>
#include<stdio.h>
int main(){
  int N;
  char S[101];
  int i;
  scanf("%d",&N);
  scanf("%s",&S[i]);
  int a=0,b;
  b=N/2;
  if(N%2==1){
    printf("No\n");
    exit(0);
  }
  for(i=0;i<b;i++){
    if(S[i]==S[i+b]){
      a++;
    }
  }
  if(a==b){
    printf("Yes\n");
  }
  else if(a!=b){
    printf("No\n");
  }
  return 0;
}




Measured memory_bytes: 128
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/
#include<bits/stdc++.h>
using namespace std;
void    		print(int n)    {printf("%d ", n);}
void    		printl(long long n)     {printf("%I64d ", n);}
long long    	readline(){long long x;scanf("%I64d", &x);return x;}
/*
1.#define  gcd(a,b) __gcd(a,b) 2. #define  lcm(a,b) (a*b)/gcd(a,b) 3. #define  PI acos(-1.0) 4.#define  sqr(x) ((x)*(x))
5.#define  min3(a,b,c) min(a,min(b,c))6.#define  min4(a,b,c,d) min(d,min(a,min(b,c)))7.#define  max3(a,b,c) max(a,max(b,c))
8.#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
*/
//.............ignore it................//
/*....... scanf.......*/
template <typename T> inline void readline(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
/*..........error........*/
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {
  vector<string>v; stringstream ss(s); string x;
  while (getline(ss, x, c))v.emplace_back(x); return move(v);
} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb                     push_back
#define  ll                     long long int
#define  nl                     printf("\n");
#define  happy          cin.tie(0);
#define  coding         ios::sync_with_stdio(false);
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;
const int N             = 500 + 5;
const int N1            = 3e5 + 5;
int visit[N][N];
string s[505];

int solve()
{
	//happy coding
	int a,b;
	cin>>a>>b;
	for(int i=1;i<1e4;i++){
		int a1 = i*8/100;
		int a2 = i*10/100;
		if(a1==a&&a2==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
	
	//error()
	return 0;
}

int main(){
	int test = 1, tc = 0;
	//scanf("%d", &test);//(void)getchar();
	while (test--)solve();
	return 0;
}

Measured memory_bytes: 256
/*input
8 7
1 7 5 6 8 2 6 5
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,1,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=505;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int k;
ll sum;
bool wk(ll x,int n){
    ll negsum=0,possum=0;
    multiset<ll> ms;
    REP(i,n){
        possum+=(x-arr[i]%x);
        ms.insert(arr[i]%x);
    }
    for(auto z:ms){
        negsum+=z;
        possum-=(x-z);
        if(negsum<=k and negsum==possum) return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n>>k;
    sum=0;
    REP(i,n){
        cin>>arr[i];
        sum+=arr[i];
    }
    ll mx=0;
    for(ll i=1;i<=sqrt(sum);i++){
        if(sum%i==0 and wk(i,n)) mx=max(mx,i);
        if(sum%i==0 and wk(sum/i,n)) mx=max(mx,sum/i);
    }
     cout<<mx;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


int main(){
    
    ll H, W;
    cin >> H >> W;
    vector<string>vec;
    string str(W, '.');
    for(ll y = 0; y < H; y++){
        string s;
        cin >> s;
        if(s != str)vec.push_back(s);
    }    
    vector<ll>flg(W, 0);
    for(ll x = 0; x < W; x++){
        for(ll y = 0; y < vec.size(); y++){
            if(vec[y][x] == '#')flg[x] = 1;
        }
    }
    for(ll y = 0; y < vec.size(); y++){
        for(ll x = 0; x < W; x++){
            if(flg[x])cout << vec[y][x];
        }
        cout << endl;
    }
    
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    rep(i, 3){
        if (n[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

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

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

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

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

const ll INF = 1e9+7;

const ll MOD = 1e9+7;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	vector<ll> fact, inv;
	FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = inv[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modinv( fact[i] );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact(200006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}


vector<int> edge[200005];
map<int,pll> memo[200005];
pll all[200005];
pll solve(int n, int b){
	if(memo[n].count(b)) return memo[n][b];
	if(all[n].Y > 0){
		if(b < 0){
			auto ret = all[n];
			ret.Y += 1;
			return memo[n][b] = ret;
		}

		auto ret = solve(b,n);
		ll sum = all[n].X * modinv(ret.X) % MOD;
		sum = (sum * modinv(cmb(all[n].Y, ret.Y))) % MOD;
		ll cnt = all[n].Y - ret.Y;
		return memo[n][b] = pll(sum, cnt + 1);
	}
	ll sum=1, cnt=0;
	for(auto t: edge[n]) if(t != b){
		auto ret = solve(t,n);
		cnt += ret.Y;
		sum = (sum * cmb(cnt, ret.Y)) % MOD;
		sum = (sum * ret.X) % MOD;
	}
	if(b >= 0 && memo[b].count(n)){
		all[n].Y = cnt + memo[b][n].Y;
		all[n].X = sum * memo[b][n].X % MOD;
		all[n].X = all[n].X * cmb(all[n].Y, memo[b][n].Y) % MOD;
	}
	cnt += 1;
	//cout << n << " " << b << ": " << pll(sum, cnt) << endl;
	return memo[n][b] = pll(sum, cnt);
}

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

	cin >> N;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	vector<ll> ans;
	rep(i,N) ans.push_back(solve(i,-1).X);
	for(auto t: ans) printf("%lld\n", t);

	return 0;
}

Measured memory_bytes: 68080
(* O(n) *)
open Hashtbl
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let h = create n
let _ =
  Array.iter (fun a -> try let c = find h a in replace h a @@ c + 1 with _ -> add h a 1) a_s;
  fold (fun _ c acc -> acc + if c mod 2 = 0 then 0 else 1) h 0 |> Printf.printf "%d\n"

Measured memory_bytes: 7936
def main():
    N, K = map(int, input().split())
    mod = 10**9 + 7
    r = 0
    for i in range(K, N+2):
        r += ((N + N-i+1) * i - i*(i-1))//2 + 1
        r %= mod
    return r
print(main())


Measured memory_bytes: 9164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	for (int i = 0; i < B; i++) {
		if ((A*i) % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;
	
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;

		if (a > 0) {
			mp[a - 1]++;
		}
		mp[a]++;
		mp[a + 1]++;
	}

	vector<int> count((int)1e5 + 1);
	int ans = 0;
	for (auto m : mp) {
		ans = max(ans, m.second);
	}

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


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main(){
	int a,b,t;
    //string s;
    cin >> a>>b>>t;

	cout << b*(t/a) << endl;

}

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

int N;
string S;

int main() {
    cin >> N >> S;
    
    int ans = 1;
    char per = S[0];
    for (int i = 1; i < S.length(); i++) {
        if (per != S[i]) {
            per = S[i];
            ans++;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main(){
    vector<int> A;

    int N;
    cin>>N;
    int An;
    for(int i=0;i<N;i++){
        cin>>An;
        A.push_back(An);
    }
    int A_size=A.size();
    sort(A.begin(),A.end());
    A.erase(unique(A.begin(),A.end()),A.end());
    if(A_size==A.size())cout<<"YES"<<endl;
    else cout<<"NO"<<endl;


}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        cout<<"vowel"<<endl;
    else
        cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

numlist = input().split()
# numlist = map(int,input().split())

# print(N,numlist)

def div(list):
    ret = []
    for i in list:
        ret.append(int(i)/ 2)
    return ret

def chkEven(list):
    for i in list:
        if not int(i) % 2 == 0:
            return False
    return True

cnt = 0


while chkEven(numlist):
    cnt += 1
    numlist = div(numlist)
    
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,g=0,cnt=0;
  cin >> n >> m; 
  vector<int> a(n);
  for(int i=0;i < n;i++)
  {
    cin >> a.at(i);
    g+=a.at(i);
  }
  for(int j=0;j < n;j++)
  {
    if(! (a.at(j) < g*(1.000/(4.000*m)) ) )
    {
      cnt++;
    }
  }
  if(cnt >= m)
  {
    cout << "Yes";
  }
  if(cnt < m)
  {
    cout << "No";
  }
  return 0;
}

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

int n,ans=0,last;
int rt[200005],b[200005];

struct node{
	int rt;
	int num;
}a[200005];

bool cmp(node a,node b){
	return a.num<b.num;
}

int Binary_search2(int l,int r,int k){
	if (l>r)  
        return last;
	if (l==r||l+1==r){
		if(b[l]==k)  
            return min(l,last);
		if(b[r]==k)  
            return min(r,last);
		else return last;
	}
	int mid=(l+r)>>1;
	if (b[mid]>=k){
		if (b[mid]==k)  last=mid;
		return Binary_search2(l,mid,k);
	}
	if (b[mid]<k)  return Binary_search2(mid,r,k);
}

int Binary_search(int l,int r,int k){
	if (l>r)  return last;
	if (l==r||l+1==r)
	{
		if (b[r]==k)  return max(r,last);
		if (b[l]==k)  return max(l,last);
		else return last;
	}
	int mid=(l+r)>>1;
	if (b[mid]<=k)
	{
		if (b[mid]==k)  last=mid;
		return Binary_search(mid,r,k);
	}
	else if (b[mid]>k)  return Binary_search(l,mid,k);
} 

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i].num;
		a[i].rt=i;
		a[i].num-=(i-1);
	}
	sort(a+1,a+n+1,cmp);
	
	for (int i=1;i<=n;i++)  rt[a[i].rt]=i;
	for (int i=1;i<=n;i++)  b[i]=a[i].num;
	for (int i=1;i<=n;i++)
	{
		int now=rt[i],sum=2-i*2;
		last=1e9+7;
		int p1=Binary_search2(1,now,sum-b[now]);
		last=-1;
		int p2=Binary_search(1,now-1,sum-b[now]);
		last=1e9+7;
		int p3=Binary_search2(now+1,n,sum-b[now]);
		last=-1;
		int p4=Binary_search(now+1,n,sum-b[now]);
		
		if (p1!=1e9+7&&b[p1]+b[now]==sum)  ans+=(p2-p1)+1;
		if (p3!=1e9+7&&b[p3]+b[now]==sum)  ans+=(p4-p3)+1;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 9896
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int f,se,t;
  int flag;
  int ans=0;
  for(int i=0;i<1000;i++){
    int buf=i;
    flag=0;
    f=buf/100;
    buf%=100;
    se=buf/10;
    t=buf%10;
    for(int j=0;j<n;j++){
      if(flag==0&&s[j]-'0'==f){
	flag++;
	continue;
      }
      if(flag==1&&s[j]-'0'==se){
	flag++;
	continue;
      }
      if(flag==2&&s[j]-'0'==t){
	flag++;
	break;
      }
    }
    if(flag==3)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
  if (c=='a' || c=='e' || c=='i' || c== 'o' || c=='u'){
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll now=1;
  rep(i,0,n){
    if(a[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }
  rep(i,0,n){
    if(INF/a[i]<now)judge=false;
    else now*=a[i];
  }
  if(judge&&now<=INF)cout<<now<<endl;
  else cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 4000
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    n,m = map(int,input().split())
    if n == 0 and m == 0:
        break
    taro = [int(input()) for i in range(0,n)]
    hanako = [int(input()) for i in range(0,m)]
    taro_hand = sum(taro)
    hanako_hand = sum(hanako)
    ans = -1
    for i in sorted(taro):
        for j in sorted(hanako):
            if ans != -1:
                break
            if taro_hand + (j - i) == hanako_hand + (i - j):
                ans = str(i) + ' ' + str(j)
    print(ans)
                

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

#define INF 1e9

int main() {
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--;
    dh--; dw--;
    vector<st> s(h);
    rep(i, h) cin >> s.at(i);
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pair<ll, ll>> q;
    dist.at(ch).at(cw) = 0;
    q.emplace_back(ch, cw);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist.at(i).at(j);
        rep(k, 4){
            int ni = i + di[k];
            int nj = j + dj[k];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s.at(ni).at(nj) == '#') continue;
            if(dist.at(ni).at(nj) <= d) continue;
            dist.at(ni).at(nj) = d;
            q.emplace_front(ni, nj);
        }
        for(int mi = -2; mi <= 2; mi++){
            for(int mj = -2; mj <= 2; mj++){
                int ni = i + mi;
                int nj = j + mj;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s.at(ni).at(nj) == '#') continue;
                if(dist.at(ni).at(nj) <= d + 1) continue;
                dist.at(ni).at(nj) = d + 1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist.at(dh).at(dw);
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 9708
#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std ;

int main()
{
    string s;
    int m=0,c=0;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            c++;
            m=max(m,c);
        }
        else
        {
            m=max(m,c);
            c=0;
        }
        
    }
    cout<<m;
}

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

using namespace std;

int main(){
    int a,b;

    cin >> a >> b;

    if(a < b){
        cout << "a < b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

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


void solve(){
	int r,g,b;
	cin >> r >> g >> b;
	int k;
	cin >> k;
	for(int i =0;i<=k;i++){
		for(int j = 0;j<=k-i;j++){
			if(b*pow(2,i)>g*pow(2,j) && g*pow(2,j)>r){
				cout << "Yes" << endl;return;
			}
		}
	}
	cout << "No" << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


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

using namespace std;
using ll = long long;

int main(){
    int N,K;
    cin >> N >> K;
    vector<ll> x(N),y(N);
    vector<ll> xarr, yarr;
    for(int i=0;i<N;i++){
        scanf("%lld %lld", &x[i], &y[i]);
        xarr.push_back(x[i]);
        yarr.push_back(y[i]);
    }

    sort(xarr.begin(), xarr.end());
    sort(yarr.begin(), yarr.end());

    unsigned long long area = 1ll * (xarr[N-1] - xarr[0]) * (yarr[N-1] - yarr[0]);

    for(int xi=0;xi<N;xi++){
        for(int xj=xi+1;xj<N;xj++){
            for(int yi=0;yi<N;yi++){
                for(int yj=yi+1;yj<N;yj++){

                    int num = 0;
                    ll lx = xarr[xi], rx = xarr[xj];
                    ll by = yarr[yi], uy = yarr[yj];

                    for(int i=0;i<N;i++){
                        if(lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy){
                            num++;
                        }
                    }

                    if(num >= K){
                        area = min(area, 1ull*(rx-lx)*(uy-by));
                    }
                }
            }
        }
    }
    cout << area << endl;
    return 0;

}

Measured memory_bytes: 256
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		int a = int.Parse(Console.ReadLine());
		int ans = (int)(a + Math.Pow((double)a, 2) + Math.Pow((double)a, 3)); 
		Console.WriteLine(ans);
		
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];



Measured memory_bytes: 27812
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r < 0: return 0
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

A = list(map(int, input().split()))

hamap = {}

for i in A:
    if i in hamap:
        hamap[i] = hamap[i] + 1

    else:
        hamap[i] = 1

ans = 0
hiku = {}
for i in hamap.keys():
    tempCmb = cmb(hamap[i], 2)
    ans += tempCmb
    hiku[i] = tempCmb - cmb(hamap[i] - 1, 2)
        
for i in A:
    # a = comb(n, r)
    print(ans - hiku[i])


Measured memory_bytes: 32400
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    long double l;
    cin >> l;
    cout << SP(10) << (l / 3.0) * (l / 3.0) * (l / 3.0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
int mod=1e9+7;





int32_t main() {
    int T;
    T=1;
    //cin>>T;
    while(T--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        vector<int>dp(n,0);
        dp[1]=abs(a[0]-a[1]);
        for(int i=2;i<n;i++){
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1], abs(a[i]-a[i-2])+dp[i-2]);
        }
        cout<<dp[n-1];
        cout<<'\n';
    }
	return 0;
}

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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int c5 = 0, c7 = 0;
  for(int i = 0; i < 3; i++) {
    if(a[i] == 5) {
      c5++;
    } else if(a[i] == 7) {
      c7++;
    }
  }
  if(c5 == 2 && c7 == 1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

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

int main(){
  int x;
  cin >> x;
  vector<int> up(x);
  vector<int> down(x);
  for (int i=0; i<x; i++) cin >> up[i];
  for (int i=0; i<x; i++) cin >> down[i];

  int res = 0, sup, sdown;
  for (int i=0; i<x; i++) {
    sup = accumulate(up.begin(), up.begin() + i + 1, 0);
    sdown = accumulate(down.begin() + i, down.end(), 0);
    if (res < sup + sdown) res = sup + sdown;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define INF (1e9)
#define LINF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define F first
#define S second
#define MOD 1000000007

/*
int get_digit(LL n) {
	int digit = 0;
	while (n > 0) {
		digit++;
		n /= 10;
	}
	return digit;
}
*/

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> y(m);
	vector<int> p(m);
	vector<vector<int>> py(n);
	REP(i, m) cin >> p[i] >> y[i], py[p[i] - 1].push_back(y[i]);
	REP(i, n) sort(ALL(py[i]));
	REP(i, m) cout << std::setw(12) << std::setfill('0') << LL(p[i]) * 1000000 + (lower_bound(ALL(py[p[i] - 1]), y[i]) - py[p[i] - 1].begin()) + 1 << endl;
}


Measured memory_bytes: 7808
// Surrounded Nodes
// 所要時間 x分
// ほんとに何もわからん
// 解説見ても理解できない
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

constexpr int mod = 1000000007;
class mint {
public:
    ll x;
    constexpr mint(long long x=0) : x((x % mod + mod) % mod) {}
    constexpr mint operator-() const { 
      return mint(-x);
    }
    constexpr mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    constexpr mint inv() const {
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};

ll n;
vector<vector<int>> graph;

mint ans;

int dfs(int v, int pre = -1){
    int ret = 1;
    vector<int> ts;
    for(auto u : graph[v]){
        if(u == pre){
            continue;
        }
        int t = dfs(u, v);
        ret += t;
        ts.push_back(t);
    }
    if(pre != -1){
        ts.push_back(n-ret);
    }
    mint now = mint(2).pow(n-1)-1;
    for(int t : ts){
        now -= mint(2).pow(t)-1;
    }
    ans += now;
    return ret;
}

int main() {

    cin >> n;
    graph.resize(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(0);
    ans /= mint(2).pow(n);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 29184
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


N, M = map(int, input().split())
p = list(map(int, input().split()))

uf = UnionFind(N)

for i in range(M):
    x, y = map(int, input().split())
    uf.union(p[x-1]-1, p[y-1]-1)

ans = 0
for i in range(N):
    if uf.is_same(p[i]-1, i):
        ans += 1

print(ans)

Measured memory_bytes: 102996
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n,k=MI()

	kk=(n-1)*(n-2)//2-k

	if kk<0:
		print(-1)
		exit()

	ans=[]
	#print(kk)
	for i in range(1,n):
		ans.append([i,n])
	#print(ans)

	for i in range(1,n):
		for j in range(i+1,n):
			if kk>0:
				kk-=1
				ans.append([i,j])

	print(len(ans))
	for i,j in ans:
		print(i,j)













if __name__ == "__main__":
	main()


Measured memory_bytes: 9696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,P;cin >> N >> P;
  vector<int> v(N);
  rep(i,N) cin >> v[i];
  vector<ll> zeros(N+1,0);
  vector<ll> ones(N+1,0);
  zeros[0] = 1;
  rep(i,N){
    if(v[i]&1){
      per(i,N){
        zeros[i+1] += ones[i];
        ones[i+1] += zeros[i];
      }
    }else{
      per(i,N){
        zeros[i+1] += zeros[i];
        ones[i+1] += ones[i];
      }
    }
  }
  rep(i,N){
    zeros[i+1] += zeros[i];
    ones[i+1] += ones[i];
  }
  if(P==1) cout << ones[N] << endl;
  else cout << zeros[N] << endl;
  return 0;
}


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

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

  bool ans {false};
  if (S.length() %2 == 0) {
    ans = true;
    for (int i{}; i < S.length(); i += 2) {
      if (S[i] != 'h' || S[i+1] != 'i') {
        ans = false;
        break;
      }
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <iostream>
#include <string>
#include <tuple>
using namespace std;

tuple<const char*, int> calc(const char* p)
{
    if (*p == '[') {
        vector<int> costs;
        const char* q = p + 1;
        while (*q != ']') {
            int c;
            tie(q, c) = calc(q);
            costs.push_back(c);
        }
        sort(begin(costs), end(costs));
        return make_tuple(q + 1, accumulate(begin(costs), begin(costs) + (costs.size() + 1) / 2, 0));
    } else {
        assert(isdigit(*p));
        int r = 0;
        for (; isdigit(*p); ++p) {
            r = r * 10 + *p - '0';
        }
        assert(*p == ']');
        return make_tuple(p, (r + 1) / 2);
    }
}

int main()
{
    ios::sync_with_stdio(false);

    int T; cin >> T;
    while (T--) {
        string line; cin >> line;
        const char* p;
        int r;
        tie(p, r) = calc(line.data());
        assert(p == line.data() + line.size());
        cout << r << endl;
    }
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] XAB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            if(XAB[1]-XAB[2]>=0){
                Console.WriteLine("delicious");
            }else if(XAB[1]-XAB[2]>=(-1)*XAB[0]){
                Console.WriteLine("safe");
            }else{
                Console.WriteLine("dangerous");
            }
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

string S;

int main(){
    cin>>S;

    if(S[S.size()-1]!='s') S+='s';
    else{
        S+="es";
    }

    cout<<S<<endl;
}

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

typedef vector<int> vi;
typedef vector<vi> vii;

vii v;
int n;

void dp(int maxNum, int total, int position, vi line){
    if(total == n) v.push_back(line);
    else if(total > n) return;
    else {
        for(int i=1; i <= maxNum; i++){
            line[position] = i;
            dp(i, total+i, position+1, line);
            line[position] = 0;
        }
    }
}

int main(){
    while(cin >> n, n){
        v.clear();
        vi line (n, 0);
        dp(n, 0, 0, line);

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

        for(int i=0; i < v.size(); i++){
            for(int j=0; v[i][j] != 0 && j < v[i].size(); j++){
                if(j == 0) cout << v[i][j];
                else cout << " "  << v[i][j];
            }
            cout << endl;
        }
    }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    for (int i = 0; i < n; ++i) {
        int x, l;
        cin >> x >> l;
        a.push_back(make_pair(x - l, x + l));
    }
    sort(a.begin(), a.end());
    int ans = n;
    int r = a[0].second;
    for (int i = 1; i < n; ++i) {
        if (a[i].first < r) {
            --ans;
            r = min(r, a[i].second);
        } else {
            r = a[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]!='L') continue;
            else{
                cout << "No";
                return 0;
            }
        }else{
            if(s[i]!='R') continue;
            else{
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";

    return 0;
}

Measured memory_bytes: 3636
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Monad.Primitive
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.IntMap as IM
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Sequence as Sq
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

readIntBS = fst . fromJust . BS.readInt

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]

  let
    sqm = ceiling $ sqrt (fromIntegral m)
    divs = [i | i<-[1..sqm], m`mod`i==0]
    divisors = VU.fromList $ divs ++ map (\d -> m`div`d) (reverse divs)
    l = VU.length divisors

    aux i = m `div` (divisors VU.! i) >= n
    solve l r
      | l == r = l
      | l + 1 == r = if aux r then r else l
      | otherwise =
          let
            m = (l+r)`div`2
          in
            if aux m then
              solve m r
            else
              solve l m
  
  print $ divisors VU.! (solve 0 (l-1))
  


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n, k;
ll t[200005];
int f[200005];

int main(){
    cin >> n >> k;
    FOR(i,1,n+1){
        cin >> t[i];
    }
    ll s=t[1];
    ll cy=0;
    REP(i,n)
    {
        if(f[s]!=0){cy=i+1-f[s];break;}
        else
        {
            f[s]=i+1;
            s=t[s];
        }
    }
    if(k<f[s])
    {
        s=1;
    }
    else
    {
        k-=f[s];
        k=k%cy;
    }
    REP(i,k)
    {
        s = t[s];
    }
    cout << s << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int A=S.size();
  long long sum_all=0;
  for(int bit=0;bit<(1<<(A-1));bit++){
    long long sum=0;
    for(int i=0;i<A-1;i++){
      sum*=10;
      int B=S.at(i)-'0';
      sum+=B;
      if(bit & (1<<i)){
        sum_all+=sum;
        sum=0;
      }
    }
    sum*=10;
    int B=S.at(A-1)-'0';
    sum+=B;
    sum_all+=sum;
  }
  cout << sum_all << endl;
}    

Measured memory_bytes: 3608
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void call(int n)
  {
    int i = 0;
    while(++i<=n)
    {
      int x = i;
      if (x%3==0)
      {
        System.out.print(" " + i);
        continue;
      }
      while (x>0)
      {
        if (x%10==3)
        {
          System.out.print(" " + i);
          break;
        }
        x /= 10;
      }
    }
    System.out.println();
  }
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    call(n);
    scan.close();
  }
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL n, m;
    cin >> n >> m;
    vector<LL> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];

    }

    LL lc = 1;
    LL div;
    for(int i = 0; i < n; ++i) {
        LL t = v[i];
        int c = 0;
        while(t % 2 == 0) {
            t >>= 1;
            ++c;

        }

        if(i == 0) div = c;
        if(c != div) {
            lc = -1;

        }

        if(lc == -1) continue;
        v[i] >>= 1;
        lc = LCM(lc, v[i]);
        if(lc > m) {
            lc = -1;

        }
    }

    if(lc == -1) {
        cout << 0;

    } else {
        LL res = m / lc;
        res -= res / 2;
        cout << res;

    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024