akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc126/tasks/abc126_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

struct WeightedUnionFind {
    vector<int> par; // 親の番号
    vector<int> ws;  // 親との重みの差

    //最初は全てが根であるとして初期化
    WeightedUnionFind(int size) : par(size, -1), ws(size) {}

    // xとyの木を併合
    bool unite(int x, int y, int w) { // x <-(w)- y (x + w = y)
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);

        if (x != y) {
            if (par[y] < par[x]) { // 多い方が根になるようにスワップする.
                swap(x, y);
                w = -w;
            }
            par[x] += par[y];
            par[y] = x;
            ws[y] = w;
            return true;
        } else {
            return false;
        }
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }

    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) {
        if (par[x] < 0) {
            return x;
        } else {
            int parent = root(par[x]);
            ws[x] += ws[par[x]];
            return par[x] = parent;
        }
    }

    // 根からの重みを返す
    int weight(int x) {
        root(x);
        return ws[x];
    }

    // xとyの差分を返す。異なるグループなら-1を返す
    int diff(int x, int y) {
        if (!same(x, y)) {
            return -1;
        }
        return abs(weight(x) - weight(y));
    }
    int size(int x) { return -par[root(x)]; }
};

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

    WeightedUnionFind tree(n);

    for (int i = 0; i < n - 1; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        tree.unite(--x, --y, z);
    }
    for (int i = 0; i < n; i++) {
        // 0 か 1 を出力
        cout << (1 & tree.weight(i)) << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;


public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        double a = nextDouble();
        double b = nextDouble();
        double h = nextDouble();
        double m = nextDouble();

        h = h*30;
        h = h+0.5*m;

        m = m*6;

        double del = Math.abs(h-m);
        //print(del);

        double ans = Math.sqrt(b*b + a*a - 2*b*a*Math.cos(Math.toRadians(del)));

        print(ans);
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}

Measured memory_bytes: 35912
// Ivan Carvalho
// Problem E - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;

ll dp[MAXV];
int N,W,V,wi[MAXN],vi[MAXN];

int main(){

	cin >> N >> W;
	for(int i = 1;i<=N;i++){
		cin >> wi[i] >> vi[i];
		V += vi[i];
	}

	for(int i = 1;i<=V;i++) dp[i] = INF;
	dp[0] = 0;

	for(int item = 1;item<=N;item++){
		int w = wi[item], v = vi[item];
		for(int i = V;i>=v;i--){
			dp[i] = min(dp[i],dp[i - v] + w);
		}
	}

	for(int i = V;i>=0;i--){
		if(dp[i] <= W){
			cout << i << endl;
			break;
		}
	}

	return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll a[100010], b[100010], bus[100010];

int main() {
	ll N, K;
	cin >> N >> K;
	if(N<2*K-1){
		cout << -1 << endl;
		return 0;
	}
	ll t=N;
	for(int i=0; i<N; ++i){
		a[i]=t;
		++t;
		if(t==K+N) t=K;
	}
	t=K+N+(K-1)*2;
	for(int i=0; i<K; ++i){
		b[i]=t;
		bus[t-K-N]=1;
		t -= 2;
	}
	t=K+N*2-1;
	for(int i=K; i<N; ++i){
		while(bus[t-K-N]==1) --t;
		b[i]=t;
		--t;
	}
	t=K+N*3-1;
	for(int i=0; i<N; ++i){
		cout << a[i] << ' ' << b[i] << ' ' << t << endl;
		--t;
	}
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

int main() {
    ll H, W;
    cin >> H >> W;
    ll sh, sw, gh, gw;
    cin >> sh >> sw;
    cin >> gh >> gw;
    sh--;
    sw--;
    gh--;
    gw--;

    // 道の一覧
    vector<vector<bool>> roads(H, vector<bool>(W, false));
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            char c;
            cin >> c;
            while (c != '.' && c != '#') {
                cin >> c;
            }
            if (c == '.') {
                roads[h][w] = true;
            }
        }
    }

    vector<vector<bool>> done(H, vector<bool>(W, false));
    vector<stack<pair<ll, ll>>> diststack(256);
    ll d = 0;
    diststack[0].push(make_pair(sh, sw));
    while (true) {
        if (diststack[d].empty()) {
            if (diststack[d + 1].empty()) {
                break;
            }
            if (diststack.size() <= d + 2) {
                diststack.resize(d * 2);
            }
            d++;
            continue;
        }
        auto src = diststack[d].top();
        diststack[d].pop();
        ll h = src.first;
        ll w = src.second;
        if (h == gh && w == gw) {
            cout << d << endl;
            return 0;
        }
        if (done[h][w]) {
            continue;
        }
        done[h][w] = true;
        for (ll y = h - 2; y <= h + 2; y++) {
            for (ll x = w - 2; x <= w + 2; x++) {
                if (y >= 0 && y < H && x >= 0 && x < W && roads[y][x] && !done[y][x]) {
                    if (abs(x - w) + abs(y - h) == 1) {
                        diststack[d].push(make_pair(y, x));
                    } else {
                        diststack[d + 1].push(make_pair(y, x));
                    }
                }
            }
        }
    }
    cout << -1 << endl;
}


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

