akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;

bool dfs(vector< vector<int> > &G, vector<int> &C, int v){
  int c = 1 - C[v];
  bool f = true;
  for(size_t i = 0; i < G[v].size(); ++i){
    int v_ = G[v][i];
    if(C[v_] >= 0 && C[v_] != c) return false;
    if(C[v_] >= 0) continue;
    C[v_] = c;
    f &= dfs(G,C,v_);
  }
  return f;
}

int main(){
  int N, M;
  while(cin >> N >> M, N){
    vector< vector<int> > G(N);
    for(int i = 0; i < M; ++i){
      int u, v;
      cin >> u >> v;
      --u;--v;
      G[u].emplace_back(v);
      G[v].emplace_back(u);
    }
    vector<int> C(N,-1);
    C[0] = 0;
    if(!dfs(G,C,0)){
      cout << 0 << endl;
      continue;
    }
    int c = 0;
    for(int i = 0; i < N; ++i){
      c += C[i];
      //cerr << "C[" << i << "] = " << C[i] << endl;
      assert(C[i] >= 0);
    }
    c = min(c, N-c);
    vector<int> ans;
    if(!(c%2)) ans.emplace_back(c/2);
    if(2*c != N && !((N-c)%2)) ans.emplace_back((N-c)/2);
    cout << ans.size() << endl;
    for(size_t i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3204
package main

import "fmt"

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

	h := int(N / 3600)
	m := (N - h*3600) / 60
	s := (N - h*3600 - m*60)
	fmt.Printf("%d:%d:%d\n", h, m, s)
}



Measured memory_bytes: 1128
n = int(input())
a = list(map(int, input().split()))
count = 0
finished = False
while True:
    for i in range(len(a)):
        if a[i] % 2 == 0:
            a[i] /= 2
        else:
            finished = True
            break
    if finished:
        break
    else:
        count += 1
print(count)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
#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 <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    string s; cin >> s;
    int n = s.size();
    bool ok = true;
    for(int i = 1; i < n; i++) {
        if(s[i] != '9') ok = false;
    }
    int ans = 0;
    if(ok) {
        for(int i = 0; i < n; i++) ans += (int) s[i] - 48;
    }else{
        ans += (int) ((s[0]- 1) - 48) + 9 * (n -1);
    }
    cout << ans << endl;
}


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

int main(){
  int n; cin >> n;
  long long ans = 0;
  map<int,int> M;
  for(int i = 1; i <= n; i++){
    int a; cin >> a;
    ans += M[i-a];
    M[i+a]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 20688
import sys
input = sys.stdin.readline

N = int(input())
AK = [list(map(int, input().split())) for _ in range(N)]
# N = 40
# AK = [(i+1, 4) for i in range(N)]

def grundy(A, K):
    if K == 1:
        return A
    X = (A+K-1)//K
    num = X*K - A
    while X*K-num > K*K:
        #print(X, num)
        if num%K == 0:
            return X - num//K
        if num//K == X//K:
            num = num%K
        else:
            num = X%K+1 + (K-1)*(num//K) + (num%K-1)
        X = X - X//K
    
    S = X*K - num
    while S >= K:
        if S%K == 0:
            return S//K
        delta = S//K + 1
        S -= max(((S%K)//delta)*delta, delta)
    return 0
    
g = 0
for A, K in AK:
    # print(A, A//K, grundy(A, K))
    # print()
    g ^= grundy(A, K)

print("Takahashi" if g else "Aoki")

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n, r;
    cin >> n >> r;
    if(n >= 10) {
        cout << r << endl;
        return 0;
    } else {
        cout << r + (100 *(10 - n)) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)a[i]-=i+1;
    sort(a.begin(),a.end());
    ll center=a[n/2];
    ll ans=0;
    for(int i=0;i<n;i++)ans+=abs(a[i]-center);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
s = gets.chomp

yymm = 0 < (s[2] + s[3]).to_i && (s[2] + s[3]).to_i <= 12
mmyy = 0 < (s[0] + s[1]).to_i && (s[0] + s[1]).to_i <= 12

if yymm && mmyy
  puts 'AMBIGUOUS'
elsif yymm
  puts 'YYMM'
elsif mmyy
  puts 'MMYY'
else
  puts 'NA'
end

Measured memory_bytes: 1788
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()
lim = 10**6+1
g = [[] for _ in range(lim+1)]
g[1].append(1)
for i in range(2, lim+1):
	if g[i] == []:
		for j in range(1, lim//i + 1):
			g[i*j].append(i)

num = [0]*(lim+1)

for a in A:
	if a == 1:
		continue
	for x in g[a]:
		if num[x]:
			break
		num[x] = 1

	else:
		continue
	break
else:
	print("pairwise coprime")
	exit()


#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
	
dic = defaultdict(int)
for x, y in factorization(A[0]):
	dic[x]=y

for a in A[1:]:
	for x, y in dic.items():
		if a%x:
			dic[x] = 0
		else:
			dic[x] = min(y, a//x)

for x, y in dic.items():
	if x != 1 and y != 0:
		print("not coprime")
		break
else:
	print("setwise coprime")




Measured memory_bytes: 254612
#include<stdio.h>
int solve(void){
int a,i,k,n,kei=0,ans=-1000000000;
static int wa[100001]={0};
scanf("%d %d",&n,&k);
if(n==0){return 1;}
for(i=1;i<=n;i++){
scanf("%d",&a);
kei+=a;
wa[i]=kei;
}
for(i=0;i<=n-k;i++){
a=wa[i+k]-wa[i];
if(ans<a){ans=a;}
}
printf("%d\n",ans);
return 0;
}
int main(void){
while(solve()==0){}
return 0;
}

Measured memory_bytes: 988
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

vector<int> adj[maxN];
int ans[maxN], n, m;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	cin >> n >> m;
	for(int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	queue<int> q;
	q.push(0);
	ans[0] = 1;
	while(q.size()) {
		int nd = q.front(); q.pop();
		for(auto sn: adj[nd]) {
			if(!ans[sn]) {
				ans[sn] = nd + 1;
				q.push(sn);
			}
		}
	}

	if(*min_element(ans, ans + n) == 0) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
		for(int i = 1; i < n; i++) cout << ans[i] << '\n';
	}
}



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

int main() {
  int x, n;
  cin >> x >> n;
  unordered_set<int> hashset;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    hashset.insert(p);
  }
  int min_diff = 100;
  int min_val = 100;
  for (int val = 101; val >= 0; val--) {
    if (hashset.find(val) == hashset.end()) {
     int diff = abs(x - val);
     if (diff <= min_diff) {
         min_diff = diff;
         min_val = val;
     }
    }
  }
  cout << min_val << endl;
}

Measured memory_bytes: 3604
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define ll long long
#define ld long double
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e9 + 100, M = 1e9 + 7, P = 6151, SQ = 120, lg = 22;
typedef pair <int, int> pii;
int a[11000];
int mp[N];

ll pw(int x, int y) {
	if(y == 0) return 1;
	ll cnt = pw(x, y / 2);
	cnt = (cnt * cnt) % M;
	if(y % 2 == 1)
		cnt = (cnt * x) % M;
	return cnt;
}

int32_t main() {
    use_fast;
    int n;
    cin >> n;
    set <int> s;
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
    	int x = a[i];
    	for(int j = 2; j * j <= x; j++) {
    		int k = 0;
    		if(x % j != 0)
    			continue;
    		while(x % j == 0)
    			x /= j, k++;
    		if(k != 0) {
    			if(mp[j] < k)
                  mp[j] = k;
    			s.insert(j);
			}
		}
		if(x != 1) {
			if(mp[x] == 0) {
              mp[x] = 1;
            }
			s.insert(x);
		}
	}
	vector <int> v;
	for(auto u : s)
		v.pb(u);
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		int x = a[i];
		ll h = 1;
		for(auto u : v) {
			int k = 0;
			while(x % u == 0) 
				x /= u, k++;
			ll cnt = mp[u] - k;
			cnt = pw(u, cnt);
			h = (h * cnt) % M;
		}
		ans = (ans + h) % M;
	}
	cout << ans << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 3072
from math import sqrt,ceil
N,M=map(int,input().split())
l=[]
for i in range(2,ceil(sqrt(M))):
    t=0
    while not M%i:
        M//=i
        t+=1
    if t:
        l.append(t)
if M>1:
    l.append(1)
MAX_NUM = 10**5 + 100
pr = 10**9+7
fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]
fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % pr
    inv[i] = pr - inv[pr%i] * (pr // i) % pr
    finv[i] = finv[i-1] * inv[i] % pr
def c(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % pr) % pr
a=1
for i in l:
    a=a*c(N+i-1,i)%pr
print(a)

Measured memory_bytes: 47284
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int N,M; cin >> N >> M;
  vector<ll> x(N),y(N),z(N);
  rep(i,N) cin >> x[i] >> y[i] >> z[i];
  
  vector<ll> sum1(N);
  rep(i,N) sum1[i] = x[i] + y[i] + z[i];
  sort(all(sum1));
  reverse(all(sum1));
  ll ans1 = accumulate(sum1.begin(),sum1.begin() + M,0LL);
  vector<ll> sum2(N);
  rep(i,N) sum2[i] = - x[i] + y[i] + z[i];
  sort(all(sum2));
  reverse(all(sum2));
  ll ans2 = accumulate(sum2.begin(),sum2.begin() + M,0LL);
  vector<ll> sum3(N);
  rep(i,N) sum3[i] = x[i] - y[i] + z[i];
  sort(all(sum3));
  reverse(all(sum3));
  ll ans3 = accumulate(sum3.begin(),sum3.begin() + M,0LL);
  vector<ll> sum4(N);
  rep(i,N) sum4[i] = x[i] + y[i] - z[i];
  sort(all(sum4));
  reverse(all(sum4));
  ll ans4 = accumulate(sum4.begin(),sum4.begin() + M,0LL);
  vector<ll> sum5(N);
  rep(i,N) sum5[i] = - x[i] - y[i] + z[i];
  sort(all(sum5));
  reverse(all(sum5));
  ll ans5 = accumulate(sum5.begin(),sum5.begin() + M,0LL);
  vector<ll> sum6(N);
  rep(i,N) sum6[i] = - x[i] + y[i] - z[i];
  sort(all(sum6));
  reverse(all(sum6));
  ll ans6 = accumulate(sum6.begin(),sum6.begin() + M,0LL);
  vector<ll> sum7(N);
  rep(i,N) sum7[i] = x[i] - y[i] - z[i];
  sort(all(sum7));
  reverse(all(sum7));
  ll ans7 = accumulate(sum7.begin(),sum7.begin() + M,0LL);
  vector<ll> sum8(N);
  rep(i,N) sum8[i] = - x[i] - y[i] - z[i];
  sort(all(sum8));
  reverse(all(sum8));
  ll ans8 = accumulate(sum8.begin(),sum8.begin() + M,0LL);

  cout << max({ans1,ans2,ans3,ans4,ans5,ans6,ans7,ans8}) << endl;
}

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

int main(){
  long long n, w;
  cin >> n >> w;
  vector<long long> v[4];
  long long w1;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (i == 0) w1 = a;
    v[a-w1].push_back(-b);
  }
  for (int i = 0; i < 4; i++) {
    sort(v[i].begin(), v[i].end());
  }

  long long ans = 0;

  long long t = w;
  long long tv = 0;
  for (int i = 0; i <= v[0].size(); i++) {
    long long p = t;
    long long pv = tv;
    for (int j = 0; j <= v[1].size(); j++) {
      long long q = p;
      long long qv = pv;
      for (int k = 0; k <= v[2].size(); k++) {
        long long r = q;
        long long rv = qv;
        for (int l = 0; l <= v[3].size(); l++) {
          r -= w1+3;
          if (r < 0 || l == v[3].size()) {
            ans = max(ans, -rv);
            break;
          }
          rv += v[3][l];
        }
        q -= w1+2;
        if (q < 0 || k == v[2].size()) {
          ans = max(ans, -qv);
          break;
        }
        qv += v[2][k];
      }
      p -= w1+1;
      if (p < 0 || j == v[1].size()) {
        ans = max(ans, -pv);
        break;
      }
      pv += v[1][j];
    }
    t -= w1;
    if (t < 0 || i == v[0].size()) {
      ans = max(ans, -tv);
      break;
    }
    tv += v[0][i];
  }

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


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

int main() {
  int n;
  cin >> n;
  while (n--) {
    double xa, ya, ra, xb, yb, rb, d;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    d = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
    if (d > ra + rb) cout << 0 << endl;
    else if (d + rb < ra) cout << 2 << endl;
    else if (d + ra < rb) cout << -2 << endl;
    else cout << 1 << endl;
  }
}


Measured memory_bytes: 3104
H,W,K = map(int, input().split())

# dp[h][w]
dp = []
for _ in range(H+1):
    dp.append([0] * W)

dp[0][0] = 1

for h in range(1,H+1):
    for w in range(0,W):
        a = 0
        b = 0
        c = 0
        
        Q = W-1
        for bit in range(1<<Q):
            invalid = False
            cur_seq = False
            for i in range(Q):
                on = (bit >> i) & 1
                if on & cur_seq:
                    invalid = True
                    break
                cur_seq = on

            # if there is sequential bar, then the combination is invalid
            if invalid:
                continue

            connected = False
            # if the combination has connection with w then count a or c
            # otherwise, inc b
            for i in range(Q):
                on = (bit >> i) & 1
                if on:
                    x = i
                    y = i+1
                    if x == w-1:
                        connected = True
                        a += 1
                    elif y == w+1:
                        connected = True
                        c += 1
            if not connected:
                b += 1

        cnt = 0
        if a > 0:
            cnt += a * dp[h-1][w-1]
        if b > 0:
            cnt += b * dp[h-1][w]
        if c > 0:
            cnt += c * dp[h-1][w+1]

        dp[h][w] = cnt

print(dp[H][K-1] % 1000000007)

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    lint N, K;
    cin >> N >> K;
    lint ans = min(N % K, K - (N % K));
    cout << ans << endl;
}

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


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

int main()
{
//	cut here before submit 
//	freopen ("testcase.yetsubmit3", "r", stdin );

	vector <bool> student (30+1, false );
	student[0] = true;

	int n, i;
	
	for (i = 0; i < 28; ++i){
		cin >> n;
		student[n] = true;
	} // end for

	for (i = 1; i <= 30; ++i){
		if (!student[i] ){
			cout << i << endl;
		} // end if
	} // end for
		
	return 0;
}

Measured memory_bytes: 0
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
int d[9][9];
int c[11][11];
void warshall_floyd(){
  for (int k = 0; k <= 9; k++){       // 経由する頂点
    for (int i = 0; i <= 9; i++) {    // 始点
      for (int j = 0; j <= 9; j++) {  // 終点
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int h,w;cin>>h>>w;
    memset(d,0,sizeof(d));
    int sum=0;
    
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++)
            cin>>c[i][j];
    }
    int a[250][250];
    warshall_floyd();
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            
            if(a[i][j]!=-1)
                sum+=c[a[i][j]][1];
            
        }
            
    }
    cout<<sum<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  ll N;
  cin >> N;
  for(ll h = 1; h <= 3500; h++){
    for(ll n = 1; n <= 3500; n++){
      if(4 * h * n - N * n - N * h <= 0) continue;
      if((N * h * n) % (4 * h * n - N * n - N * h) == 0 && (N * h * n) / (4 * h * n - N * n - N * h)){
        cout << h << " " << n << " " << N * h * n / (4 * h * n - N * n - N * h) << endl;
        return 0;
      }
    }
  }
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if(a <= 9 && b <= 9) cout << a * b << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 256
#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 a, b, c;
 cin >> a >> b >> c;
 if(a + b + c <= 21){
  puts("win");
 }else{
   puts("bust");
 }
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

  int N; cin>>N;
  string s; cin>>s;
  if(s.substr(0,N/2)+s.substr(0,N/2)==s){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <iostream>
// #include<fstream>

int main(int argc, char** argv)
{
    int N=0;
    int A,B;
    std::cin >> A;
    std::cin >> B;
    for(int i=0;i<2;i++)
    {
        if(A >B)
        {
            N += A; A--;
        }else
        {
            N+=B; B--;
        }
        
    }
    std::cout << N;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,five=0,seven=0;
	cin>>a>>b>>c;
	if(a==5)five++;
	if(a==7)seven++;
	if(b==5)five++;
	if(b==7)seven++;
	if(c==5)five++;
	if(c==7)seven++;
	cout<<(five==2&&seven==1?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char str[50];
	long long int i = 0,n;
	cin>>n;
	while (n > 0) {
		int rem = n % 26;
		if (rem == 0) {
			str[i++] = 'z';
			n = (n / 26) - 1;
		}
		else
		{
			str[i++] = (rem - 1) + 'a';
			n = n / 26;
		}
	}
	str[i] = '\0';
	reverse(str, str + strlen(str));
	cout << str << endl;

}

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


def main():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    x.sort()
    y.sort()
    if x[-1] < y[0]:
        war = True
        for z in range(x[-1] + 1, y[0] + 1):
            if X < z <= Y:
                war = False
                break
        if war: print("War")
        else: print("No War")
    else:
        print("War")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
/**
 *   @FileName	c.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.19 21:04:55
**/

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

int main() {
    int n;cin >> n;
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; i * j < n; j++) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K == 0:
        print(max(A))
        exit()
    
    # 二分探索で答えxを求める
    MIN = 0
    MAX = max(A)

    while MAX - MIN > 1:
        MID = (MIN + MAX)//2
        cnt = 0
        for i in range(N):
            cnt += (A[i]-1)//MID
        if cnt <= K:
            MAX = MID
        else:
            MIN = MID
    print(MAX)

if __name__ == "__main__":
    main()


Measured memory_bytes: 32176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
    int N;  cin >> N;
    vector<int> d(N);  rep(i, N) cin >> d[i];

    ll sum = 0;
    rep(i, N-1) {
        for(int j = i+1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }

    print(sum);

    return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, A, B = list(map(int, sys.stdin.buffer.readline().split()))

if abs(A - B) % 2 == 0:
    a = abs(A - B) // 2
    print(int(a))
else:
    a = abs(A - B) // 2
    ans = min(a + A, N - B + 1 + a)
    print(ans)


Measured memory_bytes: 22876
s = input()
temp1 = temp2 = 0
for i in range(len(s)):
    if s[i] == "A" and temp1 == 0:
        a = i
        temp1 = 1
    if s[(len(s)-1)-i] == "Z" and temp2 == 0:
        b = (len(s)-1)-i
        temp2 = 1
print(b-a+1)

Measured memory_bytes: 3512
function main()
  x = parse.(split(readline()))
  ret = 0
  max = 1
  for i in 2:3
    if x[max] <= x[i]
      max = i
    end
  end
  for i in 1:3
    if i == max
      ret += x[i] *10
    else
      ret +=x[i]
    end
  end
  print(ret)
end

main()

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S; cin >> S;
    ll cnt[2][2]; // first row is for 0 (mod2), first column is for 0
    rep(i, 2){rep(j, 2){cnt[i][j] = 0;}}
    rep(i, S.size()){
        cnt[i % 2][S[i] - '0'] += 1;
    }
    ll bw = cnt[0][0] + cnt[1][1];
    ll wb = cnt[0][1] + cnt[1][0];
    if (bw > wb){cout << S.size() - bw << endl;} else {cout << S.size() - wb << endl;}
}

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


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

int r, n;
int H[64];
int& Height(int x) {
  return H[x + 32];
}

int main(int argc, char *argv[]) {


  for(;;) {
    for(int& h : H) h = 0;
    scanf("%d %d", &r, &n);
    if( r == 0 and n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      int xl, xr, h;
      scanf("%d %d %d", &xl, &xr, &h);
      for(int x = xl; x < xr; ++x) {
        Height(x) = std::max(Height(x), h);
      }
    }
    double res = 1048576;
    for(int x = -r + 1; x < r; ++x) {
      double t = (double)std::min(Height(x-1), Height(x)) - sqrt(r*r-x*x) + r;
      res = std::min(res, t);
    }
    printf("%.20lf\n", res);
  }
  
  return 0;
}

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

int main()
{
	vector<int> x(3);
	for (int i = 0; i < 3; i++){
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	printf("%d %d %d\n", x[0], x[1], x[2]);
	return 0;
}

Measured memory_bytes: 1188
S=input()[::-1]
i=0
while i<len(S):
    if S[i:i+6]=="resare":
        i+=6
    elif S[i:i+5]=="esare":
        i+=5
    elif S[i:i+7]=="remaerd":
        i+=7
    elif S[i:i+5]=="maerd":
        i+=5
    else:
        print("NO")
        break
else:
    print("YES")

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

typedef long long ll;

int main(void)
{
    int a, b, k;
    cin >> a >> b >> k;

    int cnt = 0;

    for(int i = min(a, b); i >= 1; i--)
    {
        if(!(a%i == 0 && b%i == 0)) continue;
        cnt++;
        if(cnt == k){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void setmin(int &x, int y){
    x = min(x, y);
}

void setmax(int &x, int y){
    x = max(x, y);
}

void setmin(ll &x, ll y){
    x = min(x, y);
}

void setmax(ll &x, ll y){
    x = max(x, y);
}

const int maxn = 1e5 + 100, inf = 1e9 + 100;

int n, a[maxn];

int f(int x, int y){
    if (x > y)
        return 1;
    if (x < y)
        return -1;
    return 0;
}

bool cmp(int x, int y){
    if (x == 0 || y == 0)
        return 1;
    return x == y;
}

int main(){
    #ifdef ONPC
    ifstream cin("a.in");
    ofstream cout("a.out");
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    #else
    //ifstream cin("anti.in");
    //ofstream cout("anti.out");
    //freopen("internship.in", "r", stdin);
    //freopen("internship.out", "w", stdout);
    #endif // ONPC
    ios::sync_with_stdio(0);
    cin >> n;
    int last = 0, ans = 1, vl = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if (i == 0)
            continue;
        int x = f(a[i - 1], a[i]);
        if (x == 0)
            continue;
        if (vl == 0)
            vl = x;
        else
        if (vl != x)
            last = i, ans++, vl = 0;
    }
    cout << ans;
}


Measured memory_bytes: 640
import itertools
import bisect

W, H = map(int, input().split())
P = [int(input()) for w in range(W)]
Q = [int(input()) for h in range(H)]

P.sort()
accum_P = list(itertools.accumulate(P))
ans = accum_P[-1]
for q in Q:
  idx = bisect.bisect_left(P, q)
  if idx >= W + 1:
    ans += accum_P[W-1] + q
  elif idx == 0:
    ans += (W + 1) * q
  else:
    ans += accum_P[idx-1] + (W + 1 - idx)*q

print(ans)

Measured memory_bytes: 16372
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, A, B; cin >> N >> A >> B;
	int a = 0, b = 0, c = 0;
	vector<int> P(N);
	rep(i, N) {
		cin >> P[i];
		if (P[i] <= A)a++;
		else if (P[i] > A&&P[i] <= B)b++;
		else c++;
	}
	cout << min(min(a, b), c) << endl;
	cin >> N;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;

int main(void)
{
	cin >> N;
	
	int sum = 0;
	for(int n = N; n; n /= 10) sum += n % 10;
	
	if(N % sum) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int main( void ) {
	int h, w, dSq, hh, ww, d;

	for ( ; scanf( "%d %d", &h, &w ), h; printf( "%d %d\n", hh, ww ) ) {
		dSq = h * h + w * w;

		for ( hh = h + 1; hh * hh * 2 < dSq; hh++ ) {
			ww = sqrt( dSq - hh * hh );

			if ( hh * hh + ww * ww == dSq )
				goto contin;
		}

		for ( d = dSq + 1; ; d++ )
			for ( hh = 1; hh * hh * 2 < d; hh++ ) {
				ww = sqrt( d - hh * hh );

				if ( hh * hh + ww * ww == d )
					goto contin;
			}

		contin: ;
	}

	return 0;
}

Measured memory_bytes: 600
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  string S;
  cin >> S;
  VI place(26, 0);

  REP(i, S.size()) {
    place[static_cast<int>(S[i]) - 'a'] = i + 1;
  }

  if (S.size() < 26) {
    cout << S;
    REP(i, 26) {
      if (place[i] == 0) {
        cout << static_cast<char>('a' + i) << endl;
        return 0;
      }
    }
  }

  char MAX = S[25];
  vector<char> erased = {S[25]};
  int id = 26;
  RREP(i, 24) {
    if (MAX < S[i]) {
      MAX = S[i];
      erased.push_back(S[i]);
    } else {
      id = i;
      break;
    }
  }

  if (id > 25) {
    cout << -1 << endl;
  } else {
    REP(i, id) {
      cout << S[i];
    }
    REP(i, erased.size()) {
      if (S[id] < erased[i]) {
        cout << erased[i] << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
	int n;
	scanf("%d",&n);
	int i=1;
	while(++i<=n) {
		int x=i;
		if(x%3==0) {
			printf(" %d",i);
			continue;
		}
		while(x) {
			if(x%10==3) {
				printf(" %d",i);
				break;
			}
			x/=10;
		}
	}
 	printf("\n");
	}



Measured memory_bytes: 2680
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	long long prev[2] = { A[0], -A[0] };
	long long next[2];

	for (auto i = 1; i < N - 1; ++i)
	{
		next[0] = max(prev[0] + A[i], prev[1] - A[i]);
		next[1] = max(prev[0] - A[i], prev[1] + A[i]);

		swap(prev, next);
	}

	cout << max(prev[0] + A[N - 1], prev[1] - A[N - 1]) << endl;

	return 0;
}

Measured memory_bytes: 1024
N, X = map(x -> parse(Int64,x), split(readline(STDIN)))
a(i) = 2^(i + 2) - 3
p(i) = 2^(i + 1) - 1
function f(i::Int64, X::Int64)
    if i == 0
        return X >= 1 ? 1 : 0
    else
        a_i = a(i)
        center_num = Int64((a_i + 1) / 2)
        if center_num > X
            return f(i - 1, X - 1)
        elseif center_num == X
            return p(i - 1) + 1
        else
            return p(i - 1) + 1 + f(i - 1, X - center_num)
        end
    end
end
println(f(N, X))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

string s;
int main(){
  int sum=0;
  cin>>s;
  rep(i,s.size())sum+=s[i]-'0';
  if(sum!=0&&stoi(s)%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


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

int main(){
    int n; cin >> n;
    map<string,ll> A;
    for (int i=0;i<n;i++){
        string a; cin >> a;
        A[a]++;
    }
    cout <<"AC x " << A["AC"] << "\n";
    cout <<"WA x " << A["WA"] << "\n";
    cout <<"TLE x " << A["TLE"] << "\n";
    cout <<"RE x " << A["RE"] << "\n";
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[55][55][5000];
signed main() {
    int N,A;
    cin >> N >> A;
    vector<int>x(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i];
    }
    dp[0][0][0] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k <= 2500-x[i]; k++) {
                if(dp[i][j][k] == 0) {
                    continue;
                }
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
}



Measured memory_bytes: 12872
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;

int main()
{
  int n, x, t;
  cin >> n >> x >> t;
  if(n%x==0)
  cout << (n / x ) * t << endl;
  else
    cout <<(n/x+1)*t<<endl;
}

Measured memory_bytes: 3628
n = int(input())
grid = [ list(input()) for i in range(n) ]


def check(a, b):
    checkgrid = [ [ grid[(i+a)%n][(j+b)%n] for j in range(n)] for i in range(n) ]
    
    ret = True
    for i in range(n):
        for j in range(n):
            if checkgrid[i][j] != checkgrid[j][i]:
                ret = False
                break
    return ret

ans = 0

for i in range(n):
    if check(i, 0):
        ans += n
print(ans)

Measured memory_bytes: 121436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  string s;
  cin >> s;
  
  int ans = 0;
  int c;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) == 'A' || s.at(i) == 'C') {
      c++;
    } else if(s.at(i) == 'G' || s.at(i) == 'T') {
      c++;
    } else {
      c = 0;
    }
    ans = max(ans,c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256