akhauriyash/Code-Regression huggingface dataset:
void E(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[3];
    d[3] = d[5];
    d[5] = d[2];
    d[2] = temp;
}
void S(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[4];
    d[4] = d[5];
    d[5] = d[1];
    d[1] = temp;
}
void N(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[1];
    d[1] = d[5];
    d[5] = d[4];
    d[4] = temp;
}
void W(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[2];
    d[2] = d[5];
    d[5] = d[3];
    d[3] = temp;
}

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i, n, t, f;
    int d[6];
    
    for(i=0; i<6; i++) {
        scanf("%d",&d[i]);
    }
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf("%d %d",&t,&f);
        while (d[1] != f) {
            if (d[2] == f || d[3] == f) {
                E(d);
            }
            N(d);
        }
        while (d[0] != t) {
            E(d);
        }
        printf("%d\n", d[2]);
    }
    return 0;
}


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

int n;
long long a[3005];
long long memo[3005][3005][2];
const long long INF = 1e15;

long long solve(int lpointer, int rpointer, int turn){
	
	if(rpointer < lpointer) return 0LL;
	if(memo[lpointer][rpointer][turn] != INF) return memo[lpointer][rpointer][turn];
	
	long long& p = memo[lpointer][rpointer][turn];
	
	if(turn == 0){
		
		p = solve(lpointer + 1, rpointer, turn^1) + a[lpointer];
		p = max(p, solve(lpointer, rpointer - 1, turn^1) + a[rpointer]);
		
		return p;
	}
	
	if(turn == 1){
		
		p = solve(lpointer + 1, rpointer, turn^1) - a[lpointer];
		p = min(p, solve(lpointer, rpointer - 1, turn^1) - a[rpointer]);
		
		return p;
	}
}

int main(){
	
	for(int i = 0 ; i < 3000 ; i ++)
		for(int j = 0 ; j < 3000 ; j ++)
			memo[i][j][0] = memo[i][j][1] = INF;
	
	cin >> n;
	
	for(int i = 0 ; i < n ; i ++)
		cin >> a[i];
	
	cout << solve(0, n - 1, 0) << "\n";
	
	return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fs first
#define se second

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

int main(){
  int N;cin>>N;
  map<string, int> list;

  string buf;
  int m = 0;
  for(int i=0; i<N; i++){
    cin>>buf;

    /*
    auto itr = list.find(buf);
    if(itr == list.end()){
      //初めての文字列
      //list.insert(mp(buf, 1));
      list[buf]=1;//これも等価
      m = max(m, 1);
    }else{
      itr->se += 1;
      m = max(m, itr->se);
    }
    //*/
    list[buf]++;
    m = max(m, list[buf]);
  }


  //debug(m);

  for(auto x: list){
    if(x.se==m){
      cout<<x.fs<<endl;
    }
  }
}

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

using namespace std;

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

int INF = 10e8;
int n, k;
int a[100000];
vector<int> g[100000];
bool show[100000];
int d[100000];

int dfs(int idx){
	if((int)g[idx].size() == 0){
		d[idx] = 0; return 0;
	} else {
		int mindis = INF;
		REP(i, (int)g[idx].size()){
			mindis = min(dfs(g[idx][i]) + 1, mindis);
		}
		d[idx] = mindis;
		return mindis;
	}
}

int main(){
	cin >> n >> k;
	REP(i, n){
		cin >> a[i];
	}

	REP(i, n){
		 show[i] = false;
	}

	REP(i, n){
		if(a[i] == 0){
			g[i] = vector<int>();
			show[i] = true;
		} else {
			g[a[i]-1].push_back(i);
		}
	}

	REP(i, n){
		d[i] = INF;
	}

	REP(i, n){
		if(a[i] == 0){
			int d = dfs(i);
		}
	}

	REP(i, n){
		if(d[i] < k){
			show[i] = true;
		}
	}
	
	int output = 0;
	REP(i, n){
		if(show[i]) output += 1;
	}

	cout << output << endl;
}

Measured memory_bytes: 15704
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 1e3+10;

priority_queue<int> pq;
vector<vector<pii> > graph;
queue<int> que;
pii edge[MAXN];
int degree[MAXN];
int subtree[MAXN];
bool rev[MAXN];
bool visited[MAXN];

int dfs(int here)
{
	visited[here] = true;
	
	int there,cur;
	
	if(degree[here]&1)subtree[here]++;
	
	for(int i=0;i<graph[here].size();i++){
		there = graph[here][i].f;
		if(visited[there])continue;
		cur = dfs(there);
		if(cur&1){
			rev[graph[here][i].s] = true;
			subtree[here]++;	
		}

	}
	
	return subtree[here];
}
int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
	int res = 0;

    cin>>n>>m;
	
	graph = vector<vector<pii> > (n+1);
	
	for(int i=0;i<m;i++){
		cin>>x>>y;
		if(x>y)swap(x,y);
		edge[i] = pii(x,y);
		degree[x]++;
		graph[x].push_back(pii(y,i));
		graph[y].push_back(pii(x,i));
	}
	
	for(int i=1;i<=n;i++)
		if(degree[i]&1)cnt++;
	
	if(cnt&1){
		cout<<"-1\n"; return 0;
	}
	
	dfs(1);
	
	for(int i=0;i<m;i++){
		x = edge[i].f; y = edge[i].s;
		if(rev[i])cout<<y<<" "<<x<<"\n";
		else cout<<x<<" "<<y<<"\n";
	}
	
    return 0;
}



Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
	bool app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = false;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
      cout << (char)(i + 'a') << endl;;
			return 0;
		}
	}
  cout << "None" << endl;;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long 
