akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	V<ll> x(N),y(N);
	REP(i,N) cin >> x[i] >> y[i];
	ll prt = abs(x[0]+y[0])%2;
	REP(i,N) corner((abs(x[i]+y[i])%2)!=prt,-1);
	int m = 31+!prt;
	V<ll> d;
	REP(i,31) d.push_back(1LL<<i);
	if(!prt)d.push_back(1);

	cout << m << endl;
	REP(i,m) cout << d[i] << " "; cout << endl;

	REP(i,N){
		ll u = x[i]+y[i];
		ll v = x[i]-y[i];
		ll ub=(u+(1<<31)-prt)/2;
		ll vb=(v+(1<<31)-prt)/2;
		string ans;
		REP(i,31) {
			char c;
			if( !(ub&(1<<i)) && !(vb&(1<<i)) ) c = 'L';
			if( (ub&(1<<i)) && (vb&(1<<i)) ) c = 'R';
			if( !(ub&(1<<i)) && (vb&(1<<i)) ) c = 'D';
			if( (ub&(1<<i)) && !(vb&(1<<i)) ) c = 'U';
			ans.push_back(c);
		}
		if(!prt)ans.push_back('L');
		cout << ans << endl;
	}



}



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

void Sort(int A[], int N);

int main()
{
	int N = 0;

	scanf("%d", &N);

	int d[200] = { 0 };
	int ans = 0;

	for (int i = 105; i <= N; i += 2) {
		for (int j = 1; j <= N; j++) {
			if (i%j == 0) {
				d[i]++;
			}
		}
		if (d[i] == 8) {
			ans++;
		}
	}




	printf("%d", ans);

	return 0;
}

void Sort(int A[], int N) {
	for (int j = 0; j < N ; j++) {
		for (int i = 0; i < N - j; i++) {
			if (A[i] < A[i + 1]) {
				int tmp = A[i];
				A[i] = A[i + 1];
				A[i + 1] = tmp;
			}
		}
	}
}

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

#define MOD 1000000007

int main()
{
    int n;
    cin>>n;
    int i,j;
    bool ok = false;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)ok = true;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

bool palin(string s) {
	string t = s;
	reverse(all(t));
	return s == t;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string a; cin >> a;
	
	bool res = palin(a) && palin(a.substr(0,sz(a)/2));
	cout << (res ? "Yes" : "No") << endl;

}



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


int main() {
  int K=0;
  cin >> K;
  int judge=0;
  vector<int> L(K);
  L.at(0)=7;
  
  if (K==7 || K==1) {
    cout << 1 << endl;
    return 0;
  }


  for (int i=1; i<K; i++) {
    L.at(i)=(10*L.at(i-1)+7)%K;
    if (L.at(i) == 0) {
      cout << i+1 << endl;
      judge=1;
      break;
    }
  }
  
  if (judge==0) {
    cout << "-1" << endl;
  }
}

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

long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }

ll power(ll a,ll b)
{
    if(b==1)
    return a;

    ll smallans = power(a,b/2);
    smallans = ((smallans)%MOD * (smallans)%MOD)%MOD;
    if(b&1)
    smallans = ((a)%MOD * (smallans)%MOD)%MOD;

    return smallans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;

    //ll ans =(((power(10LL,n)%MOD - power(9LL,n)%MOD)%MOD - power(9LL,n)%MOD)%MOD + power(8LL,n)%MOD)%MOD;
ll ans=minu(add(power(10LL,n),power(8LL,n)),mul(2LL,power(9LL,n)));
    cout<<ans;
    return 0;
}

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

int main()
{
	int n, quantum;
	queue<pair<int, string> > q;
	
	cin >> n >> quantum;
	for (int i = 0; i < n; i++) {
		pair<int, string> temp;
		cin >> temp.second >> temp.first;
		q.push(temp);
	}

	int t = 0;
	while (!q.empty())
	{
		if (q.front().first > quantum)	// プロセス未完了
		{
			pair<int, string> temp = q.front();
			temp.first -= quantum;
			t += quantum;
			q.pop();
			q.push(temp);
		}
		else	// プロセス完了
		{
			t += q.front().first;
			cout << q.front().second << ' ' << t << endl;
			q.pop();
		}
	}

	return 0;
}


