akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int a, b;
	cin >> a >> b;
	string ans = IsEven(a * b) ? "Even" : "Odd";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 2005
#define oo 1000000000
#define zyy 1000000007
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;
	return f?-x:x;
}
set<int> s;
int n;
int main(){
	n=read();
	For(i,1,n){
		int x=read();
		if(s.find(x)==s.end()) s.insert(x);
		else s.erase(x);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int X = reader.nextInt();
		int ans = getMaxSquareBase(X);

		System.out.println((int)Math.pow(ans, 2));
		reader.close();
	}

	public static int getMaxSquareBase(int num) {
		int base = 1;
		while (Math.pow((base + 1), 2) <= num) {
			base++;
		}
		return base;
	}
}





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

#define MAXN 25
#define int long long
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

using namespace std;

int N;
int a[MAXN][MAXN];
int dp[1<<MAXN];
int mod = 1e9+7;

int cnt(int x) {
    int res = 0;
    while (x) {
        res++;
        x &= x-1;
    }
    return res;
}

signed main() {
    fastio;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) cin >> a[i][j];
    }
    dp[0] = 1;
    
    for (int s = 0; s < (1 << N); s++) {
        int i = cnt(s);
        for (int j = 0; j < N; j++) {
            if (s & (1 << j)) continue;
            if (a[i+1][j+1])
                dp[s | (1 << j)] = (dp[s | (1 << j)] + dp[s]) % mod;
        }
    }
    
    cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 18688
#include <iostream>
#include <cmath>

int main(void) {
  long long int n, d;
  long long int x, y;
  std::cin >> n >> d;

  int answer = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> x >> y;
    if (std::sqrt(x*x + y*y) <= d) {
      answer++;
    }
  }
  std::cout << answer << std::endl;
  return 0;
}


Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100];

int main(void){
	int n,i,m;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i]; 
	}
	sort(a,a+n);
	if(n%3){
		cout << ((a[0]==a[n-1])?"Yes":"No") << endl;
		return 0;
	}
	m = n/3;
	for(i=0; i<3; ++i){
		if(a[i*m]!=a[(i+1)*m-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << ((a[0]^a[m]^a[m*2])?"No":"Yes") << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

s = input()
n = len(s)
a = s[:n//2]
b = s[(n+1)//2:]
def f(s):
    return s == s[::-1]
y(f(s) and f(a) and f(b))



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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

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

int main() {
	int N;
	cin >> N;
	vector<int> A;
	A.push_back(0);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	A.push_back(0);
	N += 2;

	ll sum = 0;
	for(int i = 0; i < N - 1; i++) {
		sum += abs(A[i] - A[i + 1]);
	}

	for(int i = 1; i < N - 1; i++) {
		ll diff = abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]) - abs(A[i + 1] - A[i - 1]);
		cout << sum - diff << endl;
	}



	return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s[50];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int c[50][26] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < s[i].size(); j++) {
            c[i][s[i][j] - 'a']++;
        }
    }
    for (int i = 1; i < n; i++) {
        for (int k = 0; k < 26; k++) {
            c[0][k] = min(c[0][k], c[i][k]);
        }
    }

    for (int k = 0; k < 26; k++) {
        for (int i = 0; i < c[0][k]; i++) {
            cout << (char)('a' + k);
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
// INCLUDES
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define what_is(x) cerr << #x << 'is' << x << endl;
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
//HELPERS
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << '=' << a << endl;
err(++it, args...);
}
vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n;
cin>>n;
int count = 0,r=0;
while(n!=0) {
    n/=2;
    count+=pow(2,r);
    r++;
}
cout<<count;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<set>
#include<vector>
#define N 500005
using namespace std;
vector<int> G[N];
set<int> S,T;
set<int> :: iterator it;
int n,k,a[N],b[N],d[N],w[N],m;
int main()
{
	int i,x;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]),b[a[i]]=i;
	for(i=1;i<k;i++) T.insert(a[i]);
	for(i=1;i<=n;i++){
		if(i+k-1<=n) T.insert(a[i+k-1]);
		if(i) T.erase(a[i-1]);
		S.insert(a[i]);
		if(i>k) S.erase(a[i-k]);
		it=S.upper_bound(a[i]);
		if(it!=S.end())
			G[b[*(it)]].push_back(i),d[i]++;
		it=T.upper_bound(a[i]);
		if(it!=T.end())
			G[b[*(it)]].push_back(i),d[i]++;
	  }
	S.clear();
	for(i=1;i<=n;i++)
		if(!d[i]) S.insert(-i);
	while(S.size()){
		x=-(*S.begin()),w[++m]=x;
		S.erase(S.begin());
		for(i=0;i<G[x].size();i++)
			if(!(--d[G[x][i]]))
				S.insert(-G[x][i]);
	  }
	for(i=1;i<=n;i++) b[w[i]]=n-i+1;
	for(i=1;i<=n;i++)
		printf("%d\n",b[i]);
	return 0;
}


Measured memory_bytes: 62720
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

//#define _DEBUG_ 2
void run() {
	int n; cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (x & 1) count++;
	}
	cout << (count & 1 ? "NO" : "YES") << endl;
}

