akhauriyash/Code-Regression huggingface dataset:
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9+7

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

one = A.count(1)

def find_prime(n):
    prime_list = []
    find_list = list(range(2,n+1))
    while True:
        if find_list[0] > n**(1/2):
            prime_list.extend(find_list)
            break
        else:
            head = find_list[0]
            prime_list.append(head)
            find_list.pop(0)
            find_list = [num for num in find_list if num % head != 0]
    return prime_list

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def multiple(a, b):
    return a*b // euclid(a, b)

def gcd(nums):
    return functools.reduce(euclid, nums)

if gcd(A) != 1:
    print("not coprime")

else:
    """
    flag = 0
    M = [False]*(10**6+1)
    for i in range(N):
        n = A[i]
        if M[n]:
            flag = 1
            break
        if n != 1:
            k = 1
            while n*k <= 10**6:
                M[n*k] = True
                k += 1
    """
    flag = 0

    if N-one <= 78500:
        M = [False]*(10**6+1)
        for i in range(N):
            n = A[i]
            if n == 1:
                continue
            l = factorization(n)
            for j in range(len(l)):
                p = l[j][0]
                if M[p]:
                    flag = 1
                    break
                M[p] = True
    else:
        flag = 1
    
    if flag == 0:
        print("pairwise coprime")
    else:
        print("setwise coprime")

