akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
struct edge{
	ll to;
	ll cost;
};
ll N,M,K,S;
ll Pa,Q,C[100000],A[200000],B[200000];
bool zon[100000];
bool terr[100000];
queue<ll> q[2];
vector<edge> G[100000];
ll b=0;
ll d[100000];
vector<ll> hen[100000];
const ll INF = 0xffffffffff;
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&N,&M,&K,&S,&Pa,&Q);
	for(ll i=0;i<K;i++){
		scanf("%lld",&C[i]);
		C[i]--;
		zon[C[i]]=1;
		terr[C[i]]=1;
		q[b].push(C[i]);
	}
	for(ll i=0;i<M;i++){
		scanf("%lld%lld",&A[i],&B[i]);
		A[i]--;
		B[i]--;
		hen[A[i]].push_back(B[i]);
		hen[B[i]].push_back(A[i]);
	}
	for(ll i=0;i<S;i++){
		while(q[b].size()){
			ll now=q[b].front();
			q[b].pop();
			for(ll j=0;j<hen[now].size();j++){
				if(!terr[hen[now][j]]){
					terr[hen[now][j]]=1;
					q[!b].push(hen[now][j]);
				}
			}
		}
		b=!b;
	}
	for(ll i=0;i<M;i++){
		if(!zon[A[i]]&&!zon[B[i]]){
			if(terr[B[i]]){
				G[A[i]].push_back( (edge){B[i],Q} );
			}
			else{
				G[A[i]].push_back( (edge){B[i],Pa} );
			}
			if(terr[A[i]]){
				G[B[i]].push_back( (edge){A[i],Q} );
			}
			else{
				G[B[i]].push_back( (edge){A[i],Pa} );
			}
		}
	}
	fill(d,d+N,INF);
	d[0]=0;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,0));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		ll x=p.second;
		if(d[x]<p.first) continue;
		for(ll i=0;i<G[x].size();i++){
			edge e=G[x][i];
			if(d[e.to]>d[x]+e.cost){
				d[e.to]=d[x]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	if(terr[N-1]) d[N-1]-=Q;
	else d[N-1]-=Pa;
	printf("%lld\n",d[N-1]);
}

Measured memory_bytes: 28904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
ll val1[100010];
ll val2[100010];
ll sum1[100010];
ll sum2[100010];
int main(){
    int n;cin >> n;
    ll C;cin >> C;
    vector<l_l> p(n);
    for(int i=0;i<n;i++) cin >> p[i].first >> p[i].second;
    ll sum=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        sum+=p[i].second;
        val1[i]=sum-p[i].first;
        if(i==0) sum1[i]=sum-p[i].first;
        else sum1[i]=max(sum1[i-1],sum-p[i].first);
        chmax(ans,sum-p[i].first);
    }
    sum=0;
    for(int i=n-1;i>=0;i--){
        sum+=p[i].second;
        val2[i]=sum-(C-p[i].first);
        if(i==n-1) sum2[i]=sum-(C-p[i].first);
        else sum2[i]=max(sum2[i+1],sum-(C-p[i].first));
        chmax(ans,sum-(C-p[i].first));
    }
    for(int i=0;i<n-1;i++){
        ll a=val1[i];
        ll b=sum2[i+1]-p[i].first;
        chmax(ans,a+b);
    }
    for(int i=n-1;i>0;i--){
        ll a=val2[i];
        ll b=sum1[i-1]-(C-p[i].first);
        chmax(ans,a+b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result}

const main = ()=>{
  new Date(sin()) <= new Date('2019/04/30') ? out('Heisei') : out('TBD');
}
main();

Measured memory_bytes: 7372
data = input().split()

N, k = int(data[0]), int(data[1])

tab = []

data = input().split()
for i in range(N):
    tab.append(int(data[i]) - 1)


parcour = []
tmp = [0] * N

position = 0

while (tmp[position] == 0):
    parcour.append(position)
    tmp[position] = 1
    position = tab[position]
i = 0
while parcour[i] != position:
    i+= 1

sizeCycle = len(parcour) - i 

#print (parcour)
if (k < len(parcour)):
    print(parcour[k] + 1)
else:
    print(parcour[i + ((k - i) % sizeCycle)] + 1)
    


Measured memory_bytes: 35184
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1020
struct node
{
  int key;
  struct node *left, *right;
};
  
struct node T[MAX];

struct node *newNode(int item)
{
  struct node *temp =  (struct node *)malloc(sizeof(struct node));
  temp->key = item;
  temp->left = temp->right = NULL;
  return temp;
} 

void Preorder(struct node* root)
{
  

  if (root == NULL)
    return;
 

  printf(" ");
  printf("%d",root->key);
 
  Preorder(root->left); 
 
   
  Preorder(root->right);
} 

void inorder(struct node *root)
{
 

  if (root != NULL)
    {

      inorder(root->left);

      printf(" ");
      printf("%d", root->key);
     
      inorder(root->right);
    }
}
  

struct node* insert(struct node* node, int key)
{
    
  if (node == NULL) return newNode(key);
 
   
  if (key < node->key)
    node->left  = insert(node->left, key);
  else if (key > node->key)
    node->right = insert(node->right, key);   
 
   
  return node;
}
  
struct node* search(struct node* root, int key)
{
    // Base Cases: root is null or key is present at root
    if (root == NULL || root->key == key)
       return root;
    
    // Key is greater than root's key
    if (root->key < key)
       return search(root->right, key);
 
    // Key is smaller than root's key
    return search(root->left, key);
}


int main()
{
  int T[MAX];
  int z,n,i,j,a,hit;
  int count=0;
  char str[7];
  
  struct node *root = NULL;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0){
      scanf("%d",&z);
      
      if(i==0)
	root = insert(root,z);
      else insert(root,z);}

    if(strcmp(str,"find")==0){
      scanf("%d",&a);
     
      if(search(root,a))
	
     printf("yes\n");
     
	else printf("no\n");
      }
 
    if(strcmp(str,"print")==0){
     
      inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }}
  free(root);
  return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;
  int N = s.size();
  bool atcoder = true;
  for (int i = 0; i < N; i++) {
    if (s.at(i) != t.at(i)) {
      atcoder = false;
    }
  }
  
  if (atcoder) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int H,W;
    string S;
    cin >> H >> W;
    REP(i,H){
        cin >> S;
        cout << S << endl;
        cout << S << endl;
    }
    
    return 0;
}


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