int main() {
#ifdef _DEBUG_
	using std::chrono::system_clock;
	using std::chrono::duration_cast;
	system_clock::time_point  start, end;
	std::ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	for (int i = 0; i < _DEBUG_; i++) {
		cout << "-------------------------- (cnt:" << i << ")" << endl;
		start = system_clock::now();
		run();
		end = system_clock::now();
		int elapsed = duration_cast<std::chrono::milliseconds>(end - start).count();
		cout << "-------------------------- (time:" << elapsed << "ms)" << endl << endl;
}
#else
	run();
#endif
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=0
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
l.sort()
for i in range(n):
    if(l[i][1]<=k):
        s+=l[i][0]*l[i][1]
        k-=l[i][1]
    else:
        s+=l[i][0]*k
        k=0
    if(k==0):
        break
print(s)


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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int L,R;
  L=A+B;
  R=C+D;
  if (L>R) {
    cout<<"Left"<<endl;
  }
  else if (L<R) {
    cout<<"Right"<<endl;
  }
  else {
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int s = (new Scanner(System.in)).nextInt();
    Set<Integer> set = new HashSet<>();
    set.add(s);
    s = s % 2 == 0 ? s / 2 : s * 3 + 1;
    while (!set.contains(s)) {
      set.add(s);
      s = s % 2 == 0 ? s / 2 : s * 3 + 1;
    }
    System.out.println(set.size() + 1);
  }
}

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

int main() {
  int n;
  cin >> n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if(s == "AC") ac++;
    if(s == "WA") wa++;
    if(s == "TLE") tle++;
    if(s == "RE") re++;
  }
  
  cout << "AC" << " " << "x" << " " << ac << endl;
  cout << "WA" << " " << "x" << " " << wa << endl;
  cout << "TLE" << " " << "x" << " " << tle << endl;
  cout << "RE" << " " << "x" << " " << re << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 300005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

ll power(ll a,ll b)
{
    ll res = 1;
    while(b != 0)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b /= 2;
    }
    return res;
}
int main() 
{ 
	// srand(time(NULL));
	// for (int i = 0; i < 50; ++i)
	// {
	// 	cout << rand() % 30 + 1 << " ";
	// }
	map <ll, ll> tm;
	ll n, cnt = 0, val, x, A[N];
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
		tm[A[i]]++;
	}
	sort(A, A + n);
	for (int i = 32; i >= 1; --i)
	{
		val = power(2, i);
		for (int i = 0; i < n; ++i)
		{
			if(A[i] <= val)
			{
				if(2 * A[i] == val)
				{
					if(tm.count(A[i]) > 0 && tm[A[i]] >= 2)
					{
						cnt += tm[A[i]] / 2;
						tm[A[i]] = tm[A[i]] % 2;
					}
				}
				else
				{
					ll pp = val - A[i], tmp;
					if(tm.count(A[i]) > 0 && tm.count(pp) > 0)
					{
						tmp = min(tm[A[i]], tm[pp]);
						cnt += tmp;
						tm[A[i]] -= tmp;
						tm[pp] -= tmp;
					}
					
				}
			}
		}
	}
	cout << cnt;
} 

Measured memory_bytes: 14848
n = list(map(int,input().split()))
l = list(map(int,input().split()))

length = 0;
answer = 1;
i = 0;

while length + l[i] <= n[1]:
    length = length + l[i]
    answer = answer + 1
    if(len(l) == (i+1)):
        break;
    i = i + 1