int main()
{
    int a,b,c;
    int sum=0;
    cin>>a>>b>>c;
    sum = a+b+c;
    if(sum>=22)
    {
        cout<<"bust"<<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
class Stack:
    def __init__(self, data=[]):
        self.data = data

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty is True:
            return None
        else:
            return self.data.pop(-1)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    # def is_full(self):


formula = input().split()
# print(formula)

s = Stack()

for f in formula:
    if f in ['+', '-', '*']:
        x2 = s.pop()
        x1 = s.pop()

        if f == '+':
            y = x1 + x2
        elif f == '-':
            y = x1 - x2
        else:
            y = x1 * x2

        s.push(y)

    else:
        x = int(f)
        s.push(x)

print(s.pop())





Measured memory_bytes: 5596
N, K = map(int,input().split())
win = 0
if N >= K:
    for i in range(1,K):
        #最初に出た目がi(1 <= i < K)の時のKを超える確率の和を求める
        j =0
        while i*(2**j) < K:
            #勝負に勝つのは最初に出た目iを2のj乗した時にKを超える時
            j +=1
        win += 1/((2**j)*N)
    #サイコロを振っただけで勝ちが確定する確率
    win += (N-K+1)/N
else:
    for l in range(1,N+1):
        #最初に出た目がl(1 <= l <= N )の時Kを超える確率の和を求める
        m = 0
        while l*(2**m) < K:
            #勝負に勝つのは最初に出た目lを2のm乗した時にKを超える時
            m +=1
        win +=1/((2**m)*N)

print(win)

Measured memory_bytes: 3060
using System;

namespace ConsoleApplication26
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                //?????°
                string N = Console.ReadLine();
                int n = int.Parse(N);
                double Lav = 0;
                double Sav = 0;
                double Lhy = 0;
                double Shy = 0;
                if (n == 0)
                    break;
                //?????°
                string[] s = Console.ReadLine().Split(' ');

                //??????
                for (int i = 0; i < n; i++)
                {
                    int av = int.Parse(s[i]);
                    Sav += av;
                }
                Lav = Sav / n;
                //?¨??????????
                for (int i = 0; i < n; i++)
                {
                    int av = int.Parse(s[i]);
                    double hy = Math.Pow(av - Lav, 2);
                    Shy += hy;
                }
                Lhy = Math.Sqrt(Shy / n);
                Console.WriteLine(Lhy);
            }
        }
    }
}

Measured memory_bytes: 9376
import sys

stdin = sys.stdin

ni = lambda: int(stdin.readline())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()


s = ns()
t = ns()
s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))
if s < t:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main
{

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

        int x = scan.nextInt();
        int n =1;
        while (x != 0) {
            System.out.println("Case "+n+": " + x);
            x = scan.nextInt();
            n++;
        }
    }
}



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