using namespace std;

void solve1() {
	int A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+')
		cout << A + B << endl;
	else
		cout << A - B << endl;

}

int main() {
	solve1();
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 1e5+5;
const ll M = 11092019;

int main() {
	string s,t;
	cin >> s >> t;
	
	int n = s.size();
	int m = t.size();
	
	bool f = 1;
	for(int i = 0;i < n;++i){
		if(s[i] != t[i]) f = 0;
	}
	
	if(f && n == m-1) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 3628
using System;

class _0042 {
    static readonly int N = 1000;
    static readonly int W = 1000;
    public static void Main() {
        int w, n, k = 0;
        int mc, mw;
        int[][] c = new int[N + 1][];
        int[,,] dp = new int[N + 1, W + 1, 2];

        c[0] = new int[1] { 0 };
        for (int i = 0; i <= N; i++)
            for (int j = 0; j <= W; j++) {
                dp[i, j, 0] = 0;
                dp[i, j, 1] = 0;
            }
        while (true) {
            w = int.Parse(Console.ReadLine());
            if (w == 0) break;
            n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++)
                c[i] = Array.ConvertAll(Console.ReadLine().Split(','), s => int.Parse(s));
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= w; j++)
                    if (j - c[i][1] >= 0 && dp[i - 1, j - c[i][1], 0] + c[i][0] > dp[i - 1, j, 0]) {
                        dp[i, j, 0] = dp[i - 1, j - c[i][1], 0] + c[i][0];
                        dp[i, j, 1] = dp[i - 1, j - c[i][1], 1] + c[i][1];
                    } else {
                        dp[i, j, 0] = dp[i - 1, j, 0];
                        dp[i, j, 1] = dp[i - 1, j, 1];
                    }
            Console.WriteLine("Case {0}:", ++k);
            mc = dp[n, w, 0]; mw = dp[n, w, 1];
            for (int i = 1; i < w; i++)
                mw = (dp[n, i, 0] == mc && mw > dp[n, i, 1]) ? dp[n, i, 1] : mw;
            Console.WriteLine(mc);
            Console.WriteLine(mw);
        }
    }
}

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

int main(){
  string S;
  cin>>S;
  
  bool ans=false;
  if(S.at(0)==S.at(1) && S.at(0)==S.at(2) && S.at(0)==S.at(3)) ans=false;
  else if(S.at(0)==S.at(1) && S.at(2)==S.at(3)) ans=true;
  else if(S.at(0)==S.at(2) && S.at(1)==S.at(3)) ans=true;
  else if(S.at(0)==S.at(3) && S.at(2)==S.at(1)) ans=true;
  
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
    long long a, b, n;
    long long ans;
    cin >> a >> b >> n;
    long long x = min(b - 1, n);
    ans = (a*x)/b - a*(x/b);
    cout << ans << endl;
    return 0; 
}

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