#define FF first
#define SS second
#define MOD 1000000007

using namespace std;

int gcd(int a, int b) {
  while (a > 0 && b > 0)
    if (a > b) a %= b;
    else b %= a;
  return a + b;
}

ll modpower(ll x, ll y, ll p) //x^y mod p
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %2!= 0)
            res = (res*x) % p;
 
        // y must be even now
        y = y/2;
        x = (x*x) % p;  
    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	ll n;cin>>n;
	ll ans = 0;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		while(a%2==0)ans++,a/=2;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
vector<int>v;
bool inrange(int x){
  if(x>=1 & x<=9) return true;
  return false;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  map<int , int >mp;

  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      mp[i*j] = 1;
    }
  }
  int n;
  cin >> n;
  if(mp[n]){
    cout <<"Yes" << '\n';
  }
  else cout <<"No"<<'\n';

}

Measured memory_bytes: 256
'''
ITP-1_9-D
 ???????????????
????????? strstr ?????????????????????????????????????????????????????????????????°???????????????????????????????????????????????\?????????????????????????????§??????
print a b: strstr ??? a ??????????????? b ??????????????§??????????????????
reverse a b: strstr ??? a ??????????????? b ??????????????§?????????????????????
replace a b p: strstr ??? a ??????????????? b ??????????????§??? p ?????????????????????
????????§??????????????? strstr ????????????????????? 0 ???????????¨????????????
???Input
1 ?????????????????? strstr ????????????????????????strstr ?????±?°????????????????????????????2 ????????????????????° qq ????????????????????????
?¶???? qq ??????????????????????¨??????¢?????§?????????????????????
???Output
??? print ???????????¨???????????????????????????????????????????????????
'''
# inputData
string = input()
exeCnt = int(input())

for cnt0 in range(exeCnt):
    exeData = input().split()
    exe00 = exeData[0]
    exe01 = int(exeData[1])
    exe02 = int(exeData[2])
#    exe03 = exeData[3]

    if exe00 == 'print':
        print(string[exe01:exe02 + 1])

    elif exe00 == 'reverse':
        string = string[0:exe01] + string[exe01:exe02 + 1][::-1] + string[exe02 + 1:]

    elif exe00 == 'replace':
        exe03 = exeData[3]
        string = string[0:exe01] + exe03 + string[exe02 + 1:]

Measured memory_bytes: 7712
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n < 1200)
		System.out.println("ABC");
		else if(n >= 1200 && n < 2800)
		System.out.println("ARC");
		else 
		System.out.println("AGC");
	}
}

Measured memory_bytes: 21460
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

