akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

typedef struct human{
  unsigned int t;
  int m;
}hman;

int main(){
  int num;
  int i,j;
  hman h[256],hcp;
  int m,a,b;
  while(scanf("%d",&num),num!=0){
    int now=0;
    int ans=0;
    for(i=0;i<num;i++){
      scanf("%d%d%d",&m,&a,&b);
      h[2*i].t=a;
      h[2*i].m=m;
      h[2*i+1].t=b;
      h[2*i+1].m=-m;
    }
    for(i=0;i<2*num;i++){
      for(j=i+1;j<2*num;j++){
	if(h[i].t>h[j].t){
	  hcp=h[i];
	  h[i]=h[j];
	  h[j]=hcp;
	}
      }
    }
    for(i=0;i<2*num-1;i++){
      if(h[i].t==h[i+1].t){
	h[i+1].m+=h[i].m;
	h[i].m=0;
      }
    }
    for(i=0;i<2*num-1;i++){
      now+=h[i].m;
      if(ans>now) ans=ans;
      else ans=now;
    }
    if(ans>150) puts("NG");
    else puts("OK");
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main ()
{
	int n;
	cin >> n;
	vector<int> p;
	for (int i = 0;i < n;i++)
	{
		int num;
		cin >> num;
		p.push_back(num);
	}
	sort(p.begin(), p.end());
	int oper;
	cin >> oper;
	while (oper--)
	{
		int finda;
		cin >> finda;
		vector<int>::iterator pp= lower_bound(p.begin(), p.end(), finda);
		
		if (pp!=p.end()&&*pp == finda)cout << 1 << endl;
		else cout << 0 << endl;
	}

}


Measured memory_bytes: 3536
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1001

vector<pair<int,pair<int,int> > > vec;


bool calc(){
  int n,m,d,p,ans=0;
  vector<pair<int,int> > vec;
  
  scanf("%d%d",&n,&m);

  if(n==0) return false;

  for(int i=0;i<n;i++){
    scanf("%d%d",&d,&p);

    vec.push_back({p,d});
    ans += p*d;
  }

  sort(vec.begin(),vec.end(),greater<pair<int,int> >());

  for(int i=0;i<n;i++){
    ans -= vec[i].first * min(m,vec[i].second);
    m = max(0,m-vec[i].second);
  }

  printf("%d\n",ans);
  
  return true;
}

int main(){

  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++){
      vec.push_back({i*i+j*j,{i,j}});
    }
  }

  sort(vec.begin(),vec.end());
  
  while(calc());
  
  return 0;
}

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

#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ep emplace
#define MOD 1000000007LL
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define for1(i, n) for(int i = 1; i <= int(n); i++)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define fore(i, a, b) for(int i = int(a); i <= int(b); i++)
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;

const ll oo = 1000000000000000000;
const int N = 100005;

char s[N];

int main(){

    scanf("%s", s);

    s[strlen(s) - 8] = 0;

    printf("%s\n", s);


    return 0;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


def solve():
    pass

def main():
    S = input().strip()
    N=len(S)
    temp=0
    for i in range(N):
        temp+=int(S[i])
        temp=temp%9
    if temp%9==0:
        ans="Yes"
    else:
        ans="No"
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 79088
N, M = [int(x) for x in input().split(' ')]
X = [int(x) for x in input().split(' ')]
X = sorted(X)
dists = []
for i in range(len(X)-1):
    dist = X[i+1] - X[i]
    dists.append(dist)
dists = sorted(dists)

result = 0

for i in range(len(dists)-N+1):
    result += dists[i]

print(result)

Measured memory_bytes: 13840
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	string S;
	cin >> S;
	ll K;
	cin >> K;


	vstring subs;
	for (ll s = 0; s < S.length(); s++)
	{
		for (ll g = s; g < min((ll)S.length(), s+K); g++)
		{
			subs.emplace_back(S.substr(s, g - s + 1));
		}
	}

	sort(subs.begin(), subs.end());

	vstring unique = {subs[0]};
	for (ll i = 0; i < subs.size() - 1; i++)
	{
		if (subs[i] != subs[i + 1])
		{
			unique.emplace_back(subs[i + 1]);
		}
	}

	cout << unique[K - 1] << endl;




}





Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>numbers;
ll dp[3005][3005][2];
ll solve(int idx, int idy, int turn) {
	if (idx > idy) { return 0; }
	if (dp[idx][idy][turn] != -1) { return dp[idx][idy][turn]; }
	else {
		if (turn == 1) {
			return dp[idx][idy][turn] = min(solve(idx + 1, idy, turn ^ 1), solve(idx, idy - 1, turn ^ 1));
		}
		else {
			return dp[idx][idy][turn] = max(solve(idx + 1, idy, turn ^ 1) + numbers[idx], solve(idx, idy - 1, turn ^ 1) + numbers[idy]);
		}

		
	}
}