using namespace std;

int find(string a,string d[],int n){
   int *result;
    int *k;
    int count = 0;
    for (int i = 0; i <= n - 1; i++) {

         if (d[i] == a) {

            k[count] = i;
            count++;
          }

    }
    return count;
    
} 
typedef pair <string, int> psi;

map <psi, int> id;

bool compare(psi x, psi y) {
  if(x.first == y.first) return x.second > y.second;
  return x.first < y.first;
}
/*int f(){
int index;
    int 
    for(i=0;i<n;++i){
        index=find(s[i],q,n);
        cout<<index<<endl;
        for(j=0;j<n;++j){
            if(s[i]==q[j]){
                cout<<j+1<<endl;
                break;
            }
            continue;
        
        
    }
    }
}
*/
int main() {

  int n; cin >> n;
  vector <psi> v;
  vector <psi> save;
  for(int i = 1; i <= n; i++) {
    string x; cin >> x;
    int p; cin >> p;
    save.push_back({x, p});
    v.push_back({x, p});
    id[{x, p}] = i;
  }
  sort(v.begin(), v.end(), compare);
  int l = 1;
  for(auto c : v) {
    cout << id[c] << '\n';
  }
}

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

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

    vector<int> v(n);

    for(auto& x : v)  cin >> x;

    int ret = 1e9;

    for(int i = 0, j = k-1; j < n; ++i, ++j){
        ret = min(ret, v[j] - v[i] + abs(v[i]));
        ret = min(ret, v[j] - v[i] + abs(v[j])); }

    cout << ret << endl;

    return 0; }