Measured memory_bytes: 6320
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<bool> div(1000001), exit(1000001);
  vector<int> b(0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (!exit[a]) {
      b.push_back(a);
      exit[a] = true;
      for (int j = a * 2; j < div.size(); j += a) div[j] = true; 
    } else {
      div[a] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < b.size(); i++) {
    if (!div[b[i]]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4460
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    String j[] = new String[n];
    
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;       
   
    for(int i = 0; i<n ; ++i){
      j[i] = sc.next();
    }
    
    for(int i = 0; i<n ; ++i){
      if(j[i].equals("AC")){
        ac +=1;
      }else if(j[i].equals("WA")){
        wa +=1;
      }else if(j[i].equals("TLE")){
        tle +=1;
      }else if(j[i].equals("RE")){
        re +=1;
      }
    }
    System.out.println("AC x "+ac);
    System.out.println("WA x "+wa);
    System.out.println("TLE x "+tle);
    System.out.println("RE x "+re);
  }
}

Measured memory_bytes: 64140
#include<iostream>
using namespace std;
int main(){
	int a,b,x;
	cin>>a>>b>>x;
	int n=b-a+1;
	if(n<x*2){
		for(int i=a;i<=b;i++){
			cout<<i<<endl;
		}
	}else{
		for(int i=a;i<=a+x-1;i++){
			cout<<i<<endl;
		}
		for(int i=b-x+1;i<=b;i++){
			cout<<i<<endl;
		}
	}
}

Measured memory_bytes: 256
import sys
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

sys.setrecursionlimit(10**6)
# def solve():
# 	n, m = read()
# 	graph = [[] for i in range(n+1)]
# 	for _ in range(m):
# 		u, v = read()
# 		graph[u].append(v)
# 	visited = [0 for i in range(n+1)]
# 	def dfs(node):
# 		if visited[node]:
# 			return(visited[node])
# 		if not graph[node]:
# 			visited[node] = 0
# 			return(0)
# 		m = 0
# 		for i in graph[node]:
# 			m = max(m, dfs(i))
# 		visited[node] = 1 + m#ax(dfs(i) for i in graph[node])
# 		# print(node, visited[node])
# 		return(visited[node])

# 	ans = 0
# 	for i in range(1, n+1):
# 		ans = max(ans, dfs(i))
# 	# print(visited)
# 	print(ans)


def grid():
	n, m = read()
	arr = []
	for i in range(n):
		arr.append(inp().strip())
	# dic = {}
	dp = [-1]*m*n
	# print(dp, len(dp))
	def count_paths(i, j):
		# key = str(i)+"-"+str(j)
		# if key in dic:
		# 	return(dic[key])
		key = (i*m + j)
		# print(key)
		if i == n-1 and j == m-1:
			dp[key] = 1
			return(1)
		if i == n or j == m:
			return(0)
		if arr[i][j] == "#":
			dp[key] = 0
			return(0)
		if dp[key] > -1:
			return(dp[key])
		paths = (count_paths(i+1, j) + count_paths(i, j+1)) % (10**9 + 7)
		# dic[key] = paths
		dp[key] = paths
		return(paths)
	print(count_paths(0, 0))

def grid2():
	n, m = read()
	arr = []
	for i in range(n):
		arr.append(inp().strip())
	dp = {}
	# print(dp, len(dp))
	def count_paths(i, j):
		key = str(i)+"-"+str(j)
		if key in dp:
			return(dp[key])
		# key = (i*m + j)
		# print(key)
		if key in dp:
			return(dp[key])
		if i == n-1 and j == m-1:
			dp[key] = 1
			return(1)
		if i == n or j == m:
			return(0)
		if arr[i][j] == "#":
			dp[key] = 0
			return(0)
		
		paths = (count_paths(i+1, j) + count_paths(i, j+1)) % (10**9 + 7)
		# dic[key] = paths
		dp[key] = paths
		return(paths)
	print(count_paths(0, 0))



if __name__ == "__main__":
	# solve()
	grid2()

Measured memory_bytes: 210808
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a==b) cout << 2*a;
    if(a>b) cout << a+(a-1);
    if(a<b) cout << b+(b-1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
int dp[maxn];
vector<int> ady[maxn];
bool mk[maxn];
void dfs(int nodo){
    mk[nodo] = 1;
    int mx = 0;
    bool flag = 0;
    for (int i : ady[nodo]){
        flag = 1;
        if (!mk[i]){
            dfs(i);
        }
        mx = max(mx,dp[i]);
    }
    if (flag)
        dp[nodo] = mx+1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N,M;
    cin >> N >> M;
    for (int i = 1; i <= M;i++){
        int a,b;
        cin >> a >> b;
        ady[a].push_back(b);
    }
    for (int i = 1; i <= N;i++){
        if (!mk[i])
            dfs(i);
    }
    cout << *max_element(dp+1,dp+1+N);
    return 0;
}


Measured memory_bytes: 8320
N=int(input())
ans=N
for i in range(N+1):
    count=0
    t=i
    while t>0:
        count+=t%6
        t//=6
    t=N-i
    while t>0:
        count+=t%9
        t//=9
    ans=min(ans,count)
print(ans)

Measured memory_bytes: 9012
import sys

sys.setrecursionlimit(10 ** 7)


def resolve():
    A = list(input())
    B = list(input())
    C = list(input())

    def solve(S, s):
        if len(S) == 0:
            return s.upper()
        s = S.pop(0)
        if s == "a":
            return solve(A, s)
        elif s == "b":
            return solve(B, s)
        else:
            return solve(C, s)

    print(solve(A, ""))


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(void) {
  int A, B;
  cin >> A >> B;

  for (int x = 1; x <= 1000000; ++x) {
    if (int(x * 0.08) == A && int(x * 0.10) == B) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3092
S = input().rstrip()
D = [[-1] for _ in range(26)]
E = [[0] for _ in range(26)]
for i, s in enumerate(S):
    E[ord(s)-ord("a")].append(i-D[ord(s)-ord("a")][-1]-1)
    D[ord(s)-ord("a")].append(i)
for i in range(26):
    E[i].append(len(S)-1-D[i][-1])
res = []
for i in range(26):
    res.append(max(E[i]))
print(min(res))



Measured memory_bytes: 61916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), cl(9, 0);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    if (0 < a.at(i) && a.at(i) < 400)
      cl.at(0) = 1;
    else if (400 <= a.at(i) && a.at(i) < 800)
      cl.at(1) = 1;
    else if (800 <= a.at(i) && a.at(i) < 1200)
      cl.at(2) = 1;
    else if (1200 <= a.at(i) && a.at(i) < 1600)
      cl.at(3) = 1;
    else if (1600 <= a.at(i) && a.at(i) < 2000)
      cl.at(4) = 1;
    else if (2000 <= a.at(i) && a.at(i) < 2400)
      cl.at(5) = 1;
    else if (2400 <= a.at(i) && a.at(i) < 2800)
      cl.at(6) = 1;
    else if (2800 <= a.at(i) && a.at(i) < 3200)
      cl.at(7) = 1;
    else cl.at(8)++;
  }
  int sum = 0;
  for (int i = 0; i < 9; i++) sum += cl.at(i);
  if (cl.at(8) > 0) cout << max(1, sum - cl.at(8)) << " ";
  else cout << sum << " ";
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  ll K; cin >> K;

  ll N = S.length();
  ll length = 0;
  rep(i, N){
    if (S[i] == '1') length++;
    else break;
  }
  if (length == 0) cout << S[0] << endl;
  else if (K <= length) cout << 1 << endl;
  else cout << S[length] << endl;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

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

    vector<ll> xv(n);

    int cnt = 0;
    rep(i, n) {
        cin >> xv[i];
    }

    ll ans = 1e17;
    int l, r;
    rep(i, (n-k+1)) {
        l = 0 + i;
        r = ( k - 1 ) + i;
//        cout << i << " " << xv[l] << " " << xv[r] << " " << abs(xv[r]-xv[l]) << endl;
        ans = min(ans, abs(xv[l])+abs(xv[r]-xv[l]));
//        cout << ans << endl;
        ans = min(ans, abs(xv[r])+abs(xv[r]-xv[l]));
//        cout << i << " " << ans << endl;
    } 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd
from math import log,ceil

def main():
    v=[0 for i in range(100001)]
    n=int(input())
    ar=list(map(int,input().split()))
    s=0
    for i in ar:
        s+=i
        v[i]+=1
    q=int(input())
    for i in range(q):
        a,b=map(int,input().split())
        s-=a*v[a]
        s+=b*v[a]
        v[b]+=v[a]
        v[a]=0
        print(s)


BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")


if __name__ == "__main__":
    main()



Measured memory_bytes: 23856
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> cnt(300001);
    vector<int> S(300002);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        cnt[x]++;
    }
    for (int j = 0; j <= 300000; ++j) {
        S[j+1] = S[j]+cnt[j];
    }
    for (int i = 0; i < q; ++i) {
        int x;
        scanf("%d", &x);
        int ans = 0;
        for (int l = 0; l <= 300000; l += x) {
            int ok = l+ans, r = min(l+x, 300001), ng = r;
            if(ok >= ng || S[ok] == S[ng]) continue;
            while(ng-ok > 1){
                int mid = (ok+ng)/2;
                if(S[r] != S[mid]) ok = mid;
                else ng = mid;
            }
            ans = ok-l;
        }
        cout << ans << "\n";
    }
    return 0;
}


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