int main() {
	ll n,tmp=0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		ll e;
		cin >> e;
		numbers.push_back(e);
		tmp += e;
	}
	memset(dp, -1, sizeof(dp));
	ll sum1 = solve(0, numbers.size() - 1, 0);
	ll sum2 = abs(tmp - sum1);
	cout << sum1-sum2 << "\n";
	
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int t, n;
vector<int> x, y;
int graph[1000][1000];
bool close_graph[1000][1000];
/**********************************************/

void bfs(){
    deque<P> que;
    que.clear();
    que.push_back(P(y.back()+500, x.back()+500));
    int cnt = 1;
    while(!que.empty()){
        if(cnt > t) break;
        int qsize = que.size();
        REP(j, qsize){
            P cur = que.front();
            que.pop_front();
            REP(i, 6){
                if(!close_graph[cur.first + dy[i]][cur.second + dx[i]]){
                    que.push_back(P(cur.first + dy[i], cur.second + dx[i]));
                    close_graph[cur.first + dy[i]][cur.second + dx[i]] = true;
                    graph[cur.first + dy[i]][cur.second + dx[i]] = cnt;
                }
            }
        }
        cnt++;
    }
    int ans = 0;
    REP(i, 1000) REP(j, 1000) if(graph[i][j] != INF){
        //cout << i -31 << " " << j-31 << " " << graph[i][j] << endl;
        ans++;
    }
    cout << ans << endl;
}

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

    while(cin >> t >> n, t != 0 || n != 0){
        x.resize(n+1);
        y.resize(n+1);
        REP(i, 1000) REP(j, 1000) close_graph[i][j] = false;
        REP(i, n+1) cin >> x[i] >> y[i];
        REP(i, 1000){
            REP(j, 1000){
                graph[i][j] = INF;
            }
        }
        REP(i, n){
            close_graph[500 + y[i]][500 + x[i]] = true;
        }
        graph[500 + y.back()][500 + x.back()] = 0;
        close_graph[500 + y.back()][500 + x.back()] = true;
        bfs();
    }
}



Measured memory_bytes: 8028
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) break;
            
            for(int i = 0 ; i < W ; i++){
                System.out.print("#");
            }
            System.out.println();
            
            for(int i = 0 ; i < H - 2 ; i++){
                System.out.print("#");
                for(int j = 0 ; j < W - 2; j++){
                    System.out.print(".");
                }
                System.out.print("#\n");
            }
            for(int i = 0 ; i < W ; i++){
                System.out.print("#");
            }
            System.out.println("\n");
        }
    }
}


Measured memory_bytes: 37132
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	long long s=0;
	for(int i=1;i<=m;i++)
	{
		int a;
		cin>>a;
		s+=a;
	}
	if(s>n)
	cout<<"-1";
	else
	cout<<n-s;
	return 0;
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


int main() {
    ll X;
    cin>>X;
    while(true){
    if (is_prime(X)){
        cout<<X<<endl;
        break;
    }
    else{
        X++;
    }
    
    }
    
return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int alice = 0;
  int bob = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      alice += a.at(i);
    }else{
      bob += a.at(i);
    }
  }
  cout << alice - bob << endl;
}

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