Measured memory_bytes: 640
/*
**   Contest : Educational DP Contest
**   Problem : D - Knapsack 1
**
**    Author : Dhiraj Govindvira
**      Date : 05-Jun-2020 ~ Friday
**      Time : 02:59:49 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n, w;
    cin>>n>>w;

    vector<pair<ll,ll>> ks(n);
    cin>>ks;

    vector<ll> dp(w+1);
    for(ll i=1; i<=n; i++)
    {
        ll W = ks[i-1].first;
        ll V = ks[i-1].second;

        for(ll j=w; j>=0; j--)
        {
            if(j >= W) {
                dp[j] = max(dp[j], dp[j-W] + V);
            }
            else break;
        }
    }
    cout<<*max_element(all(dp))<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    loop(Case,1,t+1)
    {
        cerr<<"Case #"<<Case<<'\n';
        solve(Case);
    }
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
t = 0
l = 0
r = 0
ans = 0
while r < n:
    if t^a[r] == t+a[r]:
        t += a[r]
        r += 1
    else:
        t -= a[l]
        ans += r-l
        l += 1
ans += (r-l)*(r-l+1)//2
print(ans)

Measured memory_bytes: 100752
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

//vector <pair<long long, int> > edges[300];
long long d[300][300];
int refill_d[300][300];
int main(){ 
    int N;
    int M;
    long long L;
    cin >> N >> M >> L;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j){
                d[i][j] = 0;
                refill_d[i][j] = 0;
            } else {
                d[i][j] = -1;
                refill_d[i][j] = -1;
            }

        }
    }

    for(int i = 0; i < M; i++){
        int A;
        int B;
        long long C;
        cin >> A >> B >> C;
        d[A - 1][B - 1] = C;
        d[B - 1][A - 1] = C;
        //edges[A - 1].push_back(make_pair(C, B - 1));
        //edges[B - 1].push_back(make_pair(C, A - 1));
    }

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int  j = 0; j < N; j++){
                if(d[i][k] != -1 && d[k][j] != -1){
                    if(d[i][j] != -1){
                        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                    } else {
                        d[i][j] = d[i][k] + d[k][j];
                    }
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i != j){
            if(d[i][j] != -1 && d[i][j] <= L){
                    refill_d[i][j] = 0;
                }
            }
        }
    }

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int  j = 0; j < N; j++){
                if(refill_d[i][k] != -1 && refill_d[k][j] != -1){
                    if(refill_d[i][j] != -1){
                        refill_d[i][j] = min(refill_d[i][j], refill_d[i][k] + refill_d[k][j] + 1);
                    } else {
                        refill_d[i][j] = refill_d[i][k] + refill_d[k][j] + 1;
                    }
                }
            }
        }
    }


    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int s;
        int t;
        cin >> s >> t;
        cout << refill_d[s - 1][t - 1] << endl;
    }

    /*
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cout << refill_d[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N), B(N+1,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
        B[A[i]]++;
    }
    sort(B.begin(),B.end());
    reverse(B.begin(), B.end());
    for(int i=B.size()-1; i>=0; i--){
        if(B[i]==0){
            B.pop_back();
        }
    }
    
    int ans=0;
    for(int i=K; i<B.size(); i++){
        ans += B[i];
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0 ; i < s.size() ; i++){
        if(s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
if 0<int(s[0:2])<=12 and 0<int(s[2:4])<=12:
    print('AMBIGUOUS')
elif 1<=int(s[0:2])<=12:
    print('MMYY')
elif 1<=int(s[2:4])<=12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	double v[50];
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lf",&v[i]);
	std::sort(v,v+n);
	for(int i=1;i<n;i++)v[i]=(v[i]+v[i-1])/2.0;
	printf("%.10lf",v[n-1]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

bool dp[100010];
int a[6]={100,101,102,103,104,105};

int main(void){
    int x;
    cin>>x;
    for(ll i=0;i<100010;i++)dp[i]=false;
    for(ll i=0;i<6;i++)dp[a[i]]=true;
    for(ll i=106;i<=x;i++){
        for(ll j=0;j<6;j++){
            dp[i]=dp[i]|dp[i-a[j]];
        }
    }
    if(dp[x])cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int dsum(lint v) {
  int result = 0;
  while (v > 0) {
    result += v % 10;
    v /= 10;
  }
  return result;
}

int ndigit(int v) {
  int result = 0;
  while (v) {
    result += 1;
    v /= 10;
  }
  return result;
}

int main() {
  const lint limit = 1000000000000000LL;
  vector<lint> result;
  for (int v = 1; v <= 9; ++v) result.push_back(v);
  for (int v = 1; v < 1000; ++v) {
    int nd = ndigit(v);
    lint value = v;
    if (v != 9 && v % 10 == 9) continue;
    for (int n9 = 0; n9 <= 15 + 1; ++n9) {
      if (value > limit)
        break;
      if (n9 >= nd)
        result.push_back(value);
      value = 10LL * value + 9;
    }
  }
  sort(result.begin(), result.end());
  result.resize(unique(result.begin(), result.end()) - result.begin());

  vector<lint> result2;
  lint smallest = -1;
  for (int i = (int)result.size() - 1; i >= 0; --i) {
    if (smallest == -1 ||
        result[i] * dsum(smallest) < smallest * dsum(result[i])) {
      smallest = result[i];
    }
    if (result[i] * dsum(smallest) <= smallest * dsum(result[i]))
      result2.push_back(result[i]);
  }
  reverse(result2.begin(), result2.end());

  int n;
  scanf("%d", &n);
  for (int i = 0; i < n && i < (int)result2.size(); ++i)
    printf("%lld\n", result2[i]);
  return 0;
}


Measured memory_bytes: 440
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n+1-i):
    if 0 <= n-i-j <= n and 10000*i+5000*j+1000*(n-i-j)==y:
      print(i,j,n-i-j)
      exit()
else:
  print('-1 -1 -1')

Measured memory_bytes: 9092
n = int(input())
h = list(map(int,input().split()))

ans='Yes'
f=0

for i in range(n-1):
    a = h[i+1]-h[i]
    if a>0:
        f=0
        continue
    elif a==0:
        continue
    elif a==-1:
        if f:
            ans='No'
            break
        f=1
        continue
    else:
        ans='No'
        break

print(ans)

Measured memory_bytes: 63856
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,chk;
map<string,ll> mp;
void solve()
{
    string a;
        cin>>a;
    for(auto it:a)
    {
        cout<<'x';
    }
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

ll dp[1<<21];

int main(){
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    dp[0]=1;
    for(int i=0;i<(1<<n)-1;i++){
        int cnt=0;
        for(int j=0;j<n;j++){
            if(i&(1<<j))cnt++;
        }
        for(int j=0;j<n;j++){
            if(!(i&(1<<j))&&a[cnt][j]){
                dp[i+(1<<j)]=(dp[i+(1<<j)]+dp[i])%MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 16640
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int N = in.nextInt();
        String S = in.nextLine();

        int count;
        int best = 0;

        for (int i = 1; i < N; i++)
        {
            count = 0;
            String substring1 = S.substring(0,i);
            String substring2 = S.substring(i,N);
            HashSet <Character> one =new HashSet<>();
            HashSet <Character> two =new HashSet<>();
            for (int j = 0; j<substring1.length();j++)
            {
                one.add(substring1.charAt(j));
            }
            for(int j=0; j<substring2.length(); j++)
            {
                two.add(substring2.charAt(j));
            }
            for (Character c : one) {
                if (two.contains(c)) {
                    count ++;
                }
            }
            best = Math.max(count,best);

        }
        System.out.println(best);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
int n,f[200010],g[200010];
char s[200010];
vector<int> a[200010];
long long p=1;
inline void dp(int i,int j)
{
	int k;
	f[i]=1;
	g[i]=s[i-1]-'0';
	for(k=0;k<a[i].size();k++)
	  if(a[i][k]!=j)
	    {
		 dp(a[i][k],i);
		 f[i]=max(f[i],f[a[i][k]]+1);
		 g[i]+=g[a[i][k]];
		}
}
inline void dp2(int i,int j,int b,int c)
{
	int k,u,v,w,d=0;
	if(i==1)
	  u=v=0,w=233333;
	else
	  {
	   u=b;
	   v=0;
	   if(c)
	     w=b;
	   else
	     w=233333;
	  }
	b++;
	c+=s[i-1]-'0';
	for(k=0;k<a[i].size();k++)
	  if(a[i][k]!=j)
	    {
	     if(f[a[i][k]]>u)
	       v=u,u=f[a[i][k]];
	     else
	       v=max(v,f[a[i][k]]);
	     if(g[a[i][k]])
	       w=min(w,f[a[i][k]]);
	     if(f[a[i][k]]+1>b)
	       d=b,b=f[a[i][k]]+1;
	     else
	       d=max(d,f[a[i][k]]+1);
	     c+=g[a[i][k]];
		}
	u=min(u-1,v+1);
	if(s[i-1]=='1')
	  w=0;
	p+=max(u-w+1,0);
	for(k=0,u=b,v=c;k<a[i].size();k++)
	  if(a[i][k]!=j)
	    dp2(a[i][k],i,(f[a[i][k]]+1==b)?d:b,c-g[a[i][k]]);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	  {
	   scanf("%d%d",&j,&k);
	   a[j].push_back(k);
	   a[k].push_back(j);
	  }
	scanf("%s",&s);
	dp(1,0);
	dp2(1,0,0,0);
	cout<<p<<"\n";
	return 0;
}


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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = "";
            var list = new List<decimal>();

            while ((s = Console.ReadLine()) != null)
            {
                var n = decimal.Parse(s);
                list.Add(n);
            }
            Console.WriteLine(list.Max() - list.Min());
        }
    }
}

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

using namespace std;

int main()
{
    int n, p, q;
    cin >> n;
    int X[n], Y[n], g[n], Su=n, s;
    map <pair<int,int>,int> M;
    for (int i = 0; i < n; i++)
    {
        cin >> X[i] >> Y[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int y = 0; y < n; y++)
        {
            if (i != y)
            {
                p = X[i] - X[y];
                q = Y[i] - Y[y];
                for (int u = 0; u < n; u++)
                {
                    g[u] = 1;
                }
                for (int u = 0; u < n; u++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if (u != j && X[u] - X[j] == p && Y[u] - Y[j] == q)
                        {
                            g[u] = 0;
                        }
                    }
                }
                s = 0;
                for (int u = 0; u < n; u++)
                {
                    s += g[u];
                }
                Su = min(Su, s);
            }
        }
    }
    cout << Su;
    return 0;
}


Measured memory_bytes: 256
//Home  » December Challenge 2017 » Chef and Universe » All Submissions » akathil [16446096]
//Solution: 16446096
//CodeChef submission 16446096 (C++14) plaintext list. Status: AC, problem CHEFUNI, contest DEC17. By akathil (akathil), 2017-12-04 17:25:12.
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pii pair< int,int>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define mxn 2000002
#define sqr 320
ll arr[mxn]={0},ans[mxn]={0};
//vector<vector<int> > v(mxn);
int yabs(int j)
{
  if(j<0) return -j;
  return j;
}
ll dp[102][102][102]={0};
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n;
    int i,tmp=0,ind=0;
    for(i=0;i<n;i++)
    {
      cin>>arr[i];
      if(yabs(arr[i])>tmp)
      {
        tmp=yabs(arr[i]);
        ind=i;
      }
    }
    cout<<2*n-1<<endl;
    for(i=1;i<=n;i++)
    {
      cout<<ind+1<<' '<<i<<endl;
    }
    if(arr[ind]>0)
    {
      for(i=1;i<n;i++)
        cout<<i<<' '<<i+1<<endl;
    }
    else
    {
      for(i=n;i>1;i--)
        cout<<i<<' '<<i-1<<endl;
    }

     return 0;
    }  

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

P x[1000], y[1000];
bool S[2005][2005];
int dx[4] = { -1,0,0,1 }, dy[4] = { 0,-1,1,0 };
int main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		set<int>c[2];
		c[0].insert(0); c[0].insert(a);
		c[1].insert(0); c[0].insert(b);
		int d; cin >> d;
		for (int e = 0; e < d; e++) {
			int f, g, h, i; scanf("%d %d %d %d", &f, &g, &h, &i);
			c[0].insert(f); c[0].insert(h);
			c[1].insert(g); c[1].insert(i);
			x[e] = P(f, g);
			y[e] = P(h, i);
		}
		memset(S, 0, sizeof(S));
		int taiou[2][2005];
		unordered_map<int, int>U[2];
		auto e = c[0].begin();
		for (int f = 0; f < c[0].size(); e++, f++) {
			taiou[0][f] = *e;
			U[0][*e] = f;
		}
		e = c[1].begin();
		for (int f = 0; f < c[1].size(); e++, f++) {
			taiou[1][f] = *e;
			U[1][*e] = f;
		}
		for (int g = 0; g < d; g++) {
			for (int l = U[0][x[g].first]; l < U[0][y[g].first]; l++) {
				for (int r = U[1][x[g].second]; r < U[1][y[g].second]; r++) {
					S[l][r] = true;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i+1 < c[0].size(); i++) {
			for (int j = 0; j+1 < c[1].size(); j++) {
				if (!S[i][j]) {
					ans++;
					queue<P>Q;
					Q.push(P(i,j));
					while (Q.size()) {
						P t = Q.front(); Q.pop();
						S[i][j] = true;
						for (int w = 0; w < 4; w++) {
							int n = t.first + dx[w], m = t.second + dy[w];
							if (n >= 0 && n+1 < c[0].size() && m >= 0 && m+1 < c[1].size() && !S[n][m]) {
								S[n][m] = true;
								Q.push(P(n, m));
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}
int main()
{
    int n;
    cin >> n;
    vector<bool> v(1e6+10, false);
    set<int> se;
    bool flag = false;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        se.insert(a);
        if(a > 1 && v[a]) flag = true;
        v[a] = true;
    }
    int x = *se.begin();
    for(int cand : se) x = gcd(x, cand);
    if(flag)
    {
        if(x == 1) cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
        return 0;
    }

    vector<bool> prime(1e6+10, true);
    set<int> pr;
    for(int i = 2; i <= 1e6; i++)
    {
        if(prime[i])
        {
            for(int j = i; j <= 1e6; j+=i)
            {
                prime[j] = false;
            }
        }
        pr.insert(i);
    }
    for(int pri : pr)
    {
        int cnt = 0;
        for(int i = pri; i <= 1e6; i+=pri)
        {
            if(v[i]) cnt++;
        }
        if(cnt > 1)
        {
            if(x == 1) cout << "setwise coprime" << endl;
            else cout << "not coprime" << endl;
            return 0;
        }
    }
    cout << "pairwise coprime" << endl;
}


Measured memory_bytes: 97580
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
      	int sum = 0;
      
        int num[] = new int[n];
        for(int i = 0; i < n; i++){
        	sum += sc.nextInt();
        }
        System.out.println(sum-n);
     }
}

Measured memory_bytes: 40704
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

int main()
{
	double x;
	cin>>x;
	if(x>=30)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}



//eVTWvt22KTVSm@v

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

long int r,c,k;
long long int a[3002][3002],dp[3002][3002][4]={0};

long long int fun(long int row,long int col,long int cnt)
{
    if(row>r || col>c)
    return 0;
    if(dp[row][col][cnt]!=-1)
    return dp[row][col][cnt];
    if(cnt)
    {
        dp[row][col][cnt]=max(dp[row][col][cnt],fun(row+1,col,3)+a[row][col]);
    }
    if(cnt)
    {
        dp[row][col][cnt]=max(dp[row][col][cnt],fun(row,col+1,cnt-1)+a[row][col]);
    }
    dp[row][col][cnt]=max(dp[row][col][cnt],fun(row+1,col,cnt));
    dp[row][col][cnt]=max(dp[row][col][cnt],fun(row,col+1,cnt));
    return dp[row][col][cnt];
}

int main() 
{
	cin>>r>>c>>k;
	memset(a,0,sizeof(a));
	memset(dp,-1,sizeof(dp));
	for(long int i=0;i<k;i++)
	{
	    long int r1,c1,v1;
	    cin>>r1>>c1>>v1;
	    a[r1][c1]=v1;
	}
	cout<<fun(1,1,3);
	return 0;
}


Measured memory_bytes: 356160
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#define llint long long
#define mod 1000000007

using namespace std;

string s, t;

int tz[500005];
int Z[3600005], z[3600005];
int dp[3600005];

void z_algorithm(string s, int z[])
{
	z[0] = s.size();
	
	int x = 0, y = 0;
	for(int i = 1; i < s.size(); i++){
		if(i > y){
			z[i] = 0;
			for(int j = 0; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
		else if(i + z[i-x] <= y) z[i] = z[i-x];
		else{
			z[i] = y-i+1;
			for(int j = y-i+1; j < s.size(); j++){
				if(i+j > s.size() || s[i+j] != s[j]) break;
				z[i]++;
			}
			x = i, y = i + z[i] - 1;
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> t;
	
	z_algorithm(t, tz);
	int p = t.size();
	for(int i = 1; i < t.size(); i++){
		if(t.size() % i == 0 && tz[i] == t.size()-i){
			p = i;
			break;
		}
	}
	//for(int i = 0; i < t.size(); i++) cout << tz[i] << " "; cout << endl;
	llint mul = t.size() / p;
	t = t.substr(0, p);
	
	//cout << t << endl;
	
	string tmp = s;
	llint rep = (t.size()+s.size()-1)/s.size(); s = "";
	for(int i = 0; i < rep; i++) s += tmp;
	
	int n = s.size() * 3, m = t.size();
	string S = t + "#" + s + s + s;
	z_algorithm(S, Z);
	
	for(int i = 0; i < n; i++) z[i] = Z[i+m+1];
	
	for(int i = 0; i < n; i++){
		if(z[i] == m && i+m < n) dp[i+m] = max(dp[i+m], dp[i] + 1);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) ans = max(ans, dp[i]);
	if(s.size() % m == 0 && ans >= 3*s.size() / m - 1) ans = -1;
	if(ans != -1) ans /= mul;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 50188
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(B * 2 <= A) {
			System.out.println(A - B * 2);
		}else {
			System.out.println(0);
		}

		sc.close();
	}
}


Measured memory_bytes: 21844
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1200031;

int n,m;
long long a[1031],b[1031],c[1031],dp[1031][1031][10];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n>>m;

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

	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++){
			for (int q=0;q<8;q++){
				dp[i][j][q]=-1e18;
			}
		}
	}
	for (int i=0;i<8;i++){
		dp[0][0][i]=0;
	}

	for (int i=0;i<n;i++){
		for (int j=0;j<=m;j++){
			for (int q=0;q<8;q++){
				dp[i+1][j][q]=max(dp[i+1][j][q],dp[i][j][q]);
				// take
				long long here=dp[i][j][q];
				if (q&1)
					here+=a[i+1];
				else
					here-=a[i+1];
				if (q&2)
					here+=b[i+1];
				else
					here-=b[i+1];
				if (q&4)
					here+=c[i+1];
				else
					here-=c[i+1];
				dp[i+1][j+1][q]=max(dp[i+1][j+1][q],here);
			}
		}
	}

	long long res=0;
	for (int i=0;i<8;i++){
		res=max(res,dp[n][m][i]);
	}
	cout<<res<<endl;

//	cin.get(); cin.get();
	return 0;
}


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

int main(int argc, char const *argv[]) {
  int a, b, c;
  std::cin >> a >> b >> c;
  
  vector<int> v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);

  sort(v.begin(), v.end());

  std::cout << v.at(0)*v.at(1)/2 << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl


void solve(long long N, std::vector<long long> A) {
    long long money = 1000;
    long long stock = 0;

    rep(i, N) {
        if (i == N-1) {
            money += stock * A[i];
            stock = 0;
            break;
        }
        if (A[i] < A[i+1]) {
            stock += money / A[i];
            money %= A[i];
        }
        if (A[i] > A[i+1]) {
            money += stock * A[i];
            stock = 0;
        }
    }

    cout << money << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3704
#include <stdio.h>
#include <string.h>

int main()
{
	int i,j,m,h,num;
	char s[301],s1[301],s2[301];
	
	while(1){
		scanf("%s",&s);
		num = strlen(s);
		if(s[0] == '-'){
			break;
		}
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%d",&h);
			strcpy(s1,s);
			strcpy(s2,s);
			strcat(s1,s2);
			for(j=0;j<num*2;j++){
				s1[j] = s1[j+h];
			}
			for(j=0;j<num;j++){
				s[j] = s1[j];
			}
		}
	for(i=0;i<num;i++){
		printf("%c",s[i]);
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 588
// abc132_b
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> vc;
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		vc.push_back(num);
	}
	int sum = 0;
	for (int i = 1; i < n - 1; i++) {
		if (vc[i-1] < vc[i] && vc[i] < vc[i + 1]) {
			sum++;
		}
		else if(vc[i - 1] > vc[i] && vc[i] > vc[i + 1])
		{
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
const int MAX = 202020;
pair<pi,int> arr[MAX];
int ans[MAX],uf[MAX],sz[MAX],mm[MAX];
int find(int now){
	if(uf[now]!=now) return uf[now] = find(uf[now]);
	return now;
}
set<pi> s;
bool tmr(pair<pi,int> a,pair<pi,int> b){
	return a.x.x < b.x.x;
}
int main(void){
	int n;
	scanf("%d",&n);
	for(int e=0;e<n;e++) {
		int x,y;
		scanf("%d%d",&x,&y);
		arr[e] = mk(mk(x,y),e);
	}
	for(int e=0;e<MAX;e++){
		uf[e] = e;
		sz[e] = 1;
	}
	sort(arr,arr+n,tmr);
	for(int e=n-1;e>=0;e--){
		set<pi>::iterator it = s.lower_bound(mk(arr[e].x.y,-1));
		int mm = arr[e].x.y;
		for(;it!=s.end();){
			int yy = it->x;
			int wh = it->y;
			wh = find(wh);
			uf[wh] = arr[e].y;
			sz[arr[e].y] += sz[wh];
			s.erase(it++);
			mm = max(mm,yy);
		}
		s.insert(mk(mm,arr[e].y));
	}
	for(int e=0;e<n;e++){
		int nn = find(e);
		printf("%d\n",sz[nn]);
	}
	return 0;
}


Measured memory_bytes: 11428
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

const int inf=1000000000;

int n,ans;

int dig(int s){
	int sum=0;
	while (s){
		sum+=s%10;
		s=s/10;
	}
	return sum;
}

int main(){
	int i,j;
	scanf("%d",&n);
	ans=inf;
	for (i=1;i<n;i++) ans=min(ans,dig(i)+dig(n-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

int main(int argc, char **argv)
{
  uint64_t X;
  std::cin >> X;
  
  if (X == 3 || X == 5 || X == 7) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

list_num = []
a_max = -1
for i in range(K):
    if A+i <= B:
        a_max = A+i
        print(a_max)

tmp = K
for i in range(K):
    if B - tmp + 1 > a_max:
        print(B - tmp + 1)
    tmp -= 1


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;



int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int>c(n);
  vector<vector<int>>a(n,vector<int>(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m)cin >> a[i][j];
  }
  ll ans=mod;
  for(int bit=0;bit<(1<<n);bit++){
    ll sum=0;
    vector<int>d(m,0);
    rep(i,n){
      if(bit&(1<<i)){
	sum+=c[i];
	rep(j,m)d[j]+=a[i][j];
      }
    }
    bool f=true;
    rep(i,m){
      if(d[i]<x)f=false;
    }
    if(f)ans=min(ans,sum);
  }
  if(ans==mod)cout << -1;
  else cout << ans;

}


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

using namespace std;

int search(int a[], int n, int key)
{
	int i = 0;
	a[n] = key;
	while (a[i] != key) i++;
	return i;
}

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

	int a, b, c, d;
	a = num[0] - '0';
	b = num[1] - '0';
	c = num[2] - '0';
	d = num[3] - '0';

	int ans[9];
	ans[0] = a + b + c + d;
	ans[1] = a + b + c - d;
	ans[2] = a + b - c + d;
	ans[3] = a + b - c - d;
	ans[4] = a - b + c + d;
	ans[5] = a - b + c - d;
	ans[6] = a - b - c + d;
	ans[7] = a - b - c - d;

	int t = search(ans, 8, 7);
	char p = '+';
	char m = '-';
	if (t == 0)  cout << a << p << b << p << c << p << d << "=7" << endl;
	if (t == 1)  cout << a << p << b << p << c << m << d << "=7" << endl;
	if (t == 2)  cout << a << p << b << m << c << p << d << "=7" << endl;
	if (t == 3)  cout << a << p << b << m << c << m << d << "=7" << endl;
	if (t == 4)  cout << a << m << b << p << c << p << d << "=7" << endl;
	if (t == 5)  cout << a << m << b << p << c << m << d << "=7" << endl;
	if (t == 6)  cout << a << m << b << m << c << p << d << "=7" << endl;
	if (t == 7)  cout << a << m << b << m << c << m << d << "=7" << endl;
}

Measured memory_bytes: 256
//go:generate echo "https://atcoder.jp/contests/abc175/tasks/abc175_a"
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *scanner) Strings(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func solve(S string) int {
	switch S {
	case "RRR":
		return 3
	case "RRS", "SRR":
		return 2
	case "SSS":
		return 0
	default:
		return 1
	}
}

func main() {
	scan := newScanner(os.Stdin)
	S := scan.String()
	fmt.Println(solve(S))
}


Measured memory_bytes: 1772