int main() {
  //A1 < B1ならi=0でB1-A1を足さなければならない
  //A2 < B2ならi=1でB2-A2を足さなければならない
  //i=0,N-1において、Ai<Biだとしたら、Bi-Ai不足する
  //これを穴埋めするために、Ai>Biとなっているところから補っていく必要がある
  //Ai-Biの大きい順に並べていく
  //大きい方からAi-Biを不足分から引いていく
  //不足分が負になったらその時のカウンターがi
  //不足分が負になる前にAi-Biが負になったら-1
  int N;
  cin >> N;
  vector<long> Ai(N);
  vector<long> Bi(N);
  vector<long> minus(N);
  int i;
  for (i=0;i<N;i++){
    cin >> Ai.at(i);
  }
  for (i=0;i<N;i++){
    cin >> Bi.at(i);
  }
  for (i=0;i<N;i++){
    minus.at(i) = Ai.at(i) - Bi.at(i);
  }
  sort(minus.begin(),minus.end());
  reverse(minus.begin(),minus.end());
  long lack = 0;
  int minus_count=0;
  for (i=0;i<N;i++){
    if (minus.at(i)<0){
      lack += abs(minus.at(i));
      minus_count++;
    }
  }
  int ans = -1;
  if (lack == 0){
      ans = 0;
  } else {
    for (i=0;i<N;i++){
      if (minus.at(i) <= 0){
        ans = -1;
        break;
      }
      lack -= minus.at(i);
      if (lack <= 0){
        ans = minus_count + i + 1;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
H,W,A,B = map(int,input().split())

mod = 10**9 + 7

f = [1]
for i in range(H+W):
    f.append(f[i]*(i+1)%mod)

def comb(A,B,mod):
    return f[A] * pow(f[B],mod-2,mod) * pow(f[A-B],mod-2,mod) % mod

res = 0

for i in range(B,W):
    res += comb(H-A+i-1,i,mod) * comb(A+W-i-2,A-1,mod) % mod

print(res%mod)

Measured memory_bytes: 11028
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

# nCr mod m
# modinvが必要
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10 ** 9 + 7):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i + 1, mod) % mod
    return res


n, a, b = map(int, input().split())
res = 0
mod = 1000000000 + 7
res = (2** (n) -1 )% mod
res -= combination(n, a)
res %= mod
res -= combination(n, b)
res %= mod
print(res)


Measured memory_bytes: 281756
#include <bits/stdc++.h>
#define For(i,l,r) for (register int i=l; i<=r; i++)
using namespace std;
typedef unsigned long long LL;
typedef signed long long ll;
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
ll a, b;
int main() {
	cin >> a >> b;
	cout << max(max(a+b, a-b), a*b);
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
 
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}
 
void skip(int k) { while (k--) gc(); }
 
void out(int n)
{
	int i;
	char ob[20];
 
	if (!n) { pc('0'); return; }
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}
 
int que[1500005]; int top, end;
 
int main()
{
	int n, i, t;
	char op;
 
	n = in(); top = 0, end = 1;
	while (n--) {
		if (gc() == 'i') {
			skip(6);
			que[end++] = in();
		} else {
			skip(5);
			op = gc();
			if (op == 'L') {
				skip(4);
				top++;
			} else if (op == 'F') {
				skip(5);
				end--;
			} else {
				que[top] = t = in();
				i = end; while (que[--i] != t);
				if (i > top) {
					if (end - i < i - top) {
						while (++i < end) que[i-1] = que[i];
						end--;
					} else {
						while (--i > top) que[i+1] = que[i];
						top++;
					}
				}
			}
		}
	}
	i = end-1; out(que[i--]);
	while (i > top) pc(' '), out(que[i--]);
	pc('\n');
	return 0;
}



Measured memory_bytes: 5420
#include<bits/stdc++.h>
#define ll long long
#define ii pair<ll,int>
using namespace std;

struct DSU {
    vector <int> P, R;
    DSU (int n) {
        P.resize(n), R.resize(n);
        for (int i = 0; i < n; i++) {
            P[i] = i, R[i] = 1;
        }
    }

    int find(int x) {return x == P[x] ? x : P[x] = find(P[x]);}

    bool unionS (int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;

        if (R[y] > R[x]) swap(x, y);
        R[x] += R[y];
        P[y] = x;
        return true;
    }
};
struct edge {
    int u, v;
    ll w;
    bool operator<(const edge & E) const {
        return w < E.w;
    }
};

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

Measured memory_bytes: 11136
<?php
    $array = [10];
    for($i=0; $i<10; $i++){
        $array[$i] = trim(fgets(STDIN));
    }
    for($i=0; $i<10; $i++){
        for($j=9; $j>$i; $j--){
            if($array[$j] > $array[$j-1]){
                $temp = $array[$j];
                $array[$j] = $array[$j-1];
                $array[$j-1] = $temp;
            }
        }
    }
    echo $array[0], "\n";
    echo $array[1], "\n";
    echo $array[2], "\n";


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pi;

#define maxn 100005

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

int main()
{
    i64 A , B , C , D ;
    i64 i , j , k , l , m , n ;

    int t=1 , tc ;

    scanf("%d",&tc) ;

    while(t++ <= tc )
    {
        scanf("%lld %lld %lld %lld",&A,&B,&C,&D) ;

        if( B>D || A<B )
        {
            printf("No\n") ;
            continue ;
        }
        if( C>= B-1 )
        {
            printf("Yes\n") ;
            continue ;
        }
        else{

            i64 d = gcd(B,D) ;
            m = ((A-C-1)/d)*d ;

            if( m > (A-B) ) printf("No\n") ;
            else printf("Yes\n") ;
        }
    }

    return 0 ;
}


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

int ans;

void dfs(int x, long long &k, vector<int> &a, vector<bool> &vis, vector<int> &cycle, stack<int> &st) {
        if (k == 0){
            ans = x;
            return ;
        }

        if (vis[a[x]]){
            st.push(x);
            while (!st.empty()){
                int xx = st.top(); st.pop();
                cycle.push_back(xx);

                if (xx == a[x])
                    break;
            }
            
            ans = -1;
            reverse(cycle.begin(), cycle.end());
            k -= 1;
            return ;
        }
        
        vis[a[x]] = true;
        st.push(x);
        k -= 1;
        dfs(a[x], k, a, vis, cycle, st);
        
        return ;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        a[i] -= 1;
    }

    vector<bool> vis(n, false);
    stack<int> st;
    vector<int> cycle;
    
    vis[0] = true;
    st.push(0);
    k -= 1;
    dfs(a[0], k, a, vis, cycle, st);

    if (k == 0 && ans != -1){
        cout << ans + 1 << '\n';
    }
    else{
        k %= (int) cycle.size();
        cout << cycle[k] + 1 << '\n';
    }


    return 0;
}


Measured memory_bytes: 20728
n = int(input())

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

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if n == 1:
    print(0)
    quit()
f = factorization(n)
ans = 0
c = len(f)
for i in range(c):
    s = 0
    g = f[i][1]
    for j in range(g):
        s += j + 1
        f[i][1] -= j+1
        if s > g:
            break
        ans += 1
print(ans)

Measured memory_bytes: 63504
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)