#if(answer <= n[0]):
print(answer)
#else:
#    print(n[0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}

signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	rep(i,n)cin>>h[i];
	sort(h.begin(),h.end());
	int ans=0;
	rep(i,n-k)ans+=h[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
const double eps=1e-8;
int main()
{
	int n;
	int m;
	cin >> n >> m;
	int a[105];
	int sum = 0;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		sum+=a[i];
	}
	sort(a+1,a+1+n,greater<int>());
	for(int i = 1; i <= m; ++i){
		if(a[i]*4*m<sum){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;

    int count = 0;

    rep(i, n)  {
        int h;
        cin >>h ;
        if( h >= k) {
            count ++;
        }
    }

    cout << count << endl;




}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
def judge(X):
  Y=[[A[0],1]]
  Z=0
  for i in range(N-1):
    if A[i]<A[i+1]:
      Y.append([A[i+1]-A[i],1])
    else:
      Z=A[i]-A[i+1]
      for j in range(len(Y)):
        if Y[-1][0]<=Z:
          Z-=Y[-1][0]
          del Y[-1]
        else:
          Y[-1][0]-=Z
          break
      Z=0
      for j in range(len(Y)-1,-2,-1):
        if j==-1:
          return False
        if Y[j][1]==X or Y[j][0]==0:
          Z+=Y[j][0]
          del Y[j]
        else:
          if Y[j][0]==1:
            Y.append([1,Y[j][1]+1])
            del Y[j]
          else:
            Y[j][0]-=1
            Y.append([1,Y[j][1]+1])
          if Z:
            Y.append([Z,1])
          break
  return True

L,R,M=1,10**9,0
while R>L:
  M=(L+R)//2
  if judge(M):
    R=M
  else:
    L=max(L+1,M)
print(L)

Measured memory_bytes: 264048
n=int(input())
H=[int(i) for i in input().split()]
H.append(0)
import math
dp=[1e10 for i in range(n+2)]
dp[0]=0

for i in range(n-1):
    dp[i+1]=min(dp[i+1],dp[i]+abs(H[i+1]-H[i]))
    dp[i+2]=min(dp[i+2],dp[i]+abs(H[i+2]-H[i]))

print(dp[n-1])

Measured memory_bytes: 13924
import java.util.Scanner;

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

		int c[][] = new int[3][3];
		for(int i = 0; i < 3; i++)
		{
			for(int j = 0; j < 3; j++)
			{
				c[i][j] = sc.nextInt();
			}
		}
		
		boolean b1 = c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[0][0] - c[0][1] == c[2][0] - c[2][1];
		boolean b2 = c[0][0] - c[0][2] == c[1][0] - c[1][2] && c[0][0] - c[0][2] == c[2][0] - c[2][2];
		boolean b3 = c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][0] - c[1][0] == c[0][2] - c[1][2];
		boolean b4 = c[0][0] - c[2][0] == c[0][1] - c[2][1] && c[0][0] - c[2][0] == c[0][2] - c[2][2];
		
		if(b1 && b2 && b3 && b4)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 21844
<?php

fscanf(STDIN, "%d", $num);

$fst = 0;

for($i=0;$i<$num;$i++){
    $tmp = str_split(trim(fgets(STDIN)));
    foreach($tmp as $n => $value){
        if($value == 1){
            $map[$i][$n] = $n;
            if($fst == 0){
                $start = [$i, $n];
                $fst = 1;
            }
            $len[$i][$n] = 1;
        }else {
            if ($i == $n) {
                $len[$i][$n] = 0;
            } else {

            $len[$i][$n] = PHP_INT_MAX;
            }
        }

    }

}
$bmap = array_fill(0,$num,-1);
$end = array_fill(0,$num,0);

$bmap[$start[0]] = 0;

if(bipartite_graph($start) == -1){
    echo -1;
    exit;
}
echo diameter_graph($len,$num) + 1;

function bipartite_graph($start){
    global $map, $bmap, $end;
    $return = 0;
    if($bmap[$start[0]] == $bmap[$start[1]]) {
        return (-1);
    }else{
        if($bmap[$start[1]] == -1){
            $bmap[$start[1]] = ($bmap[$start[0]] + 1 )% 2;
        }
    }
    if($end[$start[1]] == 0) {
        $end[$start[1]] = 1;
        foreach ($map[$start[1]] as $value => $_value) {
            $return = min($return, bipartite_graph([$start[1], $value]));
        }
    }
    return($return);
}

function diameter_graph($map, $n){
    for($i=0;$i<$n;$i++){
        for($j=0;$j<$n;$j++){
            for($k=0;$k<$n;$k++){
                $map[$j][$k] = min($map[$j][$k], $map[$j][$i] + $map[$i][$k]);

            }
        }
    }
    $max = 0;
    for($i=0;$i<$n;$i++){
        $max = max($max, max($map[$i]));
    }
    return $max;
}

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

int H, W;
string A[1010];
bool used[1010][1010];

int dr[4] = {0, 0, -1, 1};
int dc[4] = {-1, 1, 0, 0};

void solve() {
    cin >> H >> W;
    REP(i, H) cin >> A[i];

    queue<vector<int>> q;
    REP(i, H) REP(j, W) if (A[i][j] == '#') q.push({i, j, 0});
    int ans = 0;

    while (!q.empty()) {
        int r = q.front()[0];
        int c = q.front()[1];
        int d = q.front()[2];
        q.pop();
        if (used[r][c]) continue;
        used[r][c] = true;
        ans = max(ans, d);
        REP(i, 4) {
            int nr = r + dr[i];
            int nc = c + dc[i];
            if (nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
            if (used[nr][nc]) continue;
            q.push({nr, nc, d+1});
        }
    }

    cout << ans << endl;
}

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


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define FOR(i,s,e) for(int i = s; i < e; i++)
#define all(x) (x).begin(),(x).end()
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair

typedef vector<int>       VI;
typedef pair<int, int> pii;
typedef long long ll;


int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    string week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int c = 7;
    string q;
    cin>>q;
    for (string w : week){
        if(w==q){
            printf("%d",c);
            return 0;
        }
        else{
            c--;
        }
    }
    // freopen("out.txt", "w", stdout);
    return 0;
}

Measured memory_bytes: 256
# 入力
N, K, X, Y = [int(input())for i in range(4)]

# 処理
S = int()
# S = K * X + (N - K) * Y
if N > K:
    S = K * X + (N - K) * Y
else:
    S = N * X

# 出力
print(S)


Measured memory_bytes: 9028
#include <iostream>

using namespace std;

int main(){
    int n;

    cin >> n;
    n %= 10;

    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon" << endl;
    }
    else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }

    return 0;
}

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