const int maxn = 100005;

int n, mx = -1, mn = maxn;
int a[maxn], cnt[maxn];

signed main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		++cnt[a[i]];
		mn = min(mn, a[i]), mx = max(mx, a[i]);
	}
	if (mx - mn > 1)
		printf("No\n");
	else if (mx == mn) {
		if (mx == n - 1 || 2 * mx <= n)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else {
		if (cnt[mn] + 1 <= mx && mx <= cnt[mn] + cnt[mx] / 2)
			printf("Yes\n");
		else
			printf("No\n");
	}
}


Measured memory_bytes: 4392
#include <iostream>
#define llint long long

using namespace std;

llint N, M;

int main(void)
{
	cin >> N >> M;
	
	if(N == 1 && M == 1){
		cout << 1 << endl;
		return 0;
	}
	if(N == 1){
		cout << M-2 << endl;
		return 0;
	}
	if(M == 1){
		cout << N-2 << endl;
		return 0;
	}
	cout << (M-2)*(N-2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int n;
vector<int> vec;

int main() {
  cin >> n;
  vec.resize(n);
  rep(i, n) {
    int a;
    cin >> a;
    vec[a - 1] = i + 1;
  }
  rep(i, n) { cout << vec[i] << " "; }
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {

    int r, d, x;
    scanf("%d %d %d", &r, &d, &x);

    for (int i = 1; i <= 10; i++) {

        int xtemp = r * x - d;
        printf("%d\n", xtemp);
        x = xtemp;

    }



    return 0;
}


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

#define rep(i,a) for(int i=0;i<(int)(a);i++)
const int INF = 1000000007;
const int MAX_V = 17;

int G[MAX_V][MAX_V];
int A[MAX_V][MAX_V];

int V;

void wf(){
  for( int k = 0; k < V ; k++){
    for( int i = 0; i < V ; i++){
      for( int j = 0; j < V ; j++){
	A[i][j] = min(A[i][j], A[i][k] + A[k][j] );
      }
    }
  }
}


int main(){

  int n;
  V = 10;

  while(1){
    cin >> n;
    if(n == 0) break;
    rep(i,V){
      rep(j,V){
	G[i][j] = INF;
      }
      G[i][i] = 0;
    }
    
    V = 0;
    rep(i,n){
      int a,b,c;
      cin >> a >> b >> c;
      V = max(V,max(a,b));
      G[a][b] = c;
      G[b][a] = c;
    }
    V++;

    rep(i,V){
      rep(j,V){
	A[i][j] = G[i][j];
      }
    }

    wf();

    int sum,min = INF,in;
    rep(j,V){
      sum = 0;
      rep(i,V){
	sum += A[j][i];
      }
      if(sum > 0 && sum < min) {
	min = sum;
	in = j;
      }
    }

    cout <<in << " "<< min << endl;
  }

     return 0;
}

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

#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int start_n, q;
    cin >> start_n >> q;
    int n = start_n, m = start_n;
    vector<int> r(n + 1, 0);
    vector<int> c(m + 1, 0);
    int black = (n - 2) * (n - 2);
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int y;
            cin >> y;
            if (y > m)
                black -= c[y] - 1;
            else {
                black -= n - 2;
                for (int j = y; j < m; j++)
                    c[j] = n - 1;
                m = y;
            }
        } else {
            int x;
            cin >> x;
            if (x > n)
                black -= r[x] - 1;
            else {
                black -= m - 2;
                for (int i = x; i < n; i++)
                    r[i] = m - 1;
                n = x;
            }
        }
    }
    cout << black;
    return 0;
}