int main(){
	int sum = 0;
	long int ans = 0;
	int N;
	
	cin >> N;
	
	int v[N];
	
	for(int i = 0; i < N; i++){
		cin >> v[i];
		sum += v[i];
	}
	
	for(int j = 0; j < N - 1; j++){
		sum -= v[j];
		ans += v[j]*sum;
	}
	
	cout << ans << endl;
	
	return 0;
}
	


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

int main() {
  long long N;
  cin >>N;
  vector<int>a(N);
  int ans=1,got=1;
  for(int i=0;i<N;i++){
    cin>>a[i];
    ans*=3;
    if(a[i]%2+(a[i]-1)%2+(a[i]+1)%2==2){
      got*=2;
    }
  }
  cout<<ans-got<<endl;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	ll n;
	cin >> n;
	ll keta = 1;
	int jyou = 1;
	while(1){
		ll mina = 1;
		rep(i, jyou){
			mina *= 26;
		}
		if(n - mina <= 0){
			break;
		}else{
			n -= mina;
			keta++;
			jyou++;
		}
	}
	vector<char> name(keta);
	rep(i, keta){
		name.at(i) = 97;
	}
	int k = keta-1;
	n--;
	while(n != 0 && k >= 0){
		name.at(k) += (n%26);
		n /= 26;
		k--;
	}
	rep(i, keta){
		cout << name.at(i);
		if(i == keta-1) cout << endl;
	}
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
int f[maxn],h[maxn],n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	cin>>h[i];
	memset(f,0,sizeof(f));
	f[1]=0,f[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;++i)
	f[i]=min(f[i-2]+abs(h[i-2]-h[i]),f[i-1]+abs(h[i-1]-h[i]));
	cout<<f[n];
	return 0;
 } 

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int a[1000], b[1000];
int A, B, C, D, S;
int main() {
	cin >> A >> B >> C >> D;
	for (int i = 0; i < A; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < 1000000; i++) {
		for (int j = 0; j < A; j++) {
			if (a[j] == 0 && b[j] == 0) {
				cout << j + 1 << endl;
				goto E;
			}
			if (a[j] >= 1) {
				S += 10; B++; a[j]--;
			}
			else {
				S += 100; C++; b[j]--;
			}
			if (B > D) {
				cout << j + 1 << endl;
				goto E;
			}
			if (S >= 90) {
				if (B >= 9) {
					B -= S / 10 - 9;
					a[j] += S / 10 - 9;
					S = 0;
				}
				else {
					cout << j + 1 << endl;
					goto E;
				}
			}
		}
	}
E:;
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#include<string>
using namespace std;

static const int MAX_H = 110, MAX_W = 110;

int main(void){
  int H, W;
  char a[MAX_H][MAX_W];
  //入力
  cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a[i][j];
    }
  }

  for(int i = 0; i < H; i++){
    bool isColAllDot = true;
    for(int k = 0; k < W; k++){
      if(a[i][k] == '#'){
        isColAllDot = false;
        break;
      }
    }
    for(int j = 0; j < W; j++){
      if(a[i][j] == '#') cout << a[i][j];
      //.の時はその一列とその一行を検索して，どちらかが全て.なら出力しない。
      else{
        bool isRowAllDot = true;
        for(int k = 0; k < H; k++){
          if(a[k][j] == '#'){
            isRowAllDot = false;
            break;
          }
        }
        if(!isColAllDot && !isRowAllDot) cout << a[i][j];
      }
    }
    if(!isColAllDot) cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
cnt=0
for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b=S.find(str(j),a+1)
        if b == -1:
            continue
        for k in range(10):
            c=S.find(str(k),b+1)
            if c != -1:
                cnt+=1
            

print(cnt)





Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String inStr = new String(in.readLine());
		String[] strArr = inStr.split(" ");
		int A = Integer.parseInt(strArr[0]);
		int B = Integer.parseInt(strArr[1]);
		if (A == 1)
			A = 14;
		if (B == 1)
			B = 14;
		if (A > B)
			System.out.println("Alice");
		else if (A < B)
			System.out.println("Bob");
		else
			System.out.println("Draw");
	}
}


