akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

 
int main() {
  int64_t N,K;
  cin>>N>>K;
  int64_t MOD=1000000007;
  int64_t count=0;
  for(int64_t i=K;i<=N+1;i++){
    int64_t S=(i*(N+1-i)+1)%MOD;
    count+=S;
    count%=MOD;
  }
  cout<<count<<endl;
}
    

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define forn(i, n) for(int i = 0; i < int__(n); i++) 
#define sz(a) int__(a.size())
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 7;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=998244353;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int x,int y){return y!=0 ? gcd(y,x%y) : x;}
 
int__ main() {
	fast;
	
	int n,W; cin >> n >> W;

	vi w(n+1),v(n+1);

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

	vvi dp(n+1,vi (W+1,0));

	for(int i=1;i<=n;i++) {
		for(int j=1;j<=W;j++) {
			if(j >= w[i]) dp[i][j] = max(dp[i-1][j],v[i] + dp[i-1][j-w[i]]);
			else dp[i][j] = max(dp[i][j],dp[i-1][j]);
		}
	}

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

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, h[100009], dp[100009], k;
int main() {
    //ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i=3;i<=n;i++) {
        dp[i] = inf;
        for(int j=1;j<=k;j++) {
            int prev = i - j;
            if(prev < 1)
                break;
            dp[i] = min(dp[i], dp[prev] + abs(h[i] - h[prev]));
        }
    }
    cout<<dp[n];
}


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

using namespace std;

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

#define int long long
#define foru(i,a,b) for (int i=(a);i<=(b);++i)
#define forn(i, a,b) for (int i = (a); i < (b); i++)
#define rep(i,n) for (int i=0;i<n;++i)
#define forl(i,a,b) for (int i=(a);i>=(b);--i)
#define bug(x) cerr << #x << " = " << x << endl
#define pb push_back
#define mp make_pair
#define bit(s,i) (((s)&(1<<(i)))>0)
#define two(x) (1<<(x))
#define fi first
#define se second
#define sz(x) ((int)x.size())

int a,b;

