akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vi A(N);
    cin >> A;
    REP(i, N) {
        A[i] -= i + 1;
    }
    sort(ALL(A));

    int ans = INF;
    REP(d, 2) {
        if (d == 1 && N % 2) break;
        int g = A[N / 2 - d];

        int tmp = 0;
        REP(i, N) {
            tmp += abs(A[i] - g);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return (0^_^0);
}



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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n,m;
const double pi=3.1415926535;

signed main()
{
	n=read();
	printf("%.10lf\n",2*n*pi);
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ri register int
using namespace std;
typedef double db;
typedef long double ld;
typedef long long ll;
typedef vector <int> poly;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef unsigned long long ulll;
typedef unsigned int uii;
typedef string strr;
#define fi first
#define se second
#define pb push_back
#define ppp pop_back
#define rez resize
const ll Inf = 1e18;
const int rlen = 1 << 20, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib =  buf) + fread(buf, 1, rlen, stdin)), ib == ob) ? -1 : *ib++)
inline int read() {
  static int ans, f;
  static char ch;
  ans = 0, ch = gc(), f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = gc();
  return f ? ans: -ans;
}
inline ll readl() {
  static ll ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  top = 0, ch = gc();
  while (!isalpha(ch) && !isdigit(ch)) ch = gc();
  while (isalpha(ch) || isdigit(ch)) s[++top] = ch, ch = gc();
  return top;
}
namespace modular {
  const int mod = 998244353;
  int ret;
  inline int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod; }
  inline void Dec(int &a, int b) { a = a < b? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) {
    for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
  }
  inline int Inv(int a) { return ksm(a, mod - 2); }
  inline int sqr(int a) { return (ll) a * a % mod; }
  inline int cub(int a) { return (ll) a * a % mod * a % mod; }
} using namespace modular;
template <typename T> inline void ckmax(T &a, T b) { a < b ? a = b : 0; }
template <typename T> inline void ckmin(T &a, T b) { a > b ? a = b : 0; }
template <typename T> inline T Abs(T a) { return a < 0 ? -a : a; }
template <typename T> inline T gcd(T a, T b) {
  T t;
  while (b) t = a, a = b, b = t - t / a * a;
  return a;
}
const int N = 3e5 + 5;
ll a, b, c, K;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  a = readl(), b = readl(), c = readl(), K = readl();
  ll res = min(K, a);
  K -= min(K, a);
  K -= min(K, b);
  res -= min(K, c);
  cout << res;
  return 0;
}

Measured memory_bytes: 3636
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;

public class Main {

    //グローバル変数を定義

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        boolean flg = false;

        if(a % 2 !=0 && b % 2 != 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21716
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
	
		long[] H = new long[N];
		
		long count = 0;

		for (int i=0;i<N;i++) {
			H[i] = sc.nextInt();
		}
		Arrays.sort(H);
		
		for (int i=0;i<H.length-K;i++) {
			count += H[i];
		}

		System.out.println(count);
		
	}
}


Measured memory_bytes: 85208
import numpy as np
X,N = map(int,input().split())
a = 0
if N != 0:
    P = [int(i) for i in input().split()]
    for p in range(0,len(P)+1):
        if X-p not in P:
            print(X-p)
            break
        elif X+p not in P:
            print(X+p)
            break
else:
    print(X)

Measured memory_bytes: 27136
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun main(args: Array<String>) {
    val N = readInt()
    val H = readIntList().toMutableList()

    var h = H[0]
    for (i in H.indices) {
        if (h < H[i]) {
            H[i]--
        } else if (h - H[i] >= 1) {
            println("No")
            return
        }
        h = H[i]
    }
    println("Yes")
}

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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) {
    if (s[i] == t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,k,x,y,w,e,f,z;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n>k){
		e=n-k;
		f=y*e;
		z=x*k;
		w=z+f;
		printf("%d\n",w);
	}
	else{
		w=n*x;
		printf("%d\n",w);
	}	
}

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

