akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 100
int selectionSort(int *,int);

int main(){
  int i,j,n,count;
  int in[N];

  /* input */  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&in[i]);
  }

  /* sort */
  count = selectionSort(in,n);

  /* output */
  for(i=0;i<n-1;i++){
    printf("%d ",in[i]);
  }
  printf("%d\n",in[i]);
  printf("%d\n",count);

  return 0;
}

int selectionSort(int *in,int n){
  int i,j,minj,count,tmp;

  count = 0;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if( in[j] < in[minj] ){
	minj = j;
      }
    }
    tmp = in[i];
    in[i] = in[minj];
    in[minj] = tmp;
    if( i != minj ){
      count++;
    }
  }
  return count;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


int main(){
    int n,sum=0;
    cin>>n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i,n) cin>>s[i]>>t[i];
    string x;
    cin>>x;
    rep(i,n){
        if(x==s[i]){
            for(int j=i+1;j<n;j++) sum += t[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
  string s;
  cin>>s;
  string t="";
  rep(i,s.size()-8)t+=string{s[i]};
  cout<<t<<"\n";
  return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
A,B,X = map(int, input().split())
ans = a = b = 0

if  X % 500 != 0:  X += 500 - X%500
if  A < B:
    a = X//1000 + (1 if (X%1000>0) else 0)
elif A > 2*B:
    b = X//500
else:
    a = X//1000; X %= 1000
    b = X//500

print(A*a + B*b)



Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>
using namespace std;
int main(void){
    long double a,b,h,m;
    long double n,l,o,ans;
    cin>>a>>b>>h>>m;
    n=h*30+m*0.5;
    l=m*6;
    o=(n-l)*3.14159265358979/180;
    if(o<0){
        o*=-1;
    }
    ans=a*a+b*b-2*a*b*cos(o);
    printf("%.30Lf",sqrt(ans));
}

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

//long long型(64bit整数)
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if(k % 2 == 0){
        ll count1 = 0, count2 = 0;
        for(ll i=1; i<=n; i++){
            if(i % k == 0) count1++;
            if(i % k == k/2) count2++;
        }
        ans = (count1 * count1 * count1 + count2 * count2 * count2);
    }else{
        ll count3 = 0;
        for(ll i=1; i<=n; i++){
            if(i % k == 0) count3++;
        }
        ans = (count3 * count3 * count3);
    }
    
    cout << ans << endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;

LL march[5];

void solve()
{
    int N;
    cin >> N;
    char letter[5] = {'M', 'A', 'R', 'C', 'H'};
    REP0(i, N)
    {
        string S;
        cin >> S;
        REP0(j, 5)
        {
            if (S[0] == letter[j])
            {
                march[j]++;
                break;
            }
        }
    }

    LL ans = 0;

    REP0(i, 3)
    {
        FOR(j, i + 1, 4)
        {
            FOR(k, j + 1, 5)
            {
                ans += march[i] * march[j] * march[k];
            }
        }
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main ()
{
  int n,i;
  long step=0;
  long *a;
 
  scanf("%d",&n);
  a = calloc(n,sizeof(long));
 
  for(i=0; i<n; i++)
    scanf("%ld", &a[i]);
 
  for(i=1; i<n; i++){
    if(a[i] < a[i-1]){
      step += (a[i-1]-a[i]);
      a[i] += (a[i-1]-a[i]);
    }
  }
 
  printf("%ld", step);
  free(a);
  return 0;
}

Measured memory_bytes: 3036
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[][] sentences = new String[3][3];
        int count = 0;
        for(int i = 0; i < 3; i++){
            String tmp = sc.nextLine();
            for(int j = 0; j < 3; j++){
                sentences[i][j] = String.valueOf(tmp.charAt(j));
                if(count==j){
                 System.out.print(sentences[i][j]);   
                }
            }
            count++;
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

using State = string::const_iterator;

int digit(State &s){
    int ret = *s - '0';
    s++;
    return ret;
}

int term(State &s){
    int ans = digit(s);
    while(true){
        if(*s == '*'){
            s++;
            ans *= digit(s);
        }else break;
    }
    return ans;
}

int expr(State &s){
    int ans = term(s);
    while(true){
        if(*s == '+'){
            s++;
            ans += term(s);
        }else break;
    }
    return ans;
}

int expr2(State &s){
    int ans = digit(s);
    while(true){
        if(*s == '+'){
            s++;
            ans += digit(s);
        }else if(*s == '*'){
            s++;
            ans *= digit(s);
        } else break;
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    int x = 0;
    cin >> x;
    State p = s.begin();
    int a = expr(p);
    p = s.begin();
    int b = expr2(p);
    string ans = "IMLU";
    cout << ans[(a==x)+(b==x)*2] << "\n";
    return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>
#include<iostream>
#include<vector> 
 
using namespace std;
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i){
    cin >> v[i];
  }
  
  int res = 0;
  for(int i = 1; i < n - 1; ++i){
    if(v[i] > v[i + 1] && v[i] < v[i - 1]){
      ++res;
    }else if(v[i] < v[i + 1] && v[i] > v[i - 1]){
      ++res;
    }
  }
    
  cout << res << "\n";
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    int n;cin>>n;
    vector<pair<int,int>> a(n);
    for (int i = 0; i < n; i++)
    {   
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(all(a));
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=(a[i].second%2!=i%2);
    }
    cout<<ans/2<<endl;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<string,int> memo;
  int n; cin>>n;
  rep(i,n){
    string s; cin>>s;
    memo[s]++;
  }
  int maxv=0;
  for(auto x:memo) maxv=max(x.second,maxv);
  for(auto x:memo) if(x.second==maxv) cout<<x.first<<endl;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)){
		char a[105],b[105],c[105];
		scanf("%s%s%s",a,b,c);
		int ans=0;
		F(i,0,n){
			if(!(a[i]==b[i]&&b[i]==c[i])){
				if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i]){
					ans++;
				}else{
					ans+=2;
				}
			}
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;

ll dp[maxn];
bool broke[maxn];

int n, m;

ll solve(int pos){
	if(pos > n)
		return 0;
	if(broke[pos])
		return 0;
	if(pos == n)
		return 1ll;
	if(dp[pos] != -1)
		return dp[pos];
	ll ans = 0;
	ans = (ans + solve(pos + 1)) % mod;
	ans = (ans + solve(pos + 2)) % mod;
	return dp[pos] = ans;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		broke[x] = true;
	}
	
	memset(dp, -1, sizeof(dp));
	cout << solve(0) << endl;

	return 0;
}


Measured memory_bytes: 4224
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    char s[4];
    string a;
    std::cin >> a;
    for (int i = 0; i < 4; i++) {
        s[i] = a[i];
    }
    sort(s,s+4);
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 764
def partition(A, p, r):
    x = A[-1]
    i = p - 1
    for j in range(p, r-1):
        if A[j] <= x:
            i = i + 1
            A[i],A[j]=A[j], A[i]
    A[i+1], A[-1]=A[-1], A[i+1]
    return i+1

    
    
if __name__ == "__main__":
    num = int(raw_input())
    num_list = raw_input().strip().split()
    num_list = map(int, num_list)
    i = partition(num_list, 0, len(num_list))
    num_list = map(str, num_list)
    data = ""
    for j in range(len(num_list)):
        if j == i:
            data += "[" + num_list[j] + "] "
        else:
            data += num_list[j] + " "
    print data[:-1]

    

Measured memory_bytes: 18044
import sys
read=sys.stdin.readline
def find(x):
    if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
        else:
            par[a]=b
            if rank[a]==rank[b]:
                rank[b]+=1
def same(a,b):
    return find(a)==find(b)
def Kruskal(Edge,E):
    cost=0
    Edge.sort(key=lambda x:x[2])
    for i in range(E):
        f,t,c=Edge[i]
        if(not same(f,t)):
            union(f,t)
            cost+=c
    return cost

N=int(input())
par=[];p=[];dic={};rank=[]
for i in range(N):
    par.append(i)
    rank.append(0)
    p.append(tuple(map(int,read().split())))
    dic[p[i]]=i
xp=sorted(p,key=lambda x:x[0])
yp=sorted(p,key=lambda x:x[1])
Edge=[]
for i in range(N):
    if(i>0):
        Edge.append((dic[xp[i]],dic[xp[i-1]],abs(xp[i][0]-xp[i-1][0])))
    if(i<N-1):
        Edge.append((dic[xp[i]],dic[xp[i+1]],abs(xp[i][0]-xp[i+1][0])))
    if(i>0):
        Edge.append((dic[yp[i]],dic[yp[i-1]],abs(yp[i][1]-yp[i-1][1])))
    if(i<N-1):
        Edge.append((dic[yp[i]],dic[yp[i+1]],abs(yp[i][1]-yp[i+1][1])))
print(Kruskal(Edge,len(Edge)))

Measured memory_bytes: 124616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,k;
    cin >> n >> k;
    int maxe = (n-1)*(n-2)/2;
    if(maxe<k){
        cout << -1 << endl;
        return 0;
    }
    vector<int> u;
    vector<int> v;
    for(int i = 1;i<=n-1;i++){
        u.push_back(i);
        v.push_back(n);
    }
    int cnt = maxe - k;
    if(cnt != 0){
        for(int i = 1;i<=n-2;i++){
            for(int j = i+1;j<=n-1;j++){
                u.push_back(i);
                v.push_back(j);
                cnt--;
                if(cnt==0) break;
            }
            if(cnt==0) break;
        }
    } 
    cout << u.size() << endl;
    rep(i,u.size()){
        cout << u[i] << " " << v[i] << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  if (A < B) {
    ans = B;
    B--;
  } else {
    ans = A;
    A--;
  }
  ans += max(A, B);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(true){
			int x1 = scan.nextInt();
			int y1 = scan.nextInt();
			int x2 = scan.nextInt();
			int y2 = scan.nextInt();
			int x3 = scan.nextInt();
			int y3 = scan.nextInt();
			if(x1==0 && y1==0 && x2==0 && y2==0 && x3==0 && y3==0) break;
			double ab = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
			double bc = Math.sqrt(Math.pow(x2-x3,2)+Math.pow(y2-y3,2));
			double ca = Math.sqrt(Math.pow(x3-x1,2)+Math.pow(y3-y1,2));
			double s =  (ab+bc+ca)/2;
			double scale = Math.sqrt(s*(s-ab)*(s-bc)*(s-ca));
			double r = scale/s;
			double h=0;
			double arad=0;
			double brad=0; 
			double crad=0;
			if(ab>=bc && ab>=ca){
				h=2*(scale/ab);
				brad = Math.asin(h/ca);
				crad = Math.asin(h/bc);
				arad = Math.PI-(brad+crad);
			}
			else if(bc>=ab && bc>=ca){
				h=2*(scale/bc);
				arad = Math.asin(h/ca);
				crad = Math.asin(h/ab);
				brad = Math.PI-(arad+crad);
			}
			else if(ca>=ab && ca>=bc){
				h=2*(scale/ca);
				arad = Math.asin(h/bc);
				brad = Math.asin(h/ab);
				crad = Math.PI-(arad+brad);
			}
			double r1 = (r*(1+Math.tan(brad/4))*(1+Math.tan(crad/4)))/(2*(1+Math.tan(arad/4)));
			double r2 = (r*(1+Math.tan(arad/4))*(1+Math.tan(crad/4)))/(2*(1+Math.tan(brad/4)));
			double r3 = (r*(1+Math.tan(arad/4))*(1+Math.tan(brad/4)))/(2*(1+Math.tan(crad/4)));
			//System.out.println(ab+":"+bc+":"+ca);
			//System.out.println("S:"+scale);
			//System.out.println(arad+":"+brad+":"+crad);
			//System.out.println(r);
			System.out.println(r2+" "+r3+" "+r1);
		}
	}

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

Measured memory_bytes: 46268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 59; //MAX 9223372036854775807


int main()
{
ll n,k;
cin >> n >> k;
ll t[n] = {};
rep(i, n){
    cin >> t[i];
}
pair<ll,ll> to[n];
{vector<ll> bac(200001,0);
vector<ll> flo(200001,-1);
rep(i,n){
    to[n-i-1].first=bac[t[n-i-1]];
    bac[t[n-i-1]]=n-i-1;
}
rep(i,n){
    if(flo[t[i]]==-1)flo[t[i]]=i;
}
rep(i,n){
    if(to[i].first==0){to[i].first=flo[t[i]];to[i].second=1;}
    if(to[i].first==n-1)to[i].second=1;
    to[i].first=to[i].first+1;
    if(i==n-1&&to[i].first==n)to[i].second++;
    to[i].first%=n;
}
}
vector<ll> v;
set<ll> st;
v.push_back(0);
st.insert(0);
ll sy=0;
while(1){
    ll too=to[v.back()].first;
    auto r = st.insert(too);
    if(r.second){sy+=to[v.back()].second;v.push_back(too);}
    else {sy+=to[v.back()].second;break;}
}
k%=sy;
if(k==0)return 0;
ll str=0;
ll now=0;
vector<ll> ans;
while(1){
    now+=to[str].second;
    if(k>now)str=to[str].first;
    else{
        
        for (ll i = str; i < n; i++)
        {
            ans.push_back(t[i]);
        }
        break;
    }
}

vector<ll> anss;
set<ll> stt;
rep(i,ans.size()){
    auto r =stt.insert(ans[i]);
    if(r.second)anss.push_back(ans[i]);
    else{
        while(1){
            if(ans[i]==anss.back())break;
            stt.erase(anss.back());
            anss.pop_back();
        }
        stt.erase(anss.back());
        anss.pop_back();
    }
}



rep(i,anss.size()){
    if(i!=0)cout << " ";
    cout << anss[i] ;
}
cout <<endl;
return 0;
}


Measured memory_bytes: 29640
// AOJ 0184: Tsuruga Castle
// 2017.10.28 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int n;
	char buf[10];
	int cnt[7];
	
	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(cnt, 0, sizeof(cnt));
		n = atoi(buf);
		while (n--) {
			fgets(buf, 8, stdin); if (*buf == ' ') while (1);
			if (*(buf+1) < '0') cnt[0]++;
			else if (*(buf+2) >= '0' || *buf >= '6') cnt[6]++;
			else cnt[*buf-'0']++;
		}

		for (n = 0; n < 7; n++) printf("%d\n", cnt[n]);
	}
	return 0;
}

Measured memory_bytes: 1796
unittest
{
	assert( [ "10 13" ].parse.expand.solve == 3 );			// 追加ケース
	assert( [ "10 8" ].parse.expand.solve == 4 );			// 追加ケース
	assert( [ "10 -13" ].parse.expand.solve == 4 );			// 追加ケース
	assert( [ "10 -8" ].parse.expand.solve == 3 );			// 追加ケース
	assert( [ "-10 13" ].parse.expand.solve == 4 );			// 追加ケース
	assert( [ "-10 8" ].parse.expand.solve == 3 );			// 追加ケース
	assert( [ "-10 -13" ].parse.expand.solve == 5 );		// 追加ケース
	assert( [ "-10 -8" ].parse.expand.solve == 2 );			// 追加ケース
	
	assert( [ "10 20" ].parse.expand.solve == 10 );
	assert( [ "10 -10" ].parse.expand.solve == 1 );
	assert( [ "-10 -20" ].parse.expand.solve == 12 );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xy = input.front.split.to!( long[] );
	return tuple( xy[ 0 ], xy[ 1 ] );
}

auto solve( long x, long y )
{
	auto ans = 0L;
	if( ( 0 <= x && 0 <= y ) || ( x < 0 && y < 0 ) )
	{
		// 両方が＋か、両方が－のとき
		if( y < x ) x = -x, ans++;		// Bボタン押す
	}
	else
	{
		// 片方が＋で、もう片方が－のとき
		if( -x < y ) x = -x, ans++;		// Bボタン押す
	}
	auto d = ( x.abs - y.abs ).abs;
	x += d,	ans += d;		// Aボタン連打
	ans += ( y != x );		// Bボタン押す
	return ans;
}


Measured memory_bytes: 256
from sys import exit
s = input()
t = input()
tset = set(t)
slen = len(s)
aord = ord('a')
if len(tset - set(s)) != 0:
    print(-1)
    exit()
s2t = [i - aord for i in (s + s).encode('ascii')]
lut = [[-1] * slen for _ in range(26)]
for c in tset:
    b = ord(c) - aord
    j = 0
    for i in range(slen * 2 - 1, -1, -1):
        if s2t[i] == b:
            j = 0
        else:
            j += 1
        if i < slen:
            lut[b][i] = j
p = 0
for c in t:
    b = ord(c) - aord
    p += lut[b][p % slen] + 1
print(p)


Measured memory_bytes: 104684
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans=0

for i in range(len(A)-1):
    if A[i]>=B[i]:
        ans += B[i]
        A[i]-=B[i]
        B[i]=0
    if B[i]>A[i]:
        ans+= A[i]
        B[i]-=A[i]
        A[i]=0
    if A[i+1]>= B[i]:
        ans +=B[i]
        A[i+1]-=B[i]
        # print(ans)
    else:
        ans+=A[i+1]
        A[i+1]=0

print(ans)

Measured memory_bytes: 19004
n, m = map(int, input().split())
mazai = []
for i in range(n):
  a, b = map(int, input().split())
  mazai.append([a, b])
mazai.sort()
ans = 0
mazaiget = 0
for i in range(n):
  if mazaiget < m:
    if mazaiget + mazai[i][1] >= m:
      ans += (m - mazaiget) * mazai[i][0]
      break
    else:
      ans += mazai[i][0] * mazai[i][1]
      mazaiget += mazai[i][1]
  else:
    break
print(ans)
  

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

int n,a,b;
 
int cald(int x)
{
	int ret=0;
	while(x) ret+=x%10,x/=10;
	return ret;
}

void work()
{
	int ans=1e9;
	for(a=1;a<n;a++){
		b=n-a;
		ans=min(ans,cald(a)+cald(b));
	}
	cout<<ans<<endl;
}

void init()
{
	cin>>n;
}

int main()
{
	init();
	work();
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int n;
    cin >> n;
    ll int a[n];
    for (ll int i = 0 ; i < n ; i++) cin >> a[i];
    map <ll int, ll int> m;
    for (ll int i = 0 ; i < n ; i++) m[a[i]]++;
    ll int b[n];
    ll int cnt = 0;
    map <int, bool> c;
    for (ll int i = 0 ; i < n ; i++) {
    	c[a[i]] = true;
	}
	for (ll int i = 1 ; i <= 200000 ; i++) {
		if (c[i] == true) {
			b[cnt] = i;
			cnt++;
		}
	}
	ll int sum = 0;
	for (ll int j = 0 ; j < cnt ; j++) {
		if (m[b[j]] == 0 || m[b[j]] == 1) continue;
		else sum += m[b[j]] * (m[b[j]]-1) / 2;
	}
	for (ll int i = 0 ; i < n ; i++) {
		int x = a[i];
		if (m[x] == 1) {
			cout << sum << endl;
		} else {
			cout << sum - m[x] + 1 << endl;
		}
	}
}
/*
5
4 4 5 4 5
*/

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

using namespace std;

const int maxn = 1e5 + 5;
const int inf = 1e9 + 5;

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

int n, sum[maxn];
pair<int, int> st[maxn][20];

char s[maxn];

inline pair<int, int> query(int l, int r) {
	int k = log2(r - l + 1);
	return max(st[l][k], st[r - (1 << k) + 1][k]);
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	
	for(register int k = 'a'; k <= 'z'; k++) {
		memset(sum, 0, sizeof(sum));
		memset(st, 0, sizeof(st));
		
		for(register int i = 1; i <= n; i++)
				sum[i] = sum[i - 1] + (k == s[i]);
				
		for(register int i = 1; i <= n; i++)
			st[i][0] = make_pair(2 * sum[i] - i, i);
		for(register int j = 1; j < 20; j++)
			for(register int i = 1; i + (1 << j) - 1 <= n; i++)
				st[i][j] = max(st[i][j - 1], st[i + (1 << j - 1)][j - 1]);
				
		for(register int i = 1; i < n; i++) {
			if(s[i] != k) continue;
			pair<int, int> tmp = query(i + 1, n);
			if(tmp > st[i][0]) {
				cout << i << " " << tmp.second; return 0;
			}
		}
	}
	
	cout << -1 << " " << -1;
	return 0;
}

Measured memory_bytes: 16384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int[] dp;
        static int[] H;
        static void Main(string[] args)
        {
            var N = Slist()[0];
            H = Sarray();
            dp = Enumerable.Repeat<int>(-1, N).ToArray();            

            dp[0] = 0;
            dp[1] = Abs(H[1] - H[0]);
            WriteLine(calccost(N - 1));
        }
        static int calccost(int no )
        {
            if (-1 != dp[no]) return dp[no];
            dp[no] = Min(Abs(H[no] - H[no - 1]) + calccost(no - 1), Abs(H[no] - H[no - 2]) + calccost(no - 2));
            return dp[no];
        }
    }
}