main()
{
    cin >> a >> b;
    cout << max(a+b,max(2*a-1,2*b-1));
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 50000; i++) {
    if (floor(i * 1.08) == N) {
      cout << i << endl;
      break;
    }
    else if (floor(i * 1.08) > N) {
      cout << ":(" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
mark = [[False, False, False] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True

ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break      
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
import numpy as np
x,y = map(int,input().split())
if abs(x)<abs(y):
  if x<0 and y<0:
    print(abs(y)-abs(x)+2)
  elif x>=0 and y>=0:
    print(y-x)
  else:
    print(abs(y)-abs(x)+1)
elif abs(x)>abs(y):
  if x<0 and y<=0:
    print(abs(x)-abs(y))
  elif x>=0 and y>0:
    print(x-y+2)
  else:
    print(abs(x)-abs(y)+1)
else:
  if np.sign(x)==np.sign(y):
    print(0)
  else:
    print(1)

Measured memory_bytes: 26320
#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>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;
 
int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int res = INF;
    rep(i,n-m+1) {
        int count = 0;
        rep(j,m) if(s[j+i] != t[j]) count++;
        chmin(res,count);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
set < ll> primes;
 
int n,m;

bool isvalid(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m);
}
int dx[]={0,0,1,-1,-1,1,1,-1};
int dy[]={1,-1,0,0,-1,1,-1,1};
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.insert(p);  
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}

void solve()
{
    
    int n,k;
    cin>>n>>k;
    int a[n];
    for(auto &x:a)cin>>x;
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++)
    sum+=a[i];
    
    cout<<sum<<'\n';
    
}
 
 

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
  //  cin>>t;
    while(t--)solve();
    
   
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <math.h>
int main(void) {
	int n;
	double s[1000];
	double sum = 0.0;
	double x = 0.0;
	scanf("%d",&n);
	while(n){
		for(int i=0;i<n;i++){
			scanf("%lf",&s[i]);
			sum+=s[i];
		}
		sum /= n;
		for(int i=0;i<n;i++){
			x += pow(sum-s[i],2);
		}
		x/=n;
		printf("%lf\n",sqrt(x));
		sum=0;
		x=0;
		scanf("%d",&n);
	}
	return 0;
}


Measured memory_bytes: 2100
/**
  @file a.cpp
  @title 404 Not Found - AtCoder
  @url https://atcoder.jp/contests/abc133/tasks/abc133_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int ans = (N * A) > B ? B : N * A;

  cout << ans << endl;

  return 0;
}


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


int main() {
    int n;
    std::cin >> n;
    while (n != 0) {
        std::vector<int> vec(n+1, 0);
        int x;
        for (int i = 1; i <= n; ++i) {
            std::cin >> x;
            vec[i] = x;
        }
        std::vector<int> sum;
        sum.assign(n+1, 0);
        sum[1] = vec[1];
        for (int i = 1; i < n; i++) {
            sum[i+1] = sum[i] + vec[i+1];
        }
        int ans = -1000000000;
        for (int l = 1; l <= n; ++l) {
            for (int r = l; r <= n; ++r) {
                ans = std::max(ans, sum[r] - sum[l-1]);
            }
        }
        std::cout << ans << std::endl;
        std::cin >> n;
    }
}


Measured memory_bytes: 3048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		byte[] barr = new byte[3];
		barr[0] = (byte) (strArr[0].charAt(0) - ('a' - 'A'));
		barr[1] = (byte) (strArr[1].charAt(0) - ('a' - 'A'));
		barr[2] = (byte) (strArr[2].charAt(0) - ('a' - 'A'));
		System.out.println(new String(barr));
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A,B,C,N,W,ans,dp[HMAX][WMAX];
char H,D;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(H == D){
		cout << 'H' << "\n";
	}else{
		cout << 'D' << "\n";
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> H >> D;
	
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
//おまじない
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
//#include <math.h>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 200000;

int main(){
    
    ll n;
    ll a[maxn];
    ull ans = INF;
    ull sum[maxn]={0};
    ull L=0;
    
    cin >> n;
    
    rep(i,n){
        cin >> a[i];
        L+=a[i];
        if(i==0)sum[i]=a[i];
        else sum[i]=sum[i-1]+a[i];
    }
    
    rep(i,n-1){
        if(sum[i]<=L-sum[i])ans=min(ans,L-2*sum[i]);
        else ans = min(ans,2*sum[i]-L);
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
vector < int > vi;
int main(){
	int n;
	scanf("%d",&n);
	int m;
	scanf("%d",&m);
	for(int i = 1; i <= 2*n; i++){
		vi.push_back(i);
	}
	for(int i = 0; i < m; i++){
		int tmp;
		scanf("%d",&tmp);
		if(tmp == 0){
			vector < int > v1;
			vector < int > v2;
			for(int i = 0; i < n; i++)v1.push_back(vi[i]);
			for(int i = n; i < 2*n; i++)v2.push_back(vi[i]);
			vi.clear();
			for(int i = 0; i < n; i++){
				vi.push_back(v1[i]);
				vi.push_back(v2[i]);
			}
		}
		else{
			vector < int > v1;
			vector < int > v2;
			for(int i = 0; i < tmp; i++)v1.push_back(vi[i]);
			for(int i = tmp; i < 2*n; i++)v2.push_back(vi[i]);
			vi.clear();
			for(int i = 0; i < 2*n-tmp; i++){
				vi.push_back(v2[i]);
			}
			for(int i = 0; i < tmp; i++){
				vi.push_back(v1[i]);
			}
		}
	}
	for(int i = 0; i < 2*n; i++){
		printf("%d\n",vi[i]);
	}
	return 0;
}

Measured memory_bytes: 1212
n = int(input())
s = input()
while True:
  c = 0
  for i in range(len(s)):
    if s[i] == "(":
      c += 1
    else:
      c -= 1
    if c < 0:
      s = "(" + s
      break
  if c > 0:
    s = s + ")"
  if c == 0:
    print(s)
    break
  


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

int main() {
  string s;
  cin >> s;
  
  int N = 0;
  while(s[N]){
    N++;
  }
  
  bool flag = true;
  int num = (N-1)/2 - 1;
  
  for (int i = 0; i < num; i++){
    if (s[i] != s[num-i]){
        flag = false;
    }
    if (s[num+2+i] != s[N-1-i]){
    	flag = false;
    }
    if (s[i] != s[num+2+i]){
    	flag = false;
    }
  }
  
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(){
   int c, i, j, k, n, q;
   c=0;
   scanf("%d",&n);
   int a[10000];
   for(i=0;i < n;i++){
       scanf("%d",&a[i]);
   }
   scanf("%d",&q);
   int b[10000];
   for(i=0;i < q;i++){
       scanf("%d",&b[i]);
   }
   for(i=0;i < q;i++){
      for(j=0;j < n;j++){
         if(b[i] == a[j]){
               c++;
               break;
         }
      }
   }
   printf("%d\n",c);
   return 0;
}

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



int main() {
int N;
cin >> N;
bool check = 1;
ll kazu[2000];
int count = 0;
for(int i = 0; i < N; i++){
    cin >> kazu[i];
}
while(check == 1){
    
for(int i = 0; i < N; i++){
    if(kazu[i] % 2 == 1)check = 0;
    else kazu[i] /= 2;
  
}
if(check == 0)break;
  count++;

}
cout << count << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var debug = false

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n string
	fmt.Scanf("%s", &n)

	res := GetAnswer(n)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(n string) string {
	prt("inputs: n:%v", n)
	result := "NO"
	n = strings.Replace(n, "eraser", "", -1)
	prt("1st: n:%v", n)
	n = strings.Replace(n, "erase", "", -1)
	prt("2nd: n:%v", n)
	n = strings.Replace(n, "dreamer", "", -1)
	prt("3rd: n:%v", n)
	n = strings.Replace(n, "dream", "", -1)
	if len(n) == 0 {
		result = "YES"
	}


	prt("%v\n", result)
	return result
}

func canMakeDreamEraser(s string) int {
	if strings.HasPrefix(s, "eraser") {

	}
	return 0
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format+"\n", inputs...)
	}
}

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

int main(){
    int n;
    cin >> n;
    map<int,int>Map;
    bool ok=true;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        Map[a]++;
        if(Map[a]==2)ok=false;
    }
    if(ok)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 12984
#include<bits/stdc++.h>
using namespace std;
const int N=310;
const int mod=998244353;
typedef vector<int> vi;
#define pb push_back
#define sz(a) int(a.size())

char s[N];
int n,f[N][N][N],g[N][N][N],h[N][N][N],sum[N][2];

int getf(int i,int j,int k) {
	if(j+k>n-i) return 0;
	if(i==n) return 1;
	if(f[i][j][k]!=-1) return f[i][j][k];
	for(int a=0;a<2;a++)
		for(int b=0;b<2;b++)
			for(int x=0;x<2;x++)
				for(int y=0;y<2;y++) {
					int st[3],tp=0;
					if(!x) st[++tp]=a;
					if(!y) st[++tp]=b;
					bool fl=1;
					for(int l=1;l<=tp;l++)
						if(s[i+l]!=st[l]) { fl=0;break; }
					if(!fl) continue;
					int cnt[2];cnt[0]=j;cnt[1]=k;
					if(cnt[b]) {
						--cnt[b];
						if(x) ++cnt[a];
						if(y) ++cnt[b];
						if(getf(i+tp,cnt[0],cnt[1])) return f[i][j][k]=1;
					}
					cnt[0]=j;cnt[1]=k;
					if(cnt[a]) {
						--cnt[a];
						if(x) ++cnt[a];
						if(y) ++cnt[b];
						if(getf(i+tp,cnt[0],cnt[1])) return f[i][j][k]=1;
					}
		}
	return f[i][j][k]=0;
}

int geth(int i,int j,int k) {
	if(i<0) return 0;
	if(h[i][j][k]!=-1) return h[i][j][k];
	if(j>=sum[i][0]&&k>=sum[i][1]&&getf(i,j-sum[i][0],k-sum[i][1])) return h[i][j][k]=1;
	return h[i][j][k]=geth(i-1,j,k);
}

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>(s+1);n=strlen(s+1);reverse(s+1,s+n+1);
	for(int i=1;i<=n;i++) s[i]-='0',sum[i][0]=sum[i-1][0],sum[i][1]=sum[i-1][1],++sum[i][s[i]];
	s[n+1]=2;
	memset(f,-1,sizeof(f));
	memset(h,-1,sizeof(h));
	int ans=0;
	g[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;i+j<n;j++)
			for(int k=0;k<=i+j;k++) {
				if(!g[i][j][k]) continue;
				g[i+1][j][k+(s[k+1]==0)]=(g[i+1][j][k+(s[k+1]==0)]+g[i][j][k])%mod;
				g[i][j+1][k+(s[k+1]==1)]=(g[i][j+1][k+(s[k+1]==1)]+g[i][j][k])%mod;
			}
	for(int i=0;i<=n;i++)
		for(int j=0;i+j<=n;j++)
			for(int k=0;k<=i+j;k++)
				if(geth(k,i,j)) ans=(ans+g[i][j][k])%mod;
	cout<<ans;
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[4][3][10];
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 10; k++)
				a[i][j][k] = 0;
	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++)
				cout << ' ' << a[i][j][k];
			cout << endl;
		}
		if (i != 3)
			cout << "####################" << endl;
	}
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) P("Possible");
  else P("Impossible");

  return 0;
}

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

p = 0
m = float('inf')
ret = 0
for a in A :
    if a < 0 :
        p ^= 1
        m = min(m, -a)
        ret -= a
    else :
        m = min(m, a)
        ret += a
        
if p == 0 :
    print(ret)
else :
    print(ret - 2 * m)

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

int a[100010];
bool cando[100010];
int ans=0;

int traning(int ai){
  if(ai==1)return 0;
  else if(cando[ai]){
    ans++;
    cando[ai]=false;
    return traning(a[ai]-1);
  }else{
    ans=-1;
    return 0;
  }
}

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

  memset(cando,true,sizeof(cando));
  traning(0);
  cout << ans << endl;
}

Measured memory_bytes: 3936
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#define ll long long
#define Inf 1000000000
#define MAXN 100000
using namespace std;



int mask[222222];
ll dp[222222];

int main() {
    string S;
    cin>>S;
    
    mask[0]=0;
    for(int i=0;i<S.size();i++) {
        mask[i+1]=mask[i];
        mask[i+1] ^= (1<<(S[i]-'a'));
    }
    
    map<int,ll> mask_to_best;
    mask_to_best[0]=0;
    int L=S.size();
    dp[0]=0;
    for(int i=1;i<=L;i++) {
        dp[i]=Inf;
        if (mask_to_best.find(mask[i]) != mask_to_best.end()) {
            dp[i]=min(dp[i], 1+mask_to_best[mask[i]]);
        }
        
        // mask[i]
        for(int c=0;c<26;c++) {
            int rmask = (mask[i]^(1<<c));
            if (mask_to_best.find(rmask) != mask_to_best.end()) {
                dp[i]=min(dp[i], 1+mask_to_best[rmask]);
            }
        }
        if (mask_to_best.find(mask[i]) == mask_to_best.end() || mask_to_best[mask[i]] > dp[i]) {
            mask_to_best[mask[i]]=dp[i];
        }
    }
    
    cout << dp[L] << endl;
    
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n; cin>>n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>>a[i];
  if (n==1) out("Yes");
  a[0] = max(1, a[0]-1);
  for (int i=1; i<n; i++) {
    if (a[i]<a[i-1]) out("No");
    a[i] = max(a[i-1],a[i]-1);
  }
  out("Yes");
  

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
long long int n,rs,f[5];string s;
int main()
{
	cin>>n;
	memset(f,0,sizeof(f));
	while(n-->0)
	{
		cin>>s;
		if(s[0]=='M')f[0]++;else if(s[0]=='A')f[1]++;else if(s[0]=='R')f[2]++;else if(s[0]=='C')f[3]++;else if(s[0]=='H')f[4]++;
	}
	long long int ly=0;rs=0;
	for(int i=0;i<5;i++)if(f[i]>0)ly++;
	if(ly>=3)
	{
			for(int i=0;i<5;i++)
			{
				if(f[i]==0)continue;
				for(int j=i;j<5;j++)
				{
					if(j==i||f[j]==0)continue;
					for(int t=j;t<5;t++)
					{
						if(i==t||t==j||f[t]==0)continue;
						rs+=f[i]*f[j]*f[t];
					}
				}
			}
	}
	cout<<rs<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	bool f = false;
	for (int i = 0; i <= n; i++)for (int j = 0; j <= m; j++)if (i*(m - j) + (n - i)*j == k)f = true;
	if (f)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
from itertools import product

N = int(input())
s = input()

answer = [''] * N

for i, j in product(['S', 'W'], repeat=2):
    answer[0] = i
    answer[1] = j
    for k in range(2, N):
        if answer[k - 1] == 'S':
            if s[k - 1] == 'o':
                answer[k] = answer[k - 2]
            else:
                if answer[k - 2] == 'W':
                    answer[k] = 'S'
                else:
                    answer[k] = 'W'
        else:
            if s[k - 1] == 'x':
                answer[k] = answer[k - 2]
            else:
                if answer[k - 2] == 'W':
                    answer[k] = 'S'
                else:
                    answer[k] = 'W'

    for k in [-1, 0]:
        if answer[k] == 'S':
            if s[k] == 'o':
                if answer[k - 1] != answer[k + 1]:
                    break
            else:
                if answer[k - 1] == answer[k + 1]:
                    break
        else:
            if s[k] == 'x':
                if answer[k - 1] != answer[k + 1]:
                    break
            else:
                if answer[k - 1] == answer[k + 1]:
                    break
    else:
        print(''.join(answer))
        exit()

print(-1)

Measured memory_bytes: 4212
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
int prime[60000];
bool is_prime[556000];
int d[35][35];
int C[505][505];
int main(int argc,char const* argv[])
{
  int n,c,ans=INF;
  cin >> n >> c;
  for(int i=1;i<=c;i++)
    {
      for(int j=1;j<=c;j++)
	{
	  cin >> d[i][j];
	}
    }
  for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=n;j++)
	{
	  cin >> C[i][j];
	}
    }
  int mod=1;
  int buckets[35][3];
  memset(buckets,0,sizeof(buckets));
  for(int k=0;k<3;k++)
    {
      mod=(mod+1)%3;
      for(int i=1;i<=n;i++)
	{
	  for(int j=1;j<=n;j++)
	    {
	      if((i+j)%3==mod) buckets[C[i][j]][k]++;
	    }
	}
    }
  vi tcolor;
  for(int i=1;i<=c-2;i++)
    {
      for(int j=i+1;j<=c-1;j++)
	{
	  for(int k=j+1;k<=c;k++)
	    {
	      tcolor.clear();
	      tcolor.push_back(i);
	      tcolor.push_back(j);
	      tcolor.push_back(k);
	      do
		{
		  int tmp=0;
		  int now=0;
		  for(auto x: tcolor) 
		    {
		      for(int i=1;i<=c;i++)
			{
			  tmp+=buckets[i][now]*d[i][x];
			}
		      now++;
		    }
		  if(tmp<ans) ans=tmp;
		} while(next_permutation(tcolor.begin(),tcolor.end()));
	    }
	}
    }
  cout << ans << endl;
  return 0;
}



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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

void solve()
{
    int n;
    cin>>n;
    int ans=0;
    int a[n];
    for(auto &it: a)
        cin >>it;
    for(int i = 0 ; i < n-1 ; i++)
    {
        if(a[i+1]<a[i])
        {
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout << ans;
}
int32_t main()
{
    SKY;
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
    {
        solve();
    }
    return 0;
}
/*
 Umang Agrawal
 @skylag
 */


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

int main(){
  int lake_long, house_num;
  int distance_house[1000000], distance_next_house;
  int max_distance=0, distance_last_to_first;
  int i;
  
  cin >> lake_long >> house_num;
    
  for(i=0; i<house_num; i++){
    cin >> distance_house[i];
    
    if (i==0){
      distance_next_house = distance_house[i];
    }
    else{
      distance_next_house = (distance_house[i]-distance_house[i-1]);
    }
    
    if(max_distance < distance_next_house){
      max_distance = distance_next_house;
    }
  }
  
  distance_last_to_first = (lake_long - distance_house[house_num-1])
    						+ distance_house[0];
  
  if(max_distance < distance_last_to_first){
    max_distance = distance_last_to_first;
  }
  
  cout << lake_long - max_distance << endl;
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

using namespace std;

const int N = 111;
int n, k;
string s;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int nrE = 0, nrW = 0, tE, tW;
	cin >> s;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'E')
			nrE++;
		else nrW++;
	}
	tE = 0;
	tW = 0;
	int ans = n - 1;
	for(int i = 0; i < n; i++) {
		ans = min(ans, tW + nrE);
		if(s[i] == 'E')
			tE++, nrE--;
		else
			tW++, nrW--;
		ans = min(ans, tW + nrE);
	}
	cout << ans << '\n';
}	