Measured memory_bytes: 6328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (int)(b) - 1; i >= (a); i--)

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> G(H);
  REP(i, H) cin >> G[i];
  queue<pair<int, int>> q;
  vector<vector<int>> dist(H, vector<int>(W, -1));
  REP(i, H) REP(j, W) if (G[i][j] == '#') {
    q.emplace(i, j);
    dist[i][j] = 0;
  }
  int ans = 0;
  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    const int dy[] = {0, 1, 0, -1};
    const int dx[] = {1, 0, -1, 0};
    ans = max(ans, dist[y][x]);
    REP(k, 4) {
      int ny = y + dy[k];
      int nx = x + dx[k];
      if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
      if (dist[ny][nx] == -1) {
        dist[ny][nx] = dist[y][x] + 1;
        q.emplace(ny, nx);
      }
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 13456
import heapq as hq
n=int(input())
A=[]
hq.heapify(A)
B=[]
for i in range(n):
    a=int(input())
    hq.heappush(A,-a)
    B.append(a)
M1=-hq.heappop(A)
M2=-hq.heappop(A)
for b in B:
    if b!=M1:
        print(M1)
    elif M1==M2:
        print(M1)
    else:
        print(M2)

Measured memory_bytes: 20528
#include <stdio.h>

int n;
int b[105];
int order[105];

int main()
{

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

	for (int i = n; i >= 1; i--) {
		int j = n;

		while (j > 0 && b[j] != j) {
			j--;
		}

		if (j <= 0) {
			printf("-1\n");
			return 0;
		}

		order[i] = j;

		//???
		while (j <= n) {
			b[j] = b[j + 1];
			j++;
		}

	}

	for (int i = 1; i <= n; i++) {
		printf("%d\n", order[i]);
	}

	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	pii P[51];

	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> P[i].first >> P[i].second;
	}

	int ans = INF;
	rep(i, 0, N)rep(j, i, N)
	{
		vector<int> yvec;
		int lx = min(P[i].first, P[j].first);
		int rx = max(P[i].first, P[j].first);
		rep(k, 0, N)
		{
			if (lx <= P[k].first&&P[k].first <= rx)
			{
				yvec.push_back(P[k].second);
			}
		}

		if (SZ(yvec) < K)continue;

		sort(all(yvec));

		int miny = INF;
		rep(i, 0, SZ(yvec) - K + 1)
		{
			chmin(miny, yvec[i + K - 1] - yvec[i]);
		}

		chmin(ans, (rx - lx)*miny);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while( 1 )
	{
		c -= b;
		if( c <= 0 )
		{
			cout << "Yes";
			break;
		}

		a -= d;
		if( a <= 0 )
		{
			cout << "No";
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,p[50],q[50],sum=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>p[i];
		q[i]=p[i];
	}
	sort(p,p+N);
	for(int i=0;i<N;i++){
		if(p[i]!=q[i])sum++;
	}
	if(sum==0||sum==2)cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_DATA 500001

int temp[MAX_DATA];
int cnt = 0;

void mergeSort(int x[], int left, int right)
{
	int mid, i, j, k;

	if (left < right) {

		mid = (left + right) / 2;
		mergeSort(x, left, mid);
		mergeSort(x, mid + 1, right);

		for (i = left; i <= mid; i++)
			temp[i] = x[i];

		for (i = mid + 1, j = right; i <= right; i++, j--)
			temp[i] = x[j];

		i = left;
		j = right;

		for (k = left; k <= right; k++) {
			cnt++;
			if (temp[i] <= temp[j])
				x[k] = temp[i++];
			else
				x[k] = temp[j--];
		}

	}
}

int main(void) {
	int n;
	int line[500001];
	int i;

	scanf("%d", &n);

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

	mergeSort(line, 0, n - 1);

	for (i = 0; i < n; i++) {
		printf("%d", line[i]);
		if (i < n - 1) {
			printf(" ");
		}
	}
	printf("\n%d\n", cnt);

	return 0;
}


Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000
typedef string::const_iterator State;
int expression(State &begin);

int data[201];
int kakko[201];
int size;

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	data[size++]=ret;
	return ret;
}

int factor(State &begin){
	if(*begin=='('){
		begin++;
		kakko[size]++;
		int ret=expression(begin);
		kakko[size-1]--;
		begin++;
	}else{
		return number(begin);
	}
}

int expression(State &begin){
	int ret=factor(begin);
	while(1){
		if(*begin=='+'){
			begin++;
			data[size++]=-1;
			ret+=expression(begin);
		}else if(*begin=='-'){
			begin++;
			data[size++]=-2;
			ret-=expression(begin);
		}else{
			break;
		}
	}
	return ret;
}

int dp[201][201][2];

int solve(int f,int t,int type){
	if(type==0 && dp[f][t][type]!=-INF)return dp[f][t][type];
	if(type==1 && dp[f][t][type]!=INF)return dp[f][t][type];
	if(t-f==1){
		return data[f];
	}
	if(t-f==3){
		if(data[f+1]==-1){
			return data[f]+data[f+2];
		}
		if(data[f+1]==-2){
			return data[f]-data[f+2];
		}
	}
	int res=-INF;
	if(type==1)res=INF;
	for(int i=f+1;i<t;i+=2){
		if(data[i]==-2 && (i-1==f || kakko[i-1]<=0) && kakko[f]>=0 && kakko[t-1]<=0 && (kakko[i+1]>=0 || i+1==t-1)){
			if(type==0)res=max(solve(f,i,0)-solve(i+1,t,1),res);
			if(type==1)res=min(solve(f,i,1)-solve(i+1,t,0),res);
		}
		if(data[i]==-1 && (i-1==f || kakko[i-1]<=0) && kakko[f]>=0 && kakko[t-1]<=0 && (kakko[i+1]>=0 || i+1==t-1)){
			if(type==0)res=max(solve(f,i,0)+solve(i+1,t,0),res);
			if(type==1)res=min(solve(f,i,1)+solve(i+1,t,1),res);
		}
	}
	return dp[f][t][type]=res;
}

int main(void){
	string str;
	cin >> str;
	State begin=str.begin();
	expression(begin);
	for(int i=0;i<=200;i++){
		for(int j=0;j<=200;j++){
			dp[i][j][0]=-INF;
			dp[i][j][1]=INF;
		}
	}
	printf("%d\n",solve(0,size,0));
	return 0;
}

Measured memory_bytes: 3628
#abc177 e
import sys,math,collections,itertools
import functools
input = sys.stdin.readline


N=int(input())
A=list(map(int,input().split()))
fact = set()
for a in A:
    if a==1:
        fact.add(1)
        continue
    if a%2 == 0 and 2 in fact:
        break
    while a%2==0:
        fact.add(2)
        a//=2
            
    i =3
    while i*i <= a:
        if a%i ==0 and i in fact:
            break
        while a%i==0:
            fact.add(i)
            a//=i
        else:
            i +=2
    else:
        if a != 1:
            if a in fact:
                break
            fact.add(a)
        continue
    break
else:
    print('pairwise coprime')
    exit()
if functools.reduce(math.gcd,A)!=1:
    print('not coprime')
else:
    print('setwise coprime')





Measured memory_bytes: 173776
#include<bits/stdc++.h>
#include<math.h>
#define pi acos(-1)
using namespace std;
typedef long long ll;
typedef long double ld;
ll x[200020], ans[200020];
int main()

{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	ll n; cin>>n; 
	ll i;
	for(i=2; i<=n; i++) cin>>x[i];
	for(i=2; i<=n; i++){ ans[x[i]]++;}
	for(i=1; i<=n; i++)cout << ans[i] << endl;


	return 0;
}




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

int main() {
    ll N,count = 0,tmp = 0;
    cin >> N;
    vector<ll> A(N+1);
    for (int i = 0; i < N+1; i++) {
        cin >> A.at(i);
    }
    vector<ll> B(N);
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
    }
    rep(i,N){
        tmp = B.at(i) - A.at(i);
        if(tmp <= 0){//AiとBiの比較
            count += B.at(i);//これしか倒せなかった
            A.at(i) = A.at(i)-B.at(i);
            continue;
        }else{//まだ倒せる場合が例外処理
            count += A.at(i);
            B.at(i) = tmp;//余力
            A.at(i) = 0;//すべて倒した
            tmp = B.at(i) - A.at(i+1);//次の町へ
        }

        if(tmp <= 0){//Ai+1とBiの比較
            count += B.at(i);
            A.at(i+1) = A.at(i+1)-B.at(i);
            continue;
        }else{
            count += A.at(i+1);
            A.at(i+1) = 0;
            continue;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define F          first 
#define S          second
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
 ll i,j,k,n,m;
 cin>>n>>k;
 ll temp=n%k;
 ll ans=min(k-temp,temp);
 cout<<ans<<endl;
}
  
int main() {
  speedup;
  ll i=0,t;
  //cin>>t;
  t=1;
  while(t--) {
    comp();
  }
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,n;cin>>a>>b>>c>>n;
  if(n<=a)cout<<n;
  else
  {
  if(n-a<=b)cout<<a;
    else cout<<a-(n-a-b);
  }
  return 0;
}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	string s;
	cin >> s;
	int cnt0 = 0, cnt1 = 0, s0 = 0; 
	for (int i = 0; i < s.length(); i++) {
		if ((s[i] - '0') != s0)
			cnt0++;
		else
			cnt1++;
		s0 = 1 - s0;
	}
	cout << min(cnt0, cnt1) << endl;
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024
var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n, m, c := nextInt(), nextInt(), nextInt()

	a, b := make([][]int, n), make([]int, m)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}

	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			a[i][j] = nextInt()
		}
	}

	count := 0
	for i := 0; i < n; i++ {
		s := c
		for j := 0; j < m; j++ {
			s += a[i][j] * b[j]
		}

		if s > 0 {
			count++
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>

using namespace std;

int gcd(int n, int m) {
    if (n == 0) return m;
    return gcd(m % n, n);
}

bool mm(int i) {
    return 1 <= i && i <= 12;
}

bool yy(int i) {
    return 0 <= i && i <= 99;
}

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

    int left = stoi(s.substr(0,2));
    int right = stoi(s.substr(2,2));

    bool left_m = mm(left);
    bool left_y = yy(left);
    bool right_m = mm(right);
    bool right_y = yy(right);

    if (left_m && right_m && left_y && right_y) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if (left_m && right_y) {
        cout << "MMYY" << endl;
        return 0;
    }

    if (left_y && right_m) {
        cout << "YYMM" << endl;
        return 0;
    }

    cout << "NA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

const ll MOD = (ll)pow(10,9)+7;

int main(){
  int s;
  cin >> s;
  vector<vector<ll>> pas(2001,vector<ll>(2001));
  pas[0][0] = 1;
  rep(i,2000) rep(j,2000){
    pas[i][j] %= MOD;
    pas[i+1][j] += pas[i][j];
    pas[i+1][j+1] += pas[i][j];
  }
  ll ans = 0;
  for(int i=1;3*i<=s;i++){
    int h = s - 3*i;
    ans += pas[h+i-1][i-1];
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 34604
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = -pow(10, 9)
for left in range(0, K + 1):
  for right in range(0, K - left + 1):
    if left + right < N:
      all_get = V[:left] + V[::-1][:right]
    else:
      all_get = V[:]
    all_get.sort(reverse=True)
    num = 0
    while True:
      if num >= K - (left + right) or len(all_get) == 0:
        break
      if all_get[-1] >= 0:
        break
      all_get.pop(-1)
      num += 1
    now = sum(all_get)
    ans = max(ans, now)
print(ans)

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

struct edge{int to,cost;};
typedef pair<int,int> P;
int n,m,k,ans,d[3007],miti[100005][3];
const int INF = 1000000000;
vector<edge> G[3007];
int main(){
	scanf("%d%d%d",&n,&m,&k);

	for(int i = 0;i <= n;i++){
		d[i] = INF;
	}
	for(int i = 0;i < m;i++){
		int a,b,l;
		scanf("%d%d%d",&a,&b,&l);
		miti[i][0] = a,miti[i][1] = b,miti[i][2] = l;
		edge tmp = {b,l};
		G[a].push_back(tmp);
		edge tmp2 = {a,l};
		G[b].push_back(tmp2);
	}
	priority_queue<P,vector<P>,greater<P> > que;
	for(int i = 0;i < k;i++){
		int a;
		scanf("%d",&a);
		d[a] = 0;
		que.push(P(0,a));
	}

	while(que.size()){
		P q = que.top(); que.pop();
		if(d[q.second] < q.first)continue;
		for(int i = 0;i < G[q.second].size();i++){
			edge es = G[q.second][i];
			if(d[es.to] > q.first + es.cost){
				d[es.to] = q.first + es.cost;
				que.push(P(d[es.to],es.to));
			}
		}
	}
	for(int i = 1;i <= n;i++){
		ans = max(ans,d[i]);
	}
	for(int i = 0;i < m;i++){
		int a =d[miti[i][0]],b = d[miti[i][1]],l = miti[i][2];
		if(a > b)swap(a,b);
		l -= (b-a);
		if(l <= 0)continue;
		ans = max(ans,b+(l+1)/2);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5356
from heapq import heappop,heappush
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

q = []
heappush(q,(-(A[0]+B[0]+C[0]),0,0,0))
for i in range(K):
    ans, i,j,k = heappop(q)
    print(-ans)
    if i+1 < X:
        t = (-(A[i+1]+B[j]+C[k]),i+1,j,k)
        if t not in q:
            heappush(q,t)
    if j+1 < Y:
        t = (-(A[i]+B[j+1]+C[k]),i,j+1,k)
        if t not in q:
            heappush(q,t)
    if k+1 < Z:
        t = (-(A[i]+B[j]+C[k+1]),i,j,k+1)
        if t not in q:
            heappush(q,t)

Measured memory_bytes: 3828
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,m=1;
	scanf("%d",&n);
	while(m<=n)
	{
		m*=2;
	}
	printf("%d",m/2);
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int alph[MAX_N] = {};

signed main()
{
    string S;
    cin >> S;
    REP(i, S.length()) {
        alph[S[i]-'a']++;
    }
    REP(i, 26) {
        if(alph[i] == 0) {
            printf("%c\n", i + 'a');
            return 0;
        }
    }
    printf("None\n");

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define vvdebug(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N, K; cin >> N >> K;
	vi h(N); rep(i, N) cin >> h.at(i);
	sort(all(h));
	int ans = 1000000000;
	rep(i, N - K + 1) ans = min(ans, h.at(i + K - 1) - h.at(i));
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 1000000007;
struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }
	int root(int x) {
		if (par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	bool issame(int x, int y) { return root(x) == root(y); }
	bool merge(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) { return -par[root(x)]; }
};
int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	UnionFind tree(n);
	while (q--) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		if (a)
			cout << (tree.issame(b, c) ? 1 : 0) << endl;
		else
			tree.merge(b, c);
	}
	return 0;
}

Measured memory_bytes: 3992
//*-- ILSH --*//
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
const ll inf=1e18+1e17;
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
long double arr[3000+5][3000+5];
void solve(){
	int n;
	cin>>n;
	long double brr[n];
	for ( int i=0;i<n;i++)
		cin>>brr[i];
	arr[1][0]=brr[0];
	arr[0][0]=1-brr[0];
	for ( int j=1;j<n;j++) {
		arr[0][j]=arr[0][j-1]*(1-brr[j]);
		for (int i=1;i<=j;i++)
			arr[i][j]=arr[i][j-1]*(1-brr[j])+arr[i-1][j-1]*brr[j];
		arr[j+1][j]=arr[j][j-1]*brr[j];
	}
	int p=n/2;
	long double total=0;
	for ( int i=n;i>p;i--)
		total+=arr[i][n-1];
	cout<<setprecision(10)<<fixed;
	cout<<total<<'\n';
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while ( t-- )
    	solve();    
}

Measured memory_bytes: 139776
import sys

n = int(input())
words = []
word = ""
for i in range(n):
    word = input()
    # 2個目かチェック
    if word in words:
        print("No")
        sys.exit(0)
    else:
        words.append(word)

for index, word in enumerate(words):
    if index == 0:
        continue
    if words[index - 1][-1] == list(word)[0]:
        continue
    else:
        print("No")
        sys.exit(0)
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll n, c;
    cin >> n >> c;
    vector<pll> v(n);
    REP(i,n) cin >> v[i].first >> v[i].second;

    // 0-時計回り 1-反時計回り 2-時計回り反転 3-反時計回り反転 
    vector<ll> best(4);
    // ベスト値の f-dest s-val
    // cl-clockwise ccl-counterclockwise
    vector<pll> vcl(n), vccl(n);
    ll cld = 0, clv = 0, ccld = 0, cclv = 0;
    REP(i,n) {
        cld = v[i].first; clv += v[i].second;
        if (best[0] < clv - cld) {
            best[0] = clv - cld;
            vcl[i].first = cld;
            vcl[i].second = clv;
        } else {
            if (i != 0) {
                vcl[i].first = vcl[i-1].first;
                vcl[i].second = vcl[i-1].second;
            }
        }
        //cerr << best[0] << " " << vcl[i].first << " " << vcl[i].second << endl;
        
        ccld = c - v[n-1-i].first; cclv += v[n-1-i].second;
        if (best[1] < cclv - ccld) {
            best[1] = cclv - ccld;
            vccl[i].first = ccld;
            vccl[i].second = cclv;
        } else {
            if (i != 0) {
                vccl[i].first = vccl[i-1].first;
                vccl[i].second = vccl[i-1].second;
            }
        }
    }

    REP(i,n-1) {
        ll cv = (vcl[i].second + vccl[n-2-i].second) - (vcl[i].first*2 + vccl[n-2-i].first);
        ll ccv = (vccl[i].second + vcl[n-2-i].second) - (vccl[i].first*2 + vcl[n-2-i].first);
        best[2] = max(best[2],cv);
        best[3] = max(best[3],ccv);
        //cerr << best[2] << " " << best[3] << endl;
    }

    cout << *max_element(ALL(best)) << '\n';

    return 0;
}

Measured memory_bytes: 4992
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

cnt=0
k=int(input())

for i in range(1,k+1):
	for j in range(1,k+1):
		for l in range(1,k+1):
			cnt+=gcd(i,j,l)

print(cnt)


Measured memory_bytes: 75004
s = input()

def solve(s):
    n = len(s)
    for i in range(n-1):
        if s[i] == s[i+1]:
            return i+1, i+2
    for i in range(n-2):
        if s[i] == s[i+2]:
            return i+1, i+3
    return -1, -1

print("%d %d" % solve(s))


Measured memory_bytes: 3188
count = int(input());
data = [int(n) for n in input().split(" ")];

def selection_sort(data):
    count = len(data);
    o = 0;
    for i in range(count):
        minI = i;
        for j in range(i + 1, count):
            if data[j] < data[minI]:
                minI = j;
        if minI != i:
            temp = data[i];
            data[i] = data[minI];
            data[minI] = temp;
            o += 1;
    show(data);
    print(o);

def show(data):
    print(" ".join(str(n) for n in data));

selection_sort(data);


Measured memory_bytes: 5600