akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    int l = 0, r = 0;
    if (s.size() % 2 == 0) {
        l = s.size() / 2 -1;
        r = s.size() / 2 ;
    } else {
        l = r = s.size() / 2;
    }

    int ans = 0;
    while(l >= 0) {
        if (s[l] != s[r]) ans++;
        l--;
        r++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;

	int cnt = 0;
	for(int x = a; x <= b; x++){
		if(c%x == 0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;
}

int main()
{   
    string s,t; cin >> s >> t;
    vector<vector<ll>> dp(s.size()+100,vector<ll>(t.size()+100,0));

    for(int i=0;i<s.size();i++){
        for(int j=0;j<t.size();j++){
            if(s[i] == t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
    //cout << dp[s.size()][t.size()] << endl;
}
    

Measured memory_bytes: 75520
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),count=0;
		for(int i=a;i<=b;i++){
			if(c%i==0){
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  bool ans=1;
  for(int i=0;i<100000;i++){
    if(a%2==1){ans=0;}
    if(b%2==1){ans=0;}
    if(c%2==1){ans=0;}
    if(ans==0){cout << i << endl;
    return 0;}
    ll ac=b/2+c/2,bc=a/2+c/2,cc=a/2+b/2;
    a+=ac;
    b+=bc;
    c+=cc;
  }
  cout << -1 << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    map<int, bool> D;
    rep(i, K) {
        int d;
        cin >> d;
        D[d] = true;
    }

    int ans = N;
    while (true) {
        int now = ans;
        while (now > 0) {
            if (D[now % 10]) break;
            now /= 10;
        }
        if (now == 0) break;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int>v1(N,0);
  int c = 0;
  for (int i = 0;i < K;i++){
    int d;
         cin >> d;
        vector<int>v(d,0);
    for (int j = 0;j < d;j++){
      cin >> v.at(j);
        for (int k = 1;k < N+1;k++){
  if (v.at(j) == k){
    v1.at(k-1)++;
  }
    }
  }
  }
  for(int i = 0;i < N;i++){
  cin >> v1.at(i);
    if (v1.at(i) == 0){
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3636
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}
pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line!().split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
macro_rules! bind_from_vec {
    ( $($variable:ident),+ = $vector:expr ) => {
        let mut v = $vector.clone().into_iter();
        $(let $variable = v.next().unwrap();)+
    };
}
fn main() {
    bind_from_vec!(height, width = read_to_vec::<usize>());
    bind_from_vec!(h, w = read_to_vec::<usize>());

    println!("{}", height * width + h * w - h * width - w * height);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
int flag,flag1,flag2;
int main(){
	char a[10000];
	scanf(" %s",a);
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='a')flag++;
		if(a[i]=='b')flag1++;
		if(a[i]=='c')flag2++;
	}
	if(flag>0&&flag1>0&&flag2>0)printf("Yes\n");
	else printf("No\n");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  int n,m;
  cin>>n>>m;
  priority_queue<ll,vector<ll>,less<ll>> q;
  ll a;
  for(int i=0;i<n;i++){
    cin>>a;
    q.push(a);
  }
  for(int i=0;i<m;i++){
    a=q.top();
    q.pop();
    a/=2;
    q.push(a);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    a=q.top();
    q.pop();
    ans+=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
const int MAX=200001;
signed main(){
  int N,C; cin>>N>>C;
  vector<bitset<30>> B(MAX);
  rep(i,0,N){
    int X,Y,Z; cin>>X>>Y>>Z;
    REP(j,X*2-1,Y*2) B[j].set(Z-1);
  }
  int ans=0;
  rep(i,0,MAX){
    ans=max(ans,(int)B[i].count());
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 1792
#include<stdio.h>
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  int N=IN(),M=IN(),a=1,i=0,p=1,q=0,temp;
  while(i<N){a=(1l*a*(M-i++))%MOD;temp=q;q=1l*(p+temp)*(N-i)%MOD;p=(1l*p*(M-N)%MOD+1l*temp*(M-N+1)%MOD)%MOD;}
  return OUT(1l*a*p%MOD),0;
}

Measured memory_bytes: 1480
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
  if n == i + 2:
    break
  else:
    
    p_com = p[i:i+3]
    sp_com= sorted(p_com)
    if sp_com[1] == p_com[1]:
      ans += 1
      
print(ans)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 1e9; i++) {
        int t = i * 111;
        if (n > t) continue;
        else {
            cout << t << endl;
            break;
        }
    }
}

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

int main() {
    string s;
    cin >> s;
   int ans = s.size(), scnt = 0, tcnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'S') {
            scnt++;
        } else {
            if (scnt > 0) {
                ans -= 2;
                scnt--;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int c = k;
		for(int i = 1; i < n; i++){
			c *= k - 1;
		}
		System.out.println(c);
	}

}


Measured memory_bytes: 21844
import random

class RollingHash(object):
    def __init__(self, S: str, MOD: int = 10 ** 9 + 7, BASE: int = 10 ** 5 + 7):
        self.S = S
        self.N = N = len(S)
        self.MOD = MOD
        self.BASE = BASE
        self.S_arr = [ord(x) for x in S]

        self.POWER = [1] * (N + 1)
        self.HASH  = [0] * (N + 1)
        p, h = 1, 0
        for i in range(N):
            self.POWER[i + 1] = p = (p * BASE) % MOD
            self.HASH[i + 1] = h = (h * BASE + self.S_arr[i]) % MOD

    def hash(self, l: int, r: int):
        # get hash for S[l:r]
        _hash = (self.HASH[r] - self.HASH[l] * self.POWER[r - l]) % self.MOD
        return _hash

# 汎用的な二分探索のテンプレ
# check_func(x) = true となるxの最小値を探索する
# left : check_func(x) = falseとなるx
# right: check_func(x) = true となるx
# search_max: check_func(x) = true となるxの"最大値"を探索する場合はTrue
# check_func: answer <= x であればcheck_func(x) = true となるような関数
def binary_search(left: int, right: int, check_func, search_max:bool=False):
    # ok と ng のどちらが大きいかわからないことを考慮
    while abs(right - left) > 1:
        mid = (left + right) // 2
    
        if check_func(mid) ^ search_max:
            right = mid
            # print(left, right, mid, 't')
        else:
            left = mid
            # print(left, right, mid, 'f')

    return left if search_max else right

def main():
    N = int(input())
    S = input()
    MOD = 998244353
    BASE = 37 # random.randint(2, MOD-1)
    rs = RollingHash(S, MOD=MOD, BASE=BASE)

    D = [0] * N
    # 長さLの部分文字列同士が、範囲を重ねず同じ文字列となる場合はTrue,
    # そうでない場合はFalseを返す関数
    def isOK(L):
        if L == 0:
            return True
        
        for i in range(min(L, N - 2 * L + 1)):
            D[i] = rs.hash(i, i + L)
        hashes = set()
        for i in range(L, N - L + 1):
            # 自分より開始点がL以上前の文字列のハッシュを検索対象に追加
            hashes.add(D[i - L])
            D[i] = v = rs.hash(i, i + L)
            # ハッシュが衝突したら、範囲を重ねず同じ文字列となる文字列が存在することになる
            if v in hashes:
                return True
        return False

    # 範囲が重ならないことが条件にあるので、答えは最大でもN // 2（文字列の長さの半分）となる。
    # ただし、二分探索する上で絶対に答えとならない範囲を含めたいので、
    # 探索範囲としてはN // 2 + 1 と、+1しておく。
    ans = binary_search(0, N // 2 + 1, isOK, search_max=True)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
using namespace std;

int main(){
	int n, y, b, r, t, bank;
	float a, max;
	
	while(cin >> n, n){
		cin >> y;
		max = bank = 0;
		REP(i, n){
			cin >> b >> r >> t;
			
			if(t == 1){
				a = 1 + 1.0 * y * r / 100;
			}else{
				a = pow(1 + 1.0 * r / 100, y);
			}
			
			if(a > max){
				max = a;
				bank = b;
			}
		}
		
		cout << bank << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
  string A,B,C;
  while(1){
    cin >> A;
    if(A=="0")break;
    cin >> B >> C;
    unsigned long N=A.size();
    unsigned long long P[2][N+1];
    P[0][0]=1;
    P[1][0]=0;
    for(int n=0;n<N;++n){
      int unknown=0;
      unsigned long sub[2][2];
      string a,b,c;
      sub[0][0]=0;
      sub[0][1]=0;
      sub[1][0]=0;
      sub[1][1]=0;
      a=A[N-n-1];
      b=B[N-n-1];
      c=C[N-n-1];
      if(a=="?")unknown++;
      if(b=="?")unknown++;
      if(c=="?")unknown++;
      for(int i=0;i<2;++i){
	switch(unknown){
	case 0:
	  if((i+atoi(a.c_str())+atoi(b.c_str()))%10!=atoi(c.c_str())){
	    sub[i][0]=0;
	    sub[i][1]=0;
	  } else if(i+atoi(a.c_str())+atoi(b.c_str())>=10) {
	    sub[i][0]=0;
	    sub[i][1]=1;
	  } else {
	    sub[i][0]=1;
	    sub[i][1]=0;
	  }
	  break;

	case 1:
	  if(c=="?"){
	    if(i+atoi(a.c_str())+atoi(b.c_str())<10){
	      sub[i][0]=1;
	      sub[i][1]=0;
	    }else{
	      sub[i][0]=0;
	      sub[i][1]=1;
	    }
	  } else if( i+atoi(a.c_str())>atoi(c.c_str()) || i+atoi(b.c_str())>atoi(c.c_str())){ 
	    sub[i][0]=0;
	    sub[i][1]=1;
	  } else {
	    sub[i][0]=1;
	    sub[i][1]=0;
	  }
	  break;

	case 2:
	  if(a=="?"&&b=="?"){
	    sub[i][0]=atoi(c.c_str())+1-i;
	    sub[i][1]=10-sub[i][0];
	  } else { 
	    sub[i][1]=atoi(a.c_str())+atoi(b.c_str())+i;
	    sub[i][0]=10-sub[i][1];
	  }
	  break;
	  
	case 3:
	  sub[0][0]=55;
	  sub[0][1]=45;
	  sub[1][0]=45;
	  sub[1][1]=55;
	  break;
	}
      }
      if(n==N-1){
	sub[0][1]=0;
	sub[1][1]=0;
	for(int i=0;i<2;++i){
	  switch(unknown){
	  case 1:
	    if(i+atoi(a.c_str())==atoi(c.c_str()) ||
	       i+atoi(b.c_str())==atoi(c.c_str()) ||
	       i+atoi(a.c_str())+atoi(b.c_str())>9){
	      sub[i][0]=0;
	    }
	    break;
	  case 2:
	    if(a=="?"&&b=="?"){
	      if(atoi(c.c_str())-i-1>0)sub[i][0]=atoi(c.c_str())-i-1;
	      else sub[i][0]=0;
	    } else {
	      if(9-atoi(a.c_str())-atoi(b.c_str())-i>0) sub[i][0]=9-atoi(a.c_str())-atoi(b.c_str())-i;
	      else sub[i][0]=0;
	    }
	    break;
	  case 3:
	    sub[0][0]=36;
	    sub[1][0]=28;
	    break;
	  }
	}
      }
      P[0][n+1]=(P[0][n]*sub[0][0]+P[1][n]*sub[1][0])%1000000007;
      P[1][n+1]=(P[0][n]*sub[0][1]+P[1][n]*sub[1][1])%1000000007;
    }
    cout << P[0][N] << endl;
  }
}
  

Measured memory_bytes: 1188
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	string s;
	cin >> s;
	cout << 700 + count(all(s), 'o') * 100;
}	

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

int main(){
  double a;
  while(cin>>a){
    double ans=a;
    for(int i=2; i<=10; i++){
      if(i%2==0){
        ans+=(a*=2.0);
      }
      else{
        ans+=(a/=3.0);
      }
    }
    printf("%.10f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1236
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    D = ii()
    print('Christmas' + ' Eve'*(25-D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fc[100001], in[100001];

int pwmd(int a, int n = mod - 2)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}
int nCr(int n, int r)
{
     fc[0] = in[0] = 1;

	for (int i = 1; i <= 100000; ++i)
	{
		fc[i] = (i * fc[i - 1]) % mod;
		in[i] = pwmd(fc[i]);
	}

	int ans = fc[n];
	ans = (ans * in[r]) % mod;
	ans = (ans * in[n - r]) % mod;

	return ans;
}
int pow(int a,int b)
{
	int ans=1;
	while(b>0)
	{
		if(b&1)
			ans*=a;
		a*=a;
		b=b>>1;
	}
	return ans;
}
//vector<pair<int,int>> vec;
bool compare(pair<int,int> v1,pair<int,int> v2)
{
	return v1.ss<v2.ss;
}

vector<int> adj[200005];
int dis[200005];
void dfs1(int par, int u)
{
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dis[x]=dis[u]+1;
		dfs1(u,x);
	}
}

void dfs(int par, int u,bool *vis)
{
	vis[u]=true;
	for(int x:adj[u])
	{
		if(x==par)
			continue;
		dfs(u,x,vis);
		vis[x]=true;
	}
}

vector<int> vec[100001];
int32_t main()
{       
    FIO;
    int x;
    cin>>x;
    int i=0;
    int j=0;
    for(i=0;i<=100000;i++)
    {
    	for(j=-100;j<=10000;j++)
    		{
    			int temp=pow(i,5) - pow(j,5);
    			if(temp==x)
    				{
    					cout<<i<<" "<<j<<endl;
    					return 0;
    				}
    	    }
    }
   
}

Measured memory_bytes: 11288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double ans,t;
    if (x>=a*a*b/2.0){
        t=2.0*(a*a*b-x)/(a*a*a);
        ans=atan(t)/pi*180;
    }
    else {
        t=a*b*b/(2*x);
        ans=atan(t)/pi*180;
    }
    cout << fixed << setprecision(6);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int D,N; cin >> D >> N;
    int res;
    if(D == 0) res = 1;
    else if(D == 1) res = 100;
    else res = 10000;
    if(N == 100) cout << res*101 << endl;
    else cout << res*N << endl;
}

Measured memory_bytes: 256
let N = stdin.ReadLine() |> int
let H = stdin.ReadLine().Split() |> Array.map int

let rec resolver i =
    if i = 0 then "Yes"
    elif H.[i] + 1 < H.[i - 1] then "No"
    elif H.[i] + 1 = H.[i - 1] then
        H.[i - 1] <- H.[i - 1] - 1
        resolver (i - 1)
    else resolver (i - 1)

resolver (N - 1) |> stdout.WriteLine


Measured memory_bytes: 24796
#include <stdio.h>
#include <math.h>
double dist(int x[], int y[], int n, int p)
{
    if (p <= 3)
    {
        double sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum = sum + pow(abs(x[i] - y[i]), p);
        }
        return pow(sum, 1.0 / p);
    }
    else
    {
        double max = 0;
        for (int i = 0; i < n; i++)
        {
            int d = abs(x[i] - y[i]);
            if (d > max)
            {
                max = d;
            }
        }
        return max;
    }
}
int main()
{

    int n, x[100], y[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &y[i]);
    }
    printf("%.6lf\n", dist(x, y, n, 1));
    printf("%.6lf\n", dist(x, y, n, 2));
    printf("%.6lf\n", dist(x, y, n, 3));
    printf("%.6lf\n", dist(x, y, n, 4));
    return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
int main()
{
  int x,y,z;
  while(scanf("%d%d",&x,&y) != EOF)
    {
      if((x==0)&&(y==0)) break;
      if(x>y)
	{
	  z=y;
	  y=x;
	  x=z;
	}
      printf("%d %d\n",x,y);
    }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll h[100010],dp[100010];

int main(void){
	          ll i;

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

	          ll N;
	          cin >> N;
	          for(i=1;i<=N;i++) cin >> h[i];

	          dp[2]=llabs(h[2]-h[1]);
	          for(i=2;i<N;i++){
	        	  dp[i+1]=min(dp[i]+llabs(h[i+1]-h[i]),dp[i-1]+llabs(h[i+1]-h[i-1]));
	          }

	          cout << dp[N] << endl;

	          return 0;
}


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

int dp[1010][1010];

int main()
{
    int H, W; cin>>H>>W;
    vector<string> a(H);
    for(auto& e: a) cin>>e;

    const int mod=1e9+7;
    dp[0][0]=1;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) if (a[i][j]=='.') {
            if (i-1>=0) dp[i][j]+=dp[i-1][j];
            if (j-1>=0) dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[H-1][W-1]<<endl;
}


Measured memory_bytes: 5248
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

const int mod = 1e9 + 7;
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  string s;
  cin >> s;
  int n = sz(s);
  s = " " + s;
  vector<int> p10(n + 2, 1);
  for (int i = 1; i <= n + 1; i++) {
    p10[i] = p10[i - 1] * 10 % 13;
  }
  vector<vector<int>> dp(n + 1, vector<int>(13, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int k = p10[n - i];
    for (int j = 0; j < 13; j++) {
      if (s[i] == '?') {
        for (int d = 0; d < 10; d++) {
          int dk = k * d;
          dp[i][j] += dp[i - 1][(j - dk + 169) % 13];
          dp[i][j] %= mod;
        }
      } else {
        int d = s[i] - '0';
        int dk = k * d;
        dp[i][j] += dp[i - 1][(j - dk + 169) % 13];
        dp[i][j] %= mod;
      }
    }
  }
  cout << dp[n][5] << "\n";
}



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

int main(){
	int S;

	cin >> S;

	int h = S / 3600;
	int temp = S % 3600;
	int m = temp / 60;
	int s = temp % 60;

	cout << h << ':' << m << ':' << s << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}

const int MAX = 50;
int n, m;
int a[MAX], b[MAX];
bool graph[MAX][MAX];
bool vis[MAX];

void dfs(int x) {
	vis[x] = true;
	REP (i, n) {
		if (vis[i])continue;
		if (!graph[x][i])continue;
		dfs(i);
	}
}

int main() {
	IOS;
	ll ans = 0;
	MEM(graph, false);
	cin >> n >> m;
	REP(i, m){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	REP(i, m) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
		MEM(vis, false);
		dfs(0);
		bool bridge = true;
		REP(i, n)bridge = bridge && vis[i];
		if (!bridge)ans++;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int n,cnt,i;
int main(){
	scanf("%d",&n);
	cnt=7%n;
	if(n%2==0||n%5==0){
		printf("-1\n");
		return 0;
	}
	for(i=1;cnt!=0;++i)cnt=(cnt*10+7)%n;
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<map>
#include<set>
using namespace std;

map<long long,int> mp;
set<int> st;

int main ()
{
	int n,t,i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>t;
		mp[t]++;
		st.insert(t);
	}
	int bj=0;
	for(set<int>::iterator it=st.begin();it!=st.end();it++)
	{
		if(mp[*it]%2==1)
		{
			bj++;
		//	cout<<*it<<endl;
		//	cout<<mp[*it]<<endl;
		}
	}
	cout<<bj<<endl;
	return 0;
 } 

Measured memory_bytes: 11136
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# 
# 
# s = input()

n = int(input())
lst = [0]*n
for i in range(1, n+1):
    a, b = input().split()
    b = int(b)
    lst[i-1] = (a, -b, i)

lst.sort()
for i in range(n):
    print(lst[i][2])


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

const int N=1e5+5;
int n,q,u,v,x,fa[N];

int getfa(int x)
{
	if(fa[x]!=x) fa[x]=getfa(fa[x]);
	return fa[x];
}

int main()
{
	scanf("%d%d",&n,&q);int i;
	for(i=1;i<=n;++i) fa[i]=i;
	while(q--)
	{
		scanf("%d%d%d",&u,&v,&x);
		int fx=getfa(u),fy=getfa(v);
		if(fx!=fy) fa[fx]=fy;
	}
	
	int cnt=0;
	for(i=1;i<=n;++i)
	{
		getfa(i);
		if(fa[i]==i) ++cnt;
	}
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
char a[51][51],b[51][51];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			a[i][j]=getchar();
			while(a[i][j]!='#' && a[i][j]!='.')a[i][j]=getchar();
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			b[i][j]=getchar();
			while(b[i][j]!='#' && b[i][j]!='.')b[i][j]=getchar();
		}
	}
	for(int i=1;i<=n-m+1;i++)
	{
		for(int j=1;j<=n-m+1;j++)
		{
			bool f=true;
			for(int k=i;k<i+m;k++)
			{
				for(int l=j;l<j+m;l++)
				{
					if(a[k][l]!=b[k-i+1][l-j+1])
					{
						f=false;
						break;
					}
				}
				if(!f)break;
			}
			if(f)
			{
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n;
	int max=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>max)
		{
			max=a[i];
		}
		else
		{
			if(max-a[i]>=2)
			{
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace Number
{
    class Program
    {
        static void Main(string[] args)
        {
            double r = double.Parse(Console.ReadLine());

            Console.WriteLine("{0} {1}",
            (Math.Pow(r, 2) * Math.PI).ToString("0.000000"),
            (r * 2 * Math.PI).ToString("0.000000"));
        }
    }
}

Measured memory_bytes: 9412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var s = Console.ReadLine();

            Console.WriteLine(s.Substring(0,1)+(s.Length-2)+s.Substring(s.Length-1, 1));

            Console.Out.Flush();
        }
    }
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 1000005;
string s[MX];
int n;
ii a[MX];
vector<string> f, g;

void no () {
	cout << "No" << endl;
	exit(0);
}

int solve (vector<string> &s) {
	int n = s.size();

	forn (i, n) {
		int x = 0, mn = 0;
	
		for (char c : s[i]) {
			if (c == '(') x++;
			else x--;

			mn = min(mn, x);
		}

		a[i] = {mn, x};
	}

	sort(a, a + n, greater<ii>());

	int sum = 0;
	forn (i, n) {
		if (sum + a[i].fi < 0) no();
		sum += a[i].se;
	}

	return sum;
}

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

	cin >> n;

	forn (i, n) {
		cin >> s[i];

		int x = 0;

		for (char c : s[i]) {
			if (c == '(') x++;
			else x--;
		}

		if (x > 0) f.pb(s[i]);
		else {
			reverse(all(s[i]));
			for (char &c : s[i]) {
				if (c == '(') c = ')';
				else c = '(';
			}
			g.pb(s[i]);
		}
	}

	if (solve(f) == solve(g)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 73600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#include <map>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<int,int>;
const ll M = 1e9+7, mx = 301;
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; void chmax(ll& x, ll y) {if (x<y) x=y;}; void chmin(ll& x, ll y) {if (x>y) x=y;};

int main() {
  int n,k; cin>>n>>k;
  int p[n]; for(int i=0;i<n;i++) cin>>p[i];
  sort(p,p+n);
  int an=0;
  for(int i=0;i<k;i++) {
    an+=p[i];
  }
  cout<<an<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N, K; cin >> N >> K;
   vector<int> A(N);
   rep(i,N)cin>>A[i];
   map<int,int> cnt;
   ll sum = 0;
   ll ans = 0;
   cnt[0]++;
   queue<pair<int, int>> que;
   que.push({K-1,0});
   rep(i,N){
        if (que.front().first == i){
            cnt[que.front().second]--;
            que.pop();
        }
        sum += A[i]-1;
        sum %= K;
        ans += cnt[sum];
        cnt[sum]++;
        que.push({i+K,sum});
   }
   cout << ans << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a == b){
    cout << "a == b" << endl;
  }
  else if(a < b){
    cout << "a < b" << endl;
  }
  else if(a > b){
    cout << "a > b" << endl;
  }
}


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

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

	int o;
	if(n%2==0)
		o = n / 2;
	else
		o = (n + 1) / 2;

	cout << o << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int x, y;
typedef long long LL;
int main(){
	scanf("%d", &x);
	y = 1;
	while(y * (y + 1) / 2 < x) y++;
	printf("%d\n", y);
}

		

Measured memory_bytes: 128
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

int n, x, sum;

int main() {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%d",&x);
    sum += (x % 2);
  }

  if (sum % 2) puts("NO");
  else puts("YES");
  return 0;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n = int(input().strip())
    print(2*n*math.pi)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78336
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    int p[n];
    rep(i,0,n-1) cin>>p[i];
    int ans = 0;
    rep(i,1,n-2){
        if(p[i-1]<p[i]&&p[i]<p[i+1]) ans++;
        else if(p[i-1]>p[i]&&p[i]>p[i+1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[200001], b[200001];
int main() {

	//C
	int n, k;
	cin >> n >> k;
	int i;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		if (i - a[i] < 0) {
			b[0]++;
		}
		else {
			b[i - a[i]]++;
		}
		if (i + a[i] >= n) {

		}
		else {
			b[i + a[i] + 1]--;
		}
	}
	for (i = 1; i <= n; i++) {
		b[i] = b[i] + b[i - 1];
	}
	int c,flag;
	for (c = 0; c < k; c++) {
		flag = 0;
		for (i = 0; i <= n; i++) {
			a[i] = b[i];
			b[i] = 0;
		}
		for (i = 1; i <= n; i++) {
			if (i - a[i] < 0) {
				b[0]++;
			}
			else {
				b[i - a[i]]++;
			}
			if (i + a[i] >= n) {

			}
			else {
				b[i + a[i] + 1]--;
			}
		}
		for (i = 1; i <= n; i++) {
			b[i] = b[i] + b[i - 1];
		}
		for (i = 1; i <= n; i++) {
			if (a[i] != n) {
				flag = 1;
			}
		}
		if (flag == 0)break;
	}

	for (i = 1; i <= n; i++) {
		cout << a[i] << ' ';
	}






	//B
	/*long long int a, b, v, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}
	if (abs(a - b) <= t * (v - w)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
	*/

	//A
	/*string s;
	cin >> s;
	int i;
	for (i = 0; i < 3; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
	*/
}

Measured memory_bytes: 5172
#include<iostream>
int main()
{
	int D;
    scanf("%d",&D);
    int C[26];
    for(int a = 0; a < 26; a++)
    {
        scanf("%d",&(C[a]));
    }
    int SCORE[365][26];
    for(int a = 0; a < 365; a++)
    {
        for(int b = 0; b <26; b++)
        {
        	scanf("%d",&(SCORE[a][b]));
        }
    }
    int HUMANABC[26] = {0};
    int KEKKA[365] = {0};
    for(int a = 0; a < 365; a++)
    {
    	for(int b = 0; b <26; b++)
        {
        	HUMANABC[b] += C[b];
        }
        int GOUKEI[26] = {0};
        for(int c = 0; c <26; c++)
        {
            GOUKEI[c] = SCORE[a][c] + (365 - a) * (HUMANABC[c]);
        }
        for(int c = 0; c < 26; c++)
        {
            int n = 0;
            if(n < GOUKEI[c])
            {
                n = GOUKEI[c];
                KEKKA[a] = c;
            }
        }
        HUMANABC[KEKKA[a]] = 0;
    }
	for(int a = 0; a < 365; a++)
    {
    	printf("%d\n",KEKKA[a]);
    }
}


Measured memory_bytes: 3280
h,w=gets.split.map(&:to_i)
a = []
h.times do
  a.push gets.chomp.split('')
end
def up(x, y, a)
  if x == 0
    '.'
  else
    a[x - 1][y]
  end
end
def down(x, y, a)
  if x == (a.size - 1)
    '.'
  else
    a[x + 1][y]
  end
end
def left(x, y, a)
  if y == 0
    '.'
  else
    a[x][y - 1]
  end
end
def right(x, y, a)
  if y == (a[0].size - 1)
    '.'
  else
    a[x][y + 1]
  end
end
h.times do |i|
  w.times do |j|
    if a[i][j] == '#'
      if (left(i, j, a) == '#' && up(i, j, a) == '#') || (right(i, j, a) == '#' && down(i, j, a) == '#')
        puts 'Impossible'
        exit
      end
    end
  end
end
puts 'Possible'


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

using namespace std;

int main(){

    while(1){
        int N;
        cin>> N;
        if(!N) break;

        vector<pair<double, string>> V;
        for(int i=0; i<N; i++){
            string L;
            int P, A, B, C, D, E, F, S, M;
            cin>> L>> P>> A>> B>> C>> D>> E>> F>> S>> M;
            int T=A+B+C+D+E;
            int t=D+E;
            int R=F*S;
            for(int i=0; i<M-1; i++){
                T+=t;
                R+=F*S;
            }
            V.push_back(make_pair(-(double)(R-P)/T, L));
        }
        sort(V.begin(), V.end());
        for(int i=0; i<V.size(); i++){
            cout<< V[i].second<< endl;
        }cout<< "#"<< endl;
    }
}

Measured memory_bytes: 3148
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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



	ll N, M;
	cin >> N >> M;

	vl A(M);
	vector<bool> ok(N, true);
	rep(i, M) {
		cin >> A[i];
		ok[A[i]-1] = false;
	}

	vl DP(N+3,0);
	DP[1] = 1;

	rep(i, N) {
		if (!ok[i])continue;
		DP[i + 2] = (DP[i] + DP[i + 1]) % MOD;
	}

	cout << DP[N + 1] << endl;

	return 0;
}



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

int main()
{
	int N;
	cin >> N;
	vector<ll> a(N * 3);
	for (int i = 0; i < N * 3; i++) {
		cin >> a[i];
	}
	vector<ll> score(N + 1);
	priority_queue<ll, vector<ll>, greater<ll>> pq;
	priority_queue<ll> gq;
	ll tmp = 0;
	for (int i = 0; i <= N * 2; i++) {
		if(i >= N) score[i - N] = tmp;
		tmp += a[i];
		pq.push(a[i]);
		if (i >= N) {
			tmp -= pq.top();
			pq.pop();
		}
	}
	tmp = 0;
	for (int i = N * 3 - 1; i >= N - 1; i--) {
		if (i < N * 2) score[i - (N - 1)] -= tmp;
		tmp += a[i];
		gq.push(a[i]);
		if (i < N * 2) {
			tmp -= gq.top(); gq.pop();
		}
	}
	ll res = score[0];
	for (int i = 1; i <= N; i++) {
		res = max(res, score[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 6136
#include <cstdio>  
#include <algorithm>  
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
#define LL long long 
LL a[10500], b[10500];
int main()
{
	int n;
	while (~scanf("%d", &n))
	{
		for (int i = 0; i < n; i++)
			scanf("%lld", &a[i]);
		for (int i = 0; i < n; i++)
			scanf("%lld", &b[i]);
		LL sum = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] == b[i])continue;
			if (a[i] > b[i])
				sum += (LL)2 * (a[i] - b[i]);
			else
				sum -= ((b[i] - a[i]) / (LL)2) * 2;
		}
		if (sum>0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>

using ull = unsigned long long;

int main() {
	unsigned n;
	std::cin >> n;
	std::vector<int> v{ };
	v.reserve(n);

	int x = 11;
	while (v.size() < n) {
		
		auto max_ = static_cast<int>( std::sqrt(x) );
		bool is_prime = true;
		for (unsigned base_{ 3 }; base_<= max_; base_+=2) {
			if (x%base_ == 0) {
				is_prime = false;
				break;
			}
		}

		if (is_prime)
			v.push_back(x);
		x+=10;
	}
	
	std::cout << v[0];
	for (unsigned i{ 1 }; i < n; ++i)
		std::cout << " " << v[i];
	std::cout << "\n";
	return 0;
}

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

int main(){
  string s;
  while(true){
    cin >> s;
    int t=0;
    if(s=="0"){break;}
    for(int i=0;i<s.length();i++){
      t+=s[i]-'0';
    }
    cout << t<<endl;
  }

}


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

typedef long long lint;
typedef long double louble;

#define so(a) ((int)((a).size()))

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
	
	template<typename T> inline int ts(T *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 1000007;

int n,val[_],sval[_]={0},smx[_]={0};

int make(int lim)
{
	int now=0,mi=0;
	for(int i=1;i<=n;i++)
	{
		if(val[i]==0)now+=(now+2+(smx[i]-sval[i-1])<=lim)?1:-1;
		else now+=val[i];
		mi=min(mi,now);
	}
	return lim-mi;
}

int main()
{
	ios_base::sync_with_stdio(0),cout.tie(nullptr);

	n=ts(val+1);
	for(int i=1;i<=n;i++)
	{
		if(val[i]=='1')val[i]=1;
		else if(val[i]=='0')val[i]=-1;
		else val[i]=0;
		sval[i]=sval[i-1]+(val[i]==1?1:-1);
	}
	
	smx[n]=sval[n];
	for(int i=n-1;i>=1;i--)smx[i]=max(smx[i+1],sval[i]);

	int mxval=0;
	for(int i=1;i<=n;i++)mxval=max(mxval,sval[i]);
	cout<<min(make(mxval),make(mxval+1))<<lf;
	
	return 0;
}


Measured memory_bytes: 15372
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    xy=list(map(int,input().split()))
    while xy!=[0,0]:
        xy.sort()
        print(*xy)
        xy = list(map(int, input().split()))

main()



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n;
    ll power = 1;
    
    cin >> n;
    
    rep(i, n){
        power = power * (i+1);
        
        power = power % 1000000007;
    }
    
    cout << power << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int n,l,i,j;
	char str[101][101];
	char t[101];
	scanf("%d %d",&n,&l);
	for(i = 0;i < n;i++)
	{
		scanf("%s",str[i]);
	}
	for(i = 0;i < n - 1;i++)
	{
		for(j = 0;j < n - i - 1;j++)
		{
			if(strcmp(str[j],str[j + 1]) > 0)
			{
				strcpy(t,str[j + 1]);
				strcpy(str[j + 1],str[j]);
				strcpy(str[j],t);
			}
		}
	}
	for(i = 0;i < n;i++)
	{
		printf("%s",str[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#coding:utf-8
n = int(input())
A = list(map(int, input().split()))

B = " ".join([str(num) for num in A])
print(B)

for i in range(1, n):   
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1], A[j] = A[j], A[j+1]
        j -= 1
        
    B = " ".join([str(num) for num in A])
    print(B)




Measured memory_bytes: 5608