Measured memory_bytes: 720
// AOJ DSL_1_B Weighted Union Find Trees
// 2018.4.28 bal4u

#include <stdio.h>

// <重み付きUnion Find>
#define MAX 100003

int par[MAX], ws[MAX];

void initWeightedUnionFind(int n)
{
	int i;
	for (i = 0; i < n; i++) par[i] = -1;
}

int find(int x)
{
	int p;
	if (par[x] < 0) return x;
    p = find(par[x]), ws[x] += ws[par[x]];
    return par[x] = p;
}
    
int weight(int x)
{
    find(x); 
    return ws[x];
}
    
int unite(int x, int y, int w)  // x <-(w)- y (x + w = y)
{
	int tmp;

    w += weight(x), w -= weight(y);
    x = find(x), y = find(y);
    if (x == y) return 0;
    if (par[y] < par[x]) // 多い方が根になるようにスワップする.
        tmp = x, x = y, y = tmp, w = -w;
    
    par[x] += par[y], par[y] = x;
    ws[y] = w;
    return 1;
}
    
int same(int x, int y)
{
	return find(x) == find(y);
}

// *ans = x - y. 比較不能なら return 0.
int diff(int *ans, int x, int y)
{
    if (find(x) != find(y)) return 0;
	*ans = ws[x] - ws[y];
	return 1;
}
// </重み付きUnion Find>