int main(){
    int ans=0;
    string s;
    char te;
    cin >> s;
    te=s.at(0);
    for(int i=1;i<s.size();i++){
        if(te!=s.at(i)){
            te=s.at(i);
            ans++;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 512
N=int(input())
L=[[] for i in range(N)]
for i in range(N):
  M=int(input())
  L[i]=[list(map(int,input().split())) for j in range(M)]
#print(L)

L_2=[[i,None] for i in range(N)]
L_3=[0 for i in range(N)]
ans=0
for k in range(2**N):
	L_3=[0 for i in range(N)]
	Y_N=True
	count=0
	for a in range(N):
		if ((k >> a) & 1):  # 正直者のリストを作る
			L_3[a]=1
	for a in range(N):  # このループが一番のポイント
		if ((k >> a) & 1):  # 正直者のリスト
			count += 1
			for b in range(len(L[a])):
				if L_3[a] == 0: #もし正直者じゃないとされてたら
					Y_N=False #破綻
				person = L[a][b][0]-1
				if L_3[person]==1-L[a][b][1]: #すでに言われてることと矛盾
					Y_N=False #破綻
				L_3[person]=L[a][b][1] #証言の内容で人となりをアップデート
				#print(L_3,a,b)
	#print(L_3,count,Y_N)
	if Y_N:
		ans = max(ans, count)
print(ans)

Measured memory_bytes: 47068
n = int(input())
mod = 1000000007
fact = [i+1 for i in range(1,n)]
ans = []
exp = 0
for base in range(2,n+1):
  exp = 0
  for i,num in enumerate(fact):
    while True:
      if num % base == 0:
        num = num // base
        exp += 1
      else:
        fact[i] = num
        break
  if exp>0:
    ans.append([base,exp])

ans_ans=1
for i in range(len(ans)):
  ans_ans *= (ans[i][1]+1)
  ans_ans %= mod

print(ans_ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;

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

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

int main() {
	int a, p; cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s;
    cin>>s;
    int l=s.length();
    FOR(i,0,l){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    vector<int> a[m + 1];
    int e, k;
    for (int i = 1; i <= m; i++) {
        cin >> k;
        while (k--) {
            cin >> e;
            a[i].pb(e);
        }
    }

    int p[m + 1];
    for (int i = 1; i <= m; i++) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        int on = 0;
        int just[m + 1];
        map<int, int> onswith;
        for (int j = 0; j < n; j++) {  //j switch
            if ((1 << j) & i) {
                onswith[j + 1] = 1;
            }
        }


        for (int bulb = 1; bulb <= m; bulb++) {
            int how = 0;
            for (int req : a[bulb]) {
                if (onswith[req]) how++;
            }

            if (how % 2 == p[bulb]) on++;
        }

        if (on == m) ans++;
    }

    cout << ans;



}


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

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  ll s = a + b - k;
  if (s >= b) a = s-b;
  else if (s < b){
    a = 0;
    b = s;
  }
  if ( 0 > b ) b =0 ;
  cout << a << " " << b << endl;
  return 0;
}


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

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(std::string C){
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    print(alpha[C[0] - 'a' + 1]);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var N, cnt int

func main() {
	fmt.Scan(&N)
	a := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	c := make([]int, 3)

	for i := 0; i < N; i++ {
		var cnt int
		for j := 0; j < 2; j++ {
			if a[i]%2 == 0 {
				cnt++
				a[i] /= 2
			}
		}
		c[cnt]++
	}
	if c[2]+1 == c[0] && N == (c[2]+c[0]) || c[2] >= c[0] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] > a[j][0]
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<char,char> p2;
#define sz(a) ll(a.size())
ll a[200005];
void solve(){
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	for(ll i=k+1;i<=n;i++)
	if(a[i]>a[i-k])
	cout<<"Yes\n";
	else
	cout<<"No\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();
}


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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for(auto& p:mp){
    int s=p.second;
    ans+=(ll)s*(s-1)/2;
  }
  cout<< ans <<endl;
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (int i = 0; i < n; i++)
int main()
{
	int H, A;
	int cnt = 0;
	cin >> H >> A;
	while (H > 0)
	{
		H = H - A;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class Pair
{
	public int I { get; private set; }
	public int X { get; private set; }
	public int M { get; set; }

	public Pair(int i, int x)
	{
		I = i;
		X = x;
	}
}


public class C
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());

		string[] args = Console.ReadLine().Split(' ');
		List<Pair> list = new List<Pair>(N);
		for(int i = 0; i < N; i++)
			list.Add(new Pair(i, Int32.Parse(args[i])));
		list.Sort((a,b) => a.X - b.X);

		int m1 = list[N/2].X;
		int m2 = list[N/2 - 1].X;
		for(int i = 0; i < N; i++)
			list[i].M = (i < N/2) ? m1 : m2;
		list.Sort((a,b) => a.I - b.I);

		for(int i = 0; i < N; i++)
			Console.WriteLine(list[i].M);	
	}
}





Measured memory_bytes: 38976
X = int(input())

def define_rate(X):
    if X >= 1800:
        return 1
    elif X >= 1600:
        return 2
    elif X >= 1400:
        return 3
    elif X >= 1200:
        return 4
    elif X >= 1000:
        return 5
    elif X >= 800:
        return 6
    elif X >= 600:
        return 7
    elif X >= 400:
        return 8

print(define_rate(X))

Measured memory_bytes: 9156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    int D, T, S;
    cin >> D >> T >> S;

    if (S * T >= D) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

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

  int A, B, M; cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int mina = 1 << 30, minb = 1 << 30;
  for (int i = 0; i < A; i++) {
    cin >> a[i];
    mina = min(mina, a[i]);
  }
  for (int j = 0; j < B; j++) {
    cin >> b[j];
    minb = min(minb, b[j]);
  }
  int ans = mina + minb;
  for (int i = 0; i < M; i++) {
    int x, y, c; cin >> x >> y >> c;
    ans = min(ans, a[x-1] + b[y-1] - c);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

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

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

ll calc(const vector<P> &L, vector<ll> p){
  vector<P> es;
  REP(i, L.size()){
    if(L[i].first < L[i].second){
      es.push_back(P(L[i].first, i + 1));
      es.push_back(P(L[i].second,- i - 1));
    }
  }
  REP(i, p.size()) es.push_back(P(p[i], 0));

  sort(ALL(es));


  ll S = 0;
  int cur = 0;  
  set<int> ls[2];
  
  REP(i, es.size()){
    S +=  ls[cur].size() * (es[i].first - (i == 0 ? 0 : es[i-1].first));
    if(es[i].second > 0){
      ls[cur].insert(es[i].second - 1);
    }else if(es[i].second < 0){
      REP(j, 2) ls[j].erase(-es[i].second-1);
    }else{
      cur = 1 - cur;
    }
  }
  
  return S;
}

int main(){
  int n, m;
  cin >> n >> m;
  const ll MAXP = 1000 * 1000 * 1000;

  vector<P> l(n);
  vector<ll> p(m);
  
  REP(i, n) cin >> l[i].first >> l[i].second;
  REP(i, m) cin >> p[i];
  ll S = calc(l, p);
  
  REP(i, n){
    l[i].first = MAXP - l[i].first;
    l[i].second= MAXP - l[i].second; 
  }
  REP(i, m){
    p[i] = MAXP - p[i];
  }
  
  cout << S + calc(l, p) << endl;
  return 0;
}

Measured memory_bytes: 12372
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 505;

int n;
int a[MAXN][MAXN];

ll ans;
ll in[MAXN][MAXN];
ll out[MAXN][MAXN];
ll f[2][MAXN][MAXN];

int main()
{
	scanf("%d",&n);
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= n;j++)
			if (i != j)
				scanf("%d",&a[i][j]);
	for (int i = 1;i <= n;i++)
		for (int j = 1;j < i;j++)
		{
			in[i][j] = in[i][j - 1] + a[j][i];
			out[i][j] = out[i][j - 1] + a[i][j];
		}
	for (int i = 0;i < 2;i++)
		for (int j = 0;j <= i;j++)
			for (int k = 0;k <= j;k++)
				f[i][j][k] = 1e18;
	f[0][0][0] = 0;
	for (int i = 0;i < n - 1;i++)
	{
		for (int j = 0;j <= i + 1;j++)
			for (int k = 0;k <= j;k++)
				f[~i & 1][j][k] = 1e18;
		for (int j = 0;j <= i;j++)
			for (int k = 0;k <= j;k++)
				if (f[i & 1][j][k] != 1e18)
				{
					f[~i & 1][j][k] = min(f[~i & 1][j][k],f[i & 1][j][k] + in[i + 2][i + 1] - in[i + 2][j] + out[i + 2][k]);
					f[~i & 1][i + 1][j] = min(f[~i & 1][i + 1][j],f[i & 1][j][k] + out[i + 2][j]);
				}
	}
	ans = 1e18;
	for (int i = 0;i <= n - 1;i++)
		for (int j = 0;j <= i;j++)
			ans = min(ans,f[~n & 1][i][j]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

int main() {
    int n, m; cin >> n >> m;

    vector<int> a(n);

    int s = 0;

    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
        s += a.at(i);
    }

    int cnt = 0;

    for (int j = 0; j < n; ++j) {
        if (a.at(j) >= 1.0 * s / (4 * m)) {
            cnt++;
        }
    }

    if (cnt >= m)
        cout << "Yes";
    else
        cout << "No";
}


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

import sys
import os
import math

N = int(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'

def encode(s, alpha, beta):
    t = []
    for c in s:
        if c == ' ':
            t.append(c)
        else:
            gamma = ord(c) - 97
            v = (alpha * gamma + beta) % 26
            w = alphabet[v]
            t.append(w)
    return ''.join(t)


for i in range(N):
    s = input().strip()
    
    for a in range(0, 26):
        for b in range(0, 26):
            encoded_this = encode('this', a, b)
            encoded_that = encode('that', a, b)
            if encoded_this in s or encoded_that in s:
                encoded_alphabet = encode(alphabet, a, b)
                table = str.maketrans(encoded_alphabet, alphabet)
                dst = s.translate(table)
                print(dst)

Measured memory_bytes: 7820
#include <iostream>
#include <cstdlib>
#include <string>
#include <stack>
using namespace std;

int main(void){
    stack <int> s;
    int a, b;
    string c;
  
    while(cin >> c){
        if(c == "+"){
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(a + b);
        }
        else if(c == "-"){
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(b - a);
        }
        else if(c == "*"){
            a = s.top(); s.pop();
            b = s.top(); s.pop();
            s.push(a * b);
        }else{
            s.push(atoi(c.c_str()));
        }
    }
/*
    while(std::cin >> c){
        if(c == "+"){
        int post = s.top(); s.pop();
        int pre = s.top();  s.pop();
        
        s.push(pre + post);
        }else if(c == "-"){
        int post = s.top(); s.pop();
        int pre = s.top();  s.pop();
        
        s.push(pre - post);
        }else if(c == "*"){
        int post = s.top(); s.pop();
        int pre = s.top();  s.pop();
        
        s.push(pre * post);
        }else{
        s.push(std::atoi(c.c_str()));
        }
    }
*/
    std::cout << s.top() << std::endl;

    return 0;
}

/*
while(std::cin >> input){
    if(input == "+"){
      int post = s.top(); s.pop();
      int pre = s.top();  s.pop();
      
      s.push(pre + post);
    }else if(input == "-"){
      int post = s.top(); s.pop();
      int pre = s.top();  s.pop();
      
      s.push(pre - post);
    }else if(input == "*"){
      int post = s.top(); s.pop();
      int pre = s.top();  s.pop();
      
      s.push(pre * post);
    }else{
      s.push(std::atoi(input.c_str()));
    }*/
  


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ws(x) cerr << #x << " is " << x << endl
#define pb push_back
#define ats(x) cout << x << "\n"
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef pair <int, int> pii;
typedef vector<pii> vii;
typedef tuple<int, int, int> tiii;

const int INF = INT_MAX;

vector <ll> a;

int main()
{
    FAST_IO;
    int n;
    cin >> n;
    ll ans = 1;
    bool zero = false;
    for (int i = 0; i < n; i++){
        ll num;
        cin >> num;
        a.pb(num);
        if (num == 0) zero = true;
    }
    if (zero) ats(0);
    else {
        for (ll x:a){
        if (x <= 1000000000000000000 / ans){
            ans *= x;
        }
        else {
            ans = -1;
            break;
        }
        }
    if (ans > 1000000000000000000) ans = -1;
    ats(ans);
    }
    return 0;
}


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

struct UnionFind {
    vector<int> Parent;

    UnionFind(int N) { Parent = vector<int>(N, -1); }

    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }

    int size(int A) { return -Parent[root(A)]; }

    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return false;
        }

        if (size(A) < size(B)) swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }

    bool same(int A, int B) { return root(A) == root(B); }

    int num(int N) {
        set<int> s;
        for (int i = 0; i < N; i++) {
            s.insert(root(i));
        }
        return s.size();
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind Uni(M);

    vector<int> L[N];
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int a;
            cin >> a;
            a--;
            L[i].emplace_back(a);
            if (j > 0) {
                Uni.connect(L[i][j - 1], L[i][j]);
            }
        }
    }
    vector<int> v(M, 0);
    for (int i = 0; i < N; i++) {
        v[Uni.root(L[i][0])]++;
    }
    int m = *max_element(v.begin(), v.end());
    cout << (m == N ? "YES" : "NO") << endl;
}

Measured memory_bytes: 6528
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
  public static void main(String[] args) {
    Integer[] age753 = {7,5,3};
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if (Arrays.asList(age753).contains(x)) System.out.println("YES");
    else System.out.println("NO");
  }
}

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

