akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String o = sc.next();
        String e = sc.next();
        String pas = "";
        for(int i = 0;i < o.length();i++){
            pas += o.charAt(i);
            if(e.length() - (i+1) < 0){
                break;
            }
            pas += e.charAt(i);
        }
        System.out.println(pas);
    }
}


Measured memory_bytes: 23252
N, Q = map(int, input().split())
S = input()
C = [0] * len(S)
for i, c in enumerate(S):
    if i != 0 and c == 'C' and S[i-1] == 'A':
        C[i] += 1
    C[i] += C[i - 1]
ans = []
for i in range(Q):
    l, r = map(int, input().split())
    ans.append(C[r-1] - C[l-1])
for i in ans:
    print(i)

Measured memory_bytes: 11892
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main(init=int(2**31-1), readline=stdin.readline):
    n, q = (int(s) for s in readline().split())

    a = [init] * n
    b = [init] * ((n // 100) + 1)

    for _ in range(q):
        com, x, y = (int(s) for s in readline().split())
        if com:
            bx = x - (x % 100) + 100
            by = y - (y % 100)
            if bx < by:
                m = min(min(a[x:bx]), min(b[bx//100:by//100]),
                        min(a[by:y+1]))
            else:
                m = min(a[x:y+1])
            print(m)
        else:
            a[x] = y
            bx = x - (x % 100)
            b[x//100] = min(a[bx:bx+100])


main()

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
int n,a[111];
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	printf("%d\n",a[n-1]-a[0]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
vector<int> keta(int x) {
  vector<int> res;
  while(x) {
    res.push_back(x%10);
    x = x/10;
  }
  return res;
}

int ketaSum(vector<int> k) {
  int sum = 0;
  rep(i, k.size()) sum += k[i];
  return sum;
}
int main() {
  int n, a, b;
  cin >> n >> a >> b; 
  int ans = 0;
  for(int i = 1; i<=n; i++) {
    int x = ketaSum(keta(i));
    if(a<= x && x <= b) 
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{

    fastio
    ll n , t ;
    cin >> n >> t ;
    vector <pair < ll , ll >> CT (n) ;
    loop(n) {
        cin >> CT[i].S >> CT[i].F ;
    }
    sort(CT.begin(), CT. end()) ;
    /*
    loop(n) {
        cout << CT[i] . F <<' ' << CT [i] . S << endl ;
    }
    */

    loop(n){
        if (CT. back (). F > t)
            CT . pob ;
    }
    /*cout << endl ;
    loop(CT.size()) {
        cout << CT[i] . F <<' ' << CT [i] . S << endl ;
    }
    cout << endl ;

    ll po = 0 ;
    loop(n) {
        if (t >= CT[i].F){
            po = i ;
        }
    }
    */
    if (!CT .empty()){
        ll mi = 1e9 ;
        loop(CT.size()){
            mi = min(mi , CT[i].S) ;
        }
        cout << mi << endl ;
    }
    else
        cout << "TLE" << endl ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N,K = map(int, input().split())
n_l = list(range(1, N+1))

while K > 0:
    i = int(input())
    j_l  = list(map(int, input().split()))
    for k in range(1, i+1):
        j = j_l[k-1]
        if j in n_l:
            n_l.remove(j)
    K -= 1

print(len(n_l))

Measured memory_bytes: 9200
#include <iostream>
#define ll long long
using namespace std;

int main () {
  ll k;
  cin >> k;
  ll n = 50;
  cout << n << endl;
  ll a[n];
  if (k <= 50) {
    for (ll i = 0; i <= k - 1; i++) {
      a[i] = 50; 
    }  
    for (ll i = k; i < n; i++) {
      a[i] = 0;  
    }
  }
  else {
    for (ll i = 0; i < n; i++) {
      a[i] = n;  
    }  
    ll j = (k - n) / n;

    for (ll i = 0; i < n; i++) {
      a[i] += j ;  
    }
    for (ll i = 0; i < k % n; i++) {
      a[i]++;  
    }
    for (ll i = k % n; i < n; i++) {
      a[i] -= k % n;  
    }
  }
  for (ll i = 0; i < n; i++) {
    if (i != n - 1) {
      cout << a[i] << " ";  
    }  
    else {
      cout << a[i] << endl;  
    }
  }
}

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

int main(){
  int N; cin >> N;
  bool flag = false;
  if (N <= 81){
    for (int i=1; i<10; i++){
      if (N % i == 0 && N / i < 10) flag = true;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut ps: [usize; n],
    }
    let mut ps_sorted = ps.clone();
    ps_sorted.sort();
    if ps == ps_sorted {
        println!("YES");
        return;
    }
    for i in 0..n - 1 {
        for j in i + 1..n {
            ps.swap(i, j);
            if ps == ps_sorted {
                println!("YES");
                return;
            } else {
                ps.swap(i, j);
            }
        }
    }
    println!("NO");
}


Measured memory_bytes: 4352
#include <stdio.h>

#define TRUE 0
#define FALSE 1
#define MAX 55555

int main(void){
  int n,i,j;
  int IsPrime[55556];
  
  /* Init Prime Table */
  IsPrime[0] = FALSE;
  IsPrime[1] = FALSE;
  for( i=2; i<MAX; i++){
    IsPrime[i] = TRUE;
  }
  
  for( i=2; i<MAX; i++){
    if( IsPrime[i] == TRUE){
      for( j=2; i*j<MAX ;j++) IsPrime[i*j] = FALSE;
    }
  }
  
  //for( i=0; i<MAX; i++) if(IsPrime[i] == TRUE) printf("%d\n",i);
  
  scanf("%d",&n);
  for( i=1; i<MAX; i+=5){
    if( IsPrime[i] == TRUE ){
      printf("%d ",i);
      n--;
    }
    if( n == 0 ) return 0;
  }
  
  return 0;
}
    
    
  
  

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    bool ok=false;
    rep(i,n){
        int a;
        cin>>a;
        if(a%2==1) ok=true;
    }

    if(!ok) cout<<"second"<<endl;
    else cout<<"first"<<endl;

}

Measured memory_bytes: 3632
<?php
list($a, $b) = explode(' ', trim(fgets(STDIN)));

$ans = 0;
$ans += getPattern($a);
$ans += getPattern($b);

echo $ans;

function getPattern($n) {
  $count = 0;
  for ($i=1; $i < $n; $i++) {
    for ($ii=$i; $ii < $n; $ii++) {
      $count++;
    }
  }

  return $count;
}


Measured memory_bytes: 4604
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int check(int n, vector<int> &v, int N){
  int res = 1;
  REP(i, N) if(i != n && v[i] > v[n]) ++res;
  return res;
}

int main() {
  int N; cin >>N;
  vector<int> v(N, 0);
  REP(i, N * (N - 1) / 2){
    int a, b, c, d; cin >>a >>b >>c >>d;
    if(c > d) v[a - 1] += 3;
    else if(c < d) v[b - 1] += 3;
    else { ++v[a - 1]; ++v[b - 1]; }
  }
  REP(i, N) cout <<check(i, v, N) <<endl;
  return 0;
}

Measured memory_bytes: 1200
import numpy as np
n=int(input())

lista=np.array(list(map(int,input().rstrip().split())))
listb=np.array(list(map(int,input().rstrip().split())))
listc=np.array(list(map(int,input().rstrip().split())))
lista=np.sort(lista)
listc=np.sort(listc)

cont=0

for naka in listb:
	ueikeruyatsu=np.searchsorted(lista,naka,side='left')
	shitaikeruyatsu=n - np.searchsorted(listc,naka,side='right')
	cont += ueikeruyatsu * shitaikeruyatsu


print(cont)

Measured memory_bytes: 26796
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main(){
    long n;
    cin>>n;
    vector<string> S(n);
    for(int i=0;i<n;i++) cin>>S.at(i);
    for(int i=0;i<26;i++){
        long m=INF;
        char x='a'+i;
        for(int j=0;j<n;j++){
            long pre=0;
            for(int l=0;l<S.at(j).size();l++) pre+=(S.at(j).at(l)==x);
            m=min(m,pre);
        }
        while(m>0){
            cout<<x;
            m--;
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(void){
    ll a,b;cin>>a>>b;
    a--;
    ll left,right;
    if(a%4==0)left=a;
    if(a%4==1)left=1;
    if(a%4==2)left=a+1;
    if(a%4==3)left=0;
    if(b%4==0)right=b;
    if(b%4==1)right=1;
    if(b%4==2)right=b+1;
    if(b%4==3)right=0;
    ll ans=left^right;
    cout<<ans<<endl;
    
}


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

void CHECK_NUM(int, int);
void INCLUDE3(int, int, int);
void END_CHECK_NUM(int, int);

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

	CHECK_NUM(n, 1);

	return 0;
}

void CHECK_NUM(int n, int i)
{
	int x = i;
	if (x % 3 == 0) {
		cout << " " << i;
		END_CHECK_NUM(n, i);
	}
	INCLUDE3(x, i,n);
}

void INCLUDE3(int x, int i,int n)
{
	if (x % 10 == 3) {
		cout << " " << i;
		END_CHECK_NUM(n, i);
	}
	x /= 10;
	if (x) {
		INCLUDE3(x, i, n);
	}
	END_CHECK_NUM(n, i);
}

void END_CHECK_NUM(int n, int i)
{
	if (++i <= n) {
		CHECK_NUM(n, i);
	}
	cout << endl;

	exit(0);
}


Measured memory_bytes: 4168
H, W = map(int, input().split())
S = [list(input().split()) for _ in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == 'snuke':
            sw = chr(ord('A') + w)
            sh = str(h+1)
            print(sw+sh)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const ll MOD = 1e9 + 7;

int main() {
    int n; cin >> n;
    map <pll, pll> cnt;
    ll c0 = MOD - 1;
    vll pw2(n + 1);
    pw2[0] = 1;
    FOR(i, 1, n) {
        pw2[i] = pw2[i - 1] * 2 % MOD;

        ll a, b; cin >> a >> b;
        if (!a && !b) {
            c0++; continue;
        }
        ll g = __gcd(a, b);
        a /= g, b /= g;
        if (b < 0) a = -a, b = -b;
        if (a <= 0) cnt[{b, -a}].se++;
        else cnt[{a, b}].fi++;
    }
    ll ans = 1;
    for (auto u : cnt)
        ans = ans * (pw2[u.se.fi] + pw2[u.se.se] - 1 + MOD) % MOD;
    cout << (ans + c0) % MOD << endl;
}

Measured memory_bytes: 20272
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  ll c, k;
  cin >> n >> c >> k;
  vector<ll> t;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    t.pb(x);
  }
  sort(t.begin(), t.end());
  int res = 1;
  int time = t[0];
  int ctmp = 1;
  int i = 1;
  while(true){
    if(i == n)break;
    if(time + k < t[i] || ctmp == c){
      res++;
      ctmp = 0;
      time = t[i];
    }
    ctmp++;
    i++;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<numeric>
#include<queue>
#include<algorithm>
#include<stack>
#include<iterator>
#include<set>
#include<utility>
#include<map>
#include<string>


#define max(x,y)        ((x>y)?x:y)
#define min(x,y)        ((x<y)?x:y)
#define PI 3.1415926535897932384626
#define REP(a, n) for (int i = a; i < n; i++)
#define pb(a) push_back(a)




using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	int result = (int) a * b;
	cout << result;
	return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map<string,int> a;
    int m = 1;
    rep(i,n){
        string s;
        cin >> s;
        if(!a.count(s)){
            a.insert(make_pair(s,1));
        }
        else{
            a[s]+=1;
            m = max(m,a[s]);
        }
    }
    vector<string> ans;
    for(auto itr = a.begin(); itr != a.end(); itr++){
        if(itr->second==m){
            ans.push_back(itr->first);
        }
        // cout << itr->first << " " << itr->second <<endl;
    }
    // cout << 1 <<endl;
    sort(ans.begin(),ans.end());
    rep(j,ans.size()){
        cout << ans[j] << endl;
    }
    return 0;
}

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

int main(){
    ll  n ;
    cin >> n ;
    vector<ll> A(100005,1000) ;
    A.at(0) = 0 ;
    A.at(1) = 1 ;
    ll tem = 1 ;
    while(tem <= 100005 ){
      for(ll i = tem ; i <= 100005 ; i++ ){
        A[i] = min(A[i],A[i-tem]+1) ;
      }
      tem *= 6 ;
    }
    tem = 1 ;
    while(tem <= 100005 ){
      for(ll i = tem ; i <= 100005 ; i++ ){
        A[i] = min(A[i],A[i-tem]+1) ;
      }
      tem *= 9 ;
    }
    cout << A[n] << endl ;
}

Measured memory_bytes: 4040
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<vector<int>> point(n,vector<int>(3));
	vector<int> hoge={-1,-1,-1};
	for(int i=0;i<n;i++) {
		cin>>point.at(i).at(0)>>point.at(i).at(1)>>point.at(i).at(2);
		if(point.at(i).at(2)>=1) hoge=point.at(i);
	}

	for(int x=0;x<=100;x++){
		for(int y=0;y<=100;y++){
			int preH=hoge.at(2)+abs(x-hoge.at(0))+abs(y-hoge.at(1));
			bool flag=true;

			for(auto a:point){
				int pre=preH-abs(x-a.at(0))-abs(y-a.at(1));
				pre=max(pre,0);

				if(pre!=a.at(2)){
					flag=false;
					break;
				}
			}

			if(flag){
				cout<<x<<" "<<y<<" "<<preH<<endl;
				goto END;
			}
		}
	}

	END:

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=1000050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	ll N;
	cin>>N;
	for(int h=1;h<=3500;h++){
		for(int n=1;n<=3500;n++){
			ll a=N*h*n,b=4*h*n-N*n-N*h;
			if(b>0 && a%b==0){
				cout<<h<<" "<<n<<" "<<a/b<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 1000000000000000001;//INFinity
using namespace std;//namespace

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

//#define int long long // yabai

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

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

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int n,kk;
    cin>>n>>kk;
    vector<ll> x(n);
    vector<ll> y(n);
    REP(i,n)cin>>x[i]>>y[i];

    vector<ll> xx=x;
    vector<ll> yy=y;

    sort(ALL(x));sort(ALL(y));

    ll min_=1LL*(x.back()-x.front()) * (y.back()-y.front());
    REP(h,n){
        FOR(i,h+1,n){
            REP(j,n){
                FOR(k,j+1,n){
                    ll x_min=x[h];ll y_min=y[j];ll x_max=x[i];ll y_max=y[k];
                    int sum=0;
                    REP(m,n)if(xx[m]>=x_min&&xx[m]<=x_max&&yy[m]>=y_min&&yy[m]<=y_max)++sum;
                    if(sum>=kk){ll tt=1LL*(x_max-x_min)*(y_max-y_min); min_=min(min_,tt);}
                }
            }
        }
    }

    cout<<min_<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int R,C,K; cin >> R >> C >> K;
    vector<vv<ll>> dp(R,vv<ll>(C,vll(4)));
    vv<int> item(R, vi(C));
    rep(i,K){
        int r,c,v; cin >> r >> c >> v;
        r--; c--;
        item[r][c] = v;
    }
    if(item[0][0]>0) dp[0][0][1] = item[0][0];
    rep(i,R)rep(j,C)rep(k,4){
        if(i+1<R){
            chmax(dp[i+1][j][0],dp[i][j][k]);
            if(item[i+1][j]>0){
                chmax(dp[i+1][j][1], dp[i][j][k]+item[i+1][j]);
            }
        }
        if(j+1<C){
            chmax(dp[i][j+1][k], dp[i][j][k]);
            if(k<3&&item[i][j+1]>0){
                chmax(dp[i][j+1][k+1], dp[i][j][k]+item[i][j+1]);
            }
        }
    }
    ll ans = 0;
    rep(i,4){
        chmax(ans, dp[R-1][C-1][i]);
    }
    cout << ans << '\n';
    
    

}


Measured memory_bytes: 671268
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;

int n;

int calc(int s, int a[], int b[]){
    if(b[s] != 0) {
        return b[s];
    }

    if(s == n-1) {
        return b[n-1] = max(0, a[n-1]);
    }
    return b[s] = max(a[s]+calc(s+1,a,b), 0);
}

int main() {
    while(1) {
        int a[5000] = {};
        int b[5000] = {};
        bool f = false;
        int max = -100000;
        cin >> n;
        if(n == 0) {
            break;
        }
        rep(i,n) {
            cin >> a[i];
            if(a[i] >= 0 && f == false) {
                f = true;
            }
        }

        if(f == false) {
            rep(i,n){
                if(a[i] > max) {
                    max = a[i];
                }
            }
            cout << max << endl;
            continue;  
        }

        calc(0,a,b);
        FOR(i,0,n) {
            if(b[i] > max) {
                max = b[i];
            }
        }
        cout << max << endl;
    }
	return 0;
}

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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int>av(m+1,1);
    vector<int>ttl(m+1,0);
    vector<vector<int> >mtx(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
            cin>>mtx[i][j];
    }
    int ans=n;

    for(int i=0;i<m;i++){
        for(int j=1;j<=m;j++){
            ttl[j]=0;

        }
        for(int j=0;j<n;j++){
            int k=0;
            while(!av[mtx[j][k]]) k++;
            ttl[mtx[j][k]]++;
        }

        int mxi=0;
        for(int j=1;j<=m;j++){
            ///cout<<ttl[j]<<' ';
            if(ttl[j]>ttl[mxi]){
                mxi=j;
            }
        }
        ans=min(ans,ttl[mxi]);
        ///cout<<ans<<'\n';
        av[mxi]=0;
    }

    cout<<ans<<'\n';
    return 0;
}
/**
5 3
0 2 1 4 3
4 4
0 1 2 3

10 4
2 0 1 3 7 5 4 6 8 9
*/


Measured memory_bytes: 3964
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i{st};i<(ed);++i)
#define FC(i,n)       for(int i{n};i;--i)
#define FZU(i,n)      for(ust i{0};i!=(n);++i)
#define FVU(i,st,ed)  for(ust i{st};i<(ed);++i)
#define FCU(i,n)      for(ust i{n};i;--i)
#define SZ(x)         ((int)x.size())
#define ALL(x)        std::begin(x),std::end(x)
#define likely(x)     __builtin_expect(!!(x), 1)
#define unlikely(x)   __builtin_expect(!!(x), 0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;

char s[1024];
int main(){
    RS(s);
    char t= s[4]; s[4] = 0;
    printf("%s ",s);
    s[4] = t;
    printf("%s\n",s+4);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

i64 modpow(i64 a, i64 n, i64 mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        i64 t = modpow(a, n / 2, mod);
        return t * t % mod;
    }
    return a * modpow(a, n - 1, mod) % mod;
}

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

    cout << modpow(k, n, MOD) << endl;
}


Measured memory_bytes: 3124
//Shopping Street

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    vector<vector<int>>f(n,vector<int>(10)),p(n,vector<int>(11));
    rep(i,0,n)rep(j,0,10)cin>>f[i][j];
    rep(i,0,n)rep(j,0,11)cin>>p[i][j];

    int ans=-inf;
    rep(bit,1,(1<<10)){
        int anss=0;
        rep(i,0,n){
            int c=0;
            rep(j,0,10)if((bit&(1<<j))&&(f[i][j]==1))c++;
            anss+=p[i][c];
        }
        ans=max(ans,anss);
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS



    	string s;
    	cin >> s;


    	if(s[s.size()-1] == 's')s += "es";
    	else s += "s";


    	cout << s;




    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(){
  int pay, oturi;
  int en500, en100, en50, en10, en5, en1;
  int maisuu;
  while(1){
  scanf("%d",&pay);
  if(pay==0){
    break;
  }
  oturi=1000-pay;
  en500=oturi/500;
  en100=(oturi-(en500*500))/100;
  en50=(oturi-(en500*500+en100*100))/50;
  en10=(oturi-(en500*500+en100*100+en50*50))/10;
  en5=(oturi-(en500*500+en100*100+en50*50+en10*10))/5;
  en1=(oturi-(en500*500+en100*100+en50*50+en10*10+en5*5));
  maisuu=en500+en100+en50+en10+en5+en1;
    printf("%d\n",maisuu);
  }
    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
const int N=2005;
int n,he[N],to[N*2],nx[N*2],s[N],f[N],g[N],ans=1e9;char c[N];
inline void wk(int w,int x,int y)
{to[w]=y,nx[w]=he[x],he[x]=w;}
inline int mn(int x,int y){return x<y?x:y;}
void dfs(int x,int fa)
{
	s[x]=c[x]&1,g[x]=0;int a=0;
	for(int i=he[x],y;i;i=nx[i])if((y=to[i])!=fa)
		dfs(y,x),s[x]+=s[y],g[y]+=s[y],f[y]+=s[y],g[x]+=g[y],g[y]>g[a]&&(a=y);
	if(f[a]<=g[x]-g[a])f[x]=g[x]&1;else f[x]=f[a]-(g[x]-g[a]);
}
int main()
{
	scanf("%d%s",&n,c+1);
	for(int i=1,x,y;i<n;++i)
		scanf("%d%d",&x,&y),wk(i*2,x,y),wk(i*2+1,y,x);
	for(int i=1;i<=n;++i)
		dfs(i,0),!f[i]&&(ans=mn(ans,g[i]>>1));
	return printf("%d",ans==1e9?-1:ans),0;
}

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

int main()
{
	int n = 0, q = 0, k = 0;
	long t = 0;

	cin >> n;
	vector<long> S(n);
	vector<long>::iterator st;

	for (int i = 0; i < n; i++)
		cin >> S[i];		

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> t;
		st = find(S.begin(), S.end(), t);
		if (st != S.end())
			k++;
	}

	cout << k << endl;

	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include<ctype.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;

void election(stack<string> &st) {
	bool flag = true;
	vi vote;
	st.pop();
	while(flag) {
		st.pop();
		//cout(st.top());
		vote.pb(stoi(st.top()));
		st.pop();
		st.pop();
		//cout(st.top());
		if (st.top() == "]") {
			//cout("true");
			flag = true;
		}else {
			flag = false;
		}
	}

	sort(vote.begin(),vote.end());
	int sum = 0;
	rep(i,0,vote.size()/2 + 1) {
		sum += vote[i];
	}
	st.push(to_string(sum));
	st.push("]");
	return ;
}

signed main() {

	stack<string> st;

	cin1(n);


	rep(i,0,n) {
		string str; cin1(str);
		//cout(str);
		rep(j,0,str.size() ) {
			if (str[j] == '[') {
				//cout(j);
				st.push("[");
			}else if(isdigit(str[j])) {
				//cout("in digit");
				string num = to_string(str[j] -'0');
				//cout << "num is " << num << endl;
				int idx = j+1;
				//cout(str[j]);
				while(isdigit(str[idx])) {
					num += to_string(str[idx] - '0');	
					idx++;
				}
				j = idx - 1;
				int tmp = stoi(num);
				tmp = tmp/2 + 1;
				num = to_string(tmp);
				//cout(num);
				st.push(num);
			}else if(str[j] == ']') {
				string top = st.top();
				st.push("]");
				if (top == "]") { 
					election(st);	
				}
			}
		}
		st.pop();
		cout(st.top());
	}

	return 0;
}

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

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

  int max_l = 0;
  int sum = 0;
  int l;
  rep(i, N) {
    cin >> l;
    sum += l;
    max_l = max(max_l, l);
  }
  if (max_l * 2 < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	int n;
	bool a = false;
	cin >> n;
	for( int i = 0; i <= n/4; i++ )
	{
		for( int j = 0; j <= n/7; j++  )
		{
			if( 4*i+7*j==n)
			{
				a = true;
			}
		}
	}
	if( a == true )
	{
		cout << "Yes" << endl;
	}else if( a == false )
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var listA = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var listB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var listC = new List<int>();
        for (int i = 0; i < vals[2]; i++)
        {
            var tmp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            listC.Add(listA[tmp[0] - 1] + listB[tmp[1] - 1] - tmp[2]);
        }
        var min = listA.Min() + listB.Min();
        Console.WriteLine(min > listC.Min() ? listC.Min() : min);
    }
}

Measured memory_bytes: 39772
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int[] x = new int[n];
        for(int i = 0; i < n; i++) x[i] = sc.nextInt();
        long[][][] dp = new long[n+1][n+1][50*n +1];
        dp[0][0][0] = 1;
        long sum = 0L;
        for(int i = 1; i <= n; i++){
            int b = x[i-1];
            sum += b;
            for(int j = 0; j <= i; j++){
                for(int k = 0; k <= sum; k++){
                if(k < b || j == 0) dp[i][j][k] = dp[i-1][j][k];
                else dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-b];
                }
            }
        }
        long ans = 0L;
        for(int i = 1; i <= n; i++) ans += dp[n][i][i*a];
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 85420
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

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

int main() {
  int n,pos,bpos;
  string s,t,b;
  while(cin>>n, n) {
    cin>>s>>t>>b;
    double mat[16][3][3];
    for(int i=0; i<16; ++i)
      for(int j=0; j<3; ++j)
	for(int k=0; k<3; ++k)
	  mat[i][j][k] = 0.0;
    pos = s.at(0)-'A';
    bpos = b.at(0)-'A';
    mat[0][pos/3][pos%3] = 1.0;
    for(int i=1; i<=n; ++i) {
      for(int j=0; j<3; ++j) {
	for(int k=0; k<3; ++k) {
	  if(mat[i-1][j][k] > 0.0) {
	    for(int l=0; l<4; ++l) {
	      if(j+dx[l] == bpos/3 && k+dy[l] == bpos%3)
		mat[i][j][k] += mat[i-1][j][k] * 0.25;
	      else if(j+dx[l] >= 0 && j+dx[l] < 3
		      && k+dy[l] >= 0 && k+dy[l] < 3)
		mat[i][j+dx[l]][k+dy[l]] += mat[i-1][j][k] * 0.25;
	      else
		mat[i][j][k] += mat[i-1][j][k] * 0.25;
	    }
	  }
	}
      }
    }
    pos = t.at(0)-'A';
    printf("%.8f\n", mat[n][pos/3][pos%3]);
  }
}

Measured memory_bytes: 0
#include <cstdio>
const int N=3005;
int fst[N],deg[N],a[N],f[N],tot=0;
struct Edge{
	int to,v,nxt;
}e[N*2];
void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}
void dfs(int x,int fa){
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=fa){
			dfs(y,x);
			f[x]+=(!f[y] && a[x]>a[y]);
		}
	}
}
void dfs2(int x,int fa){
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=fa){
			f[y]+=(f[x]==(!f[y] && a[x]>a[y]) && a[x]<a[y]);
			dfs2(y,x);
		}
	}
}
int main(){
	int n;
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
		addedge(y,x);
		deg[x]++;deg[y]++;
	}
	dfs(1,0);
	dfs2(1,0);
	for (int i=1;i<=n;i++)
		if (f[i]) printf("%d ",i);
}

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

using namespace std;

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

    int a,b,c;
    cin>>a>>b>>c;

    set<int> nums;

    nums.insert(a);
    nums.insert(b);
    nums.insert(c);

    cout<<nums.size()<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	char ch;
	long long int n;
	scanf("%lld",&n);
	string s;
	while(n) {
		n--;
		s+='a'+n%26;
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	/*26
	n--;
	25
	n%26 -> 0 + 1  = A
	n/=26;
	0 -> A
	
	28
	n%26 -> 
	*/
	 
}

Measured memory_bytes: 3672
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = set(map(int, input().split()))
    NP = [i for i in range(0, 102) if i not in P]
    mx = 102
    for p in NP:
        mx = min(mx, p, key=lambda p: abs(x-p))
    print(mx)


Measured memory_bytes: 9184
#include<stdio.h>
#include<string.h>
int main()
{
	int N,S,C[50],t[50],c,p,i;
	for(;scanf("%d%d",&N,&S),N;)
	{
		for(i=0;i<N;i++)C[i]=N-i;
		for(i=0;i<S;i++)
		{
			scanf("%d%d",&p,&c);
			memcpy(t,C,4*(p-1));
			memmove(C,C+(p-1),4*c);
			memcpy(C+c,t,4*(p-1));
		}
		printf("%d\n",C[0]);
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> 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);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  string s;
  ll x,a;
  while(1){
    cin >> s;
    if(s == "-")break;
    cin >> x;
    for (int i = 0; i < x; i++) {
      cin >> a;
      s += s.substr(0,a);
      s.erase(s.begin(),s.begin()+a);
    }
    cout << s << endl;
  }
}



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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 100 + 20, Maxk = 1e5 + 100, Mod = 1e9 + 7;

int N, K, A[Maxn];
int Dp[Maxk], Sum[Maxk];

inline void Add (int &a, int b) { a += b; if (a >= Mod) a -= Mod; }

inline void Solve ()
{
	Dp[0] = Sum[0] = 1;
	for (int j = 1; j <= K; ++j)
		Sum[j] = (Sum[j - 1] + Dp[j]) % Mod;

	for (int i = 1; i <= N; ++i)
	{
		for (int j = 1; j <= K; ++j)
		{
			if (j - A[i] - 1 < 0) Dp[j] = Sum[j];
			else Dp[j] = (Mod - Sum[j - A[i] - 1] + Sum[j]) % Mod;
		}

		for (int j = 1; j <= K; ++j)
			Sum[j] = (Sum[j - 1] + Dp[j]) % Mod;
	}
	cout<<Dp[K]<<endl;
}

inline void Input ()
{
	N = read<int>(), K = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

int main()
{
#ifdef hk_cnyali
	freopen("M.in", "r", stdin);
	freopen("M.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

int ans[100000];
int main(){
    string S;
    cin >> S;

    
    bool r_mode = true;
    bool l_mode = false;
    int r_count = 0;
    int l_count = 0;
    int r_mode_begin = 0;
    int l_mode_begin = 0;
    for(int i = 0; i < S.size(); i++){
        /* 
        if(S[i] == 'R' && !r_mode){
            r_mode = true;
            r_mode_begin = i;
        }
        */
        if(r_mode){
            if(S[i] == 'L'){
                ans[i] = (i - r_mode_begin) / 2;
                ans[i - 1] = i - r_mode_begin - (i - r_mode_begin) / 2;
                r_mode = false;
                l_mode = true;
                l_mode_begin = i;
            }
        }
        if(l_mode){
            if(S[i] == 'R'){
                ans[l_mode_begin - 1] += (i  - l_mode_begin) / 2;
                ans[l_mode_begin] += i - l_mode_begin - (i - l_mode_begin) / 2;
                r_mode = true;
                l_mode = false;
                r_mode_begin = i; 
            }
        }

         
        /* 
        cout << i << ": ";
        for(int i = 0; i < S.size(); i++){
            if(i != S.size() - 1){
                cout << ans[i] << " ";
            } else {
                cout << ans[i] << endl;
            }
        }
        */

    }

    ans[l_mode_begin - 1] += (S.size() - l_mode_begin) / 2;
    ans[l_mode_begin] += S.size() - l_mode_begin - (S.size() - l_mode_begin) / 2;

    for(int i = 0; i < S.size(); i++){
        if(i != S.size() - 1){
            cout << ans[i] << " ";
        } else {
            cout << ans[i] << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

string S;
ul N,i,j,t,ans;

inline void solve(){
  IN(S);
  N=1<<(S.size()-1);
  REP(i,N){
    t=0;
    REP(j,S.size()){
      t=t*10+(S[j]-'0');
      if(1<<j&i){
        ans+=t;
        t=0;
      }
    }
    ans+=t;
  }
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(){
	std::vector<int> a(4, 0), b(4, 0);
	
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		std::cin >> b[0] >> b[1] >> b[2] >> b[3];
		int hit = 0, blow = 0;
		for(int i = 0 ; i < 4 ; ++i){
			if(a[i] == b[i]){
				++hit;
				continue;
			}
			for(int j = 0 ; j < 4 ; ++j){
				if(a[i] == b[j]){
					++blow;
					break;
				}
			}
		}
		std::cout << hit << " " << blow << std::endl;
	}
    return 0;
}

Measured memory_bytes: 1192
<?php
$a = fgets(STDIN);
$b = fgets(STDIN);
$c = fgets(STDIN);
$x = fgets(STDIN);

$result = 0; // 何通りあるか
for($fiveH = 0; $fiveH <= $a; $fiveH++) {
    for($hund = 0; $hund <= $b; $hund++) {
        for($fifty = 0; $fifty <= $c; $fifty++) {
            if(500 * $fiveH + 100 * $hund + 50 * $fifty == $x) {
                $result++;
             }
        }
    }
}
echo($result);

Measured memory_bytes: 4604
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <queue>

using namespace std;

const int N = 2e6 + 14;
const int INF = 1e9;
const int mod = 1e9;
const int SZ = (1 << 17) - 1;
const int K = 320;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define ppb pop_back

#define ll long long

#define int ll

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b and b != c) {
		cout << "Yes";
		return;
	}
	if (a != b and b == c) {
		cout << "Yes";
		return;
	}
	if (a == c and b != c) {
		cout << "Yes";
		return;
	}
	cout << "No";
}

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cerr << "Ready\n";
	solve();
	return 0;
}

Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
  l.append(int(input()))
bit=[]
for i in range(1,4**n):
  bl=[]
  num=i
  while num!=0:
    bl.append(num%4)
    num=num//4
  while len(bl)<n:
    bl.append(0)
  bit.append(bl)
min=10**10
for i in bit:
  bit1=i
  l1=0
  l2=0
  l3=0
  c1,c2,c3=0,0,0
  for j in range(n):
    if bit1[j]==0:
      l1+=l[j]
      c1+=1
    elif bit1[j]==1:
      l2+=l[j]
      c2+=1
    elif bit1[j]==2: 
      l3+=l[j]
      c3+=1
  if l1==0 or l2==0 or l3==0:
    pass
  else:
    ans=0
    ans+=(c1+c2+c3-3)*10
    ans+=abs(a-l1)+abs(b-l2)+abs(c-l3)
    if min>ans:
      min=ans
print(min)

Measured memory_bytes: 12788
#include <iostream>
#include <map>
#include <vector>
using namespace std;
constexpr int N_max = 2'000;
constexpr int M_max = 2'000;
constexpr int mod = 1'000'000'007;

#ifdef _MSC_VER
constexpr int debug = 1;
#else
constexpr int debug = 0;
#endif

//             s-pos  t-pos
static int dp0[2'005][2'005];
static int dp1[2'005][2'005];

int main() {
    int n, m;
    cin >> n >> m;
    auto s = vector<int>(n + 5);
    auto t = vector<int>(m + 5);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int j = 0; j < m; j++)
        cin >> t[j];

    dp0[0][0] = 1;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            dp0[i + 1][j] = (dp0[i + 1][j] + dp0[i][j]) % mod;
            dp1[i][j] = (dp1[i][j] + dp0[i][j]) % mod;
            dp1[i][j + 1] = (dp1[i][j + 1] + dp1[i][j]) % mod;
            if (s[i] == t[j]) {
                dp0[i + 1][j + 1] = (dp0[i + 1][j + 1] + dp1[i][j]) % mod;
            }
        }
    }

    cout << dp1[n][m];
    return 0;
}


Measured memory_bytes: 31616