akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
#include <vector>
#include <functional>
using namespace std;
#define INF 2000010000

pair<int,int> bou[100010],kae[100010];
int S[1010];int ar[1010],ra[1010];
int main(){
	int N,M,H,K,a,b,dai,sho,mim,res,cnt;
	while(true){
		cin>>N>>M>>H>>K;
		if(N==0&&M==0&&H==0&&K==0) break;
		for(int i=1;i<=N;i++){
			cin>>S[i];
		}
		for(int i=1;i<=M;i++){
			cin>>a>>b;
			bou[i]=make_pair(b,a);
		}
		sort(bou+1,bou+M+1,greater<pair<int,int> >());
		for(int i=1;i<=N;i++) ar[i]=i;
		for(int i=1;i<=M;i++){
			kae[i]=make_pair(ar[bou[i].second],ar[bou[i].second+1]);
			swap(ar[bou[i].second],ar[bou[i].second+1]);
		}
		for(int i=1;i<=N;i++){
			ra[ar[i]]=i;
		}
		mim=0;
		for(int i=1;i<=M;i++){
			if(S[kae[i].first]>S[kae[i].second]){
				dai=ra[kae[i].first];sho=ra[kae[i].second];
			}
			else{
				dai=ra[kae[i].second];sho=ra[kae[i].first];
			}
			if(dai<=K&&sho>K){
				mim=max(mim,abs(S[kae[i].first]-S[kae[i].second]));
			}
		}
		cnt=0;
		for(int i=1;i<=K;i++){
			cnt+=S[ar[i]];
		}
		cout<<cnt-mim<<endl;
	}
	return 0;
}

Measured memory_bytes: 2736
n=int(input())
ans=0
ans1=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        ans+=1
        if ans==3:
            ans1=1
    else:
        ans=0
if ans1==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62268
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int m = 1000003;
char T[1000003][12];

long long change(char str[]) {
    long long a = 0, b = strlen(str), c = 1, d;
    for (long long i = 0; i < b; i++) {
        if (str[i] == 'A') d = 1;
        else if (str[i] == 'C') d = 2;
        else if (str[i] == 'G') d = 3;
        else if (str[i] == 'T') d = 4;
        else d = 0;
        a += d*c; c *= 5;
    }
    return a;
}

long long h(int key, int i) {
    return ((key%m) + i*(1+(key%(m-1))))%m;
}