int main() {
	int k,x;
  	cin>>k>>x;
  
  	x+=1000000;
      
      
  
  for(int i=0;i<=2000000;i++){
    if(i>x-k&&i<x+k) {
    	cout<<i-1000000<<" ";
    }
  }
  	
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}


#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}


use std::fmt::Display;
#[allow(dead_code)]
pub fn print_vec<T: Display>(v: &Vec<T>, prefix: &str, suffix: &str) {
    if v.is_empty() {
        println!("[]");
        return;
    }
    print!("{}", prefix);
    print!("{}", v[0]);
    for i in 1..v.len() {
        print!(" {}", v[i]);
    }
    println!("{}", suffix);
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, ) = input!(usize);

    let b = invec!(u32);

    let mut a = Vec::with_capacity(n);

    a.push(b[n - 2]);
    for i in (1..(n - 1)).rev() {
        a.push(std::cmp::min(b[i], b[i - 1]));
    }
    a.push(b[0]);

    a.reverse();
    // print_vec(&a, "", "");
    println!("{}", a.iter().sum::<u32>());
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
import Data.List
import Data.Function

main :: IO ()
main = do
 n <- read <$> getLine :: IO Int 
 as <- map read . words  <$> getLine :: IO [Int]
 let ias = zip [0..] as
     summed = sum as
     ans = minimumBy (compare `on` snd)
       $ map (\(i, a) -> (i, abs (a*n-summed))) ias
 putStrLn $ show $ fst ans