Measured memory_bytes: 193056
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]) {
  long A, B, C;
  std::cin >> A >> B >> C;
  if (A == 5 && B == 5 && C == 7) {
    cout << "YES" << endl;
  } else if (A == 7 && B == 5 && C == 5) {
    cout << "YES" << endl;
  } else if (A == 5 && B == 7 && C == 5) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
S = input()
#A = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
A = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for i in set(S):
	A.remove(i)
	#print(A)
if len(A) == 0:
	print("None")
else:
	print(A[0])

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// constexpr ll INF = 1LL << 60;

int gcd(int a, int b){
  if(b==0){
    return a;
  }
  return gcd(b, a%b);
}
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  int maxa = 0;
  REP(i, N){
    cin >> A[i];
    maxa = max(maxa, A[i]);
  }
  int G = A[0];
  REP(i, N){
    G = gcd(A[i], G);
  }
  if(K % G ==0 && K <= maxa){
    cout << "POSSIBLE" << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    bool addFront,reversing=false;
    string frontS="",backS="";
    rep(q,0,Q){
        int T; cin>>T;
        if(T-1){ //add char
            int F; cin>>F;
            char c; cin>>c;

            if(F-1) addFront=false;
            else addFront=true;

            if(addFront^reversing) frontS=c+frontS;
            else backS+=c;
        }else{  //reverse
            reversing=!reversing;
        }
    }

    S=frontS+S+backS;
    if(reversing) reverse(ToEnd(S));
    cout<<S<<endl;
}

Measured memory_bytes: 1360
w, h, n = gets.chomp.split(' ').map(&:to_i)
arr1 = [0]
arr2 = [w]
arr3 = [0]
arr4 = [h]

n.times do |i|
  tmp_x, tmp_y, tmp_a = gets.chomp.split(' ').map(&:to_i)
  if tmp_a == 1
    arr1.push(tmp_x)
  elsif tmp_a == 2
    arr2.push(tmp_x)
  elsif tmp_a == 3
    arr3.push(tmp_y)
  else
    arr4.push(tmp_y)
  end
end
width = arr2.min - arr1.max
height = arr4.min - arr3.max

if width > 0 && height > 0
  print width * height
else
  print 0
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>a;
  ll ar[n];
  rep(i,0,n) cin>>ar[i];
  rep(i,0,n)
  {
    m+=ar[i];
    if(m>a) break;
    k++;
  }
  //k=min(n+a,min(n+b,a+b));
  cout<<k+1;
  /*if(n<a) cout<<0;
  else cout<<10;*/
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
 //  cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3640
n, x, y = map(int,input().split())
 
x-=1
y-=1
cnt = [0] * n
 
for i in range(n):
    for j in range(i+1, n):
        dist = min(j-i, abs(j-x) + 1 + abs(i-y),  abs(j-y) + 1 + abs(i-x))
        cnt[dist] += 1
        
for i in range(1, n):
    print(cnt[i])

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;

    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;

    else if (b <= a && a <= c)
        cout << b << " " << c << " " << a << endl;

    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;

    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;

    else
        cout << c << " " << b << " " << a << endl;

    return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, m;
	std::cin >> n >> m;
	uint32 l, r;
	int64 d;
	std::vector<std::vector<std::pair<uint32,int64>>> D(n);
	for (uint32 i = 0;i < m;++i) {
		std::cin >> l >> r >> d;
		D[l - 1].push_back({ r - 1,d });
		D[r - 1].push_back({ l - 1,-d });
	}
	std::vector<int64> x(n,INT_FAST64_MIN);
	std::vector<char> re(n, 0);
	std::queue<uint32> Q;
	std::set<uint32> S;
	for (uint32 i = 0;i < n;++i) {
		S.insert(i);
	}
	while (!S.empty()) {
		if (Q.empty()) {
			Q.push(*S.begin());
			x[*S.begin()] = 0;
			S.erase(S.begin());
		}
		uint32 t = Q.front();Q.pop();
		if (re[t]) continue;
		re[t] = 1;
		S.erase(t);
		for (uint32 i = 0;i < D[t].size();++i) {
			if (x[D[t][i].first] == INT_FAST64_MIN) {
				x[D[t][i].first] = x[t] + D[t][i].second;
			}
			else {
				if (x[D[t][i].first] != x[t] + D[t][i].second) {
					std::cout << "No\n";
					return 0;
				}
			}
			if (!re[D[t][i].first]) {
				Q.push(D[t][i].first);
			}
		}
	}
	std::cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 18688
#include <iostream>
#include <cstring>
#include<algorithm>
using namespace std;
int n;
struct person
{
	int i;
	int Ai;
}p[100005];

bool cmp(person&p1,person&p2)
{
	return p1.Ai<p2.Ai;
}

int main()
{
	cin>>n;
	for(int j=1;j<=n;j++)
	{
		p[j].i=j;
		cin>>p[j].Ai;
	}
	sort(p+1,p+1+n,cmp);
	for(int j=1;j<=n;j++)
	{
		cout<<p[j].i<<" ";
	}
 } 

Measured memory_bytes: 1536
color = input()

kosuu = input()

trashc = input()

_ = 0

color = color.split()
kosuu = kosuu.split()
trashc = trashc.split()


while True:
  if(trashc[0] == color[_]):
    kosuu[_] = int(kosuu[_]) -1
    break
      
  _= _+1
    
print(" ".join(map(str, kosuu)))


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int N;
	int A[100];
	int i;
    scanf("%d", &N);
	for(i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for(i = 0; i < N - 1; i++) {
		printf("%d",A[i]);
		printf(" ");
	}
	printf("%d\n", A[N-1]);
	int v;
	int j;
	int k;
	for(i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		for(k = 0; k < N - 1; k++) {
			printf("%d",A[k]);
			printf(" ");
		}
		printf("%d\n", A[N-1]);
	}
    return 0;
}

Measured memory_bytes: 604
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); while( _t-- )
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
// head collected

string str;
ll a, b, c;

start;

    cin3(a, b, c);
    cous(c);
    cous(a);
cou(b);

