akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int zero,negative,positive,n,k,ans;
vector<int> a,b;

bool check(int lim){
	int cnt=0;
	if(lim==0){
		cnt=zero+negative;
	}
	if(lim>0){
		cnt=zero+negative;
		if(b.size()) for(int l=0,r=b.size()-1;;r--){
			while(b[l]*b[r]>lim&&l<r) l++;
			if(l>=r) break;
			cnt+=r-l;
		}
		if(a.size()) for(int l=0,r=a.size()-1;;l++){
			while(a[l]*a[r]>lim&&r>l) r--;
			if(l>=r) break;
			cnt+=r-l;
		}
	}
	if(lim<0){
		int p=0;
		if(a.size()&&b.size()) for(auto x:b){
			if(x*a[a.size()-1]>lim) break;
			while(x*a[p]>lim) p++;
			cnt+=a.size()-p; 
		}
	}
//	printf("#%lld %lld\n",lim,cnt);
	return cnt>=k;
}

signed main(){
	read(n);read(k);//k=n*(n-1)/2-k+1;
	for(int i=1,x;i<=n;i++){
		read(x);
		if(x>0) a.push_back(x);
		if(x<0) b.push_back(x);
		if(!x) zero++;
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	zero=zero*(n-zero)+zero*(zero-1)/2;
	negative=a.size()*b.size();
//	check(read(positive));
	positive=a.size()*(a.size()-1)/2+b.size()*(b.size()-1)/2;
	int l=-1e18,r=1e18;//max(a.size()>1?a[a.size()-1]*a[a.size()-2]:0,b.size()>1?b[0]*b[1]:0);
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	write(ans);
}

Measured memory_bytes: 2420
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
const int INF = (1 << 30);

//毎回変える場所
#define N_MAX 200


//問題文のとおり
int H, W;
int alpha[26];
int main() {
	cin >> H >> W;
	REP(i, H) {
		string a;
		cin >> a;
		REP(j, W) {
			alpha[a[j] - 'a']++;
		}
	}
	//両方偶数
	if (H % 2 == 0 && W % 2 == 0) {
		REP(i, 26)if (alpha[i] % 4 != 0)goto bad;
	}
	//片方偶数
	else if (H % 2 == 0 || W % 2 == 0) {
		int four = 0, two = 0;
		REP(i, 26)switch (alpha[i] % 4) {
		case 1:
		case 3:
			goto bad;
		case 0:
			four++;
			break;
		case 2:
			two++;
			break;
		}
		
		if (H % 2 != 0) {
			if (two > W / 2)goto bad;
		}
		else {
			if (two > H / 2)goto bad;
		}
	}
	//両方奇数
	else {
		int one = 0, two = 0, three=0,four = 0;
		REP(i, 26)switch (alpha[i] % 4) {
		case 0:four++; break;
		case 1:one++; break;
		case 2:two++; break;
		case 3:three++; break;
		}
		//中央
		if (one + three != 1)goto bad;
		//境目
		if (two + three > (H - 1) / 2 + (W - 1) / 2)goto bad;
	}
	cout << "Yes" << endl;
	cin >> W;
	return 0;
bad:
	cout << "No" << endl;
	cin >> W;
	return 0;
}

Measured memory_bytes: 256
def abc():
    w, a, b = map(int, input().split())
    if a < b:
        x1 = a
        x2 = b
    else:
        x1 = b
        x2 = a
    if x1 <= x2 <= x1 + w:
        print(0)
        return
    print(x2 - (x1 + w))


abc()


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

using i64 = int64_t;

int main(){
    int a, b;
    while(cin >> a >> b, a > 0){
        int n;
        cin >> n;
        vector<pair<int, int>> v;
        for(int i=0;i<n;++i){
            int x, y;
            cin >> x >> y;
            x--; y--;
            v.emplace_back(x, y);
        }
        vector<vector<i64>> dp(a, vector<i64>(b));
        dp[0][0] = 1;
        for(int i=0;i<a;++i){
            for(int j=0;j<b;++j){
                bool flag = false;
                for(int k=0;k<n;++k){
                    if(i == v[k].first && j == v[k].second){
                        flag = true;
                        break;
                    }
                }
                if(flag)continue;
                if(i < a-1)dp[i+1][j] += dp[i][j];
                if(j < b-1)dp[i][j+1] += dp[i][j];
            }
        }
        cout << dp[a-1][b-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

void chmax(int &a, int b) { a = max(a, b); }

int h, w, n;
int r[200000], c[200000], v[200000];
int mp[3001][3001];
int dp[3001][3001][5];

signed main() {
	int i, j, k;
	
	cin >> h >> w >> n;
	rep(i, n) { cin >> r[i] >> c[i] >> v[i]; r[i]--; c[i]--; }
	rep(i, n) { mp[r[i]][c[i]] = v[i]; }
	
	int INF = 1e+16;
	rep(i, h) rep(j, w) rep(k, 4) dp[i][j][k] = -INF;
	
	dp[0][0][0] = 0;
	rep(i, h) {
		rep(j, w) {
			rep(k, 4) {
				if (dp[i][j][k] == -INF) continue;
				//拾う
				if (k < 3) {
					chmax(dp[i][j + 1][k + 1], dp[i][j][k] + mp[i][j]);
					chmax(dp[i + 1][j][0], dp[i][j][k] + mp[i][j]);
				}
				chmax(dp[i][j + 1][k], dp[i][j][k]);
				chmax(dp[i + 1][j][0], dp[i][j][k]);
			}
		}
	}
	
	int ans = 0;
	rep(i, 4) {
		if (i < 3) ans = max(dp[h-1][w-1][i] + mp[h-1][w-1], ans);
		else ans = max(dp[h-1][w-1][i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 430100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n) ans += a[i]-1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$S = array();
for ($n=0; $n<$N; $n++){
    fscanf(STDIN, "%s", $tmp);
    $S[] = $tmp;
}
$array_count = array_count_values($S);

$max = array_keys($array_count, max($array_count));
#var_dump($max);

asort($max);

foreach($max as $word){
    echo $word."\n";
}

Measured memory_bytes: 107732
#include <bits/stdc++.h>
using namespace std;
int main() {
    int P,ans=0;
    int maximum=0;
    for(int i=0;i<5;i++){
        cin>>P;
        ans=ans+P;
        if(P%10!=0){
            ans=ans+(10-(P%10));
            maximum=max(maximum,10-(P%10));
        }
    }
    cout<<ans-maximum;

    return 0;
}

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

int main() {
	int N;
	cin >> N;
	long ans = 1;
	unordered_map<int, long> a;
	for (int i = 1; i <= N; i++) {
		int b = i;
		for (int j = 2; j * j <= b; j++) {
			while (b % j == 0) {
				b /= j;
				a[j]++;
			}
		}
		if (b != 1) a[b]++;
	}
	for (const pair<int, long>& i : a) {
		ans *= i.second + 1;
		ans %= 1000000007;
	}
	cout << ans;
}

Measured memory_bytes: 256
n = int(input())
R = [list(input().split()) for i in range(n)]

for i in range(n):
    R[i].append(i+1)

R = sorted(R, key=lambda x: int(x[1]), reverse=True)
R = sorted(R, key=lambda x: x[0])

for r in R:
    print(r[2])


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <tuple>
#include <set>
#include <functional> 
#include <string.h>

#define X first
#define Y second
#define MP make_pair
#define MT make_tuple
#define FOR(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REP(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll > pll;
using namespace std;
const int MAX = 101;
const double PI = 3.1415926535897932384;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

int main(){
	string s;
	while (cin >> s){
		if (cin.eof()) break;
		
		vector<vector<char> > w(3, vector<char>(3, 0));
		FOR(i, s.size()){
			w[i / 3][i % 3] = s[i];
		}

		char ans = 0;
		bool d1 = true, d2 = true;
		FOR(i, 3){
			if (i){
				if (w[i - 1][i - 1] != w[i][i]) d1 = false;
				if (w[2 - (i - 1)][i - 1] != w[2 - i][i]) d2 = false;
			}

			bool t = true, y = true;
			REP(j, 1, 3){
				if (w[i][j - 1] != w[i][j]) y = false;
				if (w[j - 1][i] != w[j][i]) t = false;
			}

			if (t || y){
				if (w[i][i] != 's') ans = w[i][i];
			}
		}

		if (d1 || d2){
			if (w[1][1] != 's') ans = w[1][1];
		}

		if (ans == 0 || ans == 's') cout << 'd' << endl;
		else cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
ll mpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1){
            res*=x;
            res%=MOD;
        }
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
int main(){
    int n;cin>>n;
    string s;cin>>s;
    int m=s.length();
    vector<vector<ll>> dp(n+1,vector<ll>(n+1));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=i;j++){
            dp[i+1][j+1]+=dp[i][j]*2LL;dp[i+1][j+1]%=MOD;
            if(j>0){
                dp[i+1][j-1]+=dp[i][j];dp[i+1][j-1]%=MOD;
            }else{
                dp[i+1][j]+=dp[i][j];dp[i+1][j]%=MOD;
            }
        }
    }
    cout<<dp[n][m]*mpow(mpow(2,m),MOD-2)%MOD<<endl;
}   


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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n;
    cin >> n;
    vi a(4);
    rep(i, n) {
        string s;
        cin >> s;
        if (s == "AC") a[0]++;
        else if (s == "WA") a[1]++;
        else if (s == "TLE") a[2]++;
        else if (s == "RE") a[3]++;
    }

    cout << "AC x " << a[0] << '\n';
    cout << "WA x " << a[1] << '\n';
    cout << "TLE x " << a[2] << '\n';
    cout << "RE x " << a[3] << '\n';

    return 0;
}


Measured memory_bytes: 3568
from sys import stdin
import numpy as np
input = stdin.readline

N = int(input())
A_list = list(map(int, input().split()))
# ans_list =np.ones(N)
# A_list = np.array(A_list)

# for i in range(N-1):
#     for j in range(i+1,N):
#         if A_list[i] %  A_list[j] == 0:
#             ans_list[i] = 0
#             if (A_list[j] %  A_list[i] == 0):
#                 ans_list[j] = 0
#         elif(A_list[j] %  A_list[i] == 0):
#             ans_list[j] = 0
# print(int(np.sum(ans_list)))
A_set = list(set(A_list))
maxA =  A_set[-1]
dp = [1] * (( 10 ** 6) + 1)

cntli = [0] * (( 10 ** 6) + 1)
unique =[]
for i in A_list:
    cntli[i] += 1
for i in range((( 10 ** 6) + 1)):
    if cntli[i] == 1:
        unique.append(i)

for elem in A_set:
    for i in range(2 * elem,  10 ** 6 + 1, elem):
        dp[i] = 0

ans = 0
for i in unique:
    if not (dp[i] == 0):
        ans += 1

print(ans)






Measured memory_bytes: 60652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
const int maxn = 1e5+10;
#define INF 1e9+10
using namespace std;
int a[maxn];
int main()
{
    int a[1000]={0};
    int num;
    for(int i = 0; i < 3; i ++)
    {
        cin >> num;
        a[num]++;
    }
    int ans = 0;
    for(int i = 0; i < 1000; i ++)
    {
        if(a[i]!=0)ans ++ ;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e4;

int main() {
    int h, n; cin >> h >> n;
    vint dp(10005,inf);
    dp[0] = 0;
    rep(i,n) {
        int a, b; cin >> a >> b;
        rep(j,10005) chmin(dp[j],dp[max(j-a,0)]+b);
    }
    cout << dp[h] << endl;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    ll ans = 0;
    ll tmp = 0;
    for(int i = 0; i < N-1; i++)
    {
        if(H[i] >= H[i+1]) tmp++;
        else if(H[i] < H[i+1])
        {
            ans = max(ans, tmp);
            tmp = 0;
        }
        if(i == N-2) ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100

int n,M[N][N];
int color[N],d[N],f[N],ad;

void visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++ad;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++ad;
}

void dfs(){
  int u;
  for(u=0;u<n;u++)color[u]=WHITE;
  ad=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
   scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}

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

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll n, m;
  cin >> n >> m;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  vector<pair<ll, ll>> os;
  rep(i, n) rep(j, m) if (s[i][j] == 'o') os.emplace_back(i, j);
  ll on = os.size();
  const ll BIG = 1'000'000;
  const ll ONMAX = 1000;
  mcf_graph<ll, ll> g(n * m + 2);
  ll gs = n * m, gt = n * m + 1;
  rep(i, n) rep(j, m) {
    if (s[i][j] == '#') continue;
    if (i > 0) g.add_edge((i - 1) * m + j, i * m + j, ONMAX, 0);
    if (j > 0) g.add_edge(i * m + (j - 1), i * m + j, ONMAX, 0);
  }
  rep(i, n) rep(j, m) {
    g.add_edge(i * m + j, gt, 1, BIG * (n - 1 - i + m - 1 - j));
  }
  itr(o, os) g.add_edge(gs, o.first * m + o.second, 1, 0);
  g.flow(gs, gt, on);
  ll ans = 0;
  itr(e, g.edges()) {
    // if (e.flow > 0 || true) {
    //   cout << e.from << "-" << e.to << " (" << e.flow << ") <" << e.cost << ">" << endl;
    // }
    if (e.from == gs || e.to == gt) continue;
    ans += e.flow;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4456
#krishrawat

import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

s=ip()
s.append('R')
n=len(s)
cnt=1
idx=-1
for i in range(1,n):
    if(s[i]!=s[i-1] and s[i]=='R'):
        mx=max(cnt-k,k)
        s[idx]=math.ceil(cnt/2)
        s[idx-1]=math.floor(cnt/2)
        if(k>cnt-k):
            s[idx],s[idx-1]=s[idx-1],s[idx]
        if(mx%2==0):
            s[idx],s[idx-1]=s[idx-1],s[idx]
        cnt=1
    elif(s[i]!=s[i-1] and s[i]=='L'):
        k=cnt
        idx=i
        cnt+=1
    else:
        cnt+=1
    if(s[i-1]=='L' or s[i-1]=='R'):    
        s[i-1]=0    
print(*s[:n-1])        

Measured memory_bytes: 86836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include<stack>
#include <unordered_map>

using namespace std;

#define MAX(A,B) (A)>(B)?(A):(B)
#define MIN(A,B) (A)<(B)?(A):(B)

int main() {

	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int max = -10000;
	for (int i = 0, x; i < N; i++) {
		cin >> x;
		if (x > max)max = x;
	}
	max++;
	int min = 10000;
	for (int i = 0, y; i < M; i++) {
		cin >> y;
		if (y < min)min = y;
	}

	if ((X < max && min <= Y)&&
		min>=max){
		cout << "No War";
	}
	else {
		cout << "War";
	}



	return 0;
}


Measured memory_bytes: 256
length,house = map(int,input().split())	
plot= list(map(int,input().split()))
plot.append(plot[0]+length)
ans=[]
for i in range(1,house):
  ans.append(min(length-abs((plot[i-1]-plot[i])),length-abs((plot[i+1]-plot[i]))))
ans.append(min(length-abs(plot[-1]-plot[-2]),length-abs(plot[1]-plot[0])))  
print(min(ans)) 

Measured memory_bytes: 26444
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
	int q;
	bool pos= true;
	string s = "Yes";
	cin >> s >> q;
	for(int i=0;i<q;i++){
		int ope;
		char hoge;
		cin >> ope;
		if (ope == 1) {
			pos = !pos;
			continue;
		}
		cin >> ope;
		cin >> hoge;
		if ((ope == 1 && pos) || (ope != 1 && !pos)) {
			s.insert(s.begin(), hoge);
		}
		else {
			s.insert(s.end(), hoge);
		}
	}
	if (!pos) {
		reverse(s.begin(), s.end());
	}
	cout << s << endl;
}


Measured memory_bytes: 1024
def main():
    n = int(input())
    a = list(map(int,input().split()))
    if 0 in a: 
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    
if __name__ =="__main__":
    main()

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

#define int long long
const int INF = 1LL << 60;


int cost(int i, int s, const vector<int> &A){
    if(s == 0 || s == 4) return A[i];
    else if(s == 1 || s == 3){
        if(A[i] % 2 == 0 && A[i] > 0) return 0;
        else if(A[i] > 0) return 1;
        else return 2;
    }else{
        if(A[i] % 2 == 0) return 1;
        else return 0;
    }
}

signed main() {

    int L; cin >> L;
    vector<int> A(L);
    for(int i = 0; i < L; i++) cin >> A[i];

    vector<vector<int> > dp(L + 1, vector<int> (5, INF));
    dp[0][0] = 0;
    for(int i = 0; i < L; i++){
        for(int j = 0; j < 5; j++){
            for(int k = j; k < 5; k++){
                dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + cost(i, k, A));
            }
        }
    }

    int ans = INF;
    for(int j = 0; j < 5; j++) ans = min(ans, dp[L][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#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<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,M;
ll res;
priority_queue<int> q;

int main(){
	scanf("%d %d",&len,&M);
	for(int i=1; i<=len; i++){
		int a; scanf(" %d",&a);
		q.push(a); res+=a;
	}
	while(M--){
		int g = q.top(); q.pop();
		res-=(g+1)/2;
		q.push(g/2);
	}
	printf("%lld\n",res);
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<int> b(N);  
  for ( int i = 0; i < N; i++ ) {
    int tmp = 0;
    for ( int j = 0; j < 10; j++ ) {
      int a;
      cin >> a;
      tmp |= (a<<j);      
    }
    b[i] = tmp;
  }

  int P[N][11];
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < 11; j++ ) {
      cin >> P[i][j];
    }
  }

  int ans = -1e15;  
  for ( int i = 1; i < (1<<10); i++ ) {
    int tmp = 0;
    for ( int j = 0; j < N; j++ ) {
      int k = i;
      k &= b[j];
      k = __builtin_popcountll(k);
      tmp += P[j][k];      
    }
    ans = max(ans, tmp);
  }

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


Measured memory_bytes: 256
n = int(input())
s = input()
ans = s.count('R')*s.count('G')*s.count('B')
if ans==0:
    print(ans)
else:
    for i in range(n):
        for j in range(i+1, n):
            k=2*j-i
            if k<n:
                if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
                    ans -= 1
    print(ans)

Measured memory_bytes: 68308
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <iomanip>
 
using namespace std;
int main(){
  int n, m;
cin >> n >> m;
int pen = 0, score = 0;
vector<int> ac(n+1, 0);
vector<int> wa(n + 1, 0);
for (int i = 0; i < m; i++) {
	string res = ""; int problem = 0;
	cin >> problem >> res;
	if (res == "AC") {
		if (ac[problem]) {
			continue;
		}
		else {
			score++;
			ac[problem] = 1;
		}
	}else if (res == "WA") {
		if (ac[problem]) {
			continue;
		}
		else {
			wa[problem]++;
		}
	}
}
 
for (int i = 1; i <= n; i++) {
	if (ac[i]) {
		pen += wa[i];
	}
}
cout << score << " " << pen << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int INF=2e9;
const double PI=acos(-1);


vector<pair<int,string>> vectorCnt(vector<string> a) {
    sort(a.begin(),a.end());
    int n=a.size();
    vector<pair<int,string>> b;
    int cnt=1;
    rep(i,n-1) {
            if (a[i+1]!=a[i]) {
                b.push_back(make_pair(-cnt,a[i]));
                cnt=1;
            } else {
                ++cnt;
            }
    }
    b.push_back(make_pair(-cnt,a[n-1]));
    return b;
}

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

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    vector<pair<int,string>> p=vectorCnt(s);
    sort(p.begin(),p.end());
    int m=p.size();
    int c=p[0].first;
    rep(i,m) {
        if (p[i].first==c) cout << p[i].second << endl;
    }
     
    return 0;   
}

Measured memory_bytes: 26268
import bisect
Q = int(input())
maxn = 10 ** 5
intn = [True] * (maxn+1)
intn[0] = False
intn[1] = False
prime = list()
like2017 = list()
for n in range(2, maxn+1):
  if(intn[n] == False):
    continue
  prime.append(n)
  tmp = n
  while(tmp <= maxn):
    intn[tmp] = False
    tmp += n

for i in prime:
  q = (i+1)//2
  q_loc = bisect.bisect_left(prime, q)
  if(prime[q_loc] == q):
    like2017.append(i)

for i in range(Q):
  l, r = map(int, input().split())
  ln = bisect.bisect_left(like2017, l)
  rn = bisect.bisect_right(like2017, r)
  print(rn-ln)

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

long long t[200000];

int main(){

    int n;
    cin >> n;

    for(int i=0;i<n;i++){
        scanf(" %d",&t[i]);
    }

    if(n%2==0){
        for(int i=n;i!=0;i-=2){
            printf("%d ",t[i-1]);
        }
        for(int i=0;i<n-3;i+=2){
            printf("%d ",t[i]);
        }
        printf("%d",t[n-2]);
    }
    else if(n==1){
        cout << t[0] << endl;
    }
    else{
        for(int i=n;i!=-1;i-=2){
            printf("%d ",t[i-1]);
        }
        for(int i=1;i<n-3;i+=2){
            printf("%d ",t[i]);
        }
        printf("%d",t[n-2]);

    }
    return 0;

}

Measured memory_bytes: 3712
#!/usr/bin/env python3
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        k = (n - i * r - j * g) // b
        if k < 0:
            continue
        if i * r + j * g + k * b == n:
            ans += 1
print(ans)


Measured memory_bytes: 40940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

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

  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;

  return 0;
}


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

int main(){
    string S = "";
    char x;
    bool left = true;
    getline(cin, S);
    for (int i = 0; i < S.size(); i++)
    {
        if (S.at(i) == ' ' && left)
        {
            x = S.at(i + 1);
            break;
        }
        
    }
    cout << 'A' << x << 'C' << endl;

}

Measured memory_bytes: 3548
package main

import (
	"fmt"
//	"strconv"
//	"sort"
	"math"
//	"regexp"
)


var N int
var ans,ans_c int

func main(){
	fmt.Scan(&N)
	if N ==1 {
		fmt.Println(1)
	}else{
		for i:=1;i<=N;i++{
			var cnt int
			var t int = i
			for t % 2 == 0{
				cnt++
				t /= 2
			}
			if ans_c < cnt{
				ans = i
				ans_c = cnt
			}
		}
		fmt.Println(ans)
	}
}

func max(x,y int)int{
	return int(math.Max(float64(x),float64(y)))
}

Measured memory_bytes: 512
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))


import itertools

L = list(itertools.permutations([i for i in range(1, N + 1)]))

a = b = 1

for l in L:
    if l == P:
        break
    a += 1
for l in L:
    if l == Q:
        break
    b += 1
print(abs(a-b))

Measured memory_bytes: 8052
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	//std::ifstream in("../../test.txt");
	//std::cin.rdbuf(in.rdbuf());

	string L;
	cin >> L;

	ll bit = L.size();


	vl DP0(bit + 3);
	vl DP1(bit + 3);

	DP1[0] = 0;
	DP0[0] = 1;

	rep(i, bit) {
		if (L[i] == '0') {
			DP0[i + 1] += DP0[i];
			DP1[i + 1] += DP1[i] * 3 % MOD;
		}
		else {
			DP0[i + 1] += DP0[i] * 2 % MOD;
			DP1[i + 1] += (DP1[i] * 3 % MOD + DP0[i]) % MOD;
		}

	}


	cout << (DP0[bit] + DP1[bit]) % MOD << endl;





	return 0;
}



Measured memory_bytes: 2616
program main
implicit none
integer :: i, j, k
integer :: n, y

read(*,*) n, y
do i = 0, n
   do j = 0, n-i
      k = n - i - j
      if( 1000*i + 5000*j + 10000*k == y ) then
         write(*,'(i0,a1,i0,a1,i0)') k, ' ', j, ' ', i
         stop
      end if
   end do
end do
write(*,'(i0,a1,i0,a1,i0)') -1, ' ', -1, ' ', -1

end program main


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

int main(){
  string S;
  cin>>S;
  int i=0;
  bool flg=true;

  while(S[i]=='L' || S[i]=='R' || S[i]=='U' || S[i]=='D'){
    if(i%2==1 && S[i]=='R') {flg=false; break;}
    if(i%2==0 && S[i]=='L') {flg=false; break;}
    i++;
  }
  cout<<(flg ? "Yes" : "No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    return d > 0? 1 : -1;
}

struct Vector {
    double x, y;
    Vector(double x, double y): x(x), y(y) {
    }
};

typedef Vector Point;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector operator-(const Point& a, const Point& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

int main() {
    double x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    Point p0(x0, y0);
    Point p1(x1, y1);
    
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        double x2, y2;
        cin >> x2 >> y2;
        Point p2(x2, y2);
        
        Vector v01 = p1 - p0;
        Vector v02 = p2 - p0;
        
        double d = dot(v01, v02);
        double c = cross(v01, v02);
        
        double norm1 = dot(v01, v01);
        double norm2 = dot(v02, v02);
        
        if (dcmp(c) > 0) {
            cout << "COUNTER_CLOCKWISE" << endl; 
        }
        else if (dcmp(c) < 0) {
            cout << "CLOCKWISE" << endl;
        }
        else if (dcmp(c) == 0 && dcmp(d) < 0 ) {
            cout << "ONLINE_BACK" << endl;
        }
        else if (dcmp(c) == 0 && dcmp(d) > 0 && dcmp(norm2 - norm1) > 0) {
            cout << "ONLINE_FRONT" << endl;
        }
        else {
            cout << "ON_SEGMENT" << endl;
        }
        
    }
    
    
    return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>
#include<string.h>
#define M 5000000
#define T '0'
#define L 14

int getChar(char);
long long getKey(char[]);
int h1(int);
int h2(int);
int find(char[]);
int insert(char[]);

int ll=0;
char H[M][L]; /* Hash Table */
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){
  int h,i=0;
  long long key,j;
  key=getKey(str);
  while(1){
    j=(h1(key)+h2(key)*i)%M;
    if(strcmp(str,H[j])==0){
      return j;
    }else if(H[j][0]=='\0'||i>=M){
      return 0;
    }else i++;
  }
  
  return 0;
}

int insert(char str[]){
  int h,i=0;
  long long key,j;
  key=getKey(str);
  while(1){
    j=(h1(key)+h2(key)*i)%M;
    if(H[j][0]=='\0'){
      strcpy(H[j],str);
      return j;
    }else i++;
  }
  
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
	      printf("yes\n");
	    } else {
	      printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 70148
N,M = [int(i) for i in input().rstrip().split()]


def nCk(N,K):
    c,p = 1,1
    for k in range(1,K+1):
        c *= (N - k + 1)
        p *= k
    return c//p

print(nCk(N,2)+nCk(M,2))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 210;

int n;
int arr[MAXN];
int ans;

bool cmp(const int &x, const int &y){return x < y;}

int main(){
	scanf("%d", &n); n <<= 1;
	for(int i = 1; i <= n; i++) scanf("%d", &arr[i]);
	sort(arr + 1, arr + n + 1, cmp);
	for(int i = 1; i <= n; i += 2) ans += arr[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define vi vector<long long>
#define vvi vector<vector<long long>>
int main(void){
    int n;
    cin>>n;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin>>h[i];
        if(i>0){
            int dif = h[i]-h[i-1];
            if(dif>=0){
                if(dif>0) h[i]--;
            }
            else{
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int gcd(int a,int b);
int main(){
    int k,sum=0;
    scanf("%d",&k);
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                sum+=gcd(i,gcd(j,l));
                

            }
        }
    }

    printf("%d\n",sum);
    
    
    
    return 0;
}

int gcd(int a,int b){
    int small;
    if(a<b){
        small=a;
    }else{
        small=b;
    }
    int max=1;
    for(int i=1;i<=small;i++){
        if((a%i==0)&&(b%i==0)){
            max=i;
        }
    }
    return max;
}

Measured memory_bytes: 1732
#include<stdio.h>
int dices[100][6];

int rotate(int res[], int x, int y, int z, int d1, int d2)
{
    int i, temp;
    for(i=0;i<6;i++){
        res[i] = dices[d1][i];
    }
    while(x--){
        temp = res[0];
        res[0] = res[1];
        res[1] = res[5];
        res[5] = res[4];
        res[4] = temp;
    }
    while(y--){
        temp = res[1];
        res[1] = res[2];
        res[2] = res[4];
        res[4] = res[3];
        res[3] = temp;
    }
    while(z--){
        temp = res[0];
        res[0] = res[2];
        res[2] = res[5];
        res[5] = res[3];
        res[3] = temp;
    }
    if(res[0]==dices[d2][0] && res[1]==dices[d2][1] && res[2]==dices[d2][2] && res[3]==dices[d2][3] && res[4]==dices[d2][4] && res[5]==dices[d2][5]){
        return 1;
    }else{return 0;}
}
int main()
{
    int res[6], i, j, k, x, y, z, found, n;

    scanf("%d", &n);
    for(i=0;i<n;i++){
        for(j=0;j<6;j++)scanf("%d", &dices[i][j]);
    }
    found = 0;
    for(i=0;i<n && found!=1;i++){
        for(j=i+1;j<n && found!=1;j++){
            for(x=0;x<4 && found!=1;x++){
                for(y=0;y<4 && found!=1;y++){
                    for(z=0;z<4 && found!=1;z++){
                        found = rotate(res, x, y, z, i, j);
                    }
                }
            }
        }
    }
    if(found == 0) printf("Yes\n");
    else printf("No\n");

    return 0;
}



Measured memory_bytes: 2112
five_hund = int(input())
one_hund = int(input())
fifty = int(input())
X = int(input())
count = 0

for five in range(five_hund + 1):
  for one in range(one_hund + 1):
    for fif in range(fifty + 1):
      if(five * 500 + one * 100 + fif * 50 == X):
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
    #define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    #define ll long long
    //pair<int, int> *p=new pair<int, int>[n];
    //std::vector<pair<int,int>> vp;
    //v.push_back(make_pair(x,y))
    //pair<int, int> p[1001];
    //string *s=new string [n];
     
    //int freq[e];
    //freq[a[i]-'a']++; freq[a[i]]++;
    using namespace std;  
        ll t,c1,c2,c3,sum,m,mn,k;
        vector<int>v1,v2,v3;

    int main(void)
    {
        SpeeD;  
 string s,t;
 cin>>s>>t;
 int a,b;
 cin>>a>>b;
 string u;
 cin>>u;
 if (u==s)a--;
 else b--;
 cout<<a<<" "<<b;
 


}



Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);
  
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  for(i=1 ; i < n+1 ; i++)
    {
      key = A[i];
      j = i - 1;
      while( j >= 0 && A[j] > key )
	{
	  A[j+1] = A[j];
	  j--;
	  A[j+1] = key;
	}
      trace(A,n);
    }
  return 0;
}

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

int main() {
   int n, k; cin >> n >> k;
   vector<int> ans(n);
   rep(i, k) {
        int d; cin >> d;
        rep(j, d) {
            int tmp;
            cin >> tmp;tmp--;
            ans[tmp]++;
        }
   }
   int sum = 0;
   rep(i, n) {
       if (ans[i] == 0) sum++;
   }    
   cout << sum << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)
    	cout<<"Yes";
 else
   	cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
bool chk[10];
int main() {
	int a;
	int i;
	for (i = 0; i < 4; i++) {
		scanf("%d", &a);
		chk[a] = true;
	}
	if (chk[1] && chk[9] && chk[7] && chk[4]) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 128
program main
integer :: n,i,j,d,c
real(8),allocatable :: p(:,:)
real(8) :: a,b

c=0

read(*,*)n,d
allocate(p(n,d))
do i = 1,n
read(*,*)(p(i,j),j=1,d)
end do

do i = 1,n-1
do j = i+1,n
a = dsqrt(sum((p(i,:) - p(j,:))**2))
b = int(a)
if (a == b) c=c+1
end do
end do

write(*,*)c

end program main

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int n;
vector<int> a;

int find_min(int d) {
  int p = a[d];
  int i;
  for (i=d+1; i<n; i++) {
    if (p < a[i]) {
      i--;
      break;
    }
    p = a[i];
  }
  return i;
}
int find_max(int d) {
  int p = a[d];
  int i;
  for (i=d+1; i<n; i++) {
    if (p > a[i]) {
      i--;
      break;
    }
    p = a[i];
  }
  if (i>=n) i=n-1;
  return i;
}

int main()
{
  ll ans=1000;
  ll stock=0;
  int state=0;
  int dmin, dmax;

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

  for (int i=0; i<n;) {
    if (state == 0) { //買い待ちの状態
      dmin = find_min(i);
//printf("day: %d, dmin=%d\n", i, dmin);
      if (dmin >= n) break;
      stock = ans/a[dmin];
      ans %= a[dmin];
//printf("stock = %lld, ans = %lld\n", stock, ans);
      state = 1;
      i = dmin+1;
    } else {
      dmax = find_max(i);
//printf("day: %d, dmax=%d\n", i, dmax);
      ans += stock * a[dmax];
      stock = 0;
//printf("stock = %lld, ans = %lld\n", stock, ans);
      state = 0;
      i = dmax+1;
    }
  }

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


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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int a=in(),b=in();
    cout << max({a+b,a-b,a*b}) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
K = 2 if N%2 else 1
INF = float('inf')
dp = [[[-INF]*2 for _ in range(K+1)] for _ in range(N+1)]
dp[0][K][0] = 0 #dp[i][can_skip][must_skip]
for i,a in enumerate(A):
    for k in range(K,-1,-1):
        dp[i+1][k][0] = max(dp[i+1][k][0], dp[i][k][1])
        dp[i+1][k][1] = max(dp[i+1][k][1], dp[i][k][0] + a)
        if k:
            dp[i+1][k-1][0] = max(dp[i+1][k-1][0], dp[i][k][0])
print(max(max(row) for row in dp[-1][:2]))

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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

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


int main(){
int K; cin>>K;
string S; cin>>S;
if(S.size() <= K){
    cout<<S<<endl;
}else{
    REP(i,K){
        cout<<S.at(i);
    }
    cout<<"..."<<endl;
}
 
}

Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a,b; cin >> a >> b;
  cout << a*b << endl;
  
}

Measured memory_bytes: 3636
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

int main(int argc, char *argv[])
{
  ll n, m, d;
  cin >> n >> m >> d;
  cout << fixed << setprecision(20) << double(d > 0 ? 2 * n - 2 * d : n) / n  * (m - 1) / n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stack>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector < int > G;
//间隔为g的插入排序 
void insertionSort(int A[],int n,int g)
{
	for(int i = g; i < n; i++)
	{
		int v = A[i];
		int j = i - g;
		while( j>= 0 && A[j] > v)
		{
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}
void shellSort(int A[],int n)
{
	for(int h = 1 ; ; )
	{
		if(h > n)
		break;
		G.push_back(h);
		h= 3*h + 1;
	}
	for(int i = G.size()-1 ; i >= 0 ; i--)
	{
		insertionSort(A , n , G[i] );
	}
}

int main()
{
  cin>>n;
  for(int i = 0;i < n; i++)
{
	cin>>A[i];
}
cnt = 0;
shellSort(A,n);

cout<<G.size()<<endl;
for(int i = G.size() - 1 ; i>=0 ; i-- )
{
	cout<<G[i];
	if(i!=0)
	{
		cout<<" ";
	 } 
  }
  cout<<endl;  
cout<<cnt<<endl;

for(int i = 0 ;i < n ;i++)
{
	cout<<A[i]<<endl;
}
	return 0;
}


Measured memory_bytes: 7080
"use strict"

const input = require("fs").readFileSync("/dev/stdin","utf8").trim();
let b = [];
for(let bit=0 ; bit < 1<<input.length-1 ;bit++) {
  let a = [];
  for(let shift=0; shift < input.length-1; shift++) {
    if((bit >> shift) & 1) a.push(1);
    else a.push(0);
  }
  b.push(a);
}
let sum = 0;
b.forEach((array) => {
  let tmpSum = 0;
  let str = "";
  Array.prototype.forEach.call(input, (item, index) => {
    str += item;
    if ((index === (input.length - 1) || array[index] === 1)) {
      tmpSum += Number(str);
      str = "";
    }
  })
  sum += tmpSum;
});
console.log(sum);

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


Measured memory_bytes: 256
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 17:01:58 2019
//
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)

	n := strconv.Itoa(N)
	if (n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

void sort(int *arr, int n);

int main(){
    int a,b;
    scanf("%d %d\n", &a, &b);
    int m1,m2,m3,ans;
    m1 = a + (a-1);
    m2 = b + (b-1);
    m3 = a + b;
    int arr[4];
    arr[0] = m1;
    arr[1] = m2;
    arr[2] = m3;

    sort(arr, 3);

    ans = arr[2];

    printf("%d\n", ans);

}

void sort(int *arr, int n){
    int i,j,temp=0;
    for(i=0;i<n-1;i++){
        for(j=0;j<n-1;j++){
            if(arr[j] > arr[j+1]){
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }
}


Measured memory_bytes: 1732