Measured memory_bytes: 8148
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll h,a; cin>>h>>a;
	cout<<ceil((double)h/a)<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
let N = Int(readLine()!)!

var dp: [Int] = .init(repeating: 0, count: N + 1)

for i in 1...N {
  var current = i
  while current <= N {
    dp[current] += 1
    current += i
  }
}
var sum = 0 
for i in 1...N {
  sum += i * dp[i]
}
print(sum)


Measured memory_bytes: 85796
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
			var n = firstLine[0];
			var k = firstLine[1];

			var cities = ReadLine().Split(' ').Select(value => int.Parse(value) - 1).ToArray();
			var hashSet = new HashSet<int>();
			var city = 0;
			hashSet.Add(city);
			long count = 0;
			while(true)
			{
				city = cities[city];
				count++;

				if(count == k)
				{
					WriteLine(city + 1);
					return;
				}

				if (hashSet.Contains(city))
				{
					break;
				}

				hashSet.Add(city);
			}

			if (city != 0)
			{
				var tmpCity = 0;
				var tmpCount = 0;
				while (true)
				{
					tmpCity = cities[tmpCity];
					tmpCount++;

					if (city == tmpCity)
					{
						break;
					}
				}

				k -= tmpCount;
				k %= count - tmpCount;
			}
			else
			{
				k %= count;
			}

			for(var i = 0; i < k; i++)
			{
				city = cities[city];
			}

			WriteLine(city + 1);
		}
	}
}


Measured memory_bytes: 44260
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

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

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

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;

	cin >> n >> m;
	cout << (n <= m ? "unsafe" : "safe");	

	return Accepted;
}

// B...a

Measured memory_bytes: 17732
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main( void ) {

    int N, count;
    cin >> N;
    int human[N];

    count = 0;

    for ( int i = 0; i < N; i++ ) {
        int tmp;
        cin >> tmp;
        
        tmp--;

        human[tmp] = i + 1;
    }

    for (int i = 0; i < N; i++ ) {
        cout << human[i] << ' ';
    }

    cout << endl;

    return 0;   
}

Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
const int M = 1010;
const int V = 5020;
int f[M][2], g[M][V], fi[M * 2], ne[M * 2], la[M], to[M * 2], n, x ,y, a[M], tot;

void add(int x, int y) {
	to[++tot] = y;
	!fi[x] ? fi[x] = tot: ne[la[x]] = tot;
	la[x] = tot;
}

void dfs(int x) {
	f[x][0] = f[x][1] = inf;
	for(int i = fi[x]; i; i = ne[i]) {
		int v = to[i];
		dfs(v);
	}
	int cnt = 0;
	for(int i = 0; i <= 1; i++) {
		g[0][0] = 0;
		cnt = 0;
		for(int j = 1; j <= a[x]; j++) g[0][j] = inf;
		for(int j = fi[x]; j; j = ne[j]) {
			int v = to[j];
			++cnt;
			for(int k = 0; k <= a[x]; k++) g[cnt][k] = inf;
			for(int k = 0; k <= a[x]; k++) {
				if(k + a[v] <= a[x]) g[cnt][k + a[v]] = min(g[cnt][k + a[v]], g[cnt - 1][k] + f[v][i ^ 1]);
				if(k + f[v][i ^ 1] <= a[x]) 
					g[cnt][k + f[v][i ^ 1]] = min(g[cnt][k + f[v][i ^ 1]], g[cnt - 1][k] + a[v]);
			}
		}
		for(int j = 0; j <= a[x]; j++) f[x][i] = min(f[x][i], g[cnt][j]);
	}
//printf("%d %d %d\n", x, f[x][0], f[x][1]);
}