finish



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b) {
            if(b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if(a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else if(b < c) {
            if(a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else {
                System.out.printf("%d %d %d\n", b, c, a);
            }
        } else {
            System.out.printf("%d %d %d\n", c, b, a);
        }
    }
}



Measured memory_bytes: 26516
#include <iostream>
using namespace std;
int main(void){
    int t,n;
    for(int i=0; i<4; i++){
        cin>>t>>n;
        if(t==1)cout<<n*6000<<endl;
        else if(t==2)cout<<n*4000<<endl;
        else if(t==3)cout<<n*3000<<endl;
        else if(t==4)cout<<n*2000<<endl;
        
    }
    
}



Measured memory_bytes: 3100
N = int(input())
STR = input().split()
W = []
for i in range(N):
    W.append(int(STR[i]))
    
SUM = sum(W)
MIN = SUM
S1 = 0
S2 = SUM

for i in range(N):
    S1 = S1+ W[i]
    S2 = S2 - W[i]
    MIN = min(abs(S2-S1),MIN)
    
print(MIN)

Measured memory_bytes: 3064
# encoding: utf-8
import sys
# input = sys.stdin.readline

H, W = map(int, input().split())

ans = 10 ** 9 + 7

# VVV
for x in range(1, W):
    a = H * x
    b = H * ((W - x) // 2)
    c = H * ((W - x) - (W - x) // 2)
    if a < 1 or b < 1 or c < 1: continue
    ans_tmp = max(a, b, c) - min(a, b, c)
    # print("#", (a, b, c), ans_tmp, ans)
    if ans > ans_tmp: ans = ans_tmp

# VHH
for x in range(1, W):
    a = H * x
    b = (H // 2) * (W - x)
    c = (H - (H // 2)) * (W - x)
    if a < 1 or b < 1 or c < 1: continue
    ans_tmp = max(a, b, c) - min(a, b, c)
    if ans > ans_tmp: ans = ans_tmp

# HHH
for y in range(1, H):
    a = y * W
    b = ((H - y) // 2) * W
    c = ((H - y) - (H - y) // 2) * W
    if a < 1 or b < 1 or c < 1: continue
    ans_tmp = max(a, b, c) - min(a, b, c)
    if ans > ans_tmp: ans = ans_tmp

# HVV
for y in range(1, H):
    a = y * W
    b = (H - y) * (W // 2)
    c = (H - y) * (W - (W // 2))
    if a < 1 or b < 1 or c < 1: continue
    ans_tmp = max(a, b, c) - min(a, b, c)
    if ans > ans_tmp: ans = ans_tmp

print(ans)

Measured memory_bytes: 3444
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,ans,sum[N],K,s[N];
multiset<int>st;
multiset<int>::iterator it;
char c[N];
int main()
{
		scanf("%d%d",&n,&K);
		for (;n--;)
		{
				scanf("%s",c);
				sum[c[0]-'A']++;
		}
		for (i=0;i<26;++i) if (sum[i]) st.insert(sum[i]);
		while (st.size()>=K)
		{
				it=--st.end();
				for (i=1;i<=K;++i) s[i]=*it,--it;
				for (i=1;i<=K;++i) st.erase(st.find(s[i]));
				for (i=1;i<=K;++i) if (s[i]>1) st.insert(s[i]-1);
				++ans; 
		}
		printf("%d\n",ans); 
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	int a[105];
	scanf("%d",&n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	if(sum%10==0)
	{
		sort(a,a+n);
		for(int i=0;i<n;i++)
		{
			if((sum-a[i])%10!=0)
			{
				printf("%d\n",sum-a[i]);
				return 0;
			}
		}
		printf("%d\n",0);
	}
	else
	{
		printf("%d\n",sum);
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

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

	ll count = 0;

	for (int i = 0; i < n - 1; i++) {
		if (h[i] > h[i + 1]) {
			count += (h[i] - h[i + 1]);
		}
	}
	count += h[n - 1];

	cout << count << endl;
	return 0;
}

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

using namespace std;

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

  int n, m;
  cin >> n;
  vector<int> v1(n);

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

  cin >> m;
  vector<int> v2(m);
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    v2[i] = tmp;
  }

  vector<int> r;
  set_union(v1.begin(), v1.end(), v2.begin(), v2.end(), inserter(r, r.end()));

  for (int i = 0; i < r.size(); i++) {
    cout << r[i] << endl;
  }
}




Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
int main(){
int D;
cin>>D;
string r22="Christmas Eve Eve Eve",r23="Christmas Eve Eve",r24="Christmas Eve",r25="Christmas";
if(D==22)cout<<r22;
else if(D==23)cout<<r23;
else if(D==24)cout<<r24;
else if(D==25)cout<<r25;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int r;
    cin >> r;
    cout << r*r << endl;

    return 0;
}


Measured memory_bytes: 3636
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n=int(input())
    s=0
    for _ in range(n):
        x,u=input().split()
        if u=='BTC':
            s+=float(x)*380000.0
        else:
            s+=int(x)
    print(s)

main()

Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    while(true) {
        auto n = readInt();
        if(n == 0) {
            break;
        }
        char[][] m;
        m ~= repeat('0', n+2).array;
        foreach(i; iota(n)) {
            m ~= '0' ~ readln().chomp().to!(char[]) ~ '0';
        }
        m ~= repeat('0', n+2).array;
        auto maxTate = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(i, n+2)) {
                        if(m[k][j] != '1') {
                            ans = max(ans, k-i);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        auto maxYoko = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(j, n+2)) {
                        if(m[i][k] != '1') {
                            ans = max(ans, k-j);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        auto maxNaname1 = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(min(n+2-i, n+2-j))) {
                        if(m[i+k][j+k] != '1') {
                            ans = max(ans, k);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        auto maxNaname2 = (){
            int ans;
            foreach(i; iota(1, n+2)) {
                foreach(j; iota(1, n+2)) {
                    foreach(k; iota(min(n+2-i, j+1))) {
                        if(m[i+k][j-k] != '1') {
                            ans = max(ans, k);
                            break;
                        }
                    }
                }
            }
            return ans;
        }();
        writeln(max(maxTate, maxYoko, maxNaname1, maxNaname2));
    }
}

Measured memory_bytes: 3284
p,q,r=map(int,input().split())
#print(p,q,r)
d=p+q
e=q+r
f=r+p
if d>f and e>f:
    print(f)
elif f>d and e>d:
    print(d)
elif f>e and d>e:
    print(e)
elif d==e or f==d:
    print(d)
elif e==f:
    print(e)


Measured memory_bytes: 3060
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

###########

s=slist()
ns=0
ew=0
if ("N" in s):
    ns+=1
if ("S" in s):
    ns+=1
if ("E" in s):
    ew+=1
if ("W" in s):
    ew+=1

if (ns%2==0 and ew%2==0):
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2820
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define vp(x,y) vector< pair<x,y> >
#define mp make_pair
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x));
#define DSort(x) sort(all(x), greater<>());
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define l_b lower_bound
#define u_b upper_bound
#define u_set unordered_set
#define u_map unordered_map
#define ff first
#define sc second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)

const ll M=1e9+7;
const ld PI=3.14159265;

using namespace std;

int main(){
    fast_io;
    ll t1,d,t,s;
    ld time;
    cin>>d>>t>>s;
    time=(ld)d/s;
    if(time<=t) cout<<"Yes";
    else cout<<"No";
}




Measured memory_bytes: 3660
import java.util.*;

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

    int n = scan.nextInt();
    int count = 0;

    for(int i = 0; i < n; i++){
      int x = scan.nextInt();
      if (CheckPrime(x)){
        count++;
      }
    }

    System.out.println(count);
  }

  static boolean CheckPrime(int x){
    if(x == 1) return false;
    else if(x == 2) return true;
    else if(x % 2 == 0) return false;

    for(int i = 3; i <= Math.sqrt(x); i += 2){
      if(x % i == 0){
        return false;
      }
    }

    return true;
  }
}



Measured memory_bytes: 41112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c=c-b;
		if(c<=0){
			cout<<"Yes";
			break;
		}
		a=a-d;
		if(a<=0)
		{
			cout<<"No";
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){ //1e6くらいまでしか使えん
	vl x(n);
	REP(i, sqrt(n)+2){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll H, W, A, B;
// 変数定義end

void solve(){
	cin >> H >> W >> A >> B;
	REP(i, B){
		REP(j, W){
			if(j < A){
				cout << 0;
			} else {
				cout << 1;
			}
			if(j == W-1){
				cout << endl;
			}
		}
	}
	REP(i, H-B){
		REP(j, W){
			if(j < A){
				cout << 1;
			} else {
				cout << 0;
			}
			if(j == W-1){
				cout << endl;
			}
		}
	}
}

int main(){
    cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 1280
N = gets.to_i
As = gets.split.map(&:to_i)

as = As.sort
am = as.last
h = Hash.new(true)
as.each_with_index do |a, i|
  next unless h[a]
  h[a] = false if a == as[i + 1]
  (2*a).step(am, a){h[_1] = false}
end
puts as.count{h[_1]}


Measured memory_bytes: 69076
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
#define LL long long
#define VLL vector<long long>
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define COUT(x) cout<<x<<endl
#define WHOLE(x) x.begin(),x.end()
	double pai = 3.1415926535;
	string atc = "atcoder";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}

int main() {
	int n, d;
	cin >> n >> d;
	int x[10][10];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	double dis=0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int k = i + 1; k < n; k++) {
			for (int j = 0; j < d; j++) {
				dis += pow(x[i][j] - x[k][j], 2);
			}
			if ((ceill(sqrtl(dis)) == floorl(sqrtl(dis))))ans++;
			dis = 0;
		}

	}
	COUT(ans);
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
void solve(bool *dp,int n){
	if(n>100){
		return ;
	}
	dp[n]=true;
	solve(dp,n+4);
	solve(dp,n+7);
}
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
    bool dp[101];
    for(int i=0;i<=100;i++){
    	dp[i]=false;
    }
    solve(dp,0);
    int n;
    cin>>n;
    if(dp[n]){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int main() {
	int H, W; cin >> H >> W;
	vector<vector<string>>sts(H, vector<string>(W));
	for(int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> sts[i][j];
			if (sts[i][j] == "snuke") {
				cout << char('A' + j) << i + 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



vector<ll> a;

inline void solve(){
    string s;
    cin >> s;
    int n = s.size()+1;
    ll sum = 0;
    a.resize(n);


    for(int i = 0; i < n-1; i++) {
        if(s[i]=='<')
            chmax(a[i+1],a[i]+1);
    }
    for(int i = n-1; i >= 0; i--) {
        if(s[i]=='>')
            chmax(a[i],a[i+1]+1);
    }

    for(int i = 0; i < n; i++) {
        sum += a[i];
    }

    cout << sum << endl;
    
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 4764
N,M = map(int,input().split())
X = sorted(list(map(int,input().split())))
#X.sort()
B=[]

if N>=M:
    print(0)
else:
    for i in range(M-1):
        B.append(X[i+1]-X[i])

    B = sorted(B,reverse = True)
    print(sum(B[N-1:]))



Measured memory_bytes: 20436
#include <stdio.h>
     
int main(void){
     
  int n;
  int a[10001];
  register int i;
  int min = 1000001,big = -1000001;
  long long int sum = 0;
     
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  } 
  for(i = 0;i < n;i++){
    if(min > a[i]){
      min = a[i];
    }
    if(big < a[i]){
      big = a[i];
    }
    sum += a[i];
  }
  printf("%d %d %lld\n",min,big,sum);
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>

int main(void) {
  int w, h, x, y, r;
  
  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

  if (x >= r && x <= w - r) {
    if (y >= r && y <= h - r)
      printf("Yes\n");
    else
      printf("No\n");
  }
  else
      printf("No\n");

  return 0;
}


Measured memory_bytes: 1992
def main():
    s = input()

    pre = [1, 0, 0, 0]

    MOD = int(1e9) + 7

    for i in range(len(s)):
        next_ = [pre[0], pre[1], pre[2], pre[3]]
        if s[i] == "A":
            next_[1] += pre[0]
        elif s[i] == "B":
            next_[2] += pre[1]
        elif s[i] == "C":
            next_[3] += pre[2]
        else:
            next_[0] = pre[0] * 3
            next_[1] = pre[1] * 3 + pre[0]
            next_[2] = pre[2] * 3 + pre[1]
            next_[3] = pre[3] * 3 + pre[2]
        for i in range(4):
            next_[i] %= MOD
        pre = next_
    
    print(pre[3])

if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << setprecision(12) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << setprecision(12) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    int a,b;
    read(a,b);
    write(a*b,a*2+b*2);
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    unordered_map<int, int> Ds;
    for (int i = 0; i < N; ++i){
        int d;
        cin >> d;
        ++Ds[d];
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; ++i){
        int t;
        cin >> t;
        if (Ds.count(t) == 1 and Ds[t] >= 1){
            --Ds[t];
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int b[n];
	int c[n];
	for(int i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	int dpa[n];
	int dpb[n];
	int dpc[n];
	dpa[0]=a[0];
	dpb[0]=b[0];
	dpc[0]=c[0];
	for(int i=1;i<n;i++)
	{
		dpa[i]=max(dpb[i-1]+a[i],dpc[i-1]+a[i]);
		dpb[i]=max(dpa[i-1]+b[i],dpc[i-1]+b[i]);
		dpc[i]=max(dpa[i-1]+c[i],dpb[i-1]+c[i]);
	}
	cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
}

Measured memory_bytes: 2560
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int n, a[100], alice = 0, bob = 0;
	scanf("%d", &n);
	rep(i, n)scanf("%d", &a[i]);
	sort(a, a + n);
	repr(i, n - 1) {
		if (i % 2) {// bob
			bob += a[i];
		}
		else {// alice
			alice += a[i];
		}
	}
	printf("%d\n", int(fabs(alice - bob)));
	return 0;
}


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

int main()
{
    int i,j,k,x,y,z;
    string s;
    stack<int>st;
    cin>>s;
    int ans=0;
    for(i=0;i<s.size();i++)
    {
        if(st.empty())
        st.push(s[i]-48);
        else if((st.top()==1 && s[i]=='0') ||(st.top()==0 && s[i]=='1'))
        {
            ans++;
            st.pop();
        }
        else
        st.push(s[i]-48);
    }
    cout<<2*ans;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y,int z)
{
    int k;
    if(x>y)
    k=x,x=y,y=k;
    while(y%x)
    k=y%x,y=x,x=k;
    if(x>z)
    k=x,x=z,z=k;
    while(z%x)
    k=z%x,z=x,x=k;
    return x;
}
int main()
{
    int ans=0,n,k;
    cin>>k;
    for(int i=1;i<=k;i++)
    for(int j=1;j<=k;j++)
    for(int l=1;l<=k;l++)
    ans+=gcd(i,j,l);
    cout<<ans;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    FOR(i, 1, 3501) {
        FOR(j, 1, 3501) {
            if (4 * i * j - n * (i + j) == 0|| (n * i * j) % (4 * i * j - n * (i + j))!=0) {
                continue;
            }
            ll a = ((n * i * j) / (4 * i * j - n * (i + j)));
            if (a <= 0) {
                continue;
            }
            if (n == 4 * i*j*a / (i*j+j*a + a*i)) {
                cout << i << " " << j << " " << a << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

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

        if(!v[i])
        {
            cout<<0;
            return;
        }
    }

    int prod=1;
    for(int i=0;i<n;++i)
    {
        int x=v[i];

        if(x>inf/prod)
        {
            cout<<-1;
            return;
        }

        prod*=x;
    }

    cout<<prod;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
int _I(){ int x ; scanf("%d", &x); return x; }
int mp[ 10005 ];
int ar[ 100005 ];
void solve()
{
    int h = _I();
    int n = _I();
    int sum = 0;
    for( int i = 0 ; i < n ;i++ ){
            sum += _I();
    }
    printf("%s\n", sum >= h ? "Yes" : "No");

}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int ans[100005];
bool vis[100005];
vector<int> v[100005];
void  dfs(int s){
    vis[s]=true;
    int mx=0;
    for(auto it : v[s]){
        if(!vis[it]){
            dfs(it);
        }
        mx=max(mx,ans[it]+1);
    }
    ans[s]=mx;
}
int32_t main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i){
        int x,y;
        cin>>x>>y;
        x--;y--;
        v[x].push_back(y);
    }
    int mx=0;
    for(int i=0;i<n;++i){
        if(!vis[i])
        dfs(i);
        mx=max(mx,ans[i]);
    }
    cout<<mx;
    return 0;
}


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

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

ans = 0
for i in range(1,len(l) - 1):
    if (l[i-1] > l[i] and l[i] > l[i+1]) or (l[i-1] < l[i] and l[i] < l[i+1]):
        ans += 1

print(ans)

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner fs = new FastScanner();

        final int N = fs.nextInt();

        int[] A = new int[N];
        int[] B = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = fs.nextInt();
            B[i] = A[i] - i - 1;
        }

        Arrays.sort(B);

        long sum = 0;

        for (int i = 0; i < N; i++) {
            sum += Math.abs(B[i] - B[N / 2]);
        }

        System.out.println(sum);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 28928
#include <stdio.h>

int n;
int pre[44], in[44];
int idx;
int flag;

void dfs(int l, int r) {
  int pos = -1;
  int i;
  if(idx == n) return;
  if(l >= r) return;
  for(i = l; i < r; i++) {
    if(pre[idx] == in[i]) pos = i;
  }
  idx++;
  dfs(l, pos);
  dfs(pos+1, r);
  if(flag) printf(" ");
  printf("%d", in[pos]);
  flag = 1;
}

int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", pre+i);
  for(i = 0; i < n; i++) scanf("%d", in+i);
  idx = 0;
  flag = 0;
  dfs(0, n);
  puts("");
  return 0;
}

Measured memory_bytes: 612
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int time = io.r<int>();
        io.w((time / 3600).ToString() + ":" + ((time % 3600) / 60).ToString() + ":" + (time % 60).ToString());
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 9936
import math
import sys

n = int(input())
a = list(map(int, input().split()))


ans = 1
num = 1000000000000000000

if 0 in a:
    print(0)
    sys.exit()

for i in a:
    ans *= i
    if ans > num:
        print(-1)
        sys.exit()

print(ans)

Measured memory_bytes: 22152
def gcd(a,b):
    if a < b:
        temp = a
        a = b
        b = temp
    if a == 0:
        return b
    elif b== 0:
        return a
    elif a % b == 0:
        return b
    else:
        return gcd(a%b,b)

n = int(input())
a = list(map(int,input().split()))
b = [0] * n
c = [0] * n
d = [0] * n
b[1] = a[0]
c[n-2] = a[n-1]
for i in range(2,n):
    b[i] = gcd(b[i-1],a[i-1])
    c[n-1-i] = gcd(c[n-i],a[n-i])
for i in range(n):
    d[i] = gcd(b[i],c[i])
ans = max(d)
print(ans)

Measured memory_bytes: 14076
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
for i in range(3):
  for j in range(3):
    for k in(B):
      if A[j][i] == k:
        A[j][i] = 1
        break
      elif k == B[-1]:
        A[j][i] = 0
if sum(A[0]) == 3 or sum(A[1]) == 3 or sum(A[2]) == 3:
  print('Yes')
elif sum([row[0] for row in A]) == 3 or sum([row[1] for row in A]) == 3 or sum([row[2] for row in A]) == 3:
  print('Yes')
elif A[0][0] + A[1][1] + A[2][2] == 3 or A[2][0] + A[1][1] + A[0][2] == 3:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064