Measured memory_bytes: 892
#include <cstdio>
#include <iostream>

using namespace std;

const int Maxn = 110;
const int INF = 1e5;

int n, m, x, y;
int a = -INF, b = INF;

int main()
{
    scanf("%d%d%d%d", &n, &m, &x, &y);
    for(int i = 1, tmp; i <= n; ++i)
    {
        scanf("%d", &tmp);
        a = max(tmp, a);
    }
    for(int i = 1, tmp; i <= m; ++i)
    {
        scanf("%d", &tmp);
        b = min(tmp, b);
    }
    // (x, y]
    // a < z, b >= z
    if(a < b && a < y && b > x) puts("No War");
    else puts("War");
    return 0;
}

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


void solve(string A, string B){
    if(A.length()>B.length()) {
        cout << "GREATER"<< endl;
        return;
    }
    else if(A.length()<B.length()) {
        cout << "LESS" << endl;
        return;
    }
    else{
        ll n = A.length();
        for(ll i=0; i< n; i++){
            if(A.at(i)>B.at(i)) {
                cout<<"GREATER"<< endl;
                return;
            }
            else if(A.at(i)<B.at(i)){
                cout << "LESS"<< endl;
                return;
            }
        }
    }
    cout << "EQUAL" << endl;
}

int main(){
    string A, B;
    cin >> A >> B;
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
# Train

n = int(raw_input())

for i in range(n):
    train = iter(raw_input().strip())
    cars = [next(train)]
    j = 0
    while True:
        try:
            rr = next(train)
            if rr == '-':
                next(train)
                rr = next(train)
                j += 1
                if j == len(cars):
                    cars = cars + [rr]
            elif rr == '<':
                next(train)
                rr = next(train)
                j -= 1
                if j == -1:
                    cars = [rr] + cars
                    j = 0
        except StopIteration:
            print ''.join(cars)
            break

Measured memory_bytes: 4244
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint par[200500]; //MAX_N
lint ufsize[200050]; //MAX_N

void init(lint x){
  rep(i,x) par[i]=i,ufsize[i]=1;
}

lint root(lint x){
  if(par[x]==x) return x;
  else return par[x]=root(par[x]);
}

bool same(lint x,lint y){
  return root(x)==root(y);
}

void unite(lint x,lint y){
  x=root(x);
  y=root(y);
  if(x==y) return;
  lint s=ufsize[x]+ufsize[y];
  ufsize[x]=s,ufsize[y]=s;
  par[x]=y;
}

lint size(lint x){
  return ufsize[root(x)];
}

struct edge{lint u,v,cost;};
bool comp(const edge& e1,const edge& e2){
    return e1.cost<e2.cost;
}

edge es[200000]; //MAX_E
int V,E;

lint kruskal(){
    sort(es,es+E,comp);
    init(V);
    lint res=0;
    rep(i,E){
        edge e=es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}

int main(void){
    int N;
    cin >> N;
    V=N;
    E=2*(N-1);
    pair<plint,int> in[N];
    rep(i,N) cin >> in[i].fi.fi >> in[i].fi.se,in[i].se=i;
    sort(in,in+N);
    rep(i,N-1) es[i].u=in[i].se,es[i].v=in[i+1].se,es[i].cost=in[i+1].fi.fi-in[i].fi.fi;
    rep(i,N) swap(in[i].fi.fi,in[i].fi.se);
    sort(in,in+N);
    rep(i,N-1) es[i+N-1].u=in[i].se,es[i+N-1].v=in[i+1].se,es[i+N-1].cost=in[i+1].fi.fi-in[i].fi.fi;
    cout << kruskal() << endl;
}

Measured memory_bytes: 12272