int main() {
	scanf("%d", &n);
	for(int i = 2; i <= n; i++) {
		scanf("%d", &x);
		add(x, i);
	}
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	dfs(1); 
	printf(f[1][0] < inf || f[1][1] < inf ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
} 

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 3e3+5;
int dp[N][N];
int dir[N][N];

void solve(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();


    memset(dp, 0, sizeof dp);
    memset(dir, 0, sizeof dir);

    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
                dir[i][j] = 1;
            }
            else{
                if(dp[i-1][j] > dp[i][j-1]){
                    dir[i][j] = 2;
                    dp[i][j] = dp[i-1][j];
                }
                else{
                    dir[i][j] = 3;
                    dp[i][j] = dp[i][j-1];
                }
            }


    string res = "";
    int i = n, j = m;
    while(i > 0 && j > 0){
        if(dir[i][j] == 1){
            res += s[i-1];
            i--; j--;
        }
        else if(dir[i][j] == 2) i--;
        else j--;
    }
    reverse(All(res));
    cout << res << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 74168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int sum = 0;
  for(int i = 0; i < n; i++){
    sum = sum + a[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if((a[i]*4*m) >= sum) ans++;
  }
  if(ans >= m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
D = int(readline())
C = list(map(int,readline().split()))
score = []
t = []
for i in range(D):
    s = list(map(int,readline().split()))
    max_ind = s.index(max(s)) + 1
    t.append(max_ind)
    score.append(s)
last = [0] * 26
S = 0
for d in range(D):
    select = t[d]-1
    S += score[d][select]
    last[select] = d+1
    for i in range(26):
        S -= C[i] * (d+1-last[i]) 
for i in range(D):
    print(t[i])

Measured memory_bytes: 9468
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int x;
  cin >> x;
  Yes(x >= 30);
}

int main()
{
  init_main();
  solve();
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int d, t, s;
  cin>>d>>t>>s;
  cout<<(d<=t*s ? "Yes" : "No")<<'\n';
  return 0;
}


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

using namespace std;

typedef long long ll;

ll a,b,c,k;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>a>>b>>c>>k;
    if(k%2==0)
        cout<<a-b<<"\n";
    else
        cout<<b-a<<"\n";
    return 0;
}
/**



**/


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int a[10];
    int fir=0;
	int sec=0;
	int thi=0;
	for(int i=0;i<10;i++){
	cin>>a[i];
	if(a[i]>fir){
	thi=sec;
	sec=fir;
	fir=a[i];}else
	if(a[i]>sec){
	thi=sec;
	sec=a[i];}else
	if(a[i]>thi){
	thi=a[i];}}
	cout<<fir<<endl<<sec<<endl<<thi<<endl;

	return 0;}


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

#define int long long

int N, A;
vector<int> x;
int dp[55][55][2555]; // dp[インデックス][枚数][合計] = 総数