int main()
{
    int N;
    double d1, x;
    cin >> N >> d1 >> x;
    double ret = 0.0;
    FOR(i, 1, N + 1) ret = ret * (i + 1) / i + 1;
    cout << ret * (d1 + x * ((double)N - 0.5)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 2000000

void maxHeapify(int i);
  
int n;
int hi[SIZE];

int main(){
  int i;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&hi[i]);
  }
  for(i=n/2;i>=1;i--){
    maxHeapify(i);
  } 

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

  return 0;
}

void maxHeapify(int i){
  int l,r,max,tem;
  l=2*i;
  r=2*i+1;
  
  if(l<=n && hi[l]>hi[i]){
    max=l;
  }
  else max=i;
  if(r<=n && hi[r]>hi[max]){
    max=r;
  }

  
  if(max != i){
    tem =hi[i]; 
    hi[i]=hi[max];
    hi[max]=tem;
    maxHeapify(max);
  }
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;
 
int main(){
    int n,len;
    string str;
 
    while(cin >> n,n){
	string key = "I";
	for(int i = 0 ; i < n ; i++){
	    key += "OI";
	}
 
	int cnt = 0;
	cin >> len >> str;
	for(int i = 0 ; i < len ; i++){
	    string search = str.substr(i,key.size());
	    if(search == key) cnt++;
	}
	cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
using namespace std;
int gcd(int x,int y){
    return y?gcd(y,x%y):x;
}

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

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


string str[2];
int n,k;
int dp[305][305][305];
int dp2[305][305][305];

int solve(int f,int t,int r){
	//printf("%d %d %d\n",f,t,r);
	if(r<=-1)return -514514;
	if(f>=t)return 0;
	if(dp2[f][t][r]!=-1)return dp2[f][t][r];
	int maxi=0;
	if(str[0][f]==str[0][t-1]){
		if(f+1==t){
			maxi=max(maxi,1);
		}else{
			maxi=max(maxi,solve(f+1,t-1,r)+2);
		}
	}else{
		maxi=max(maxi,solve(f+1,t-1,r-1)+2);
	}
	maxi=max(maxi,solve(f+1,t,r));
	maxi=max(maxi,solve(f,t-1,r));
	//printf("%d %d %d %d\n",f,t,r,maxi);
	return (dp2[f][t][r]=maxi);
}

int main(void){
	memset(dp2,-1,sizeof(dp2));
	cin >> str[0];
	scanf("%d",&k);
	n=str[0].size();
	for(int i=0;i<n;i++){
		str[1]+=str[0][i];
	}
	reverse(str[1].begin(),str[1].end());
	memset(dp,-1,sizeof(dp));
	dp[0][0][0]=0;
	int ans=0;
	for(int i=0;i<=n/2;i++){
		for(int j=0;j<=n/2;j++){
			for(int a=0;a<=k;a++){
				if(dp[i][j][a]>=0){
					ans=max(ans,solve(i,n-j,k-a)+dp[i][j][a]*2);
					dp[i+1][j][a]=max(dp[i+1][j][a],dp[i][j][a]);
					dp[i][j+1][a]=max(dp[i][j+1][a],dp[i][j][a]);
					if(i<n && j<n){
						if(str[0][i]==str[1][j]){
							dp[i+1][j+1][a]=max(dp[i+1][j+1][a],dp[i][j][a]+1);
						}else if(a<k){
							dp[i+1][j+1][a+1]=max(dp[i+1][j+1][a+1],dp[i][j][a]+1);
						}
					}
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 222080
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main()
{
  finp;
  string s;
  cin>>s;
  int n = s.length();
  int ans = n;
  int tt = 0;
  bfor(i,n-1,0)
  {
    if(s[i]=='T')++tt;
    else if(tt)
    {
      tt--;
      ans-=2;
    }
  }
cout<<ans;
  
return 0;
}

Measured memory_bytes: 720
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/01 16:47:56 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#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 rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	string	o, k;
	cin >> o >> k;
	string	mins;
	rep(i, o.size())
		mins += 'z';
	bool	final;
	final = false;
	rep(i, o.size() - k.size() + 1)
	{
		string	s;
		s = o.substr(o.size() - (k.size() + i), k.size());
		bool	flag;
		flag = true;
		rep(j, k.size())
		{
			if (s.at(j) != k.at(j) && s.at(j) != '?')
			{
				flag = false;
				break;
			}
		}
		if (flag == true)
		{
			final = true;
			string	t;
			t = o;
			rep(x, k.size())
				t.at(t.size() - (k.size() + i) + x) = k.at(x);
			while (t.find("?") != string::npos)
				t.at(t.find("?")) = 'a';
			mins = min(mins, t);
		}
	}
	if (final)
		cout << mins << endl;
	else
		cout << "UNRESTORABLE" << endl;
}
// END

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


Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s = line.trim();
    if (s.chars().nth(2) == s.chars().nth(3)) & (s.chars().nth(4) == s.chars().nth(5)) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string S, T, U;
    int A, B;
    cin >> S >> T ;
    cin >> A >> B ;
    cin >> U ;
    if(S==U){
        cout << A-1 << " " << B << endl;
    }
    else{
        cout << A << " " << B-1 << endl;
    }
    
}

Measured memory_bytes: 256
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
import math
# from itertools import product, accumulate, combinations, product
#import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())


def run():
    A, B, C, D, E, F = mapline()
    aa = 100 * A
    bb = 100 * B
    max_con = 0
    ans = (100 * A, 0)
    for x in range(0, F // aa + 1):
        ylim = (F - aa * x) // bb
        for y in range(0, ylim + 1):
            tot = aa * x + bb * y
            if not tot:continue
            slim = E * (x * A + y * B)
            #print(tot, slim)
            for w in range(0, slim // C + 1):
                vlim = (slim - w * C) // D
                for v in range(0, vlim + 1):
                    sug = C * w + D * v
                    #print(sug)
                    if tot + sug <= F:
                        _con = sug / (tot + sug)
                        if max_con < _con:
                            max_con = _con
                            ans = (tot + sug, sug)
    print(f'{ans[0]} {ans[1]}')


if __name__ == "__main__":
    run()


Measured memory_bytes: 9232
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

k ,x = i2()
if 500*k >= x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		int n1 = sc.nextInt();

		boolean flg = false;
		for (int i = 1; i <= n1; i++) {
			int nn = sc.nextInt();
			if (nn % 2 == 0) {
				if (!(nn % 3 == 0 || nn % 5 == 0)) {
					flg = true;
					break;
				}
			}
		}

		if (flg) {
			System.out.println("DENIED");
		} else {
			System.out.println("APPROVED");
		}
	}
}


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

int main() {
  string A, C, s, a, x, c;
  cin >> A >> s >> C;
  
  for (int i = 0; i < A.size(); i++){
    a = A.at(0);
  }
  for (int i = 0; i < s.size(); i++){
    x = s.at(0);
  }
  for (int i = 0; i < C.size(); i++){
    c = C.at(0);
  }
  
  cout << a + x + c << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll X; cin >> X;
  ll A = 0; ll B = 0;
  for(int i = -500; i <= 500; ++i) {
    for(int k = -500; k <= 500; ++k) {
      ll a = pow(i, 5);
      ll b = pow(k, 5);
      if(a - b == X) {
        A = i;
        B = k;
        break;
      }
    }
  }
  cout << A << " " << B << endl;
}

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

int main() {
	const string vowel = "aiueo";
	char character;
	cin >> character;

	if ( vowel.find(character) != string::npos){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll W, H, N;
    cin >> W >> H >> N;
    ll w = 0, h = 0;
    rep(i, N){
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1)chmax(w, x);
        if(a == 2)chmin(W, x);
        if(a == 3)chmax(h, y);
        if(a == 4)chmin(H, y);
    }
    if(w >= W)cout << 0 << endl;
    else if(h >= H)cout << 0 << endl;
    else cout << (W - w) * (H - h) << endl;
    
    return 0;
}

Measured memory_bytes: 256
'''input
4 2
1 3
2 3
'''
import time
import math
l = [[] for i in range(5)]
flag = 0
for i in range(3):
	a, b = map(int, input().strip().split())
	l[a].append(b)
	l[b].append(a)
for i in range(1, 5):
	if(len(l[i]) > 2):
		flag = 1
		break
print("YES" if not flag else "NO")

Measured memory_bytes: 3064
N = int(input())

ans = 0
count = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count += 1
        ans = max(ans, count)
    elif D1 != D2:
        ans = max(ans, count)
        count = 0

if ans >= 3: ans = 'Yes'
else: ans = 'No'

print(ans)

Measured memory_bytes: 9188
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

MOD = 10**9+7

tot = sum(A)
tot %= MOD

ans = 0
rmv = 0

for a in A:
    rmv += a
    rmv %= MOD
    ans += a*(tot-rmv)
    ans %= MOD

print(ans)


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

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

  ll sum = 0, cnt1 = 0, cnt2 = 0;
  //奇＋
  for (int i = 0; i < n; i++) {
    sum += a[i];
    ll t = 0;
    if (i % 2 == 0 && sum <= 0) {
      t = abs(sum) + 1;
      sum = 1; 
    }
    else if (i % 2 == 1 && sum >= 0) {
      t = sum + 1;
      sum = -1;
    }
    cnt1 += t;
  }

  //偶＋
  sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    ll t = 0;
    if (i % 2 == 1 && sum <= 0) {
      t = abs(sum) + 1;
      sum = 1; 
    }
    else if (i % 2 == 0 && sum >= 0) {
      t = sum + 1;
      sum = -1;
    }
    cnt2 += t;
  }

  cout << min(cnt1, cnt2) << endl;;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    string s;
    cin >> s;
    int n = s.size();
    forn (i, n - 1) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << '\n';
            return 0;
        }
    }
    forn (i, n - 2) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3 << '\n';
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << '\n';
}

Measured memory_bytes: 512
H,W = map(int,input().split())
L = [input() for i in range(H)]
X = [False for i in range(W)]
Y = [False for i in range(H)]

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "#" :
            X[x] = True
            Y[y] = True

for y in range(H) :
    if Y[y] == True :
        ANS = []
        for x in range(W) :
            if X[x] == True :
                ANS.append(L[y][x])
        print("".join(ANS))
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end() 

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    string A,B;
    cin>>A;
    for(int i=0;i<A.length();i++){
        B+='x';
    }
    cout<<B<<endl;
    return 0;
}


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

int main() {
  string s1, s2;
  cin >> s1 >> s2;

  if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


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

struct UniFi {
    vector<int> par;

    UniFi(int n):par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int is_par(int x) {
        if (x == par[x]) return x;
        else return par[x] = is_par(par[x]);
    }

    void unite(int x, int y) {
        x = is_par(x);
        y = is_par(y);

        if (x < y) par[y] = x;
        else par[x] = y;
    }

    int count() {
        int ret = 0;
        for (int i = 0; i < par.size(); i++) {
            if (i == par[i]) ret++;
        }
        return ret;
    }
};

int main() {
    int N, H, W;
    cin >> N >> H >> W;

    UniFi uf(N);
    vector<vector<pair<int,int> > > x(H), y(W);
    vector<vector<int> > v(4);
    for (int i = 0; i < N; i++) {
        int _x, _y;
        cin >> _x >> _y;
        _x--, _y--;
        x[_x].push_back(make_pair(_y, i));
        y[_y].push_back(make_pair(_x, i));
        if (_x == 0) v[0].push_back(i);
        if (_x == H-1) v[1].push_back(i);
        if (_y == 0) v[2].push_back(i);
        if (_y == W-1) v[3].push_back(i);
    }

    for (int i = 0; i < H; i++) {
        int point;
        if (x[i].size()) point = x[i][0].second;
        else continue;
        for (auto p : x[i]) {
            uf.unite(point, p.second);
        }
    }
    for (int i = 0; i < W; i++) {
        int point;
        if (y[i].size()) point = y[i][0].second;
        else continue;
        for (auto p : y[i]) {
            uf.unite(point, p.second);
        }
    }
    int count = uf.count();
    int ans = 1 << 28;
    if (count > 1) {
        for (int i = 0; i < 4; i++) {
            set<int> s;
            for (auto j : v[i]) s.insert(uf.is_par(i));
            ans = min(ans, count - (int)s.size());
        }
    } else {
        ans = 0;
    }
    cout << ans + N - 1 << endl;

    return 0;
}

Measured memory_bytes: 9616
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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 prime[101];

int main(){
	int n;
	cin >> n;
	
	for(int i=2; i<=n; i++){
		int num = i;
		for(int k=2; k*k<=num; k++){
			while(num%k==0){
				prime[k]++;
				num /= k;
			}
		}
		prime[num]++;
	}
	
	// 75 = 3 * 25 = 5 * 15 = 3 * 5 * 5
	int ans=0;
	FOR(i,2,n+1){
		if(prime[i] >= 74) ans++;
	}
	
	FOR(i,2,n+1){
		FOR(j,2,n+1){
			if(i==j) continue;
			
			if(prime[i]>=2 && prime[j]>=24) ans++;
			if(prime[i]>=4 && prime[j]>=14) ans++;
		}
	}
	
	FOR(i,2,n+1){
		FOR(j,2,n+1){
			FOR(k,j+1,n+1){
				if(i==j || i==k) continue;
				
				if(prime[i]>=2 && prime[j]>=4 && prime[k]>=4) ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int n;
ll a[222222];
int main(void){
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    scanf("%lld",a+i);
  }
  for(int i = 1; i <= n; i++){
    a[i] += a[i-1];
  }

  ll ret = 1LL<<60;
  for(int i = 0; i < n-1; i++){
    ret = min(ret, abs(a[i] - (a[n]-a[i])));
  }
  printf("%lld\n", ret);
}


Measured memory_bytes: 1792
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

pair<int, int> a[100000];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a, a + n);
    cout << a[0].second;
    for (int i = 1; i < n; ++i) {
        cout << " " << a[i].second;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[123456];
signed main() {
	int n, sum = 0, atai = 0, ans = 0; cin >> n;
	for (int h = 0; h < 30000; h++) {
		test[atai + 1] = test[sum] * 10 + 3;
		if (test[atai + 1] > n) { break; }
		test[atai + 2] = test[sum] * 10 + 5;
		if (test[atai + 2] > n) { atai++; break; }
		test[atai + 3] = test[sum] * 10 + 7;
		if (test[atai + 3] > n) { atai += 2; break; }
		sum++; atai += 3;
	}
	for (int h = 13; h <= atai; h++) {
		int a = 0, b = 0, c = 0;
		while (test[h] > 0) {
			if (test[h] % 10 == 3) { a++; }
			if (test[h] % 10 == 5) { b++; }
			if (test[h] % 10 == 7) { c++; }
			test[h] /= 10;
		}
		if (a != 0 && b != 0 && c != 0) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	while (true)
	{
		int n, x;
		cin >> n >> x;
		if (!n && !x)
			break;
		int count = 0;
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				for(int k=j+1;k<=n;k++)
					if(i+j+k==x)
						count++;
		cout << count << endl;
	}
}


Measured memory_bytes: 3068
#include <cstdio>
using namespace std;
int main(){
    char x[3];
    scanf("%s",x);
    for (int i = 0;i < 3;i++){
        if (x[i] == *"7"){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1732
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

// 最大公約数
template <typename T>
T gcd(T n1, T n2) {
	return n1 ? gcd(n2 % n1, n1) : n2;
}

int main()
{
	i64 A,B,K;
	cin >> A >> B >> K;

	vector<i64> muls;
	muls.push_back(1);
	FOR(i, 2, min(A, B) + 1)
	{
		if (A % i == 0 && B % i == 0)
		{
			muls.push_back(i);
		}
	}

	ALL(sort, muls, greater<i64>());

	cout << muls[K - 1] << endl;
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  ll ans = 0;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0) ans+=(ll)i;
  }
  cout << ans << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int mia=292020,miz=0;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FOR(i,S.size()) {
		if(S[i]=='A') mia=min(mia,i);
		if(S[i]=='Z') miz=max(miz,i);
	}
	cout<<miz-mia+1<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


ll calculate_gcd(ll a, ll b){
    if(a<b){swap(a,b);}
    if(b<1){return 0;}
    ll r;
    while((r = a%b) != 0){
        a = b;
        b = r;
    }
    return b;
}

ll calculate_lcm(ll a,ll b){
    return a*b/calculate_gcd(a,b);
}

ll func(ll x, ll c, ll d){
    ll cdiv = x/c;
    ll ddiv = x/d;
    ll cddiv = x/calculate_lcm(c,d);
    return x - cdiv - ddiv + cddiv;
}

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

    cout << func(b, c, d) - func(a-1, c, d) << endl;

    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int N,D,span,count=0;
    int min=0;
    int max=0;
    scanf("%d",&N);
    scanf("%d",&D);
    span=D*2+1;
    for(int i=1;i<=N;i++){
        if(i%span==0)
            count++;
    }
    if(N%span!=0)
        count++;
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int f(int k){
	if(k==0) return 5;
	else if(k==1) return 0;
	else return 2;
}

ll x[200001], x2[200001];

int main(){
	int n,X; cin>>n>>X;
	FOR(i,0,n) cin>>x[i];
	x2[0]=x[0];
	FOR(i,1,n) x2[i]=x2[i-1]+x[i];

	ll m=1e18;
	FOR(k,1,n+1){
		int t=0;
		ll ans=0;
		while(n-1-t*k>=0){
			ans+=f(t)*x2[n-1-t*k];
			if(ans>m) break;
			t++;
		}
		if(ans>m) continue;
		ans+=(ll)X*(n+k);
		m=min(ans,m);
	}
	cout<<m<<endl;
}

Measured memory_bytes: 3328