int main() {
 string A ;
 cin >> A;
  
  bool flag = true;
  for(int i = 0; i < 3; i++){
    if(A.at(i) == A.at(i+1)){
      cout << "Bad" << endl;
      flag = false;
      break;
    } 
  }
  if(flag) cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

const int MAXN = 1000000 + 1000;

int n;
char s[MAXN], t[MAXN];

void no()
{
	cout << -1 << endl;
	exit(0);
}

vector<int> sp, ri;

void init()
{
	int p = n;
	for(int i = n; i >= 1; i--)
		if(i == n || t[i] != t[i + 1] || i == p)
		{
			ri.push_back(i);
			while(p >= 1 && s[p] != t[i])
				p--;
			if(p <= 0) no();
			sp.push_back(p);
			p = p - 1;
			// cout << i << ' ' << p << endl;
		}
	reverse(sp.begin(), sp.end());
	reverse(ri.begin(), ri.end());
	sp.push_back(n + 1), ri.push_back(n + 1);
	// for(int i = 0; i < sp.size(); i++)
	// 	cout << sp[i] << ' ' << ri[i] << endl;	
}

void solve()
{
	if(strcmp(s + 1, t + 1) == 0)
	{
		cout << 0 << endl;
		exit(0);
	}
	int ans = 0;
	int pos = 0, cnt = 0;
	for(int i = 0; i < sp.size() - 1; i++)
	{
		if(cnt > 0) cnt--;
		while(i + cnt < sp.size() && sp[i + cnt] - cnt < ri[i])
			cnt++;
		ans = max(ans, cnt);
		// cout << cnt << endl;
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("game.in", "r", stdin);
	// freopen("game.out", "w", stdout);

	cin >> n;
	cin >> (s + 1);
	cin >> (t + 1);

	init();
	solve();

	return 0;
}
/*
12
abxxcdefghij
aabbbbccdeee
*/
/*
8
bbaabbxx
bbbbbbba
*/
/*
10
cydjgcbckr
cccdggggcc
*/
/*
10
aaaaaaaa
aaaaaaaa
*/


Measured memory_bytes: 12640
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);
    auto c = new int[](n);
    auto s = new int[](n);
    auto f = new int[](n);
    foreach (i ; 0 .. n-1) {
        int ci, si, fi;
        scan(ci,si,fi);
        c[i] = ci;
        s[i] = si;
        f[i] = fi;
    }

    foreach (i ; 0 .. n) {
        int ans;

        foreach (j ; i .. n-1) {
            if (ans < s[j]) {
                ans = s[j];
            }
            else {
                if (ans % f[j]) {
                    ans += f[j] - ans % f[j];
                }
            }
            ans += c[j];

            debug {
                writeln(j, " ", ans);
            }
        }

        writeln(ans);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 312
# coding: utf-8

N = int(input())
Data = input().split(" ")
for i in range(N):
  Data[i] = int(Data[i])

Flag = 0
for i in range(N):
  if(Data[i] % 2 == 0):
    if(Data[i] %3 == 0 or Data[i] % 5 == 0):
      Flag = 0
    else:
      Flag = 1
      break
if(Flag == 0):
  print("APPROVED")
elif(Flag == 1):
  print("DENIED")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void){
    int N, M;
    int L, R;
    int nowL, nowR;
    cin >> N >> M;
    cin >> nowL >> nowR;
    for(int i = 1; i < M; i++){
        cin >> L >> R;
        if(nowL < L){
            nowL = L;
        }
        if(R < nowR){
           nowR = R; 
        }
    }
    if(nowR >= nowL){
        cout << nowR - nowL + 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
ll fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll x[5];
	for(int i=0;i<5;i++)
	{
		cin>>x[i];
	}
	for(int i=0;i<5;i++)
	{
		if(x[i]==0)
		{
			cout<<i+1;
			break;
		}
	}
	return 0;
}


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

const int MAX = 998244353;
 
 



signed main(){
    int n;
    cin>>n;
    double v[n];
    for(int i=0;i<n;i++)cin>>v[i];
    sort(v,v+n);
    double ans=v[0];
    for(int i=1;i<n;i++){
        ans+=v[i];
        ans/=2;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,q;
	cin>>n>>q;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	Query queries[q];
	for(int i=0;i<q;i++){
	    int l,r;
	    cin>>l>>r;
	    l--;r--;
	    queries[i].l = l; 
        queries[i].r = r; 
        queries[i].idx = i; 
	}
	sort(queries, queries+q, cmp); 
    answeringQueries(arr, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 19388
use strict;
#use Tie::IxHash;

my $i = 0;
my @mlist = ();
while(defined(my $line = <STDIN>)){
    chomp;
    $mlist[$i] = $line;
    $i ++;
}

my $n = shift @mlist;
if($n == 1){
    print 0;
    exit;
}

chomp (my $x = pop @mlist);

my @mlists = ();
my @mlistt = ();
for(my $i = 1; $i <= $n; $i++){
    my @kari;
    @kari = split(/ /,$mlist[$i - 1]);
    $mlists[$i - 1] = $kari[0];
    $mlistt[$i - 1] = $kari[1];
}

my $i = 0 ;
while(@mlistt) {
    if ($mlists[0] eq $x){
        shift @mlistt;
        my $total = 0;
        my $i = 0;
        while(@mlistt){
            $total = $total + $mlistt[$i];
            shift @mlistt;
        }
        #@mlistt = @$mlistt;
        #print (&sum(\@mlistt));
        print $total;
        last;
    }else{
        shift @mlistt;
        shift @mlists;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define fi first
#define se second
static const int INF = 1e8;

int main(void){
	while(1){
		int n, k;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) return 0;
		int dist[101][101];
		rep(i, 101) rep(j, 101){
			if(i == j) dist[i][j] = 0;
			else dist[i][j] = INF;
		}

		int flag, a, b, c, d, e;
		//????????????????????£???????????????????????¶??????????§??????????
		int kousinnflag = false;//?????????????????¢????????????????????´??°??????????????¨?????????????????°
		rep(i, k){
			scanf("%d", &flag);
			if(flag == 0){
				scanf("%d %d", &a, &b);
				a--; b--;
				//???????????£?????????????????§?????????????????´??°?????????????????????????????£???????????????????¨??????????????????????????????¢?????´??°????????????????????°?¨????????????????????????????
				if(kousinnflag == true){
					rep(m, n) rep(l, n) rep(j, n)
						dist[l][j] = min(dist[l][j], dist[l][m] + dist[m][j]);
					kousinnflag = false;
				}

				if(dist[a][b] >= 1e8) printf("-1\n");//?????????????????¨???
				else printf("%d\n", dist[a][b]);
			}else{
				scanf("%d %d %d", &c, &d, &e);
				c--; d--;
				if(dist[c][d] > e){
					dist[c][d] = dist[d][c] = e;//????????????????????????????????°??´??°
					kousinnflag = true;
				}
			}
		}
	}
	return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;


void solve() {
	int n;
	cin >> n;
	if (n % 2) {
		cout << 0;
		return;
	}
	int x = 2;
	int cnt1 = 0;
	while (x <= n) {
		cnt1 += n / x;
		x *= 2;
	}

	x = 5;
	int cnt2 = 0;
	while (x * 2 <= n) {
		cnt2 += n / x / 2;
		x *= 5;
	}
	cout << min(cnt2, cnt1);
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,i,j,tmp,sum=0;
  scanf("%d",&N);
  int L[N];
  for(i=0;i<N;i++){
    scanf("%d",&L[i]);
  }
  for(i=N-1;i>0;i--){
    for(j=0;j<i;j++){
      if(L[j]>L[j+1]){
      tmp=L[j+1];
      L[j+1]=L[j];
      L[j]=tmp;
      }
    }
  }
  for(i=0;i<N-1;i++){
    sum+=L[i];
  }
  if(sum>L[N-1]){
    printf("Yes");
  }
  else
    printf("No");
  return 0;
}
  

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX_RN = 1e5;
ll dp[105][MAX_RN];

int main() {
	ll N, K;
	cin >> N >> K;
	vll L;
	vll M;
	ll i = 1;
	ll j;
	while (N / i > i) {
		L.push_back(i);
		M.push_back(N / i);
		i++;
	}
	if (N / i == i) {
		L.push_back(i);
	}
	for (i = 0; i < M.size(); i++) {
		L.push_back(M[M.size() - 1 - i]);
	}
	dp[2][0] = N;
	ll len = L.size();
	for (i = 1; i < len; i++) {
		dp[2][i] = ((ll)(N / L[i]) * (L[i] - L[i - 1])) % MOD;
	}
	for (i = 3; i <= K; i++) {
		vll ACC;
		ll isum = 0;
		for (j = 0; j < len; j++) {
			isum = (isum + dp[i - 1][j]) % MOD;
			ACC.push_back(isum);
		}
		dp[i][0] = ACC[len - 1];
		for (j = 1; j < len; j++) {
			dp[i][j] = (ACC[len - 1 - j] * (L[j] - L[j-1])) % MOD;
		}
	}
	ll ans = 0;
	for (i = 0; i < len; i++) {
		ans = (ans + dp[K][i]) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 80264
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    AS = [0] + list(map(int, input().split()))

    res = [0]*(N+1)
    for i in range(N,0,-1):
        a = AS[i]
        if sum(res[i*2::i]) % 2 != a:
            res[i] = 1

    print(res.count(1))
    if res.count(1) != 0:
        print(*[i for i,r in enumerate(res) if r == 1])

if __name__ == '__main__':
    main()

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int n, m;
int t[105]; int h[105];

int main()
{
	while (cin >> n >> m, n)
	{
		int sumt = 0; int sumh = 0;
		REP(i, n)
		{
			cin >> t[i]; sumt += t[i];
		}
		REP(i, m)
		{
			cin >> h[i]; sumh += h[i];
		}
		int mid = (sumt + sumh) / 2;
		if (mid * 2 != sumt + sumh)
		{
			cout << -1 << endl;
			continue;
		}
		int change = sumt - mid;
		P ans;
		int anssum = INF;
		REP(i, n)REP(j, m)
		{
			if (t[i] - h[j] == change)
			{
				if (anssum > t[i] + h[j])
				{
					ans = P(t[i], h[j]);
					anssum = t[i] + h[j];
				}
			}
		}
		if (anssum == INF) cout << -1 << endl;
		else cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	string s, t;
	int i;
	cin >> s;
	cin >> t;
	int ans = 0;
	fo(i, 0, s.size()) 
	ans += (s[i] != t[i]);
	cout << ans;
}


Measured memory_bytes: 3796
N, A, B = map(int, input().split())
v_arr = list(map(int, input().split()))
v_max = max(v_arr)
v_sorted = sorted(v_arr)
ave = 0
last_count = 1 # 何個とるか
p_prev = 0

factorial = [1]
for i in range(1, N + 1):
    factorial.append(factorial[i-1] * i)

def combination(n, k):
    if n < k:
        return 0
    elif n == k or k == 0:
        return 1
    elif k == n-1 or k == 1:
        return n
    else:
        return factorial[n] / (factorial[k] * factorial[n - k])

for _ in range(A):
    p = v_sorted.pop()
    if p == p_prev:
        last_count += 1
    else:
        last_count = 1
    ave += p
    p_prev = p
    
ave /= A
print(ave)
        
last_count_all = 0 # 何個のうちから
for v in v_arr:
    if v == p:
        last_count_all += 1

# print(last_count_all, last_count)
ans = 0
if p == v_max:
    for i in range(min(last_count_all, B) - last_count + 1):
        ans += combination(last_count_all, last_count + i)
else:
    ans = combination(last_count_all, last_count)
print(int(ans))

Measured memory_bytes: 3064
def resolve():
    import sys
    
    readline = sys.stdin.readline

    N, K = map(int, readline().split())
    h = [int(x) for x in readline().split()]

    inf = float('inf')
    dp = [inf] * N
    dp[0] = 0

    for i in range(1, N):
        leng = i + 1 if i < K else K + 1
        for j in range(leng):
            cal = dp[i - j] + abs(h[i] - h[i - j])
            if dp[i] > cal:
                dp[i] = cal

    print(dp[-1])
            

resolve()


Measured memory_bytes: 20468
<?php
fscanf(STDIN, "%d%d", $A, $V);
fscanf(STDIN, "%d%d", $B, $W);
fscanf(STDIN, "%d", $T);
$d = abs($A-$B);
$dv = $V-$W;
if($dv <= 0){
  echo "NO";
}else{
  echo $d <= $T * $dv ? "YES" : "NO";
}


Measured memory_bytes: 16036
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int a;
	cin >> a;
	if (a >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

L, R, d = ints()
print(R // d - (L - 1) // d)


Measured memory_bytes: 67940
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class XTower {
public:

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;

        auto dp = make_v<int>(1005, 30005);

        vector<int> w(N), s(N), v(N), o(N);
        REP(i, N) {
            cin >> w[i] >> s[i] >> v[i];
            o[i] = i;
        }
        sort(o.begin(), o.end(), [&](int i, int j) {
            return min(s[i], s[j] - w[i]) > min(s[j], s[i] - w[j]);
        });

        REP(i, N) {
            int t = o[i];
            REP(j, 20001) {
                // 積まない
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
                // 積む
                if (j <= s[t]) {
                    dp[i + 1][j + w[t]] = max(dp[i + 1][j + w[t]], dp[i][j] + v[t]);
                }
            }
        }

        int res = 0;
        REP(j, 20001) {
            res = max(res, dp[N][j]);
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    XTower solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 237696
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190616
{
    class ProblemB
    {
        static List<int> values = new List<int>();
        static List<int> bounds = new List<int>();
        static int answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            values = IOUtilities.ReadSpaceSeparatedValues();
            bounds = IOUtilities.ReadSpaceSeparatedValues();
        }

        static void Logic()
        {
            int n = values[0];
            int x = values[1];
            int tmp = 0;
            for (int i = 0; i < n; i++)
            {
                tmp += bounds[i];
                if (tmp > x)
                {
                    answer = i + 1;
                    return;
                }
            }
            answer = n + 1;
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }
    }
}

    class IOUtilities
    {
        public static List<int> ReadSpaceSeparatedValues()
        {
            List<int> values = new List<int>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(int.Parse(input));
            }

            return values;
        }

        public static List<int> ReadIndentationSeparatedValues(int num)
        {
            List<int> values = new List<int>();
            for (int i = 0; i < num; i++)
            {
                string input = Console.ReadLine();
                values.Add(int.Parse(input));
            }

            return values;
        }

        public static List<List<int>> ReadIndentationSeparatedLists(int num)
        {
            List<List<int>> Lists = new List<List<int>>();
            for (int i = 0; i < num; i++)
            {
                Lists.Add(ReadSpaceSeparatedValues());
            }
            return Lists;
        }
    }

Measured memory_bytes: 13268
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]

def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = min([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [+float('inf')])
		
		cc = collections.Counter()
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h > 0:
				Y = h + q
				if 1<=Y <= H:
					cc[Y]+=1
				else:
					cc[-1] += 1
		if len(cc) == 1:
			for k in cc:
				if 1<=k <= H:
					return k,cx,cy

h,x,y = f(pts)

print x,y,h

Measured memory_bytes: 88116
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
const long long mod = 1e6 + 3;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
string s, t;
ll dp[3005][3005], ans = 0;
ll solve(int si, int ti)
{
    if( si >= s.size() || ti >= t.size() )
        return 0;
    if( dp[si][ti] != -1 )
        return dp[si][ti];
    if(s[si] == t[ti])
        ans = 1 + solve(si + 1, ti + 1);
    else
        ans = max( solve(si, ti + 1), solve(si + 1, ti) );
    dp[si][ti] = ans;
    return ans;
}
void print(int si, int ti)
{
    if(si >= s.size() || ti >= t.size())
        return;
    if( s[si] == t[ti] )
    {
        cout << s[si];
        print(si + 1, ti + 1);
    }
    else
    {
        if( solve(si, ti + 1) >= solve(si + 1, ti))
            print(si, ti + 1);
        else
            print(si + 1, ti);
    }
    return;
}
int main()
{
    Hello
    memset(dp, -1, sizeof dp);
    cin >> s >> t;
    solve(0, 0);
    print(0, 0);
    return 0;
}


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

int debug = 0;

int h, w, k, ans = 0;
int a[10][10];

main() {
    cin >> h >> w >> k;
    ans = 0;
    rep(i, 0, h) {
        string s;
        cin >> s;
        rep(j, 0, w) {
            a[i][j] = int(s[j] == '#');
        }
    }
    rep(maskh, 0, (1 << h)) {
        rep(maskw, 0, (1 << w)) {
            int cnt = 0;
            rep(i, 0, h) {
                if ((maskh >> i) & 1) {
                    rep(j, 0, w) {
                        if ((maskw >> j) & 1) {
                            cnt += a[i][j];
                        }
                    }
                }
            }
            if (cnt == k) {
                ans++;
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3584
#include <cstdio>
#define maxn (ll)1e5+10
using namespace std;
typedef long long ll;
int n,m,cnt[maxn];

int main() {
	scanf("%d %d",&n,&m);
	for (int i=1;i<=m;i++) {
		int a,b;
		scanf("%d %d",&a,&b);
		cnt[a]++;
		cnt[b]++;
	}
	bool t=true;
	for (int i=1;i<=n;i++)
		if (cnt[i]%2==1) {
			t=false;
			break;
		}
	if (t)
		printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

card = [[0 for i in range(14)]for j in range(4)]
        #S:0, H:1, C:2, D:3

dic1 = {'S': 0, 'H': 1, 'C': 2, 'D': 3}

for a in range(n):
    mark, num = map(str, input().split())
    card[dic1[mark]][int(num)] = 1

for b in dic1:
    for c in range(1, 13+1):
        if card[dic1[b]][c] == 0:
            print(b, c)


Measured memory_bytes: 5600
"AGC 033 A - Darker and Darker"
# 入力
H, W = gets.split.map(&:to_i)
c = []
H.times do |i|
  #.charsで1文字ずつ別の配列に入れる
  #.mapで '#'をtrue、それ以外をfalseに置き換える
  c[i] = gets.chomp.chars.map{ |x| x == '#'}
end

# main
# '#'のある位置をqに入れていく
q = []
H.times do |i|
  W.times do |j|
    if c[i][j]
      q.push([i, j])
    end
  end
end

res = 0
# 移動方向
# dx = [1, 0, -1, 0]
# dy = [0, 1, 0, -1]
y, x = 0, 0
# 移動先
# ny, nx = 0, 0
# 移動先を保存するキュー
nq = []
loop do
  # キューが空でない間   
  until q.empty?
    # キューから1個取り出す
    y, x = q.shift

    if x+1<W && !c[y][x+1]
      nq.push([y, x+1])
      c[y][x+1] = true
    end

    if y+1<H && !c[y+1][x]
      nq.push([y+1, x])
      c[y+1][x] = true
    end

    if 0<=x-1 && !c[y][x-1]
      nq.push([y, x-1])
      c[y][x-1] = true
    end

    if 0<=y-1 && !c[y-1][x]
      nq.push([y-1, x])
      c[y-1][x] = true
    end

    

    # 各方向についてループ
    # 4.times do |i|
    #   ny = y + dy[i]
    #   nx = x + dx[i]
    #   # 移動先がcの範囲内で壁ではなく、かつ白色ならば
    #   if (0<=nx) && (nx<W) && (0<=ny) && (ny<H) && (!c[ny][nx])
    #     # 移動先に追加する
    #     nq.push([ny, nx])
    #     # 移動先を白から黒にする
    #     c[ny][nx] = true
    #   end
    # end
  end
  if nq.empty?
    # nqが空ってことは行ける先がないのでreturn
    break
  else
    # nqが空でないなら、resを1増やしてqとnqを交換して上に戻る
    res += 1
    q, nq = nq, q
  end
end

puts res

Measured memory_bytes: 65020
raw_input()
cards = map(int, raw_input().split(" "))
total = sum(cards)

min_delta = None
a = 0
for i in xrange(0, len(cards)-1):
  a += cards[i]
  delta = abs((total - a) - a)
  if min_delta is None or delta < min_delta:
    min_delta = delta
print min_delta

Measured memory_bytes: 18440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double w,h,x,y;
  cin >>w>> h>> x >> y;
double ans = w*h/2.0;
  
  if(x==w/2.0 && y==h/2.0)
    cout << ans << " "<< 1  <<endl;
  else
    cout << ans << " "<<0<<endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}


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

  vector <int> A(N), B(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }


  ll DP[100001];
  fill(DP, DP + 30001, 1e9);

  priority_queue<int, vector<int>, greater<int> > que;
  DP[0] = 0; que.push(0);

  vector <bool> visited(30001);

  while (!que.empty()){
    int Q = que.top(); que.pop();
    if (visited[Q] == true) continue;
    visited[Q] = true;
    for (int i = 0; i < N; i++){
      int next = Q + A[i];
      if (next < 30001 && DP[next] > DP[Q] + B[i]){
        que.push(next);
        DP[next] = DP[Q] + B[i];
      }
    }
  }
  
  for (int i = 30000; i >= 1; i--){
    DP[i - 1] = min(DP[i], DP[i - 1]);
  }
  cout << DP[H] << endl;


  return 0;
}


Measured memory_bytes: 1660
#a,b=map(int,input().split())
import numpy as np

s=input()
n=len(s)
wayA=np.array([0,0,0,0],dtype=np.int64)
wayB=np.array([0,0,0,0],dtype=np.int64)
wayC=np.array([0,0,0,0],dtype=np.int64)
hatena=0
MOD=1000000007
for c in s:
	if c=="A":
		wayA[0]=wayA[0]+1
	if c=="B":
		wayB+=wayA;
	if c=='C':
		wayC=wayC+wayB
	if c=='?':
		wayC[1]=wayC[1]+wayB[0]
		wayC[2]=wayC[2]+wayB[1]
		wayC[3]=wayC[3]+wayB[2]
		wayB[1]=wayB[1]+wayA[0]
		wayB[2]=wayB[2]+wayA[1]
		wayA[1]=wayA[1]+1
		hatena=hatena+1
	for z in range(0,4):
		wayA[z]=wayA[z]%MOD
		wayB[z]=wayB[z]%MOD
		wayC[z]=wayC[z]%MOD
ans=0
for i in range(0,4):
	p3=1
	if wayC[i]<=0:
		continue
	for k in range(0,hatena-i):
		p3=p3*3
		p3=p3%MOD
	ans=ans+p3*wayC[i]
	ans=ans%MOD
print(int(ans))

Measured memory_bytes: 14664
N = int(input())
infos = [0 for i in range(N)]

for i in range(N):
    x,y,h = map(int, input().split())
    infos[i] = [x,y,h]
    if h > 0:
        x1, y1, h1 = x,y,h

for i in range(101):
    for j in range(101):
        H = h1 + abs(x1-i) + abs(y1-j)
        for info in infos:
            x,y,h = info
            if h != max(H - abs(x-i) - abs(y-j), 0):
                break
        else:
            print(i,j,H)
            exit()

Measured memory_bytes: 3188
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=1e9+7;
const int N=500000;

ll gcd(ll x,ll y){
    if(x) return gcd(y%x,x);
    else return y;
}

main(){
    int a,b,c;cin>>a>>b>>c;
    cout<< ( a+b+c >21 ? "bust" : "win");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
	cin>>s;
	stack<char> st;
	for(int i=0;i<s.length();i++)
	{
	    if(s[i]=='B')
	    {
	        if(!st.empty()) st.pop();
	    }
	    else st.push(s[i]);
	}
	vector<char> ans;
	while(!st.empty())
	{
	    ans.pb(st.top());
	    st.pop();
	}
	reverse(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++) cout<<ans[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }

    for (int i = 0; i < n; i++)
    {
        int min_dist = INT_MAX;
        int min_indx;
        for (int j = 0; j < m; j++)
        {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist < min_dist)
            {
                min_indx = j;
                min_dist = dist;
            }
        }
        min_indx++;
        cout << min_indx << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>

using namespace std;

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

	deque<char> a(S.begin(), S.end());

	bool reversed = false;

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int T;
		cin >> T;
		if (T == 1) {
			reversed = !reversed;
		}
		else if (T == 2) {
			int F;
			char C;
			cin >> F >> C;
			if (reversed == (F == 1)) {
				a.emplace_back(C);
			}
			else {
				a.emplace_front(C);
			}
		}
	}
	string ans(a.begin(), a.end());
	if (reversed) {
		reverse(ans.begin(), ans.end());
	}

	cout << ans << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

bool check(const string &s)
{
	int n = s.size();
	for(int i=0;i<n;i++)
		if(s[i] != s[n-1-i])
			return false;
	return true;
}
int main(void)
{
	string s; cin >> s;
	int n = s.size();
	string s1 = s.substr(0, n/2);
	string s2 = s.substr(n/2+1, n-n/2);
	bool ans = true;
	ans = ans && check(s);
	ans = ans && check(s1);
	ans = ans && check(s2);
	cout << (ans? "Yes" : "No") << endl;



	return 0;
}


Measured memory_bytes: 256
from collections import deque
k = int(input())
d = deque([i for i in range(1, 10)])
for i in range(1, k+1):
    i = d.popleft()
    if i%10 != 0:
        d.append(i*10+(i-1)%10)
    d.append(i*10+i%10)
    if i%10 != 9:
        d.append(i*10+(i+1)%10)
print(i)

Measured memory_bytes: 40944
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

template<class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        int a;
        cin >> a;
        a--;
        A[a] = i + 1;
    }


    REP(i, N - 1) {
        cout << A[i] << " ";
    }

    cout << A[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A, *B;

  int C[VMAX + 1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ )C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ) {
    if ( i > 1 ) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9640