signed main() {
  cin >> N >> A;
  x.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  dp[0][0][0] = 1;
  for (int idx = 0; idx < N; idx++) {
    for (int mai = 0; mai < N; mai++) {
      for (int sum = 0; sum < 2555; sum++) {
        // 選ぶ
        if (sum + x[idx] < 2555) {
          dp[idx + 1][mai + 1][sum + x[idx]] += dp[idx][mai][sum];
        }
        // 選ばない
        dp[idx + 1][mai][sum] += dp[idx][mai][sum];
      }
    }
  }

  // 条件に合うものを答えに足し合わせる
  int ans = 0;
  for (int mai = 1; mai <= N; mai++) {
    for (int sum = 1; sum < 2555; sum++) {
      if (sum == mai * A) {
        ans += dp[N][mai][sum];
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int INF = (int)1e9;

#define maxn 100010



int main() {
#ifdef BZ
    freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(6);

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!(i % 2)) continue;
        int v = 0;
        for(int j = 1; j <= i; j++) {
            if(i % j == 0) v++;
        }
        if(v == 8) ans++;
    }

    cout << ans << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n;
//void qs(int l,int r){
//	int x=a[r];
//	int p1=l,p2=r;
//	while(p1!=p2){
//		while(p1!=p2&&a[p1]<x)p1++;
//		a[p2]=a[p1];
//		while(p1!=p2&&a[p2]>x)p2--;
//		a[p1]=a[p2];
//	}
//	a[p1]=x;
//	for(int i=0;i<p1;i++)printf("%d ",a[i]);
//	printf("[%d]",a[p1]);
//	for(int i=p1+1;i<=r;i++)printf(" %d",a[i]);
//}
void pa(int l,int r,int p){
	int x=a[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			swap(a[i],a[j]);
		}
	}
	i++;
	swap(a[i],a[r]);
	for(int j=0;j<i;j++)printf("%d ",a[j]);
	printf("[%d]",a[i]);
	for(int j=i+1;j<=r;j++)printf(" %d",a[j]);
	printf("\n");
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	pa(0,n-1,0);
	return 0;
}


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

#define FOR(i, l, r) for (size_t i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main(void)
{
    int x;
    cin >> x;

    cout << not(x) << "\n";
}


Measured memory_bytes: 3196
sam_num = int(input())  # 4
num = list(map(int, input().split()))  # [12, 6, 24, 44]
count = 0
flag = 0

while True:
    for i in range(sam_num):
        # print(num[i])
        if num[i] % 2 != 0:  # odd
            flag = 1
            break
        num[i] = num[i] / 2
        # print(num[i])
    if flag == 1:
        break
    count = count + 1

print(count)


Measured memory_bytes: 2940
#include <stdio.h>
int bsort(int n, int a[])
{
    int cnt = 0; //交換回数

    for (int i = 0; i < n; i++)
    {
        for (int j = n - 1; j > 0; j--)
        {
            if (a[j - 1] > a[j])
            {
                int tmp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tmp;
                cnt++;
            }
        }
    }
    return cnt;
}
int main(void)
{
    int n;
    int a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

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

    return 0;
}


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

int main(){
    char b; cin >> b;
    char ans;
    if(b == 'A') ans = 'T';
    if(b == 'T') ans = 'A';
    if(b == 'C') ans = 'G';
    if(b == 'G') ans = 'C';
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
typedef long long ll;

main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int l = 0, r = n + 1;
    while (r - l > 1){
        int m = (l + r) >> 1;
        bool fl = 1;
        vector<pair<int, int> > vv;
        for (int i = 1; i < n; i++){
            if (a[i] <= a[i-1]){
                if (m == 1){
                    fl = 0;
                    break;
                }
                int cur = a[i] - 1;
                while (vv.size() && vv.back().fi > cur)
                    vv.pop_back();
                while (cur >= 0 && vv.size() && vv.back().fi == cur && vv.back().se == m)
                    vv.pop_back(), cur--;
                if (cur < 0){
                    fl = 0;
                    break;
                }
                if (vv.empty() || vv.back().fi < cur)
					vv.eb(cur, 2);
				else
					vv.back().se++;
            }
        }
        if (fl)
            r = m;
        else
            l = m;
    }
    cout << r << endl;






}


Measured memory_bytes: 1792
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int n;
    VE l;
    ll L;
    cin >> n;
    REP(i, n){
        cin >> L;
        l.push_back(L);
    }
    sort(l.rbegin(), l.rend());
    ll sum = 0;
    rep(i, 1, l.size()){
        sum += l[i];
    }
    if(l[0] < sum){print("Yes");}
    else {print("No");}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;
ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }

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

    vector<ll> B(N + 1);
    rep(i, N) B[i + 1] = (B[i] + A[i]) % MOD;

    vector<ll> F(N + 1);
    F[0] = 1;
    rep(i, 1, N + 1) {
        F[i] = F[i - 1] * i % MOD;
    }

    vector<ll> G(N + 1);
    rep(i, 0, N) {
        G[i + 1] = (G[i] + F[N] * mpow(i + 1, MOD - 2) % MOD) % MOD;
    }

    ll ans = 0;
    rep(i, N) {
        int j = N - i - 1;
        ll tmp = (G[i + 1] - G[1] + MOD + G[j + 1] - G[1] + MOD + 1 * F[N]) % MOD;
        ans = (ans + tmp * A[i]) % MOD;
    }

    write(ans);
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL k,x;
    cin>>k>>x;
    for(LL i = x - k + 1; i < x + k; i++){
        cout<<i<<" ";
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	char[] S, T;

	Main(BufferedReader in) throws IOException {
		S = in.readLine().toCharArray();
		T = in.readLine().toCharArray();
	}

	int diff(int sStart) {
		int len = T.length;
		int result = 0;
		for (int i = sStart; i < sStart + len; ++i) {
			if (S[i] != T[i - sStart]) {
				++result;
			}
		}
		return result;
	}

	void calc() {
		int min = Integer.MAX_VALUE / 2;
		for (int i = 0; i + T.length <= S.length; ++i) {
			min = Math.min(min, diff(i));
		}
		System.out.println(min);
	}

	void showResult() {
	}
}

Measured memory_bytes: 25888
/*我是菜鸡
╭╮＿＿╭╭╭╭╭＿＿╭╮
│　　　　　　　　　　　│　
│　　　　　　　　　　　│　
│　●　╭———╮　●　│　
│≡　　│●　●│　　≡│
│　　  ╰———╯　　　│
╰——┬○————┬—○╯
*/
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define cci ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1000 + 5;
int ans[maxn][maxn];
int main() {
	cci;
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	int a, b;
	while (cin >> a >> b) {
		if (a >= b)_for(i, 0, a)cout << b;
		else _for(i, 0, b)cout << a;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
buttons = [int(input()) for i in range(N)]
light_offset = 0
cnt = 0

while True:
    
    if light_offset == 1:
        print(cnt)
        break
    light_offset = buttons[light_offset] - 1
    cnt += 1
    
    if cnt > N:
        print(-1)
        break
    

Measured memory_bytes: 7084
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> na;
	vector<int> nb;
	for(int i = 0; i < a; ++i){
		int x; cin >> x;
		na.push_back(x);
	}
	for(int i = 0; i < b; ++i){
		int x; cin >> x;
		nb.push_back(x);
	}
	ll minnum = 1e9 + 7;
	for(int i = 0; i < m; ++i){
		int x, y, c;
		cin >> x >> y >> c;
		int sum = na[x - 1] + nb[y - 1] - c;
		if(sum < minnum) minnum = sum;
	}
	sort(na.begin(), na.end());
	sort(nb.begin(), nb.end());
	if(na[0] + nb[0] < minnum) minnum = na[0] + nb[0];
	cout << minnum << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int64 long long int
#define uint64 unsigned long long int
using namespace std;

const int md = 1e9 + 7;
int64 A[100005], F[100005], ANS[100005], b[100005];
int n;

int64 pw (int64 x, int64 y)
{
	int64 r = 1;
	while (y) {
		if (y & 1) r *= x, r %= md;
		y >>= 1;
		x *= x;
		x %= md;
	}
	return (r + md) % md;
}

int64 inv (int64 x)
{
	return (pw (x, md - 2)) % md;
}

int64 ncr (int64 n, int64 c)
{
	int64 r = (F[n] * inv (F[c])) % md;
	r = r * inv(F[n - c]) % md;
	return r;
} 
int main ()
{
	ios_base::sync_with_stdio (0);
	F[0] = 1;
	cin >> n;
	int num = 0;
	for (int i = 1; i <= n + 1; i++) cin >> A[i];
	for (int i = 1; i <= n + 1; i++) {
		if (b[A[i]]) {
			num = A[i];
			break;
		}
		b[A[i]] = 1;
	}
	int L = 1;
	while (A[L] != num) L++;
	int R = n + 1;
	while (A[R] != num) R--;
	int mn = L - 1 + n + 1 - R + 1;
	for (int i = 1; i <= 100004; i++) F[i] = F[i - 1] * i, F[i] %= md;
	ANS[1] = n;
	for (int i = 2; i <= n + 1; i++) {
		ANS[i] = ncr (n + 1, i);
		if (i <= mn) {
			ANS[i] -= ncr (L - 1 + n + 1 - R, i - 1);
		}
		ANS[i] = (ANS[i] + md) % md;
	}
	for (int i = 1; i <= n + 1; i++) cout << ANS[i] << endl;
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
	int a,b,c,d;
int check(int q,int w,int e)
{
	int sum=a;
	if(q==0) sum+=b;else sum-=b;
	if(w==0) sum+=c;else sum-=c;
	if(e==0) sum+=d;else sum-=d;
	if(sum==7) 
	return 1;
	return 0;	
}
int main(){
	string num;
	cin>>num;
	a=num[0]-'0';
	b=num[1]-'0';
	c=num[2]-'0';
	d=num[3]-'0';

	for(int i=0;i<8;i++)
	if(check(i&4,i&2,i&1)) 
	{	
		printf("%d%c%d%c%d%c%d=7\n",a,(i&4)==0?'+':'-',b,(i&2)==0?'+':'-',c,(i&1)==0?'+':'-',d);
		break;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a, b, c;
    long long ans = 1e18;
    scanf("%lld%lld%lld", &a, &b, &c);
    if (c & 1)
        ans = min(a * b, ans);
    else
        ans = 0;
    if (b & 1)
        ans = min(a * c, ans);
    else
        ans = 0;
    if (a & 1)
        ans = min(b * c, ans);
    else
        ans = 0;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
pair<int,int> sac[105]; //first : poids, second : valeur
long long dp[2][100010];
int main()
{
	int nItem;
	scanf("%d", &nItem);
	int iCapacite;
	scanf("%d", &iCapacite);
	for(int i=0;i<nItem;i++)
	{
		scanf("%d %d", &sac[i].first, &sac[i].second);
	}
	for (int i = 0; i < nItem; i++)
	{
		for(int s=0;s<=iCapacite;s++)
		{
			dp[(i+1)%2][s] = max(dp[(i+1)%2][s], dp[i%2][s]); // Ne pas prendre
			if (s+sac[i].first<=iCapacite)
			{
				dp[(i+1)%2][s+sac[i].first] = max(dp[(i+1)%2][s+sac[i].first],dp[i%2][s] + sac[i].second); // Prendre
			}
		}
	}
	printf("%lld", dp[nItem % 2][iCapacite]);
}

Measured memory_bytes: 1792
def dfs(i,f):
  if i == n - 1:
    return sum(list(map(int, f.split('+'))))
  return dfs(i + 1, f + s[i+1]) + dfs(i + 1, f + '+' + s[i+1])

s=input()
n=len(s)
print(dfs(0,s[0]))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
  int n,ans = 0;
  char name[26];
  scanf("%d %s",&n,name);
  int len = strlen(name);
  for(int gohan=0;gohan<n;gohan++){
    char s[101];
    scanf("%s",s);
    int l = strlen(s);
    for(int i=0;i<l;i++){
      bool flag1 = false;
      for(int j=1;i+j*(len-1)<l;j++){
        bool flag = true;
        for(int k=0;k<len;k++){
          if(s[i+j*k]!=name[k]){
            flag = false;
            break;
          }
        }
        if(flag){
          flag1 = true;
          ans++;
          break;
        }
      }
      if(flag1) break;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL dp[3300][3300][5];
LL val[3300][3300];

int main(){
    int n,m,q;
    int i,j,k;
    LL a,b,c;
    cin>>n>>m>>q;
    for(i=0;i<q;i++){
        cin>>a>>b>>c;
        a--,b--;
        val[a][b]=c;
    }
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++){
            for(k=0;k<=3;k++){
                if(i<n){
                    dp[i+1][j][k]=max(dp[i][j][k],dp[i+1][j][k]);
                    if(k<3)dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]+val[i][j]);
                }
                if(j<m){
                    dp[i][j+1][k]=max(dp[i][j][k],dp[i][j+1][k]);
                    dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+val[i][j]);
                }
            }
        }
    }
    a=0;
    for(k=0;k<=3;k++){
        a=max(a,dp[n][m][k]);
    }
    cout<<a<<endl;
}

Measured memory_bytes: 444576