const long long N_MAX = 200001;
pair<long, long> D[N_MAX];
long N;
long cum=0;
bool flag = true;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D[i].second >> D[i].first;
	}
	sort(D, D + N);

	int i = 0;
	while (i < N && flag) {
		cum += D[i].second;
		if (cum > D[i].first) flag = false;
		i++;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3328
a,b,c,d = map(int,input().split(" "))
def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = c*d
lcm = prod//gcd(c,d)
a1=b//c - (a-1)//c
a2=b//d - (a-1)//d
a3=b//lcm-(a-1)//lcm
print(b-a+1-a1-a2+a3)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define Max(a,b) a=max(a,b);
typedef long long ll;

using namespace std;
#define N 200010
ll n,m,a[N],cnt[N],sum[N];
int main(){
    cin>>n>>m;
    lol(i,N)cnt[i]=0,sum[i]=0;
    lol(i,n){
	cin>>a[i];
	if(a[i]<N)cnt[a[i]]++;
    }
    lol(i,N){
	for(ll j=i-cnt[i]+1;j<=i;j++)sum[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)ans+=sum[i]==0;
    lol(i,m){
	ll x,y;cin>>x>>y; x--;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]]+1;
	    if(p>=1){
		sum[p]--;
		if(sum[p]==0)ans++;
	    }
	    cnt[a[x]]--;
	}
	a[x]=y;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]];
	    if(p>=1){
		if(sum[p]==0)ans--;
		sum[p]++;
	    }
	    cnt[a[x]]++;
	}
	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6144