Measured memory_bytes: 25824
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	vector<int> a;
	vector<int> b;
	int a1;
	int b1;
	cin>>a1>>b1;
	for(int i=0;i<a1;i++)
	{
		a.push_back(b1);
	}
	for(int i=0;i<b1;i++)
	{
		b.push_back(a1);
	}
	if(a[0]<b[0])
	{
		for(int i=0;i<a.size();i++)
		{
			cout<<a[i];
		}
		cout<<endl;
	}
	else
	{
		for(int i=0;i<b.size();i++)
		{
			cout<<b[i];
		}
		cout<<endl;
	}
	return 0;
}

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

int main() {
    int N;
    int V[20 + 10];
    int C[20 + 10];
    int sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> V[i];
    for (int i = 0; i < N; i++) cin >> C[i];
    for (int i = 0; i < N; i++) {
     if (V[i] - C[i] > 0) sum += V[i] - C[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N, A, B = map(int, input().split())

print (min(A*N, B))


Measured memory_bytes: 38384
// ============================================================================
// なんかACもらえない
// ============================================================================

#include <iostream>

int main()
{
    unsigned long long N;
    std::cin >> N;

    // int s = 0;
    // for (int i = 1; i < N; i++)
    // {
    //     s += i;
    // }

    unsigned long long s;
    s = ((N - 1) * N) / 2;

    std::cout << s << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


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






























int main(){
    ll h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<string> s(h);
    REP(i, h){
        cin >> s[i];
    }
    const ll dy[4] = {-1, 0, 1, 0};
    const ll dx[4] = {0, 1, 0, -1};
    deque<pair<ll, ll>> que;
    que.push_back({ch, cw});
    vector<vector<ll>> d(h, vector<ll>(w, INF));
    d[ch][cw] = 0;
    vector<vector<bool>> f(h, vector<bool>(w));
    while(!que.empty()){
        auto tmp = que.front(); que.pop_front();
        ll y = tmp.first, x = tmp.second;
        if(f[y][x]) continue;
        f[y][x] = true;
        REP(i, 4){
            ll yy = y + dy[i], xx = x + dx[i];
            if(yy < 0 || yy >= h || xx < 0 || xx >= w || s[yy][xx] == '#' || d[yy][xx] <= d[y][x]) continue;
            d[yy][xx] = d[y][x];
            que.push_front({yy, xx});
        }
        for(ll i = -2; i <= 2; i++){
            for(ll j = -2; j <= 2; j++){
                ll yy = y + i, xx = x + j;
                if(yy < 0 || yy >= h || xx < 0 || xx >= w || s[yy][xx] == '#' || d[yy][xx] <= d[y][x] + 1) continue;
                d[yy][xx] = d[y][x] + 1;
                que.push_back({yy, xx});
            }
        }
    }
    cout << ((d[dh][dw] != INF)? d[dh][dw] : -1) << endl;
}

Measured memory_bytes: 13756
N,Y = map(int,input().split())

for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 10000*x+5000*y+1000*z==Y:
            print(str(x)+' '+str(y)+' '+str(z))
            exit()
print('-1 -1 -1')

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	char S[201],P[101];
	int i,j,ns=0,np=0;
	scanf("%s %s",S,P);
	for(i=0;S[i]!='\0';i++){
		ns++;
	}
	for(i=0;P[i]!='\0';i++){
		np++;
	}
	for(i=0;i<ns;i++){
		S[ns+i] =S[i];
	}
	S[2*ns-1]='\0';
	
	int check;
	
	for(i=0;i<2*ns;i++){
		check=0;
		if(P[0]==S[i]){
			for(j=0;j<np;j++){
				if(P[j]!=S[i+j]) check=-1;
			}
			if(check==0){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

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


int main(){
  string s;
  cin >>s;
  int n =s.size();
  string t;
  bool flag =true;
  bool ans =true;
  for(int i=0;i<n/2;i++){
    if(s.at(i)==s.at(n-i-1)){
      t+=s.at(i);
    }
    else {
      flag =false;
      break;
    }
  }

  if(flag){
    int x =t.size();

    if(x==1){
      cout<<"Yes"<<endl;
      return 0;
    }

    for(int i=0;i<x/2;i++){
      if(t.at(i)!=t.at(x-i-1)){
        ans=false;
      }
    }
  }
  else {
    cout <<"No"<<endl;
    return 0;
  }

  if(ans){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
constexpr auto mod = 1000000000 + 7;
constexpr auto maxn = 200000 + 5;
ll a[maxn];
void exgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1, y = 0;
        return;
    }

    exgcd(b, a % b, y, x);
    y -= a / b * x;
}
int main() {
    ll n, sum = 0, sum1 = 0,x,y;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 1; i <= n; i++) {
        sum1 = (sum1 + (sum - a[i]) %mod * a[i] ) % mod;
    }
    exgcd(2, mod, x, y) ;
    cout << ((x+mod)%mod)*sum1%mod;
    return 0;
}

Measured memory_bytes: 4732
import Foundation
let line1 = readLine()!

let abc = line1.componentsSeparatedByString( " " )

let aa:String = abc[0]
let bb:String = abc[1]
let cc:String = abc[2]

let a:Int = Int(aa)!
let b:Int = Int(bb)!
let c:Int = Int(cc)!

if b-a == c-b{
    
    print("YES")
    
}
else {
    print("NO")
    
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int N,Q,S,T;
ll A[200010];
ll dif[200010];
ll now;

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

	cin>>N>>Q>>S>>T;
	S=-S;
	T=-T;
	REP(i,N+1) cin>>A[i];
	REP(i,N) dif[i+1]=A[i+1]-A[i];

	REP(i,N+1) {
		now+=(dif[i]>0?S:T)*dif[i];
	}
	REP(i,Q) {
		int l,r;ll x;cin>>l>>r>>x;
		now-=(dif[l]>0?S:T)*dif[l];
		if(r<N) now-=(dif[r+1]>0?S:T)*dif[r+1];
		dif[l]+=x;
		if(r<N) dif[r+1]-=x;
		now+=(dif[l]>0?S:T)*dif[l];
		if(r<N) now+=(dif[r+1]>0?S:T)*dif[r+1];
		cout<<now<<endl;
	}
	return 0;
}



Measured memory_bytes: 6352
#include <bits/stdc++.h>
using i64 = long long;

i64 dp[2020][2020];

int main() {
    i64 n, m;
    constexpr i64 mod = 1000000007;
    std::cin >> n >> m;
    std::vector<i64> a(n + 1), b(m + 1);
    for (int i = 1; i <= n; i++) std::cin >> a[i];
    for (int i = 1; i <= m; i++) std::cin >> b[i];

    for (int i = 0; i <= n; i++) dp[i][0] = 1;
    for (int i = 1; i <= m; i++) dp[0][i] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i] == b[j]) {
                dp[i][j] = dp[i - 1][j - 1];
            }
            dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1] + mod - dp[i - 1][j - 1]) % mod;
        }
    }
    std::cout << dp[n][m] << std::endl;

    return 0;
}


