akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


ll d(ll n) {
  return to_string(n).length();
}


void Main() {
  ld a, b, x;
  ll max_item = 1000000000;
  cin >> a >> b >> x;
  ld kakudo;

  if (a*a*b/2 > x) {
    kakudo = atan(2*x/a/b/b);
  }
  else {
    kakudo = atan(a*a*a/2/(a*a*b-x));
  }

  COUT(90 - kakudo * 180 / PI);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


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

ll MOD = 1000000007;

int main(){
  ll N, K;
  cin >> N >> K;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  ll ans = 0;
  for(int i = 0; i < N; i++){
    ll A = 0;
    ll B = 0;
    for(int j = 0; j < N; j++){
      if(a[j] < a[i]) A++;
    }
    for(int j = i + 1; j < N; j++){
      if(a[j] < a[i]) B++;
    }

    ans += K * B;
    ans %= MOD;

    ll tmp = K * (K - 1) / 2;
    tmp %= MOD;
    tmp *= A;
    tmp %= MOD;

    ans += tmp;
    //ans += ((A + (K - 1) * A) % MOD) * ((K - 1) % MOD / 2;
    ans %= MOD;
  }

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


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

int main()
{
	string S;
	cin >> S;
	int sl = S.size();
	int i,t, count = 0, Max = 0;
	for (i = 0; i < sl; i++) {
		count = 0;
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') {
			count = 1;
			for (t = i + 1; t < sl; t++) {
				if (S[t] == 'A' || S[t] == 'T' || S[t] == 'C' || S[t] == 'G') {
					count++;
				}
				else
					break;
			}
			Max = max(Max, count);
		}

	}
	cout << Max;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int seat[17] = {0};
	int X = 0;
	int stop[100] = {0};
	int time = 0;
	queue<int> Q;
	while(X < 100){
		int x;
		if(time%5 == 0 && time < 500){
			Q.push(time/5);
		}
		while(1){
			if(Q.size())x = Q.front();
			else x = -1;
			bool f = false;
			
			if(~x){
				int people = (x%5==1?5:2);
				int use = 19 + 3 * (x%3) + 17 * (x%2);
				rep(i,17-people+1){
					bool flag = true;
					rep(j,people){
						flag &= seat[i+j] == 0;
					}
					if(flag){
						rep(j,people){
							seat[i+j] = use;
						}
						f = true;
						break;
					}
				}
			}
			if(f){
				stop[x] = time - x * 5;
				Q.pop();
				X++;
			}
			if(!f)break;
		}
		rep(i,17){
			seat[i] = max(0,seat[i]-1);
		}
		time++;
	}
	int n;
	while(cin >> n){
		cout << stop[n] << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

// greatest common divisor
long long gcd(long long a, long long b) {
  long long r = 1;
  while (r != 0) {
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

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

  int n, k; cin >> n >> k;
  vector<int> a(n);
  int ma = 0;
  rep(i, n) {
    cin >> a[i];
    ma = max(a[i], ma);
  }

  if (k > ma) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  int gd = a[0];
  rep(i, n) {
    gd = gcd(gd, a[i]);
  }
  
  if (k%gd == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

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

    ll cnt1 = 0, cnt2 = 0;
    ll sumv = 0;

    rep(i, n)
    {
        sumv += a[i];
        if (i % 2 == 0 && sumv <= 0)
        {
            cnt1 += abs(sumv) + 1;
            sumv = 1; //符号がプラスになるべきところ。
        }
        else if (i % 2 == 1 && sumv >= 0)
        {
            cnt1 += abs(sumv) + 1;
            sumv = -1; //符号がマイナスになるべきところ。
        }
    }

    sumv = 0;

    rep(i, n)
    {
        sumv += a[i];
        if (i % 2 == 0 && sumv >= 0)
        {
            cnt2 += abs(sumv) + 1;
            sumv = -1; //符号マイナスになるべきところ。
        }
        else if (i % 2 == 1 && sumv <= 0)
        {
            cnt2 += abs(sumv) + 1;
            sumv = 1; //符号がプラスになるべきところ。
        }
    }

    OP(min(cnt1, cnt2));

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int v,e;
    cin >> v >> e;
    vector<vector<pair<int, int>>> G(v);
    int s,t,d;
    rep(i,e){
        cin >> s >> t >> d;
        G[s].emplace_back(t, d);
    }
    auto solve = [&](int s){
        vector<vector<int>> dp(1 << v, vector<int>(v, INF));
        dp[0][s] = 0;
        for(int bit = 0; bit < 1 << v; bit++){
            for(int i = 0; i < v; i++){
                for(int j = 0; j < G[i].size(); j++){
                    int to = G[i][j].first, dist = G[i][j].second;
                    if(bit & 1 << to) continue;
                    dp[bit | 1 << to][to] = min(dp[bit | 1 << to][to], dp[bit][i] + dist);
                }
            }
        }
        return dp[(1 << v) - 1][s];
    };
    /*
    int ans = INF;
    for(int i = 0; i < v; i++){
        ans = min(ans, solve(i));
    }*/
    cout << (solve(0) != INF ? solve(0) : -1) << endl;
    return 0;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

H,W = IL()

for _ in range(H):
  s = S()
  P(s)
  P(s)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
long long calc_str(string formula) {
	string tmp_value = "";
	long long result = 0;
	for(int i=0; i<(int)formula.size(); i++) {
		if(formula.at(i) == '+') {
			result += stoll(tmp_value);
			tmp_value = "";
		}
		else {
			tmp_value.push_back(formula.at(i));
		}
	}

	result += stoll(tmp_value);
	return result;
}

int main(void) {
	string input_line;
	cin >> input_line;

	long long result = 0;
	for(int i=0; i<(1<<(int)input_line.size() - 1);i++) {
		string formula = input_line;
		bitset<10> s(i);
		int times = 0;
		for(int j=0; j<(int)input_line.size(); j++) {
			if(s.test(j)) {
				formula.insert(formula.begin() + j + 1 + times, '+');
				times++;
			}
		}
		result += calc_str(formula);
	}
	cout << result << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll A,B,C;
ll frac[100];
int len=0;
ll gcd(ll i,ll j){
	if(!j)return i;
	return gcd(j,i%j);
}
int main(){
	scanf("%lld%lld",&A,&B);
	C=gcd(A,B);
	ll tmp=floor(sqrt(C));
	for(register int i=2;i<=tmp;++i)
	    if(C%i==0){
	    	frac[++len]=i;
	    	while(C%i==0)C/=i;
		}
	if(C>1)frac[++len]=C;
	printf("%d\n",len+1);
	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define T3I tuple<int, int, int>
#define x first
#define y second
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    int a, b, m;
    cin >> a >> b >> m;
    vector<int> A(a), B(b);
    int ans = INF;
    int mina, minb;
    mina = minb = INF;
    for(int i = 0; i < a; ++i) {
        cin >> A[i];
        mina = min(mina, A[i]);
    }
    for(int i = 0; i < b; ++i) {
        cin >> B[i];
        minb = min(minb, B[i]);
    }
    for(int i = 0; i < m; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        --x, --y;
        ans = min(A[x]+B[y]-c, ans);
    }
    ans = min(ans, mina + minb);
    cout << ans << endl;
}


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

using namespace std;

int main(){
    int v,e;
    scanf("%d%d",&v,&e);
    vector< set<int> > g(v+1);
    for(int i=0;i<e;i++){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        g[t1].insert(t2);
        g[t2].insert(t1);
    }
    int perm[10];
    for(int i=0;i<v-1;i++){
        perm[i]=i+2;
    }
    int cnt=0;
    do{
        cnt++;
        if(g[1].count(perm[0])==0){
            cnt--;
            continue;
        }
        for(int i=1;i<v-1;i++){
            if(g[perm[i-1]].count(perm[i])==0){
                cnt--;
                break;
            }
        }
    }while(next_permutation(perm,perm+v-1));
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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++)
typedef long long ll;

int main(){
    ll n,a,b,ans=0;
    cin >> n >> a >> b;
    
    if(n==1){
        if(a==b){
            cout << 1 << endl;
        }
        else cout << 0 << endl;
    }
    
    if(n==2){
        if(a<=b){
            cout << 1 << endl;
        }
        else cout << 0 << endl;
    }
    
    if(n>2){
        if(a>b){
            cout << 0 << endl;
        }
        if(a==b){
            cout << 1 << endl;
        }
        if(a<b){
            ll sa=b-a;
            ans=sa*(n-2)+1;
            cout << ans << endl;
        }
    }
    
    return 0;
}







Measured memory_bytes: 256
import math

M=list(map(int, input().split()))
N=M[0]
K=M[1]

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

def cancut(A,N,K,X): #A1..ANをK回で全てX以下に切れるか？Yesなら1、Noなら2を返す。
    cut=0
    for a in A:
        n = (a + X - 1) // X  # a/x の少数切上げ
        cut += n - 1
    if cut<=K:
        return 1
    else:
        return 0

left=0
right=max(A)

while(abs(right - left) > 1):
    mid=(right+left)//2
    if cancut(A,N,K,mid)==1:
        right=mid
    else:
        left=mid

print(right)

Measured memory_bytes: 104260
N,M = map(int, input().split())
X = list(map(int, input().split()))
if M <= N:
    print(0)
    exit()
X.sort()
L = []
for i in range(1,M):
    L.append(X[i]-X[i-1])
L.sort()
L.reverse()
res = sum(L)
for i in range(N-1):
    res -= L[i]
print(res)

Measured memory_bytes: 56744
h,w=map(int,input().split())
grid = []
for i in range(10):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
wall = []
for i in range(h):
    array = list(map(int, input().strip().split(' ')))
    wall.append(array)
def warshall_floyd(n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                grid[i][j] = min(grid[i][j], grid[i][k] + grid[k][j])
warshall_floyd(10)
cost=[]
for arrays in grid:
  cost.append(arrays[1])
ans = 0
for arrays in wall:
  for nums in arrays:
    if nums == -1:
      pass
    else:
      ans += cost[nums]
print(ans)

Measured memory_bytes: 3444
# coding: utf-8
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn  = inputs[0][0]
lst = inputs[1]

lst.sort!
lst.reverse!

pd lst

tmp = nn - 1
(nn/2).times do |i|
  unless lst[2*i] == lst[2*i+1] and lst[2*i] == tmp
    puts 0
    exit
  end
  tmp -= 2
end

if nn%2 == 1
  unless lst[-1] == 0
    puts 0
    exit
  end
end

ans = 1
(nn/2).times do |i|
  ans *= 2
  ans %= 1000000007
end

puts ans



Measured memory_bytes: 9488
n, m = map(int, input().split())
delta = abs(n - m)

mod = 10 ** 9 + 7
N = 10 ** 5 + 5
bikkuri = [0 for i in range(N)]
bikkuri[0] = 1
gyaku = [0 for i in range(N)]
gyaku[0] = 1
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod
    gyaku[i] = pow(bikkuri[i], mod - 2, mod)

if delta > 1:
    print(0)
else:
    if n > m:
        ans = bikkuri[n] * bikkuri[m]
    elif m > n:
        ans = bikkuri[m] * bikkuri[n]
    else:
        ans = 2 * bikkuri[m] * bikkuri[n]
    print(ans % mod)


Measured memory_bytes: 11068
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
string st;
int n,j=1,maxx;
int shu[100+50];
int main()
{
	cin>>n;
	cin>>st;
	for(int i=0;i<=st.size()-1;i++)
		if(int(st[i])==73) shu[j]++;
		else
		{
			j++;
			shu[j]=shu[j-1]-1;
		}
	for(int i=1;i<=j;i++)
		if(shu[i]>maxx)
			maxx=shu[i];
	cout<<maxx<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <stack>
const int inf=0x3f3f3f3f;
const double PI=acos(-1.0);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

char str[100050];
int len;
int main()
{
    //freopen("input.txt","r",stdin);
    scanf("%s",str+1);
    len=strlen(str+1);
    //
    if(str[1]==str[len])
    {
        len-=2;
        if(len%2==1) printf("Second\n");
        else printf("First\n");
    }
    else
    {
        len-=2;
        if(len%2==1) printf("First\n");
        else printf("Second\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N;
    cin >> N;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    int id = 0;
    int maxV = 0;
    for(int i = 0; i < N; i++){
        if(v[i] > maxV){
            maxV = v[i];
            id = i;
        }
    }

    sort(rall(v));

    if(v[0] == v[1]){
        for(int i = 0; i < N; i++){
            cout << v[0] << endl;
        }
    }
    else{
        for(int i = 0; i < N; i++){
            if(i == id){
                cout << v[1] << endl;
            }
            else{
                cout << v[0] << endl;
            }
        }

    }


}

Measured memory_bytes: 3200
from itertools import accumulate


def solve(string):
    n, *ab = map(int, string.split())
    ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1])
    a = [a for a, b in ab]
    b = [b for a, b in ab]
    *a, = accumulate(a)
    return "No" if any([_a > _b for _a, _b in zip(a, b)]) else "Yes"


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 51460
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b!=c)||(a==c&&c!=b)||(b==c&&a!=c))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php

list($n, $m) = explode(" ", trim(fgets(STDIN)));
for($i = 0; $i < $n; $i++){
    list($p, $c) = explode(" ", trim(fgets(STDIN)));
    @$amount[$p] += $c;    
}
ksort($amount);

$total = 0;
foreach($amount as $price => $a){
    $buyCount = min($m, $a);
    $m = $m - $buyCount;
    $total += $price * $buyCount;
}
echo $total;


Measured memory_bytes: 13048
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 3e5 + 1; int n;
const lli mod = 1e9 + 7;
lli a[maxN];
lli r[60][2][maxN];

lli multMod(lli x, lli y)
{
  lli ans = 0;
  while (y)
  {
    if (y & 1LL) ans = (ans + x) % mod;
    x = (x + x) % mod, y >>= 1LL;
  }
  return ans;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    for (int i = 0; i < n; i ++)
      scanf("%lld", &a[i]);
    for (lli bit = 0; bit < 60; bit ++)
    {
      r[bit][0][n] = r[bit][1][n] = 0;
      for (int i = n - 1; i >= 0; i --)
      {
        r[bit][0][i] = !((a[i] >> bit) & 1LL) + r[bit][0][i + 1];
        r[bit][1][i] = ((a[i] >> bit) & 1LL) + r[bit][1][i + 1];
      }
    }

    lli ans = 0;
    for (lli bit = 0; bit < 60; bit ++)
      for (int i = 0; i < n - 1; i ++)
        ans = (ans + (1LL << bit) % mod * r[bit][!((a[i] >> bit) & 1LL)][i + 1] % mod) % mod;
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 283776
#include<iostream>
using namespace std;
int main(){
  int Y, M, D;
  char A, B;
  cin >> Y >>A >>M >>B >>D;
  if(Y < 2019) cout << "Heisei" <<endl;
  if(Y > 2019) cout << "TBD" <<endl;
  if(Y == 2019 && M < 5) cout << "Heisei" <<endl;
  else cout << "TBD" <<endl;
  
    return 0;
}

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

int fibmemo[45] = {0};
int fibMemo(int n);

int fib(int n){
    if(n == 0 || n == 1)   return 1;
    else
        return fibMemo(n - 1) + fibMemo(n - 2);    
}

int fibMemo(int n){
    if(fibmemo[n] == 0){
        fibmemo[n] = fib(n);
    }
    return fibmemo[n];
}


int main(void){
    int n;
    cin >> n;
    cout << fib(n) << endl;
}



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

int main(){
    int num=1,n,cnt=0;
    cin >> n;
    vector<int> btn(n);
    for(int i=0;i<n;i++)
        cin >> btn.at(i);
    while(cnt<n){
        num = btn.at(num-1);
        cnt++;
        if(num==2)
            break;
    }
    if(cnt<n)
        cout << cnt << endl;
    else
        cout << -1 << endl;        
}

Measured memory_bytes: 640
import java.io.*;

class Main{
    public static void main(String[] a){
	for(int i = 1;i < 10;i++)
	    {
		for(int j=1;j<10;j++)
		    {
			System.out.println(i +"x"+ j + "=" + i*j);
		    }
	    }
    }
}

Measured memory_bytes: 16996
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return f*x;
}
#define MAXN 20
#define Mod int(1e9)
#define INF 0x3f3f3f3f
int X[MAXN+5][MAXN+5];
int main(){
	int n=read(),d=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			X[i][j]=read();
	LL ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			int tmp=0;
			for(int k=1;k<=d;k++)
				tmp+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			int t=sqrt(tmp);
			if(t*t==tmp)
				ans++;
		}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main(){
  int a,b,c;
  set<int> s;
  cin >> a >> b >> c;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << s.size() << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#define ll long long
#define out(a) printf("%d",a)
#define ln printf("\n")
const int N=1e5+50;
const int MOD=1e9+7;
const int inf=0x7f7f7f7f;
using namespace std;
int n,m,now;
int ans=0;
int main()
{
	scanf("%d%d",&n,&m);
    while (now<n){
      now+=2*m+1;
      ans++;
  	}
  	out(ans);
	return 0;
}

Measured memory_bytes: 256
//Keep Working hard
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);cout.precision(10);

const int N = 1e5+5;
int a[N];

void solve()
{
    int n;
    cin >> n;
    for(int i = 0; i <n ; i++)cin >> a[i];
    sort(a,a+n);
    int mid = n/2-1;
    if(a[mid] == a[mid+1])
    {
        cout << 0;
        exit(0);
    }
    cout << a[mid+1]-a[mid];
}

void fileIO()
{
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
}

int32_t main()
{
    IOS;
  //  fileIO();
    int t = 1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
typedef pair<int, int>P;


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

    vector<int>s(n);

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

    int next = 1;
    int ans = 0;


    for (int i = 0; i < n; i++)
    {
        if (next == s[i])
        {
            ans++;
            next++;
        }

    }

    if (ans == 0)
    {
        ans = n + 1;
    }

    cout << n - ans << endl;


    return 0;
    
}


Measured memory_bytes: 1024
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr, group, sort)
import Control.Monad
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  ss <- replicateM n $ do
    BS.sort <$> BS.getLine
  let xs = map (fromIntegral . length) $ group $ sort ss
  print (sum [x*(x-1) `quot` 2 | x <- xs] :: Int64)


Measured memory_bytes: 486908
use std::collections::HashSet;
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n : u32,
        arr : [u32;n],
    );
    let arr : Vec<u32> = arr;
    let uniq: HashSet<u32> = arr.into_iter().collect();
    println!("{}",uniq.len());
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int input = Integer.parseInt(sc.nextLine());
		int amari = input % 1000;
		int result = amari == 0 ? 0 : 1000 - amari;
	    System.out.println(result);
	}
}


Measured memory_bytes: 35672
#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;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
typedef long long				ll;
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						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 pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> H(N);
	REP(i, N) cin >> H[i];
	sort(ALL(H));

	ll sum = 0;
	REP(i, N - K) {
		sum += H[i];
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 5001;



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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n;
    ll ans = 0;
    for(ll c1 = 2; c1*c1 <= n; c1++){
        a = 0;
        while(n%c1 == 0){
            a++;
            n /= c1;
        }
        if(a > 0){
            rep(c2,1,1000){
                a -= c2;
                if(a < 0)break;
                ans++;
                if(a == 0)break;
            }
        }
    }

    if(n > 1)ans++;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define clt(x) 63-__builtin_clzll(x)
#define bct(x) __builtin_popcountll(x)
#define all(v) (v).begin(),(v).end()
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector<pair<ll,ll>>
#define maxq priority_queue<ll>
#define minq priority_queue<ll,vector<ll>, greater<ll>>
#define cont continue;
#define reto return 0;
#define sz size()
#define spmod 1116295198451
#define mod 1000000007
#define md 998244353 
#define N 2e5+10
//typedef tree<int,null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> //pbds;


int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  string s,t;
  cin>>s>>t;
  ll i=0;
  ll ans=LLONG_MAX;
  ll sum,j,k;
  while(i+t.size()-1<s.size())
  {
    j=0;
    k=i;
    sum=0;
    while(j<t.size())
    {
      if(t[j]!=s[k])
        sum++;
      j++;
      k++;
    }
    ans=min(ans,sum);
    i++;
  }
  deb(ans)
}

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

int main() {
  string S,T;
  cin >> S >> T;
  map<char,char> rep1,rep2;
  
  bool check = true;
  for (int i = 0; i<S.size();i++) {
    char s,t;
    s = S.at(i);
    t = T.at(i);
    if (rep1.count(s)) {
      if (rep1[s] != t) {
        check = false;
      }
    }
    if (rep2.count(t)) {
      if (rep2[t] != s) {
        check = false;
      }
    }
    rep1[s] = t;
    rep2[t] = s;
  }
  if (check) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m;
    cin >> n >> m;
    VI x(m);
    REP(i,0,m) cin >> x[i];
    REP(i,0,m) x[i] += 100000;
    sort(all(x));
    if (m == 1 || n >= m) {
        cout << 0 << endl;
        return;
    }
    int sum = 0;
    VI ds(m-1);
    REP(i,0,m-1) {
        int d = x[i+1] - x[i];
        sum += d;
        ds[i] = d;
    }
    sort(all(ds));
    reverse(all(ds));
    REP(i,0,n-1) sum -= ds[i];
    cout << sum << endl;
}

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

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

int main() {
    long a,b,c,d;
    cin >> a >> b >> c >> d;
    long x = max(a * c, a * d);
    x = max(x, b * c);
    x = max(x, b * d);
    if (a <= 0 && b >= 0 || c <= 0 && d >= 0) {
        x = max(x, 0l);
    }
    cout << x << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

string board[1001];
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int h, w;
bool hantei(int y, int x){
	if(0 <= y && y < h && 0 <= x && x < w) return true;
	else return false;
}

int main(void){
	cin >> h >> w;
	rep(i, h) cin >> board[i];
	queue<pair<int, int> > q1, q2;
	rep(i, h)rep(j, w){
		if(board[i][j] != '.') q1.push(make_pair(i, j));
	}

	int ans = -1, cnt = 0, nowy, nowx;
	bool flag = true;
	while(flag){
		flag = false; ans++;
		vector<pair<int, int> > memo;//???????????¢??§????????°??????????????§?¨?????¨????????????????
		set<pair<int, int> > s;
		if(cnt % 2 == 0){
			while(!q1.empty()){//q1???????????¨???
				pair<int, int> now = q1.front(); q1.pop();
				if(board[now.first][now.second] == '.') continue;
				int tmp = 0;
				rep(i, 8){
					int nowy = now.first + dy[i], nowx = now.second + dx[i];
					if(!hantei(nowy, nowx)) continue;
					if(board[nowy][nowx] == '.')tmp++;
				}
				if(tmp >= board[now.first][now.second] - '0'){
					memo.push_back(make_pair(now.first, now.second));
					rep(k, 8){//???????´?????????¨?????????????¬??????¢??§?´???????????????§??????????????§
						int ny = now.first + dy[k], nx = now.second + dx[k];
						if(!hantei(ny, nx)) continue;
						if(board[ny][nx] != '.'){
							s.insert(make_pair(ny, nx));
						}
					}
					flag = true;
				}
			}
		}else{
			while(!q2.empty()){//q2???????????¨???
				pair<int, int> now = q2.front(); q2.pop();
				if(board[now.first][now.second] == '.') continue;
				int tmp = 0;
				rep(i, 8){
					int nowy = now.first + dy[i], nowx = now.second + dx[i];
					if(!hantei(nowy, nowx)) continue;
					if(board[nowy][nowx] == '.')tmp++;
				}
				if(tmp >= board[now.first][now.second] - '0'){
					memo.push_back(make_pair(now.first, now.second));
					rep(k, 8){//???????´?????????¨?????????????¬??????¢??§?´???????????????§??????????????§
						int ny = now.first + dy[k], nx = now.second + dx[k];
						if(!hantei(ny, nx)) continue;
						if(board[ny][nx] != '.'){
							s.insert(make_pair(ny, nx));
						}
					}
					flag = true;
				}
			}
		}
		//????????°???
		rep(k, memo.size()){
			board[memo[k].first][memo[k].second] = '.';
		}
		if(cnt % 2 == 0){
			for(auto x : s) q2.push(make_pair(x.first, x.second));
		}else{
			for(auto x : s) q1.push(make_pair(x.first, x.second));
		}
		cnt++;
	}
	printf("%d\n", ans);
	return 0;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

ll n, m, s;
vector < vector<ll> > adj;
ll a[51][51], b[51][51];
ll c[51], d[51];
ll dp[51][5005];

int main()
{
    // Fast_IO();
    cin >> n >> m >> s;
    adj.resize(n);
    f(_,1,m) {
    	ll ui, vi, ai, bi; cin >> ui >> vi >> ai >> bi;
    	ui--; vi--;
    	adj[ui].pb(vi);
    	adj[vi].pb(ui);
    	a[ui][vi] = ai;
    	a[vi][ui] = ai;
    	b[ui][vi] = bi;
    	b[vi][ui] = bi;
    }
    f(i,0,n-1) cin >> c[i] >> d[i];
    if(s > 5000) s = 5000;
    f(i,0,50) f(j,0,5004) dp[i][j] = 1000000000000000000;
    dp[0][s] = 0;
    priority_queue < pair< ll, pair<ll,ll> >, 
    vector < pair< ll, pair<ll,ll> > >, 
    greater < pair< ll, pair<ll,ll> > > > pq;
    pq.push(mp(0,mp(0,s)));
    // Dijkstra object_name(n,adjList,source);
    while(!pq.empty()) {
    	// normal dijkstra
    	pair< ll, pair<ll,ll> > Top = pq.top();
    	ll Time = Top.ff, u = Top.ss.ff, coins = Top.ss.ss;
    	pq.pop();
    	if(dp[u][coins] < Time) continue;
    	fa(v,adj[u]) if(coins >= a[u][v]) {
    		ll next_time = dp[u][coins] + b[u][v];
    		if(next_time < dp[v][coins - a[u][v]]) {
    			dp[v][coins - a[u][v]] = next_time;
    			pq.push(mp(next_time,mp(v,coins - a[u][v])));
    		}
    	}
    	// special check
    	ll updated = min(5000LL, coins + c[u]);
    	ll next_time = dp[u][coins] + d[u];
    	if(dp[u][updated] > next_time) {
    		dp[u][updated] = next_time;
    		pq.push(mp(next_time, mp(u, updated)));
    	}
    }
    ll ans[n];
    f(i,1,n-1) {
    	ans[i] = 1000000000000000000;
    	f(j,0,5004) ans[i] = min(ans[i], dp[i][j]);
    }
    f(i,1,n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11420
#!/usr/bin/env python3
s = input()
l = ["A", "C", "G", "T"]
ans = 0
tmp = 0
for i in range(len(s)):
    if s[i] in l:
        tmp += 1
        if ans <= tmp:
            ans = tmp
    else:
        tmp = 0
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>

int main(){

    size_t n, m, k;
    std::cin >> n >> m >> k;

    std::vector<size_t> a = {0}, b = {0};

    for(size_t i = 1; i < n + 1; i++){
        size_t in;
        std::cin >> in;
        a.emplace_back(a.at(i - 1) + in);
    }

    for(size_t i = 1; i < m + 1; i++){
        size_t in;
        std::cin >> in;
        b.emplace_back(b.at(i - 1) + in);
    }

    size_t ans = 0, index = m;

    for(size_t i = 0; i < n + 1; i++){
        if(a.at(i) > k) break;

        while(b.at(index) > k - a.at(i)) index--;

        ans = std::max(ans, i + index);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 7984
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = [0]
s = set()
s.add(0)
cur = a[0] - 1
while True:
    if cur in s:
        break
    else:
        s.add(cur)
        l.append(cur)
        cur = a[cur] - 1
i = l.index(cur)
if k <= i:
    print(l[k] + 1)
else:
    print(l[(k - i) % (len(l) - i) + i] + 1)

Measured memory_bytes: 35116
def gcd(a,b):
    if a==0: return b
    else: return gcd(b%a,a)

def main():
    n,k=map(int,input().split(" "))
    a=list(map(int,input().split(" ")))
    g=a[0]
    m=a[0]
    for e in a:
        g=gcd(g,e)
        if m<e: m=e
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

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

int main() 
{
    string s;
    cin >> s;
    int res = INT_MAX;
    for (int i=0; i<s.size()-2; i++)
    {
        int x = stoi(s.substr(i,3));
        res = min(res, abs(x-753));
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll hh(ll n){
  if(n<=1) return 0;
  return n*(n-1)/2;
}
int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  ll ans=n;
  ll cu=0;
  for(int i=n-1;i>=0;i--){
    if(s[i]=='S'){
      if(cu>0){
        ans-=2;
        cu--;
      }
    }
    else{
      cu++;
    }
  }
  COUT(ans);
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		long x=in.nextLong();
		printBin(fillZero(Long.toBinaryString(x)));
		printBin(fillZero(Long.toBinaryString(~x)));
		printBin(fillZero(Long.toBinaryString(x<<1)));
		printBin(fillZero(Long.toBinaryString(x>>1)));
	}
	
	static void printBin(String str) {
		//System.out.println(str);
		for(int i=str.length()-32;i<str.length();i++)System.out.print(str.charAt(i));
		System.out.println();
	}
	
	static String fillZero(String str) {
		String zero="";
		if(str.length()<32) {
			for(int i=0;i<32-str.length();i++)zero+="0";
		}
		return zero.concat(str);
	}

}



Measured memory_bytes: 26344
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	int calc(int r) {
		String s = Integer.toString(r);
		
		int res = 0;
		for (int i = 1; i < s.length(); i++) {
			int a = Integer.valueOf(s.substring(0, i));
			int b = Integer.valueOf(s.substring(i));
			res = Math.max(res, a * b);
		}
		return res;
	}
	
	public void run() {
		int n = in.nextInt();
		for (int t = 0; t < n; t++) {
			int r = in.nextInt();
			
			int res = 0;
			while (r > 9) {
				r = calc(r);
				res++;
			}
			
			System.out.println(res);
		}
		out.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 24352