/*input
10000000000 10 99959
*/
/**
    Author: Kristopher Paul
    Date Created: 08-09-2020
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

//Uncomment for File I/O
//ifstream fin("input.in")

//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n,x,m;
    cin >> n >> x >> m;
    vi vec;
    vec.pb(x);
    umap<int,int> th;
    int ind = 2;
    th[x] = 1;
    int rep = 0;
    while(true){
        int nx = ModExp(vec[ind-2],2,m);
        if(th[nx] != 0){
            rep = th[nx];
            break;
        }
        vec.pb(nx);
        th[nx] = ind;
        ind++;
    }
    rep--;
    if(n <= vec.size()){
        int ans = 0;
        FOR(i,0,n){
            ans += vec[i];
        }
        cout << ans << endl;
        return;
    }
    int sz = vec.size();
    int ans = 0;
    FOR(i,0,sz){
        ans += vec[i];
    }
    n -= sz;
    int bsz = sz-rep;
    int tim = n/bsz;
    n = n%bsz;

    int bs = 0;
    FOR(i,rep,sz){
        bs += vec[i];
    }
    ans += tim*bs;
    FOR(i,rep,rep+n){
        ans += vec[i];
    }
    cout << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 6732
#[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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      mut abs: [(usize,usize); n],
    }
    abs.reverse();
    let mut add = 0;
    for (a,b) in abs {
        let a = a + add;
        if a%b != 0 {
            add += b - (a%b);
        }
    }
    println!("{}", add);
}


Measured memory_bytes: 6396
#include <iostream>                                                                                 
#include <math.h>                                                                                   
using namespace std;                                                                                
int main(){                                                                                         
  double r;                                                                                         
  cin >> r;                                                                                         
  cout << fixed << r*r*M_PI << " " << 2*r*M_PI << endl;                                             
}                                                                                                   
                                                                                                    
                                                                                                    
                                                                                                    
                                                                                                    
             


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;i++)
const ll INF=1e9;
typedef pair<ll, ll> P;
const ll MAX_N = 100,MAX_M=100;

char maze[MAX_N][MAX_M+1];
ll N, M;
ll sx, sy;
ll gx, gy;

ll d[MAX_N][MAX_M];

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

ll bfs() {
    queue<P> que;
    //すべての点をINFで初期化
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++)d[i][j]=INF;
    }
    //スタート地点をキューに入れ、その点の距離を0にする
    que.push(P(sx, sy));
    d[sx][sy] = 0;

    //キューが空になるまでループ
    while (que.size()) {
        P p=que.front();que.pop();
        if(p.first == gx && p.second == gy)break;
        for(int i=0;i<4;i++){
            int nx=p.first + dx[i], ny=p.second + dy[i];
            //移動が可能かの判定とすでに訪れたことがあるかの判定
            if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#' && d[nx][ny] == INF){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}
int main(){
    cin >> N >> M;
    sx=0;sy=0;gx=N-1;gy=M-1;
    ll white=0;
    rep(i,N){
        rep(j,M){
            cin >> maze[i][j];
            if(maze[i][j]=='.')white++;
        }
    }
    
    ll res = bfs();
    if(res==INF){
        cout << "-1" << endl;
        return 0;
    }
    cout << white-res-1 << endl;
}

Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let xyz: Vec<u32> = read_vec();
  
  let ans = (xyz[0] - xyz[2]) / (xyz[1] + xyz[2]);
  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

void trace(int A[],int N){
	int i;
	for(i=0;i<N;i++){
		if(i>0)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertion(int A[],int N){
	int i,j,v;
	for(i=1;i<N;i++){
		v = A[i];
		j =i-1;
		while(j>=0&&A[j]>v){
			A[j+1] = A[j];
			j--;
		}A[j+1] = v;
		trace(A,N);
	}
}
int main(){
	int N,i,j;
	int A[100];
	
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	trace(A,N);
	insertion(A,N);
	return 0;
}
		
		

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


int main(){
    long long Q,H,S,D,N; cin >> Q >> H >> S >> D >> N;
    Q *= 4; H *= 2; 
    if (N % 2 == 0){
        Q *= 2; H *= 2; S *= 2;
        cout << min(Q,min(H,min(S,D)))*(N/2) << endl;
    } else {
        long long ans = min(Q,min(H,S));
        
        //cout << ans << endl;
        //cout << " ------- " << endl;
        N--;
        Q *= 2; H *= 2; S *= 2;
        ans += min(Q,min(H,min(S,D)))*(N/2);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	double pi=3.14159;
	double r; cin>>r;
	cout<<2*pi*r<<"\n";
}

Measured memory_bytes: 3804
#include<stdio.h>
int main()
{
  int N;
  10<=N<=99;
  scanf("%d",&N);
  if (N==19||N==29||N==39||N==49||N==59||N==69||N==79||N==89||N==90||N==91||N==92||N==93||N==94||N==95||N==96||N==97||N==98||N==99)
  {
      printf("Yes");
  }
  else
  {
    printf("No");
  }
  return 0;
  }


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1'000'000'007LL;

#define INT(NAME) int NAME; cin>>NAME;
#define INT64(NAME) int64_t NAME; cin>>NAME;
#define VECTOR(NAME, TYPE, SIZE) std::vector<TYPE> NAME((SIZE));\
    for(int xxxx_i=0; xxxx_i<SIZE; xxxx_i++) cin>>NAME[xxxx_i];
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    

inline uint32_t get_exponent(uint32_t n, uint32_t p) {
    uint32_t res = 0;
    while (n%p == 0) {
        n /= p;
        res++;
    }
    return res;
}

void solve() {
    int N; cin>>N;
    if (N==1) {
        cout<<1<<endl; return;
    }
    vector<uint32_t> fs(N+1, 1);
    ull ans = 1;
    for (uint32_t i = 2; i<=N; i++) {
        if (fs[i]==1) {
            fs[i] = 2;
            for (uint32_t j=i+i; j<=N; j+=i) {
                auto c = get_exponent(j, i);
                fs[j] *= (c+1);
            }
        } 
        ans += fs[i] * i;
    }
    cout<<ans<<endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 42308
a,b,m= map(int, input().split())
a1= list(map(int, input().split()))
b1= list(map(int, input().split()))
m1= [list(map(int, input().split())) for i in range(m)]

ans=min(a1)+min(b1)

for i in range(m):
    cnt=a1[m1[i][0]-1]+b1[m1[i][1]-1]-m1[i][2]
    ans=min(cnt,ans)

print(ans)

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

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

  bool flg = true;
  rep(i, n) if (a[i]%2) flg = false;

  if (flg) cout << "second" << endl;
  else cout << "first" << endl;

  return 0;
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
typedef long long ll;
ll a[200005];
int main(void)
{
	ll n,k;
	scanf("%lld%lld",&n,&k);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		if(i>=k)
		{
			if(a[i]>a[i-k]) puts("Yes");
			else puts("No");
		}
	}
}

Measured memory_bytes: 5240
import java.util.*;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		int sum=c-(a-b);
		
		if(sum>=0){
			System.out.println(sum);
		}
		else{
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i;
    bool kt;
    string s,t;
    cin>>s>>t;
    kt=true;
    for (i=0;i<s.length();i++)
    {
        if (s[i]!=t[i])
        {
            kt=false;
            break;
        }
    }
    if (kt&&t.length()-s.length()==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define ll long long
#define pb push_back

const int maxn = 2e3 + 20;
const int mod = 1e9 + 7;

int dp[maxn][maxn] , a[maxn] , b[maxn];

inline void mkay(int &a)
{
	if(a >= mod)
		a -= mod;
	else if(a < 0)
		a += mod;
}

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

	int n , m;
	cin >> n >> m;

	for(int i = 1; i <= n; i++)
		cin >> a[i];

	for(int i = 1; i <= m; i++)
		cin >> b[i];

	dp[0][0] = 1;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= m; j++)
		{
			if(a[i] == b[j] && i && j)
				mkay(dp[i][j] += dp[i - 1][j - 1]);

			if(i)
				mkay(dp[i][j] += dp[i - 1][j]);
			if(j)
				mkay(dp[i][j] += dp[i][j - 1]);

			if(i && j)
				mkay(dp[i][j] -= dp[i - 1][j - 1]);
		}

	cout << dp[n][m] << endl;
}










 


Measured memory_bytes: 16128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)
#define ll long long
#define INF 100000000

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    int max_val = h;
    rep(i, 0, n) {
        cin >> a[i] >> b[i];
        max_val = max(a[i], max_val);
    }
    const int p = max_val+h;

    int dp[n+1][p+1];
    rep(i, 0, p+1) {
        dp[0][i] = INF;
    }
    rep(i, 0, n+1) {
        dp[i][0] = 0;
    }
    dp[0][0] = 0;

    rep(i, 0, n) {
        //int a, b;
        //cin >> a >> b;
        rep(j, 0, p+1) {
            int num = j-a[i];
            dp[i+1][j] = dp[i][j];
            if(num >= 0) {
                dp[i+1][j] = min({dp[i][j], dp[i+1][num]+b[i]});
            }
        }
    }

    int ans = 1000000000;
    rep(i, 0, n+1) {
        rep(j, h, p+1) {
            //cout << dp[i][j] << " ";
            ans = min(dp[i][j], ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78464
// https://atcoder.jp/contests/abc170/tasks/abc170_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll X, Y;
  cin >> X >> Y;

  rep(crane_ct, X + 1) {
    ll turtle_ct = X - crane_ct;

    if (crane_ct * 2 + turtle_ct * 4 == Y) drop("Yes");
  }

  drop("No");
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 100005
#define db double
#define mod 998244353
using namespace std;
void solve()
{
	ll n;
	cin >> n;
	ll arr[n],mp[n+1]={0};
	for(ll i=0;i<n;i++)
	{
		cin >> arr[i];
		mp[arr[i]]++;
	}
	ll sum=0;
	for(ll i=1;i<=n;i++)
	{
		sum+=(mp[i]*(mp[i]-1))/2;
	}
	for(ll i=0;i<n;i++)
	{
		cout << sum-mp[arr[i]]+1 <<"\n";
	}
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

Measured memory_bytes: 5760
n=int(input())
a=list(map(int,input().split()))
c=[0,0,0,0,0,0,0,0]
f=0
for i in a:
  if i//400<8:
    c[i//400]=1
  else:
    f+=1
ans=0
for i in c:
  ans+=i
print(max(1,ans),ans+f)

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}
template<typename T>
vector<T> make_v(size_t a, T b){ return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts){
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
#define int long long
constexpr int inf = 1000000000;
int N;
int L[100000], R[100000];
int maxL, minR;
int posL, posR;

// solve
signed main(){

    cin >> N;
    maxL = -inf;
    minR = inf;
    rep(i, N){
        cin >> L[i] >> R[i];
        if(chmax(maxL, L[i]))posL = i;
        if(chmin(minR, R[i]))posR = i;
    }

    int answer = -inf;
    {
        int ma = -inf;
        rep(i, N)chmax(ma, max(R[i] - L[i] + 1, 0ll));
        chmax(answer, ma + max(minR - maxL + 1, 0ll));
    }
    
    // 1 に maxL, 2 に minR がある
    int R1 = R[posL], L2 = L[posR];
    int score1 = R1 - maxL + 1, score2 = minR - L2 + 1;
    vector<int> dif1(N, 0), dif2(N, 0);
    rep(i, N){
        if(i == posL || i == posR)continue;
        dif1[i] = score1 - max(min(R1, R[i]) - maxL + 1, 0ll);
        dif2[i] = score2 - max(minR - max(L2, L[i]) + 1, 0ll);
    }

    // int ma1 = -inf, ma2 = -inf;
    // int po1 = -1, po2 = -1;
    // rep(i, N){
    //     if(chmax(ma1, dif1[i]))po1 = i;
    //     if(chmax(ma2, dif2[i]))po2 = i;
    // }

    vector<int> ord(N);
    iota(all(ord), 0);
    sort(all(ord), [&](int i, int j){
        return dif1[i] > dif1[j];
    });

    int minimum = inf * 2, maximum = 0;
    rep(k, N){
        int i = ord[k];
        chmin(minimum, dif1[i] + maximum);
        chmax(maximum, dif2[i]);
    }
    chmin(minimum, maximum);

    chmax(answer, score1 + score2 - minimum);
    cout << answer << '\n';

}

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

int main() {
long N,sum=0;
  cin>>N;
  vector<long> A(N);
for(int i=0;i<N;i++){
  cin>>A.at(i);
  	for(int j=0;j<31;j++){
      if(A.at(i)%2==0){
        sum++;
        A.at(i)/=2;
      }
      else{
        break;
      }
    }
}
  
    cout<<sum<<endl;
  
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>

#include <math.h>

using namespace std;

int main()
{
	double x0, x1, y0, y1;

	cin >> x0 >> y0 >> x1 >> y1;

	cout << fixed << setprecision(8) << sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)) << endl;
}


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

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

    if(a == b && b == c && a == c) result = 1;
    else if(a != b && a != c && b != c) result = 3;
    else result = 2;

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
  string s;
  cin >> s;
  int ret=1000;
  for(int i=0; i<s.length()-2; i++){
    int n=100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0');
    ret = min(ret, abs(n-753));
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
x, N = map(int, input().split())
p = list(map(int, input().split()))

min =10000
temp = 0
num = 10000

for i in range(-1000, 1000):
  temp = abs(x- i)
  
  if temp < min and i not in p:
    min = temp
    num = i
    
print(num)


Measured memory_bytes: 9076
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s;
int ans=1e9;

int main()
{
	cin>>s;
	rep(i,s.size()-2)
	{
		string t=s.substr(i,3);
		int p=atoi(t.c_str());
		ans=min(ans,abs(p-753));
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    int ans = 0;
    rep(i,N)for(int j=i+1;j<N;j++)ans+=d[i]*d[j];
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;

long long T[1005];
long long A[1005];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> T[i] >> A[i];
	}
	for(int i = 1; i < N; i++){
		long long mul;
		if(T[i-1]%T[i] == 0){
			mul = T[i-1]/T[i];
		}else{
			mul = T[i-1]/T[i] + 1;
		}
		if(A[i-1]%A[i] == 0){
			mul = max(A[i-1]/A[i], mul);
		}else{
			mul = max(A[i-1]/A[i] + 1, mul);
		}
		T[i] = T[i] * mul;
		A[i] = A[i] * mul;
	}
	cout << T[N-1] + A[N-1] << endl;

}



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

unsigned int A[2000];

using namespace std;
int main(void)
{
	unsigned int N, K, Q;
	cin >> N >> K >> Q;
	for (unsigned int i = 0; i < N; i++) cin >> A[i];

	unsigned int ans = 0x7FFFFFFF;
	int min_cnt;
	for (unsigned int base_pos = 0; base_pos < N; base_pos++) {
		vector <unsigned int> min_list;
		unsigned int min = A[base_pos];

		vector <unsigned int> sub_seq;
		for (unsigned int seek_pos = 0; seek_pos < N; seek_pos++) {

			if (A[seek_pos] < min) {
				min_cnt = sub_seq.size() - K + 1;
				if (min_cnt >= 1) {
					sort(sub_seq.begin(), sub_seq.end());
					for (int k = 0; k < min_cnt; k++) {
						min_list.push_back(sub_seq.at(k));
					}
				}
				sub_seq.clear();
			} else {
				sub_seq.push_back(A[seek_pos]);
			}
		}

		min_cnt = sub_seq.size() - K + 1;
		if (min_cnt >= 1) {
			sort(sub_seq.begin(), sub_seq.end());
			for (int k = 0; k < min_cnt; k++) {
				min_list.push_back(sub_seq.at(k));
			}
		}
		sub_seq.clear();

		sort(min_list.begin(), min_list.end());
		if (min_list.size() >= Q) {
			ans = std::min(ans, min_list.at(Q-1) - min_list.at(0));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
const int MOD = 1000000007;


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());

    int ans = 0;
    rep(i,n){
        if(s[i+1] != s[i]){
            ans-=-1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9596
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define DOF 0x7f7f7f7f
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int maxn=1e5+10;

int n;
int a[maxn],b[maxn],vis[maxn];

ll solve()
{
    map<int,int>mt;
    int x=INF;
    for(int i=1;i<=n;++i)
    {
        b[i]=a[i];
        x=min(x,a[i]);
    }
    sort(b+1,b+1+n);
    for(int i=1;i<=n;++i)
        mt[b[i]]=i;
    ll ans=0;
    for(int i=1;i<=n;++i)
    {
        ll cnt=0,sum=0,minn=INF,tmp=i;
        while(1)
        {
            vis[tmp]=1;
            ++cnt;
            minn=min(minn,a[tmp]*1ll);
            sum+=a[tmp];
            tmp=mt[a[tmp]];
            if(vis[tmp]) break;


        }
        ans=ans+min(sum+(cnt-2)*minn,sum+(cnt-2)*minn+2*(minn+x)-(cnt-1)*(minn-x));
    }
    return ans;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;++i) cin>>a[i];
    ll ans=solve();
    cout<<ans<<endl;
}



Measured memory_bytes: 3244
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          int N = int.Parse(Console.ReadLine());
          //仕事を登録する辞書
          Dictionary<int,int> jobs = new Dictionary<int, int>();
          //仕事をした合計時間
          int time = 0;
          //結果
          string result = "Yes";
          
          //仕事を登録
          for(int i=0; i < N; i++){
            var AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = AB[0];
            var B = AB[1];
            if(!jobs.ContainsKey(B)){
              jobs.Add(B,A);
            }else{
              jobs[B] += A;
            }
          }
          
          IOrderedEnumerable<KeyValuePair<int, int>> jobs2 = jobs.OrderBy(x => x.Key);
          //貪欲法で各状態ごとの最善手を打つ
          foreach(KeyValuePair<int, int> job in jobs2){
            //仕事後の時間が納期に間に合う場合
            if(time+job.Value <= job.Key){
              //何もしないんか
              time += job.Value;
              //Console.WriteLine(time);
            }else{
              //Console.WriteLine(job.Key);
              result = "No";
            }
            
            //Console.WriteLine("納期:"+job.Key+"仕事時間"+job.Value+"合計時間:"+time);
          }
          
          Console.WriteLine(result);
          
        }
 }

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = int(1e9) + 7;

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

  int n, m;
  while (cin >> n >> m, n) {

    vector<vector<int>> student(n);

    rep(i, m) {
      int a, b;
      cin >> a >> b;
      --a; --b;
      student[a].push_back(b);
      student[b].push_back(a);
    }

    set<int> st;
    st.insert(0);
    for (int i = 0; i < student[0].size(); ++i) {
      int X = student[0][i];
      st.insert(X);
      for (int j = 0; j < student[X].size(); ++j) {
        st.insert(student[X][j]);
      }
    }

    cout << st.size() - 1 << "\n";
  }

  return 0;
}


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

typedef long long ll;

using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<vector<int>>;
using vll = vector<vector<long long int>>;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
       const int INF=1e9+7;
     int n;
     cin>>n;
     int arr[n];
     int store[n+1]={0};
     for(int i=0;i<n-1;i++)
     {
      cin>>arr[i];
      store[arr[i]]++;
     }
     
     for(int i=1;i<=n;i++)cout<<store[i]<<endl;
      cout<<endl;
return 0;

}




Measured memory_bytes: 5220
n = int(input())
s = list(input())
l = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = []
for i in range(len(s)):
  for j in range(26):
    if s[i] == l[j]:
      if 25-j > n:
        ans.append(l[j+n])
      else:
        x = (j+1+n)%26-1
        ans.append(l[x])
print(''.join(ans))

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

int main(){
   int a,b;
   char op;
   
   while(1){
       cin >> a >> op >> b;
       if(op == '?') return 0;
       switch(op){
           case '*': a = a * b;
            break;
           case '/': a = a / b;
            break;
           case '+': a = a + b;
            break;
           case '-': a = a - b;
   }
   cout << a << endl;
   } 
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, less<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 18;

int n, m, k;
vector<int> g[N];

int64 dfs(int v, int p, int x)
{
  int64 ans = x;
  int sub = p != -1;
  for (int u : g[v]) {
    if (u == p) {
      continue;
    }
    ans *= dfs(u, v, k - ++sub);
    ans %= mod;
  }
  return ans;
}

void solve(int test)
{
  cin >> n >> k;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cout << dfs(0, -1, k) << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 11648