#define gc() getchar_unlocked()
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc();
	while (c >= '0');
	return n;
}

int main()
{
	int n, q, k, x, y, z;
	
	n = in(), q = in();
	initWeightedUnionFind(n);
	while (q--) {
		if (in()) {
			x = in(), y = in();
			z = diff(&k, x, y);
			if (!z) puts("?");
			else printf("%d\n", k);
		} else {
			x = in(), y = in(), z = in();
			unite(y, x, z);
		}
	}
	return 0;
}


Measured memory_bytes: 2620
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();

        double l = Math.sqrt((Math.pow((x2-x1) , 2) + Math.pow((y2-y1) , 2)));
        
        System.out.println(l);
    }
}

Measured memory_bytes: 27928
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
fast;
ll a,b;
cin>>a>>b;
cout<<a*b<<endl;

}


Measured memory_bytes: 3664
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include <algorithm>
using namespace std;
using ll = long long;

typedef pair<int,int> P;
 
struct UnionFind{
    vector<int> d;
    UnionFind(int n):d(n,-1){}
    int root(int x){
        if(d[x]<0)return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y){return false;}
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    int size(int x){
        return -d[root(x)];
    }
} ;
int main(void){
    int N,M;
    cin >>N>>M;
    UnionFind uni(N);
    for(int k=0;k<M;k++){
        int a,b;
        cin >> a>>b;a--;b--;
        bool q=uni.unite(a,b);
    }
    int max=0;
    for(int k=0;k<N;k++){
        if(uni.size(k)>max)max=uni.size(k);
    }
    cout <<max<<endl;

}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a1, a2, b1, b2;
char c[1000010];
char s[1000010];
int dis[1000010];
struct node{
	int x, y;
};
queue<node> q;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int f(int x, int y) {
	return (x - 1) * m + y;
}
bool check(int x, int y) {
	if (x < 1 || x > n) return false;
	if (y < 1 || y > m) return false;
	if (c[(x - 1) * m + y] == '@') return false;
	return true;
}
int main() {
	memset(dis, 0x3f, sizeof(dis));
	cin >> n >> m >> k;
	cin >> a1 >> b1 >> a2 >> b2;
	for (register int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for (register int j = 1; j <= m; ++j) {
			c[(i - 1) * m + j] = s[j];
		}
	}
	q.push(node{a1, b1});
	dis[(a1 - 1) * m + b1] = 0;
	while (!q.empty()) {
		node now = q.front();
		q.pop();
		int num = dis[f(now.x, now.y)] + 1;
		for (register int i = 0; i < 4; ++i) {
			int xx = now.x, yy = now.y;
			for (register int j = 1; j <= k; ++j) {
				xx += dx[i];
				yy += dy[i];
				if (!check(xx, yy) || dis[f(xx, yy)] < dis[f(now.x, now.y)] + 1) break;
				if (dis[f(xx, yy)] > num) {
					dis[f(xx, yy)] = num;
					q.push(node{xx, yy});
				}
			}
		}
	}
	if (dis[f(a2, b2)] < 0x3f3f3f3f) cout << dis[f(a2, b2)];
	else puts("-1");
	return 0;
}