Measured memory_bytes: 31872
#include <stdio.h>

int main(void)
{
	int h, m, s, base;
	scanf("%d", &base);
	h = base / 3600;
	base %= 3600;
	m = base / 60;
	base %= 60;
	s = base;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct BIT{
  vector<int> bit;
  int n;
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    bit.clear();
    bit.resize(n+1,0);
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
};
int MOD=1000000007LL;
int s[114514],t[114514];
int fact[114514];
void init(int mod){
  fact[0]=fact[1]=1;
  for(int i=2;i<114514;i++)
    fact[i]=(fact[i-1]*i)%MOD;
}
signed main(){
  int n;
  init(MOD);
  while(cin>>n,n){
    BIT bit(n);
    for(int i=0;i<n;i++) s[i]=i+1;
    int r;
    cin>>r;
    for(int i=0;i<r;i++){
      int a,b;
      cin>>a>>b;
      a--;b--;
      swap(s[a],s[b]);
    }
    for(int i=n-1;i>=0;i--){
      t[i]=bit.sum(s[i]);
      bit.add(s[i],1);
    }
    int ans=0;
    for(int i=0;i<n;i++){
      (ans+=t[i]*fact[n-1-i])%=MOD;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 6360
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

// Xの時に必要な攻撃回数
map< ll, ll > memo;
ll f(ll x)
{
  if (x == 1)
  {
    return 1;
  }
  if (memo[x])
  {
    return memo[x];
  }
  return memo[x] = 2 * f(x / 2) + 1;
}

signed main()
{
  ll H;
  cin >> H;
  cout << f(H) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

int x, i, n;

scanf("%d",&n);

for(i=1;i<=n;i++)
{
    x=i;
    if(x % 3==0)
    {
      printf(" %d",i);
    }else
    {
        while(x)
        {
            if(x%10==3)
            {
                printf(" %d",i);
                x=0;
            }else
            {
                x /=10;
            }
        }
    }
}
    
    printf("\n");
}




Measured memory_bytes: 2100
package main

import (
	"fmt"
)

func main() {

	var p []string

	for {
		var m, f, r int
		fmt.Scanf("%d%d%d", &m, &f, &r)

		if m == -1 && f == -1 && r == -1 {
			break
		}

		var a string

		if m == -1 || f == -1 || m+f < 30 {
			a = "F"
		} else if m+f >= 80 {
			a = "A"
		} else if m+f >= 65 {
			a = "B"
		} else if m+f >= 50 || r >= 50 {
			a = "C"
		} else {
			a = "D"
		}

		p = append(p, a)
	}

	for _, v := range p {
		fmt.Println(v)
	}
}



Measured memory_bytes: 1104
#include <iostream>

using namespace std;
typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  ll count = n / 11 * 2;
  n %= 11;
  if(0 < n && n <= 6) count++;
  else if(6 < n) count += 2;
  cout << count << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define oo 1000000000
using namespace std;
 
int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    int dp[n + 1];
    // memset(dp, 0, (n + 1) * sizeof(int));
    for(int i=1;i<=n;i++)
    {
        dp[i]=oo;
    }
    dp[1] = 0;
    for (int i = 1; i <= n; i++)
    {
        for(int j=i-1;j>=i-k && j>0;j--)
        {
            dp[i]= min(dp[i],dp[j]+abs(arr[i]-arr[j]));
        }
 
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static  void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Integer> array = new ArrayList<>();
        for(int i = 0; i < 3; i++){
            array.add(scanner.nextInt());
        }
        Collections.sort(array);
        int s = array.get(0);
        int m = array.get(1);
        int l = array.get(2);
        int count = 0;
        while (s <= l-2){
            s += 2;
            count++;
        }
        while (m <= l-2){
            m += 2;
            count++;
        }

        if(s == m){
            if(m != l){
                count += 1;
            }
        }else{
            count += 2;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21716
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

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

		LinkedList<Integer> list = new LinkedList<Integer>();
		
		final int n = sc.nextInt();
		
		for(int i = 1; i <= 2*n; i++){
			list.add(i);
		}
		
		final int m = sc.nextInt();
		
		for(int i = 0; i < m; i++){
			final int ops = sc.nextInt();
			
			if(ops == 0){
				LinkedList<Integer> lf1 = new LinkedList<Integer>();
				LinkedList<Integer> lf2 = new LinkedList<Integer>();
				
				int count = 0;
				for(ListIterator<Integer> iter = list.listIterator(); iter.hasNext();){
					if(count / n == 0){
						lf1.add(iter.next());
					}else{
						lf2.add(iter.next());
					}
					count++;
				}
				
				list.clear();
				for(int j = 0; j < 2*n; j++){
					if(j % 2 == 0){
						list.add(lf1.poll());
					}else{
						list.add(lf2.poll());
					}
				}
			}else{
				for(int j = 0; j < ops; j++){
					list.addLast(list.poll());
				}
			}
		}
		
		for(int i : list){
			System.out.println(i);
		}

	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    ll a[n];
    ll ans=0;
    for(int i=0;i<k;i++){
        if(t[i]=='r'){
            a[i]=2;
            ans+=p;
        }else if(t[i]=='s'){
            a[i]=0;
            ans+=r;
        }else{
            a[i]=1;
            ans+=s;
        }
    }
    for(int i=k;i<n;i++){
        if(t[i]=='r'){
            if(a[i-k]==2){
                a[i]=3;
            }else{
                a[i]=2;
                ans+=p;
            }
        }else if(t[i]=='s'){
            if(a[i-k]==0){
                a[i]=3;
            }else{
                a[i]=0;
                ans+=r;
            }
        }else if(t[i]=='p'){
            if(a[i-k]==1){
                a[i]=3;
            }else{
                a[i]=1;
                ans+=s;
            }
        }
    }
    cout << ans<<endl;

    return 0;
}

Measured memory_bytes: 1232
import java.util.*;
public class Main{
  public static void main(String[]args){
  	Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String ans = "No";
    
    int []kuku = new int [81];
    int c=0;
    for(int x=1; x<=9; x++){
    	for(int y=1; y<=9; y++){
          kuku[c]=x*y;
          c++;
        }
    }
    for(int i=0; i<81; i++){
    	if(a==kuku[i])ans="Yes";
    }
    
    System.out.println(ans);
  }
}



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

int main(){
  int N, K, h_temp, diff=1000000000;
  vector<int> h;
  cin >> N >> K;
  while (cin >> h_temp) {
    h.push_back(h_temp);
  }
  sort(h.begin(), h.end());
  for (int i=0; i < N - K + 1; i++) {
    int diff_temp = h[i+K-1] - h[i];
    if (diff_temp < diff) {
      diff = diff_temp;
    }
  }
  cout << diff << endl;
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;

ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    int MIN = p[0];
    
    rep(i,n){
        if(p[i]<=MIN){
            ans ++ ;
            MIN = min (p[i],MIN);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	cout << N * (N - 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int k,i,j,s;
    scanf("%d",&k);
    for(j=2,s=0; j<=k; j++)
    {
        for(i=1; i<=j; i++)
        {
            if((i%2!=0 && j%2==0) || (i%2==0 && j%2!=0))
            {
                s++;
            }
        }
    }
    printf("%d\n",s);
    return 0;
}


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

#define      ll      long long int

int main( )
{
    ll i, j, k, r, n, l;
    string s;
    cin >> n;
    if (n == 0) {
        s = "0";
    }
    while (n != 0) {
        r = n % -2;
        n = n / -2;
        if (r < 0) {
            r += 2;
            n += 1;
        }
        s.push_back(char(r + '0'));
    }
    reverse(s.begin(), s.end());
    cout << s << '\n';
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W;
    cin>>H>>W;
    
    rep(i,H)rep(j,W){
        string s; cin>>s;
        if(s=="snuke"){
            cout<<((char)('A'+j))<<(i+1)<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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

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

	vector<vector<char>> a(H + 1, vector<char>(W + 1));
	repn(i, H)repn(j, W) cin >> a[i][j];

	vector<ll> c(26,0);
	repn(i, H)repn(j, W) c[a[i][j] - 'a']++;

	ll d = 0;
	ll s = 0;
	rep(j, 26) {
		if (c[j] % 4 >= 2) { d++; }
		if (c[j] % 2 == 1) { s++; }
	}

	
	ll dmax = 0;
	ll smax = 0;
	if (H % 2 == 1) { dmax += W / 2; }
	if (W % 2 == 1) { dmax += H / 2; }
	if (H % 2 == 1 && W % 2 == 1) { smax = 1; }

	if (d <= dmax && s <= smax) { cout << "Yes"; }
	else { cout << "No"; }

	system("PAUSE");
}


Measured memory_bytes: 504