int main(){
    int n;
    char com[6], str[12];
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        long long key, j = 0, x = 0;
        key = change(str);
        while(true) {
            int H = h(key, j);
            if (strcmp(T[H], str) == 0) { x = 1; break; }
            else if (strlen(T[H]) == 0) {
                if (com[0] == 'i') strcpy(T[H], str); break;
            }
            else j++;
        }
        if (com[0] == 'f') {
            if (x == 1) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 14772
#include<bits/stdc++.h>
using namespace std;
typedef pair<double, int> PD;

struct edge{int to; double cost;};
const int MAX_N = 1005;
const double INF = 1e12;
int N;
double x[MAX_N], y[MAX_N], r[MAX_N], dist[MAX_N];
vector<edge> E[MAX_N];

void dijkstra(int s){
    fill(dist, dist+MAX_N, INF); dist[s] = 0.0;
    priority_queue<PD, vector<PD>, greater<PD>> pq; pq.push(PD(0.0, s));

    while(pq.size()){
        PD p = pq.top(); pq.pop();
        int v = p.second;
        if(dist[v]<p.first) continue;
        for(edge e : E[v]){
            if(dist[v]+e.cost<dist[e.to]){
                dist[e.to] = dist[v] + e.cost;
                pq.push(PD(dist[e.to], e.to));
            }
        }
    }
}

int main(){
    int xt, yt; cin >> x[0] >> y[0] >> xt >> yt;
    cin >> N;
    x[N+1] = xt; y[N+1] = yt;
    for(int i=1;i<=N;i++) cin >> x[i] >> y[i] >> r[i];

    for(int i=0;i<=N+1;i++){
        for(int j=i+1;j<=N+1;j++){
            double dist = sqrt(pow(x[j]-x[i], 2)+pow(y[j]-y[i], 2)) - r[i] - r[j];
            if(dist<=(double)0) dist = 0.0;
            edge e1; e1.to = j; e1.cost = dist;
            edge e2; e2.to = i; e2.cost = dist;
            E[i].push_back(e1); E[j].push_back(e2);
        }
    }

    dijkstra(0);

    printf("%.12lf\n", dist[N+1]);
    return 0;
}


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

const double pi = acos(-1.0);

signed main(void){

  double a,b,h,m; cin >> a >> b >> h >> m;
  
  double theta = h+((double)m/60.0);
  
  theta *= ((double)11.0/6.0);
  
  theta *= pi;
  
  int res =  floor(theta/(2.0*pi));
  
  theta -= 2.0*res*pi;
  
  if(false){ 
  printf("%.10f\n", 180*theta/pi);
  }
  
  double ans = sqrt(a*a+b*b-2.0*a*b*cos(theta));
  
  printf("%.20f\n", ans);
  
  return 0;
}

Measured memory_bytes: 4228
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);

    ll ans = 0;
    vector<ll> cnt(N+1);
    for(int i=1; i<=N; i++) {
        for(int j=i; j<=N; j+=i) cnt[j]++;
    }
    for(int i=1; i<=N; i++) ans += cnt[i] * i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81380
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n;
int a[200000];
int main()
{
    scanf("%d" , &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d" , &a[i]);
    }
    vector<int> b;
    for(int i = n - 1; i >= 0; i -= 2)
    {
        b.pb(a[i]);
    }
    for(int i = n % 2; i < n; i+=2)
        b.pb(a[i]);
    for(int i = 0; i < n; i++)
        printf("%d " , b[i]);

    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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 ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    int l = 0, r = 0, num = 0, ans = 101010;
    int cnt[101010];
    while(true) {
        while(num != k && r < n) {
            if(a[r] <= k) {
                if(cnt[a[r]]++==0) ++num;
            }
            ++r;
        }
        if(num != k) break;

        ans = min(ans, r - l);
        if(--cnt[a[l++]]==0) --num;
    }

    if(ans==101010) ans = 0;
    cout << ans << endl;

    return 0;
}


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

int main() {
  vector<int>bingo(9);
  vector<int>tf(9);
  for(int i = 0 ; i < 9 ; i++ ){
    cin >> bingo.at(i);
  }
  int N;
  cin >> N ;
  for(int i = 0; i < N ; i++ ){
    int num;
    cin >> num;
    for(int j = 0; j < 9 ; j++ ){
      if(num == bingo.at(j)){
        tf.at(j) = 1;
      }
    }
  }
  
  if(tf.at(0) == 1 && tf.at(1) == 1  && tf.at(2) == 1){
    cout << "Yes" << endl;
  }else if(tf.at(3) == 1 && tf.at(4) == 1  && tf.at(5) == 1){
    cout << "Yes" << endl;
  }else if(tf.at(6) == 1 && tf.at(7) == 1  && tf.at(8) == 1){
    cout << "Yes" << endl;
  }else if(tf.at(0) == 1 && tf.at(3) == 1  && tf.at(6) == 1){
    cout << "Yes" << endl;
  }else if(tf.at(1) == 1 && tf.at(4) == 1  && tf.at(7) == 1){
    cout << "Yes" << endl;
  }else if(tf.at(2) == 1 && tf.at(5) == 1  && tf.at(8) == 1){
    cout << "Yes" << endl;
  }else if(tf.at(0) == 1 && tf.at(4) == 1  && tf.at(8) == 1){
    cout << "Yes" << endl;
  }else if(tf.at(2) == 1 && tf.at(4) == 1  && tf.at(6) == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
//parshant
 int main(void){
 int a, b, c;

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
}


Measured memory_bytes: 256
function main(input) {
  var n = input[0]-0
  var m = input[1].split(" ");

  var ans = m.sort((a,b)=>a-b);
  while(ans.length>1){
    var newans = [];
    newans.push(ans[0]-0);
    for(var i=1;i<ans.length;i++){
      var tmp = ans[i]%ans[0];
      if(tmp>0) newans.push(tmp);
    }
    ans = newans.sort((a,b)=>a-b);
  }
  console.log(ans[0]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 29888
MAX_NUM = 10**6 + 1
MOD = 10**9+7

fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]

fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1

for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def combinations(n,k):
    if (n < k):
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

X,Y = map(int,input().split())

if (-Y + 2*X) % 3 == 0 and (2*Y - X) %3 == 0:
    x = (-Y + 2*X) // 3
    y = (2*Y - X) // 3
    
    result = combinations(x+y,min(x,y))
    print(int(result % MOD))
    
else:
    print(0)
    


Measured memory_bytes: 129656
#include <stdio.h>

int main(void)
{
	int n, m, max, cs[1024], b[1024], cnt[1024] = {0};
	int i, j;
	
	scanf("%d %d", &n, &m);
	
	for (i = 1; i <= n; i++){
		scanf("%d", &cs[i]);
	}
	
	for (i = 1; i <= m; i++){
		scanf("%d", &b[i]);
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; b[i] < cs[j]; j++){
			
		}
		cnt[j]++;
	}
	
	max = cnt[1];
	for (i = 1; i <= n; i++){
		if (cnt[max] < cnt[i]){
			max = i;
		}
	}
	
	printf("%d\n", max);
	
	return (0);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n; string col, sol = ""; cin >> n;
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  cin >> col;
  int curr = 0;
  while (curr <= n-1) {
    char val = col[curr];
    sol += col[curr];
    while (curr < n && col[curr] == val) curr++;
  }
  cout << sol.size() << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    repi(i,N,0){
        cin >> A[i];
    }
    sort(all(A));
    cout << A.at(N-1) - A.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

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

    sort(all(d));
    if (d[n/2 - 1] < d[n/2]) {
        cout << d[n/2] - d[n/2 - 1] << endl;
        return 0;
    } else {
        cout << 0 << endl;
        return 0;
    }

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m,x,y,i;
    cin>>n>>m>>x>>y;
    int xi[n],yi[m];
    for(i=0;i<n;i++){
    cin>>xi[i];
    }
    for(i=0;i<m;i++){
        cin>>yi[i];
    }
    sort(xi,xi+n);
    sort(yi,yi+m);
    if(x>xi[n-1])xi[n-1]=x;
    if(y<yi[0])yi[0]=y;
    if(xi[n-1]<yi[0]){
    cout<<"No War"<<endl;
    }
    else{
        cout<<"War"<<endl;
    }
    return 0;
}


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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var lst = new List<int>();
        for (int i = 0; i < 5; i++) {
            lst.Add(sc.nextInt());
        }
        int k = sc.nextInt();
        if ((lst.Max() - lst.Min()) > k) {
            WriteLine(":(");
        } else {
            WriteLine("Yay!");
        }
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
from collections import deque
import sys
input = sys.stdin.readline
inf = pow(10, 10)

n, m = map(int, input().split())
a = [inf] * n

edge = [[] for i in range(n)]

for i in range(m):
    l, r, d = map(int, input().split())
    l-=1;r-=1
    edge[l].append((r, d))
    edge[r].append((l, -d))

flag = True
dist = [inf] * n
for i in range(n):
    if not flag: break
    if dist[i] == inf:
        dist[i] = 0
        dq = deque([i])
        while dq:
            now = dq.popleft()
            for e in edge[now]:
                nnode, d = e
                if dist[nnode] == inf:
                    dist[nnode] = dist[now] + d
                    dq.append(nnode)
                else:
                    if dist[nnode] != dist[now] + d:
                        flag = False
                        break
if flag:
    print('Yes')
else:
    print('No')


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}


void solve(int &test) {
	int n;
	cin >> n;

	int cur, pre, ans = 0;
	for(int i = 0; i < n; i++) {
		cin >> cur;
		if(i) {
			ans += max(pre-cur, 0LL);
			cur = max(cur, pre);
		}
		pre = cur;
	}

	cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

   
    int t = 1;
    // cin >> t;

    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= t; ++i){
        solve(i); 
    }

    cerr << time(start);
    return 0;
}

Measured memory_bytes: 3808
def getanswer(num, ops, total):
    idx = len(ops)
    if idx == 3:
        return ops if total == 7 else None
    return getanswer(num, ops + "+", total + num[idx+1]) or \
        getanswer(num, ops + "-", total - num[idx+1])


def main():
    num = [int(x) for x in input()]
    ops = getanswer(num, "", num[0])
    retval = ""
    for i in range(3):
        retval += str(num[i]) + ops[i]
    retval += str(num[3]) + "=7"
    print(retval)


if __name__ == "__main__":
    main()


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

int main(void){
	int e;
	while(1){
		cin >> e;
		if(!e) break;
		int ans = 1000001;
		for(int z = 0; z*z*z <= e; ++z){
			for(int y = 0; z*z*z+y*y <= e; ++y){
				ans = min(ans,e-(z*z*z+y*y)+y+z);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2988
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
#include <climits>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const int mod = 998244353;

ll a[600000];

int s = 1;
vector<ll> dat, lazy;

void init(int n_) {
	while (s < n_)s *= 2;
	dat.resize(2 * s - 1), lazy.resize(2 * s - 1);
}

void eval(int k, int l, int r) {
	if (lazy[k]) {
		dat[k] = lazy[k] * a[k];
		if (r - l > 1) {
			lazy[2 * k + 1] = lazy[k];
			lazy[2 * k + 2] = lazy[k];
		}
		lazy[k] = 0;
	}
}

void add(int a, int b, int x, int k = 0, int l = 0, int r = s) {
	eval(k, l, r);
	if (r <= a || b <= l)return;
	if (a <= l && r <= b) {
		lazy[k] = x;
		eval(k, l, r);
		return;
	}
	add(a, b, x, 2 * k + 1, l, (l + r) / 2);
	add(a, b, x, 2 * k + 2, (l + r) / 2, r);
	dat[k] = dat[2 * k + 1] + dat[2 * k + 2];
}

ll query(int a, int b, int k = 0, int l = 0, int r = s) {
	if (r <= a || b <= l)return 0;
	eval(k, l, r);
	if (a <= l && r <= b)return dat[k];
	ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
	ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
	return vl + vr;
}

int n, q;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n >> q;
	init(n);
	ll p = 1;
	for (int i = n - 1; i >= 0; i--) {
		a[i + s - 1] = p;
		p = (p * 10) % mod;
	}
	for (int i = s - 2; i >= 0; i--)a[i] = a[i * 2 + 1] + a[i * 2 + 2];
	add(0, n, 1);
	for (int i = 0; i < q; i++) {
		int l, r, x; cin >> l >> r >> x;
		add(l - 1, r, x);
		cout << query(0, n) % mod << endl;
	}
}

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

int main(){
  int N;
  cin>>N;
  int p[N];
  int HIGHCOST=0,sum=0;
  for(int i=0;i<N;i++){
    cin>>p[i];
    HIGHCOST=max(HIGHCOST,p[i]);
    sum=sum+p[i];
  }
  cout<<sum-HIGHCOST/2<<endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
  var list = input.split(" ");
  var A = parseInt(list[0]);
  var B = parseInt(list[1]);
  
  if (A == B) console.log(A+B);
  else if (A > B) console.log(2*A-1);
  else console.log(2*B-1);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
int k,a[100];

cin >>k;

for(int i=0;i<k;i++){
cin >>a[i];
}

for(int i=k-1;i>=0;i--){
if(i!=k-1)cout <<" ";
cout <<a[i];
}
cout <<endl;

return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define MAX 505
#define MOD 1000000007

typedef long long ll;

int a[MAX] = {0};
int b[MAX] = {0};
int c[MAX] = {0};
int d[MAX] = {0};
int ans = 0;
int n, m, q;

void calc(int n, vector<int> a_v, int s)
{
    if (n == 0) {
        int tmp = 0;
        for (int i = 0; i < q; i++) {
            if (a_v[b[i]-1] - a_v[a[i]-1] == c[i]) tmp += d[i];
            if (tmp > ans) ans = tmp;
        }
        return;
    }

    for (int i = s; i <= m; i++) {
        vector<int> a_v2 = a_v;
        a_v2.push_back(i);
        calc(n-1, a_v2, i);
    }
}


int main(int, char**)
{
    cin >> n >> m >> q;

    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vector<int> a_v;
    calc(n, a_v, 1);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3624
def sign(x):
    return (x > 0) - (x < 0)


def main():
    _ = int(input())
    a = map(int, input().split())
    ans = []
    arr = []
    state = 0
    for an in a:
        if len(arr) < 2:
            arr.append(an)
        else:
            state += (arr[-1] - arr[-2])
            if state == 0:
                arr.append(an)
            else:
                current = an - arr[-1]
                if current == 0 or sign(state) == sign(current):
                    arr.append(an)
                else:
                    ans.append(arr)
                    arr = [an]
                    state = 0
    ans.append(arr)

    print(len(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 24192
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	unordered_map<string, ll> mp;
	f(i, 0, n)
	{
		string temp;
		cin >> temp;
		sort(all(temp));
		if (mp.find(temp) == mp.end())
			mp[temp] = 1;
		else
			mp[temp] += 1;
	}
	ll ans = 0;
	for (auto i = mp.begin(); i != mp.end(); i++)
	{
		auto it = *i;
		ans += (it.second) * (it.second - 1) / 2;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 10660
#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
typedef long long ll;
cpnst ll mod=924844033,g=5;
ll qpow(ll x,ll k){ll r=1;for(;k;k>>=1,(x*=x)%=mod)if(k&1)(r*=x)%=mod;return r;}
int rev[1111111],V;
void resiz(int _v)
{
	V=_v;
	register int i;
	for(i=1;i<V;i++)rev[i]=(rev[i>>1]>>1)|((i&1)*(V>>1));
}
int wi[1111111];
void swap(register ll&x,register ll&y)
{x^=y^=x^=y;}
void NTT(ll*x,int op)
{
	register int i,ii,iii;
	for(i=1;i<V;i++)if(rev[i]>i)swap(x[i],x[rev[i]]);
	wi[0]=1;
	for(i=1;i<V;i<<=1)
	{
		register int w=qpow(g,(mod-1)/(i<<1));
		if(op<0)w=qpow(w,mod-2);
		for(register int*p=wi+1;p<wi+i;p++)*p=*(p-1)*1ll*w%mod;
		for(ii=0;ii<V;ii+=(i<<1))
			for(iii=0;iii<i;iii++)
			{
				int px=ii+iii,py=px+i;
				ll vx=x[px]+wi[iii]*x[py],vy=x[px]-wi[iii]*x[py];
				x[px]=vx%mod,x[py]=vy%mod; 
			}
	}ll t=op>0?1:qpow(V,mod-2);
	for(i=0;i<V;i++)x[i]=(x[i]+mod)*t%mod;
}
#include<vector>
int n;
std::vector<int>v[222222];
int cnt[1111111],siz[1111111];
void dfs(int p=1,int f=0)
{
	siz[p]=1;
	for(auto t:v[p])if(t^f)dfs(t,p),siz[p]+=siz[t],cnt[siz[t]]++;
	if(siz[p]^n)cnt[n-siz[p]]++;
}
ll Tp[1111111],Tg[1111111];
void mul(ll*x,ll*y,int CyC)
{
	resiz(CyC);
	register int i;
	for(i=0;i<(CyC>>1);i++)Tp[i]=x[i],Tg[i]=y[i];
	for(i=CyC>>1;i<CyC;i++)Tp[i]=Tg[i]=0;
	NTT(Tp,1),NTT(Tg,1);
	for(i=0;i<CyC;i++)(Tp[i]*=Tg[i])%=mod;
	NTT(Tp,-1);
	for(i=0;i<(CyC>>1);i++)x[i]=Tp[i];
}
ll fac[1111111],inv[1111111],A[1111111],B[1111111];
ll C(ll n,ll r){return fac[n]*inv[r]%mod*inv[n-r]%mod;}
void solve()
{
	register int i;
	for(i=fac[0]=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
	for(i=n,inv[i]=qpow(fac[i],mod-2);i;i--)inv[i-1]=inv[i]*i%mod;
	for(i=0;i<=n;i++)A[i]=fac[n-i]*cnt[n-i]%mod,B[i]=inv[i]%mod;
	mul(A,B,524288);
	for(i=1;i<=n;i++)printf("%lld\n",(n*C(n,i)+mod-A[n-i]*inv[i]%mod)%mod);
}
int main()
{
	scanf("%d",&n);
	register int i;
	for(i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y),v[x].push_back(y),v[y].push_back(x);
	}dfs(),solve();
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 2 == 0) continue;
        int cnt = 0;
        for (int j = 1; j * j <= i; ++j) {
            if (i % j == 0) {
                if (j * j == i)
                    ++cnt;
                else
                    cnt += 2;
            }
        }
        if (cnt == 8) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
import math
f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

px = [p.real for p in f]
ox = (max(px) + min(px)) / 2.0

py = [p.imag for p in f]
oy = (max(py) + min(py)) / 2.0

fo = ox + oy * 1j

ss = 0.0
for i in range(len(f)):
    if i == len(f)-1:
        j = 0
    else:
        j = i + 1
    a = abs(f[i]-fo)
    b = abs(f[j]-fo)
    c = abs(f[j]-f[i])
    z = (a + b + c) / 2.0
    s = math.sqrt(z*(z-a)*(z-b)*(z-c))
    ss += s
print("%.6f" % ss)

Measured memory_bytes: 7668
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a,b;
    cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;
static const double PI = 3.141592653589793;

long long modpow(long long x, long long n, long long mod = 0) {
  if (mod == 0) {
    long long res=1;
    while (n > 0) {
      if (n%2 == 1) {
        res = ( res*x );
      }
      x = (x*x);
      n /= 2;
    }
    return res;
  }

  long long res=1;
  while (n > 0) {
    if (n%2 == 1) {
      res = ( res*x ) % mod;
    }
    x = (x*x) % mod;
    n /= 2;
  }
  return res;
}

long long modinverse(long long x, long long mod) {
  // mod must be prime number.
  return modpow(x, mod-2, mod);
}

// メモリ不足に注意！
vector<long long> vecmodfact(2,1);
long long modfact(long long n, long long mod) {
  std::size_t n_size_t = n;
  if (vecmodfact.size()-1 >= n_size_t) return vecmodfact.at(n);
  std::size_t i=vecmodfact.size();
  vecmodfact.resize(n+1);
  for (; i<=vecmodfact.size()-1; i++) {
    vecmodfact.at(i) = vecmodfact.at(i-1)*i % mod;
  }
  return vecmodfact.at(n);
}

long long modcomb(long long m, long long n, long long mod){
  if (m < n || n < 0) return 0;
  if (n == 0 || n == m) return 1;
  long long ans = modfact(m,mod) * modinverse(modfact(n,mod), mod) % mod;
  ans = ans * modinverse(modfact(m-n,mod), mod) % mod;
  return ans;
}

map<int, int> prime_factors(long long n) {
  map<int, int> res;
  if (n <= 1) return res;
  for (int i=2; i*i<=n; i++) {
    while (n%i==0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) ++res[n];
  return res;
}

int main() {
  int x,y;
  cin >> x >> y;
  if (y%2 == 1) {
    cout << "No"  << endl;
    return 0;
  }

  if (y < 2*x || 4*x < y) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
	int A = 0;
	int B = 0;
	int C = 0;
	int X = 0;
	int Y = 0;
	int cost = 0;
	cin >> A >> B >> C >> X >> Y;
	
	int min = A * X + B * Y;
	int n = min;
	int temp = min;
	int x = 0, y = 0, z = 0;
	for ( int Z = 1;X > 0 || Y > 0; Z++ ) {
		if ( X > 0 ) {
			n -= A;
			X--;
		}
		
		if ( Y > 0 ) {
			n -= B;
			Y--;
		}
		
		temp = n + ( 2 * C * Z );
		if ( temp < min ) {
			min = temp;
			x = X, y = Y, z = Z;
		}
	} // for
	
	cout << min;
} // int main()

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; ++i) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; ++i) {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right){
    if(left+1 < right){
        int mid = (left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){
    int A[MAX], n;
    cnt = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    mergeSort(A,n,0, n);

    for (int i = 0; i < n; ++i) {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}


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




int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> A;
  int64_t ans = 0LL;
  int a,now;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    A.push_back(a);
  }
  // if (N == 1)
  // {
  //   int aa = A.at(0);
  //   for (int i = 0; i < M; i++)
  //   {
  //     aa = aa / 2;
  //   }
  //   cout << aa << endl;
  //   return 0;
  // }
  sort(A.begin(), A.end());

  for (int i = 0; i < M; i++)
  {
    now = A.at(N - 1) / 2;
    A.pop_back();
    A.insert(lower_bound(A.begin(),A.end(), now), now);
  }

  for (int i : A)
  {
    ans += i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n), ans;
  rep(i, n) {
    cin >> a.at(i);
  }
  REP(i, n) {
    if(n % 2 == 0) {
      if(i % 2 == 1) ans.push_back(a.at(i-1));
      else ans.insert(ans.begin(), a.at(i-1));
    }
    else {
      if(i % 2 == 0) ans.push_back(a.at(i-1));
      else ans.insert(ans.begin(), a.at(i-1));
    }
  }
  rep(i, n) cout << ans.at(i) << " ";
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int N = 55;
const int M = 110;
const int K = 5010;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
int n, m, money;
struct edge{
    int v, cost, tim, nxt;
}e[M<<2];
int tot, head[N], c[N], d[N];
ll dis[N][K];
struct node{
    int u, cst;
    ll dis;
    node(int u = 0, int cst = 0, ll dis = 0):u(u),cst(cst),dis(dis){}
    bool operator<(const node& rh)const{
        return dis > rh.dis;
    }
};
void init(void){
    tot = 0; memset(head, -1, sizeof head);
}
void addedge(int u, int v, int a, int b){
    e[tot] = (edge){v, a, b, head[u]}; head[u] = tot++;
    e[tot] = (edge){u, a, b, head[v]}; head[v] = tot++;
}
void dijkstra(int s){
    for (int i = 1; i <= n; ++i){
        for (int j = 0; j < K; ++j) dis[i][j] = INF;
    }
    for (int i = 0; i <= min(money, K-1); ++i){
        dis[s][i] = 0;
    }
    priority_queue<node> q;
    q.push(node(s, min(money, K-1), 0));
    while (!q.empty()){
        node p = q.top(); q.pop();
        int u = p.u, cost = p.cst;
        ll ds = p.dis;
        if (ds != dis[u][cost]) continue;
        for (int i = head[u]; i != -1; i = e[i].nxt){
            int v = e[i].v, cst = e[i].cost, tim = e[i].tim;
            if (cost >= cst && dis[v][cost-cst] > dis[u][cost]+tim){
                dis[v][cost-cst] = dis[u][cost]+tim;
                q.push(node(v, cost-cst, dis[v][cost-cst]));
            }
        }
        if (cost+c[u] < K){
            if (dis[u][cost+c[u]] > dis[u][cost]+d[u]){
                dis[u][cost+c[u]] = dis[u][cost]+d[u];
                q.push(node(u, cost+c[u], dis[u][cost+c[u]]));
            }
        }
    }
}
int main(void){
    IOS;
    init();
    cin >> n >> m >> money;
    for (int i = 1; i <= m; ++i){
        int u, v, a, b; cin >> u >> v >> a >> b;
        addedge(u, v, a, b);
    }
    for (int i = 1; i <= n; ++i){
        cin >> c[i] >> d[i];
    }
    dijkstra(1);
    for (int i = 2; i <= n; ++i){
        ll t = INF;
        for (int j = 0; j < K; ++j){
            t = min(t, dis[i][j]);
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 9308
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
std::vector<int> compress(std::vector<int> D){
    std::map<int,int> G;
    std::vector<int> E,r;
    int s=D.size();
    for(int i=0;i<s;i++){
        E.push_back(D[i]);
    }
    sort(E.begin(),E.end());
    int t=0;
    for(int i=0;i<s;i++){
        if(i!=0 && E[i]!=E[i-1]){
            t++;
        }
        G[E[i]]=t;
    }
    for(int i=0;i<s;i++){
        r.push_back(G[D[i]]);
    }
    return r;
}
signed main(void){
    const int MEM = 114514;
    int N;
    int a[MEM],b[MEM];
    cin >> N;
    REP(i,N-1){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    vector<int> G[MEM],child[MEM];
    int color[MEM],parent[MEM];
    int kai[MEM]={};
    bool visited[MEM] = {};
    REP(i,N-1){
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
        kai[a[i]]++;
        kai[b[i]]++;
    }
    
    int root=0;
    REP(i,N){
        if(kai[i]==1){
            root=i;
            break;
        }
    }
    //cout << root << endl;
    queue<int> P;
    P.push(root);
    while(!P.empty()){
        int q = P.front();
        P.pop();
        visited[q]=1;
        REP(i,G[q].size()){
            if(!visited[G[q][i]]){
                P.push(G[q][i]);
                child[q].push_back(G[q][i]);
                parent[G[q][i]]=q;
            }
        }
    }
    parent[root]=-1;
    
    /*REP(i,N){
        cout << i << ": ";
        REP(j,child[i].size()){
            cout << child[i][j] << " ";
        }cout << endl;
    }*/
    
    P.push(root);
    color[root]=0;
    while(!P.empty()){
        int q = P.front();
        P.pop();
        int now=0;
        if(color[q]==now)now++;
        REP(i,child[q].size()){
            P.push(child[q][i]);
            color[child[q][i]]=now;
            now++;
            if(color[q]==now)now++;
        }
    }
    vector<int> Ans;
    REP(i,N-1){
        if(a[i]==parent[b[i]]){
            Ans.push_back( color[b[i]]+1);
        }else if(b[i]==parent[a[i]]){
            Ans.push_back( color[a[i]]+1);
        }
    }
    Ans=compress(Ans);
    int K = 0;
    REP(i,Ans.size()){
        K=max(K,Ans[i]+1);
    }
    cout << K << endl;
    REP(i,Ans.size()){
        cout << Ans[i]+1 << endl;
    }
    return 0;
}



Measured memory_bytes: 19572
open Printf
open Scanf

let () =
  let s = read_line () and t = read_line () in
  let n = String.length s in
  let m = String.length t in
  let next = Array.make_matrix (n * 2) 26 ~-1 in
  for i = n*2-2 downto 0 do
    for j = 0 to 25 do
      if Char.code s.[i mod n] - Char.code 'a' = j then
        next.(i).(j) <- i
      else
        next.(i).(j) <- next.(i+1).(j)
    done;
  done;
  Array.init m (fun i -> t.[i])
  |> Array.fold_left (fun (i, ans) c ->
    match ans with
    | Some ans ->
        let c' = Char.code c - Char.code 'a' in
        let i' = next.(i).(c') in
        if i' <> -1 then
          ((i' + 1) mod n, Some (i'+1-i+ans))
        else
          (0, None)
    | None -> (0, None)
  ) (0, Some 0)
  |> snd
  |> (fun x -> match x with Some x -> x | None -> ~-1)
  |> printf "%d\n"


Measured memory_bytes: 50940
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		
		public static void Compute(TextReader reader, TextWriter writer)
		{
			while (true)
			{
				var t = reader.ReadLine();
				if ("-" == t)
				{
					break;
				}
				var sb = new StringBuilder(t);
				
				var n = int.Parse(reader.ReadLine());
				
				for (int i = 0; i < n; i++)
				{
					var h = int.Parse(reader.ReadLine());
					
					for (int j = 0; j < h; j++)
					{
						var c = sb[0];
						sb.Remove(0, 1);
						sb.Append(c);
					}
				}
				writer.WriteLine(sb.ToString());
			}
		}
	}
}

Measured memory_bytes: 7376
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdlib>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,j,k) for(int i=j;i<(int)(k);++i)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();++i)
#define all(x) (x).begin(),(x).end()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 99999999;
const double EPS = 1e-9;

struct UnionFind
{
    vi par,rank;
    UnionFind(int n){
        par.resize(n),rank.resize(n,0);
        rep(i,n) par[i]=i;
    }

    int find(int x){
        return par[x]==x ? x : par[x]=find(par[x]);
    }

    void unite(int x, int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return find(x)==find(y);
    }
};

struct Edge
{
    int s,d,c;
    Edge(int s, int d, int c) : s(s),d(d),c(c){}
    bool operator<(const Edge &x) const{
        return c < x.c;
    }
};

int s,d,in;

int main()
{
    while(cin>>s>>d,s&&d){
        vector<Edge> ve;
        rep(i,s)rep(j,d){
            cin >> in;
            ve.pb(Edge(i,j+s,in));
        }
        rep(i,d-1)REP(j,i+1,d){
            cin >> in;
            ve.pb(Edge(i+s,j+s,in));
        }

        UnionFind uf(s+d);
        sort(all(ve));
        REP(i,1,s) uf.unite(0,i);

//        rep(i,ve.size()) cout << ve[i].c << endl;
        int ans = 0;
        rep(i,ve.size()){
            if(!ve[i].c) continue;
            if(uf.same(ve[i].s,ve[i].d)) continue;
            ans+=ve[i].c;
            uf.unite(ve[i].s,ve[i].d);
            }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
// Main maut ko takiya, aur kafan ko chadaar banakar audhta hoon!

#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define len(a) ll(a.size())
#define endl "\n"
#define rep(i,n) for(int i = 0; i < n; i++)

#define vll vector< ll >
#define pll pair< ll, ll >
#define vvll vector< vll >
#define vpll vector< pll >

#define umsll unordered_map<string,ll>
#define umll unordered_map<ll,ll>
#define sll set<ll>
#define minpqll priority_queue<ll,vector<ll>,greater<ll>>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " : " << arg1 << endl;
    }

    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

const double pi=3.141592653589793238462643383279502884197169399375105820974944;
const double e=2.71828182845904523536028747135266249775724709369995;
const ll mod=1e9+7;
const ll inf=2e18;
const ll ninf=-2e18;
const ll nax=1e6;

ll power(ll x, ll y, ll mod)
{
    ll ans=1;
    x=x%mod;
    while(y)
    {
        if(y&1)
            ans=(x*ans)%mod;

        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}

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

    time_t t1, t2;
    t1 = clock();

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

    if(a+b >= c) cout<<"Yes";
    else cout<<"No";




    t2 = clock();
    cerr << endl << "time taken: " << t2 - t1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, ans = 0;
  cin >> N;
  for (long long i = 0; i < N+1; i++) {
    if (i*i <= N) {
      ans = i*i;
    }
  }
  cout << ans;
}

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

using namespace std;

int main()
{
	string s;
	string ans;
	cin >> s;
	int n = s.size();

	for (int i = 0; i < n - 8; i++)
	{
		ans = ans + s[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		if (a < b) {
			repeat(a, b);
		}else {
			repeat(b, a);
		}

	}

	private static void repeat(int a, int b) {
		for (int i = 0; i < b; i++) {
			System.out.print(a);
		}
	}

}


Measured memory_bytes: 35676
// 解説を読んだ　難しい
#include<iostream>
using namespace std;

int dp[3000][3000] = {};
const int mod = 1e9+7;

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++)  dp[0][i] = 1;
    auto f = [=](int i, int j, int k)->int{
        return (dp[i][k] - (j==0 ? 0 : dp[i][j-1]) + mod)%mod;
    };
    for(int i = 1; i < n; i++){
        for(int j = 1; j < n; j++)  dp[i-1][j] = (dp[i-1][j]+dp[i-1][j-1])%mod;
        for(int j = 0; j <= n-1-i; j++){
            if(s[i-1] == '<') dp[i][j] = f(i-1, 0, j);
            if(s[i-1] == '>') dp[i][j] = f(i-1, j+1, n-1);
        }
    }
    cout << dp[n-1][0] << endl;
    return 0;
}

Measured memory_bytes: 35456
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define ll long long
#define INF 1000000000
#define clr(x) memset(x,0,sizeof(x))
using namespace std;

inline int read()
{
	register int ret=0,c=getchar();
	while(!isdigit(c))c=getchar();
	while(isdigit(c))ret=ret*10+c-'0',c=getchar();
	return ret;
}

ll p,a[2],n,ans,temp;
ll C[55][55];

void pre()
{
	for(int i=0;i<=50;i++)
		for(int j=0;j<=i;j++)
		{
			if(i==j||j==0){C[i][j]=1;continue;}
			C[i][j]=C[i-1][j-1]+C[i-1][j];
		}
}

int main()
{
	pre();
	n=read();p=read();
	for(int i=1;i<=n;i++)a[read()%2]++;
	for(int i=0;i<=a[0];i++)temp+=C[a[0]][i];
	for(int i=p;i<=a[1];i+=2)ans+=C[a[1]][i];
//	printf("%d %d\n",a[0],a[1]);
	printf("%lld\n",temp*ans);
	return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque
import copy
import math
def main():
    N, K = map(int, input().split())
    a = [int(i) for i in input().split()]
    A = [0] * (N + 1)
    if K >= 41:
        for i in range(1, N+1):
            if i > 1:
                print(' ', end='')
            print(N, end='')
        print()
        sys.exit()
    for i in range(1, N+1):
        A[i] = a[i - 1]
    for _ in range(K):
        count = [0] * (N + 1)
        for i in range(1, N+1):
            left_d = max(math.ceil(i - A[i]), 1)
            right_d = min(math.floor(i + A[i]), N)
            count[left_d] += 1
            if right_d + 1 <= N:
                count[right_d + 1] -= 1
        for i in range(1, N+1):
            count[i] += count[i - 1]
        A = copy.copy(count)
    
    for i in range(1, N+1):
        if i > 1:
            print(' ', end='')
        print(A[i], end='')
    print()


if __name__ == '__main__':
    main()


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

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


ll n,d;
cin>>n>>d;


ll ans=0;

while(n--){
  ll a,b;
  cin>>a>>b;
  ll k=(a*a+b*b);

  if(k<=d*d){
    ans++;
  }

}

cout<<ans;



}










Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("input.txt", "r", stdin);
    int a, b, c;
    cin >> a >> b;
    if(((a * b) * 1) % 2 > 0 || ((a * b) * 2) % 2 > 0 || ((a * b) * 3) % 2 > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
using namespace std;
INT n, m, a, b, c[1010][1010];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>b>>a;
    for(int i = 0 ; i < n ; i++, a-- )
        for(int j = 0 ; j < m ; j++ )
            if( j < b ) c[i][j] = a>0?1:0;
            else c[i][j] = a>0?0:1;
    for(int i = 0 ; i < n ; i++ )
    {
        for(int j = 0 ; j < m ; j++ )
            cout<<c[i][j];
        cout<<endl;
    }
    
}

Measured memory_bytes: 9088