Measured memory_bytes: 9464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<ll> a(n+1,0);
    rep(i,n){
        cin>>a[i+1];a.push_back(a[i+1]);
    }
    rep(i,2*n-1){
        if(i%2==1)a[i+1]=a[i]-a[i+1];
        else a[i+1]+=a[i];
    }
    rep(i,n){
        ll res=a[n+i]-a[i];
        res=abs(res);
        cout<<res<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a, q, l, r;



int32_t main(){
INIT

cin>>a;

cout<<a+a*a+a*a*a<<"\n";


return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include<algorithm>
using namespace std;

long long a[200005],n;
long long f(long long x)
{
    long long sum=0;
    for(int i=0;i<n;i++)
        sum+=abs(a[i]-x);
    return sum;
}
long long SanFen(long long l,long long r) //找凸点
{
    while(l < r-1)
    {
        long long mid  = (l+r)/2;
        long long mmid = (mid+r)/2;
        if(mid==l) mid++;
        if(mmid==r) mmid--;
        if( f(mid) > f(mmid) )
            l = mid;
        else
            r = mmid;
    }
    return f(l) < f(r) ? l : r;
}


int main()
{
    long long i,j,mi,ma;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    mi=ma=a[0]-1;
    for(long long i=0;i<n;i++)
    {
        a[i]=a[i]-i-1;
        mi=min(mi,a[i]);
        ma=max(ma,a[i]);
    }
    printf("%lld\n",f(SanFen(mi-1,ma+1)));
    return 0;
}


Measured memory_bytes: 1664
a,b,c,d =  gets.split.map(&:to_i)
A = []
B = []
for num in a..b do
  A << num
end  
for num in c..d do
  B << num
end  
if (A & B).length - 1 >=0
  p (A & B).length - 1
else
  p 0
end

Measured memory_bytes: 3836
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

ll c[200005];
ll s[200005];

void solve()
{
    IN(n, k);
    ll m = 998244353;
    vector<pair<ll,ll>> v;
    rep(i, k) {
        IN(l, r);
        v.emplace_back(l, r);
    }
    c[0] = 1;
    s[0] = 0;
    s[1] = 1;
    reps(i, 1, n) {
        rep(j, k) {
            auto [l, r] = v[j];
            if (i-l < 0) continue;
            if (i-r < 0) c[i] = (c[i] + s[i-l+1]) % m;
            else c[i] = (c[i] + s[i-l+1] - s[i-r] + m) % m;
        }
        s[i+1] = (s[i] + c[i]) % m;
    }
    cout << c[n-1] % m << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main(void) {
	int a, b, h = 0;
	
	cin >> a >> b;
	
	for (int i = 0; i < b - a - 1; i++)
		h += i + 1;
	
	cout << h - a << endl;
	
	return 0;
}

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

bool comp(pair<int, int> a, pair<int, int> b) {
  return a.second < b.second;
}

int main() {
  int n, k, tmp;
  unordered_map<int, int> m;
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    cin >> tmp;
    m[tmp]++;
  }
  vector<pair<int, int> > v(m.begin(), m.end());
  sort(v.begin(), v.end(), comp);
  int cnt = 0;
  for (int i=0;i<v.size() - k && v.size() > k;i++) {
     cnt += v[i].second;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 10056
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long k, q;
    cin >> k >> q;
    vector<long long>d(k + 3);
    for(long long i = 0; i < k; i++){
        cin >> d[i];
    }
    for(long long i = 0; i < q; i++){
        long long n, m, x;
        cin >> n >> x >> m;
        x = x % m;
        vector<long long>d2(k + 3);
        for(long long j = 0; j < k; j++){
            d2[j] = d[j] % m;
        }
        long long cnt = n - 1, val = x;
        for(long long j = 0; j < k; j++){
            long long z = (n + k - 2 - j)/k;
            if(z < 0){
                z = 0;
            }
            if(d2[j] == 0){
                cnt -= z;
            }
            val += z * d2[j];
        }
        cnt -= val/m;
        cout << cnt << '\n';
    }
    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;
int main() {
    string s, t;
    cin>>s>>t;
 
    int lenS=s.length();
    int lenT=t.length();

  int ans=1e4;
    for (int i=0; i+lenT<=lenS; i++) {
        int change=0;
        for (int j=0; j<lenT; j++) {
            if (s[i+j]!=t[j]) {
                change++;
            }
        }
        ans = min(ans, change);
    }
 
    cout<<ans<<"\n";
 
    return 0;
}

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

using namespace std;

const int MX = 100000, md = 1000000007;

int a[MX], inv[MX + 1], s_inv[MX + 1];

int main() {
	int n;
	ignore = scanf("%d", &n);
	for (int i = 0; i < n; i++) ignore = scanf("%d", a + i);
	
	s_inv[1] = inv[1] = 1;
	for (int i = 2; i <= n; i++) {
		inv[i] = md - (md / i) * 1ll * inv[md % i] % md;
		s_inv[i] = (s_inv[i - 1] + inv[i]) % md;
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = (ans + (s_inv[i + 1] + s_inv[n - i] - 1ll) * a[i]) % md;
	}
	
	for (int i = 1; i <= n; i++) ans = ans * 1ll * i % md;
	
	printf("%d\n", ans);
	
	return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;

    vector<array<int , 2> > v(n);
    for (int i = 1 ;i <= n ;i++) {
        int x;
        cin >> x;
        v[i - 1] = {x , i};
    }

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

    for (auto &c : v)
        cout << c[1] << ' ';
}


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

int main() {
  int N, K, i, j  ;
  std::cin >> N >> K ;
  std::string S ;
  std::cin >> S ;
  std::vector<int> nums ;
  if (S[0] == '0')
    nums.push_back(0) ;
  for (i = 0 ; i < S.size() ;) {
    j = i ;
    while (j < S.size() && S[++ j] == S[i])  ;
    nums.push_back(j - i) ;
    i = j ;
  }
  if (S.back() == '0')
    nums.push_back(0) ;
  std::vector<int> sums((int)nums.size() + 1, 0) ;
  for (i = 0 ; i < nums.size() ; ++ i)
    sums[i + 1] = sums[i] + nums[i] ;
  int res = 0, left ;
  for (left = 0 ; left < sums.size() ; left += 2) {
    int right = left + K * 2 + 1 ;
    if (right >= sums.size())
      right = (int)sums.size() - 1 ;
    res = std::max(res, sums[right] - sums[left]) ;
  }
  std::cout << res  ;
}


Measured memory_bytes: 1272
n,a,b = map(int, input().split())
s = input()
count = 0
count_b = 0
for i in range(len(s)):
    if s[i]=="a":
        if(count < a+b):
            print("Yes")
            count += 1
        else:
            print("No")
    elif s[i]=="b":
        count_b += 1
        if count < a+b and count_b <= b:
            print("Yes")
            count += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
int n , a[1000000] , frog , memo[1000000];

int f(int n){
	if(n == 1)return 0;
	if(n == 2)return abs(a[1] - a[2]);
	if(memo[n] != -1)return memo[n];
	memo[n] = min(f(n-1) + abs(a[n] - a[n-1]) , f(n-2) + abs(a[n] - a[n-2]));
	return memo[n];
}
int main(){
	memset(memo , -1 , sizeof(memo));
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d" , &a[i]);
	}
	printf("%d" , f(n));
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main() {
  ll l,r; cin>>l>>r;
  ll ans = 3000;
  for (ll i=l; i<=r-1; i++){
    for (ll j=i+1; j<=r; j++){
      if ((i*j) % 2019 == 0){
        cout << 0 << endl;
        return 0;
      }
      ans = min(ans, (i*j)%2019);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3536
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

bool check(int x, int y, vector<pair<int, int>> &jewelry) {
    for (auto &i: jewelry) {
        if (i.first == x && i.second == y) {
            i.first = -1;
            i.second = -1;
            return true;
        }
    }
    return false;
}

string solve(int N) {
    vector<pair<int, int>> jewelry;
    for (int i = 0; i < N; i++) {
        int x, y; cin >> x >> y;
        jewelry.push_back({x, y});        
    }
    int x, y;
    x = y = 10;

    int M; cin >> M;
    size_t cnt = 0;
    for (int i = 0; i < M; i++) {
        char dir;
        int dist;
        cin >> dir >> dist;
        if (dir == 'N') {
            for (int j = 0; j < dist; j++) {
                y++;
                if (check(x, y, jewelry)) cnt++;
            }
        } else if (dir == 'S') {
            for (int j = 0; j < dist; j++) {
                y--;
                if (check(x, y, jewelry)) cnt++;
            }            
        } else if (dir == 'E') {
            for (int j = 0; j < dist; j++) {
                x++;
                if (check(x, y, jewelry)) cnt++;
            }            
        } else if (dir == 'W') {
            for (int j = 0; j < dist; j++) {
                x--;
                if (check(x, y, jewelry)) cnt++;
            }            
        }    
    }
    if (cnt == jewelry.size()) return "Yes";
    else return "No";
}

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

    vector<string> ans;
    while (1) {
        int N; cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }

    for (auto &i: ans) {
        cout << i << endl;
    }
}





Measured memory_bytes: 3052
using System;
class _0022
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        while (n != 0)
        {
            long sum = 0;
            int[] num = new int[n];
            for (int i = 0; i < n; i++) num[i] = int.Parse(Console.ReadLine());
            long max = long.MinValue;
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                {
                    sum += num[j];
                    if (sum > max) max = sum;
                }
                sum = 0;
            }
            Console.WriteLine(max);
            n = int.Parse(Console.ReadLine());
        }
    }
}

Measured memory_bytes: 5704
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define rz(x) resize(x)
#define rz(x,y) resize(x,y)

int n,U,V;
vector<vi> edges;
vi Adis,Tdis;

void dfs(int u,int d, vi &dis, vector<bool> visited){
    /*visited[u]=1;
    dis[u]=d;
    for(int v : edges[u]){
        if(!visited[v]){
            dfs(v,d+1,dis,visited);
        }
    }*/
    queue<int> q;
    q.push(u);
    visited[u]=1;
    dis[u]=0;
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        for(int v : edges[cur]){
            if(!visited[v]){
                q.push(v);
                visited[v] = 1;
                dis[v] = dis[cur] + 1;
            }
        }
    }

}

void mymain(){
   cin >> n >> U >> V;
   U--;V--;
   edges.rz(n,vi());
   for(int i=0;i<n-1;i++){
    int u,v;
    cin >> u >> v;
    u--;v--;
    edges[u].pb(v);
    edges[v].pb(u);
   }
    Adis.rz(n,0);
    Tdis.rz(n,0);
    vector<bool> vis(n,false);
    dfs(U,0,Tdis,vis);
    for(int i=0;i<n;i++)
        vis[i]=false;
    dfs(V,0,Adis,vis);
    //for(int i : Adis)
    //    cout << i << " ";
    bool ok = true;
    set<int> s1,s2;
    for(int i : edges[U])
        s1.insert(i);
    for(int i : edges[V])
        s2.insert(i);
    if(s1==s2)
        ok=false;
    if(!ok){
        cout << 1 << endl;
        return;
    }

    int ans = INT_MIN;
    for(int i=0;i<n;i++){
        if(Tdis[i] < Adis[i])
            ans = max(ans,Adis[i]-1);
        else if(Tdis[i] == Adis[i])
            ans = max(ans,Adis[i]);
    }
    cout << ans << endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


Measured memory_bytes: 8064
package main

import (
	"fmt"
	"os"
)

func main() {
	var S, result string

	_, err := fmt.Scan(&S)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	for i := 0; i < len(S); i++ {
		result += "x"
	}

	fmt.Printf("%s\n", result)
}


Measured memory_bytes: 512
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
string a,b,c;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
X,Y = map(int, input().split())

#足が奇数
if Y%2 ==1:
  print("No")
#全部鶴
elif 2*X > Y:
  print("No")
#全部カメ
elif 4*X <Y:
  print("No")
  
#解が存在する
else:
  print("Yes")

Measured memory_bytes: 9168