akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >>a>>b;
    
    if (a+b >= 24)cout << a+b-24 << endl;
    else cout << a+b << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.1415926535898
int main()
{
	int a,b;
	double h,m,d,u,z;
	scanf("%d%d%lf%lf",&a,&b,&h,&m);
	h=h*30+30*m/60.0;
	m*=6;
	z=fabs(h-m);
	if(z>=180.0) d=cos((360.0-z)*PI/180.0);
	else d=cos(z*PI/180.0);
	u=sqrt(a*a+b*b-2*a*b*d);
	printf("%.17lf",u);
	return 0; 
} 

Measured memory_bytes: 3644
import random

def calc_score(D, C, S, T):
    score = 0
    last = [0]*26
    for d in range(D):
        t = T[d] - 1
        score += S[d][t]
        last[t] = d + 1
        for i in range(26):
            score -= C[i]*(d + 1 - last[i])
    return score

def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))

    last = [0]*26
    ans = []
    for d in range(D):
        score = -100*365*365
        t = 0
        for i in range(26):
            tmp = S[d][i]
            for j in range(26):
                if i != j:
                    tmp -= C[j]*(d + 1 - last[j])
            if tmp > score:
                score = tmp
                t = i + 1
        last[t - 1] = d + 1
        ans.append(t)
    score = calc_score(D, C, S, ans)
    for i in range(10**3):
        d = random.randint(0, D - 1)
        t = random.randint(1, 26)
        org_t = ans[d]
        ans[d] = t
        s = calc_score(D, C, S, ans)
        if s <= score:
            ans[d] = org_t
        else:
            score = s
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9736
import math
import copy

N = int(input())

if N == 1 :
    print(1)
else :
    ball = [0] * N

    for i in range(N) :
        ball[i] = list(map(int,input().split()))

    ans = N - 1
    pq = []

    # p,q の組
    for i in range(N) :
        for j in range(N) :
            p = ball[j][0] - ball[i][0]
            q = ball[j][1] - ball[i][1]

            if p == 0 and q == 0 :
                continue
            pq.append((p,q))

    ans = N - 1

    for p , q in pq :
        check = [0] * N
        count = 0

        for i in range(N) :
            if check[i] == 0 :
                check[i] = 1
                count += 1
                for j in range(1,N) : # 上
                    if [ball[i][0] - j * p , ball[i][1] - j * q] in ball :
                        index = ball.index([ball[i][0] - j * p , ball[i][1] - j * q])
                        check[index] = 1
                    else :
                        break
                for j in range(1,N) : # 下
                    if [ball[i][0] + j * p , ball[i][1] + j * q] in ball :
                        index = ball.index([ball[i][0] + j * p , ball[i][1] + j * q])
                        check[index] = 1
                    else :
                        break
        ans = min(ans,count)
    print(ans)

Measured memory_bytes: 3828
import sys
input = sys.stdin.readline

S = list(input().strip())

y = int("{}{}".format(S[0], S[1]))
m = int("{}{}".format(S[2], S[3]))

c = 0

if m >= 1 and m <= 12:
    c += 1
if y >= 1 and y <= 12:
    c += 2

if c == 1:
    print("YYMM")
elif c == 2:
    print("MMYY")
elif c == 3:
    print("AMBIGUOUS")
elif c == 0:
    print("NA")

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

#define REP( i, n) for( int i = 0; i < (n); ++i)
#define FOR( i, a, b) for( int i = (a); i < (b); ++i)

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){
  int n;
  std::vector<int> a;
  int ans = 0;

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

  bool f = true;
  while(f){
    f = true;
    for( int i = 0; i < n; ++i){
      if( a[i]%2 != 0){
        f = false;
      }
      a[i] /= 2;
    }
    if(f){
      ++ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <queue>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	
	priority_queue<double, vector<double>, greater<double> > pq;
	
	for (int i = 0; i < n ; ++i) {
		double k;
		cin >> k;
		pq.push(k);
	}
	
	// N > 2
	while (pq.size() > 1) {
		double a = pq.top(); pq.pop();
		double b = pq.top(); pq.pop();
		
		double c = (a+b)/2;
		pq.push(c); 
	}
	
	cout << pq.top() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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 my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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



const long long INF = 1LL << 60;

int main() {
    long long X, Y;
    cin >> X >> Y;
    bool ok = true;
    long long ans = 1;
    while (ok) {
        X = X * 2;
        if (X > Y) {
            break;
        }
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long x = sc.NextLong();

        for (long a = 0; a <= 1000; a++)
        {
            for (long b = -1000; b <= a; b++)
            {
                long answer = (a - b) * ((a * a * a * a) + (a * a * a * b) + (a * a * b * b) + (a * b * b * b) + (b * b * b * b));
                if (answer == x)
                {
                    Console.WriteLine(a + " " + b);
                    return;
                }
            }
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27540
#include<cstdio>
#include<cmath>
int main(){
    char s1[15],s2[15],s3[15];
    scanf("%s %s %s",s1,s2,s3);
    printf("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);
    return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, m, c; cin >> n >> m >> c;
	vector<int> b(m);
	int a, ans = 0;
	for (int i = 0; i < m; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) {
		int tmp = c;
		for (int j = 0; j < m; ++j) {
			cin >> a;
			tmp += a * b[j];
		}
		if (tmp > 0) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1000000000;

int main() {
  //
  string s;
  cin >> s;
  vi ch(26, 0);
  rep(i, s.size()) { ch[s[i] - 'a'] = 1; }
  int e = -1;
  rep(i, 26) {
    if (ch[i] == 0) {
      e = i;
      break;
    }
  }
  if (e >= 0) {
    cout << s + string(1, 'a' + e);
    return 0;
  }
  for (int i = s.size() - 2; i >= 0; i--) {
    if (s[i] < s[i + 1]) {
      char smallest = 'z';
      for (int j = i + 1; j < s.size(); j++) {
        if (s[j] > s[i]) {
          smallest = min(smallest, s[j]);
        }
      }
      s[i] = smallest;
      cout << s.substr(0, i + 1) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);

  int sum=0;
  rep(i,n) sum+=a.at(i);
  int ave=sum/n;

  int ans1=0;
  rep(i,n) ans1+=(a.at(i)-ave)*(a.at(i)-ave);

  ave++;
  int ans2=0;
  rep(i,n) ans2+=(a.at(i)-ave)*(a.at(i)-ave);

  cout << min(ans1, ans2);
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;   cin>>n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}

    sort(arr,arr+n);

    int lower, upper;
    lower=arr[0];   upper=arr[n-1];
    std::map<int, int> mp;
    int total;
    
    for(int i=lower;i<=upper;i++){
    	total=0;
    	for (int j = 0; j < n; ++j)
    	{
    		     total+=((arr[j]-i)*(arr[j]-i));
    	}
    	mp[total]=i;
    }
    
    map<int,int>::iterator it;
    it=mp.begin();
    	cout<<it->first;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int a[100];
	int n;
	int ck=0;
	a[0]=0;
	cin>>n;

	for (int i = 1; i <=n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 1; i <= n; ++i)
	{
		if(a[i]==i)
			continue;
		else {
			int t=a[i];
			int c=a[t];
			a[t]=a[i];
			a[i]=c;
			ck=1;
			break;
		}
	}

	for (int i = 1; i <=n; ++i)
	{
		if(a[i]==i)
			continue;
		else{
			ck=2;
			break;
		}
	}

	if(ck==2)
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;


	return 0;
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll N;
    cin>>N;
    typedef pair<ll,ll> P;
    vector<P> A(N);

    rep(i,N){
        ll a;
        cin>>a;
        A[i] = P{i,a};
    }

    sort(A.begin(),A.end(),[](P p1, P p2){return p1.second>p2.second;});
    
    ll dp[N+1][N+1] = {};
    dp[0][0] = 0;
    rep(i,N){
        ll ind,a;
        ind = A[i].first+1;
        a = A[i].second;

        rep(x,i+1){
            ll y = i-x;
            dp[x+1][y] = max(dp[x+1][y],dp[x][y]+a*(ind-(x+1)));
            dp[x][y+1] = max(dp[x][y+1],dp[x][y]+a*((N-(y-1))-(ind+1)));
        }
    }

    ll ans = 0;
    rep(i,N+1){
        ans = max(ans,dp[i][N-i]);
    }

    cout<<ans<<"\n";
    



	return 0;
}

Measured memory_bytes: 34972
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int i,h[n];
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	sort(h,h+n);
	int s,d=h[n-1];
	for(i=0;i<=n-k;i++)
	{
		s=h[i+k-1]-h[i];
		if(s<d)
		{
			d=s;	
		}
	}
	cout<<d<<endl;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




ll power(ll x,ll k){
  ll ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}



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

  int c[300000]={};
  rep(i,n){
    c[i]=(i?c[i-1]:0)+(s[i]=='1');
  }

  int ans=power(2,c[n-1]);

  rep(i,n){
    if(s[i]=='1'){
      int res=power(2,c[i]-1)*power(3,n-i-1);
      res%=M;
      ans+=res;
      ans%=M;
    }
  }

  cout<<ans<<endl;
}


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

#define int long long

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 1) {
      if (i + 1 < n && a[i + 1] > 0) {
        --a[i];
        --a[i + 1];
        ++res;
      }
    }
  }
  for (int i = 0; i < n; i++)
    res += a[i] / 2;
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, m, cost[114514];
vector<int>G[114514];
bool used[114514];
void dfs(int x, vector<int>& v) {
	used[x] = true;
	for (int i : G[x]) {
		if (!used[i]) {
			v.push_back(cost[i]);
			dfs(i, v);
		}
	}
}
signed main() {
	cin >> n >> m;
	rep(i, n)cin >> cost[i];
	rep(i, m) {
		int a, b; cin >> a >> b;
		G[a].push_back(b); G[b].push_back(a);
	}
	int ans = 0, cnt = 0;
	vector<int>x;
	rep(i, n) {
		if (used[i])continue;
		vector<int>v; v.push_back(cost[i]); dfs(i, v);
		cnt++;
		int mi = inf, index;
		rep(j, v.size()) {
			if (mi > v[j]) {
				mi = v[j]; index = j;
			}
		}
		ans += mi;
		v.erase(v.begin() + index);
		x.insert(x.end(), v.begin(), v.end());
	}
	sort(all(x));
	int memo = 2 * (cnt - 1) - cnt;
	if (m == n - 1) {
		cout << 0 << endl; return 0;
	}
	if ((int)x.size() < memo) {
		cout << "Impossible" << endl; return 0;
	}
	rep(i, memo)ans += x[i];
	cout << ans << endl;
}

Measured memory_bytes: 9204
n = int(input())
def main(n):
    if n == 1:
        return 2,0
    
    if n == 3:
        return 3,0
    m = n //2 
    for i in range(1,m+1):
        if i * (i + 1) <= 2*n < (i+1)*(i+2):
           right  = i + 1
           break
       
    diff = right * (right+1) //2 - n
       
    return right+1,diff


right,diff = main(n)

for i in range(1,right):
    if i != diff:
        print(i)
        
    

Measured memory_bytes: 3408
/*
This is code of SuperJ6 for Atcoder.
Don't copy my code during f*kin' contests.

2.71828182845904523536
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std;
#define endl '\n'

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(7);
	
	int n;
	cin >> n;
	
	double a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	
	double sum = a[0];
	for(int i = 1; i < n; i++) sum = (sum + a[i]) / 2;
	
	cout << sum << endl;

	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static int D;
        static List<int> monitors;

        static void Main(string[] args)
        {
            //[summary]B - Golden Apple
            var line = ReadLine();
            int N = line[0];
            D = line[1];

            monitors = new List<int>();

            for(int i = 1; i <= N; i++)
            {
                if (!IsMonitorning(i))
                {
                    monitors.Add(i + D);
                }
            }

            Console.WriteLine(monitors.Count);
        }

        static bool IsMonitorning(int i)
        {
            foreach(var m in monitors)
            {
                int left = m - D;
                int right = m + D;

                if (left <= i && i <= right)
                {
                    return true;
                }
            }

            return false;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <map>
#include <memory.h>

using namespace std;

int a[200002],o[200002];
int n;

int getOs(int p) {
	int s = 0;
	for (int i = p; i <= n;i+=p) {
		s += o[i];
	}
	return s % 2;
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int c = 0;
	for (int i = n; i >= 1; i--) {
		int cur = 0;
		if (getOs(i) != a[i])o[i] = 1,c++;
	}
	cout << c << endl;
	for (int i = 1; i <=n; i++) {
		if (o[i])cout << i << " ";
	}
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(long long N, std::string S)
{
    vector<int> R(N);
    vector<int> G(N);
    vector<int> B(N);
    int rcnt = 0;
    int gcnt = 0;
    int bcnt = 0;
    rep(i, S.length())
    {
        if (S[i] == 'R')
        {
            rcnt++;
            R[i] = rcnt;
            G[i] = gcnt;
            B[i] = bcnt;
        }
        else if (S[i] == 'G')
        {
            gcnt++;
            R[i] = rcnt;
            G[i] = gcnt;
            B[i] = bcnt;
        }
        else if (S[i] == 'B')
        {
            bcnt++;
            R[i] = rcnt;
            G[i] = gcnt;
            B[i] = bcnt;
        }
    }

    ll tot = 0;
    rep(i, S.length())
    {
        int dis = 0;
        char c1 = S[i];
        char c2 = 0, c3 = 0;
        for (int j = i + 1; j < S.length(); j++)
        {
            if (c1 != S[j])
            {
                c2 = S[j];
                dis = j - i;

                if (c1 != 'R' && c2 != 'R')
                {
                    tot += R.back() - R[j];
                    if (j + dis < N && S[j + dis] == 'R')
                        tot--;
                }
                else if (c1 != 'G' && c2 != 'G')
                {
                    tot += G.back() - G[j];
                    if (j + dis < N && S[j + dis] == 'G')
                        tot--;
                }
                else
                {
                    tot += B.back() - B[j];
                    if (j + dis < N && S[j + dis] == 'B')
                        tot--;
                }
            }
        }
        if (c2 == 0)
        {
            break;
        }
    }
    cout << tot << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3756
# Aizu Problem 0105: Book Index
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


index = {}
for line in sys.stdin:
    word, page = line.split()
    if word not in index:
        index[word] = []
    index[word].append(int(page))

for word in sorted(index.keys()):
    print(word)
    print(' '.join([str(page) for page in sorted(index[word])]))

Measured memory_bytes: 7764
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[] a = new int[n];
        int[] b = new int[n];
        int answer = 0;
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            sc.nextLine();
            answer += b[i]-a[i]+1;
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


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

int main() {
ll a,b;
cin>>a>>b;
cout<<max({a+b,a-b,a*b})<<endl;
return 0;




}





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

int s[100009] = {0};
int n;
int main(){
    cin >> n;
    for(int i = 0 ; i < n; ++i){
        int a;
        scanf("%d", &a);
        s[max(0, a-1)]++;
        s[a+2]--;
    }
    for(int i = 0; i < 100003; ++i){
        s[i+1] = s[i+1]+s[i];
    }
    int maxI = 0;
    int index = 0;
    for(int i = 0; i < 100003; ++i){
        if(maxI < s[i]){
            maxI = s[i];
            index = i;
        }
    }

    cout << maxI << endl;
    return 0;

}


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    constexpr ll INF = 1e18;
    vector<ll> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + k and j < n; ++j) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n - 1] << '\n';
    
    return 0;
}


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

using namespace std;

uint64_t eval(const vector<int64_t>& in) {
  deque<int64_t> arr;
  int l = 0, r = in.size() - 1;
  arr.push_back(in[l++]);
  while (l <= r) {
    if (((arr.size() + 1)/ 2) % 2 == 1) {
      if (arr.size() % 2 == 0) {
        arr.push_back(in[r--]);
      } else {
        arr.push_front(in[r--]);
      }
    } else {
      if (arr.size() % 2 == 0) {
        arr.push_back(in[l++]);
      } else {
        arr.push_front(in[l++]);
      }
    }
  }

  uint64_t ans = 0;
  for (size_t i = 1; i < arr.size(); ++i) {
    ans += abs(arr[i] - arr[i - 1]);
  }
  return ans;
}

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

  int n;
  cin >> n;
  vector<int64_t> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  uint64_t ans1 = eval(a);
  reverse(a.begin(), a.end());
  uint64_t ans2 = eval(a);
  cout << max(ans1, ans2) << "\n";
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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 <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  string s; cin >> s;
  s += "$";
  int res = 0;
  rep(i, n){
    if(s[i] != s[i+1])++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
n=int(input())
l=[]
for i in range(n):
    l.append(input())
ac,re,tle,wa=0,0,0,0
for i in range(n):
    if(l[i]=='AC'):
        ac+=1
        
    if(l[i]=='RE'):
        re+=1
        
    if(l[i]=='TLE'):
        tle+=1
        
    if(l[i]=='WA'):
        wa+=1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll n,k;
	cin>>n>>k;
	n=n%k;
	cout<<min(min(n,abs(n-k)+k),abs(n-k))<<endl;return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H,W;
    cin>>H>>W;
    int cnt=0;
    rep(i,0,H){
        rep(j,0,W){
            char c;
            cin>>c;
            if(c=='#') cnt++;
        }
    }
    cout <<(cnt==H+W-1?"Possible":"Impossible")<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;
    string v;
    cin >> v;
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    if(v.length() == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[256];
string x;
int main(){
  cin>>x;
  for(char c:x)a[c]++;
  for(int c='a';c<='z';c++){
    if(!a[c]){
        putchar(c);
        return 0;
     }
  }
  puts("None");
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9
const int mod = 1e9+7;
int N;

int main(){
  cin >> N;
  vector<int> soin(51, 0);
  ll ans = 0;
  FOR(i, 2, N+1){
    int n = i;
    int j = 2;
    while(n != 1){
      while(n % j == 0){
        soin[j]++;
        n /= j;
      }
      j++;
    }
  }
  sort(soin.begin(), soin.end());
  REP(i, 51){
    if(soin[i] < 2) continue;
    REP(j, 51){
      if(i==j) continue;
      if(soin[j] < 4) continue;
      ans+= 51-j-1;
      if(i > j) ans--;
    }
  }
  REP(i, 51){
    if(soin[i] < 2) continue;
    REP(j, 51){
      if(i==j) continue;
      if(soin[j] >= 24){
        ans += 51-j;
        if(i > j) ans--;
        break;
      }
    }
  }
  REP(i, 51){
    if(soin[i] < 4) continue;
    REP(j, 51){
      if(i==j) continue;
      if(soin[j] >= 14){
        ans += 51-j;
        if(i > j) ans--;
        break;
      }
    }
  }
  REP(i, 51){
    if(soin[i] >= 74){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    
    vector<int> di={-1,-1,0,1,1,1,0,-1};
    vector<int> dj={0,1,1,1,0,-1,-1,-1};
    
    vector<string> t(h);
    rep(i,h)rep(j,w){
        if(s[i][j]=='#'){
            t[i].push_back('#');
            continue;
        }
        
        int count = 0;
        
        rep(k,8){
            int ni = i+di[k];
            int nj = j+dj[k];
            if(ni<0 || ni>=h)continue;
            if(nj<0 || nj>=w)continue;
            
            if(s[ni][nj]=='#')
                count++;
        }
        
        t[i].push_back((char)count+'0');
        
    }
    
    rep(i,h)cout<<t[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for a in range(min(n, k) + 1):
    for b in range(min(n, k) - a + 1):
        li = v[:a]
        if b > 0:
            li += v[-b:]
        li.sort()
        count = 0
        while (a + b + count < k):
            if len(li) > 0 and li[0] < 0:
                count += 1
                li = li[1:]
            else:
                break
        ans = max(ans, sum(li))

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

struct S{
    int A;
    int B;
    double v;

    S(int A, int B){
        this->A = A;
        this->B = B;
    }

    bool operator<(const S &l) const{
        return static_cast<double>(B)/A < static_cast<double>(l.B)/l.A;
    };
};

struct P{
    int x;
    int y;

    P(int x, int y){
        this->x = x;
        this->y = y;
    }
};

int main() {
    int N;
    int cnt=0;
    int min;

    cin >> N;

    for(int i=0;i<N;i++){
        int p;
        cin >> p;
        if(cnt==0){
            min=p;
            cnt++;
        }else{
            if(min>=p){
                min=p;
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<long long> ss(a), tt(b);
    for (int i = 0; i < a; i++) {
        cin >> ss[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> tt[i];
    }
    auto nearest_s = [&](long long x) -> vector<long long> {
        auto it = lower_bound(ss.begin(), ss.end(), x);
        if (it == ss.end()) {
            --it;
            return {*it};
        } else if (it == ss.begin()) {
            return {*it};
        } else {
            vector<long long> ret = {*it};
            --it;
            ret.push_back(*it);
            return ret;
        }
    };
    auto nearest_t = [&](long long x) -> vector<long long> {
        auto it = lower_bound(tt.begin(), tt.end(), x);
        if (it == tt.end()) {
            --it;
            return {*it};
        } else if (it == tt.begin()) {
            return {*it};
        } else {
            vector<long long> ret = {*it};
            --it;
            ret.push_back(*it);
            return ret;
        }
    };
    while (q--) {
        long long x;
        cin >> x;
        long long ans = 1e18;
        for (long long s : nearest_s(x)) {
            long long tmp = abs(x - s);
            for (long long t : nearest_t(s)) {
                ans = min(ans, tmp + abs(s - t));
            }
        }
        for (long long t : nearest_t(x)) {
            long long tmp = abs(x - t);
            for (long long s : nearest_s(t)) {
                ans = min(ans, tmp + abs(t - s));
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T a,Args... args) {cout<<a<<' ';debug(args...);}
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;

const ll MAX = 3234566667ll;
vector<ll> ans;

void f(ll n) {
    if (n > MAX) return;
    ans.pb(n);
    int d = n%10;
    int a = max(0, d-1);
    int b = min(9, d+1);
    fore(i,a,b+1) {
        f(n*10+i);
    }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
    #else
    	#define endl '\n'
    #endif
    fore(i,1,10) f(i);
    sort(ans.begin(), ans.end());
    int k;
    while (cin >> k) {
        cout << ans[k-1] << endl;
    }
}


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

int N;
int main (){
    cin >> N;
    int x;
    int n = N;
    while( n > 0) {
        x += n % 10;
        n /= 10;
    }
    if( N % x == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main() {
  int n,a[200000];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  int mark;
  if(a[0] < a[1]) mark = 0;
  if(a[0] > a[1]) mark = 1;
  if(a[0] == a[1]) mark = 2;
  
  int cnt = 1;
  for(int i = 1; i < n-1; i++) {
    if(mark == -1) {
      if(a[i] < a[i+1]) mark = 0;
      if(a[i] > a[i+1]) mark = 1;
      if(a[i] == a[i+1]) mark = 2;
    }
    if(mark == 0) {
      if(a[i] > a[i+1]) {
        cnt++; mark = -1; 
      }
    }
    if(mark == 1) {
      if(a[i] < a[i+1]) {
        cnt++; mark = -1; 
      }
    }
    if(mark == 2) mark = -1;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4000
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#ifndef rd
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int a[205];
int bits[60];
void add(int n) {
	for(int i=59; i>=0; i--) {
		if((n>>i)&1) {
			if(bits[i])
				n^=bits[i];
			else {
				bits[i]=n;
				break;
			}
		}
	}
}
int mini(int n) {
	for(int i=59; i>=0; i--)
		if((n^bits[i])<n)
			n^=bits[i];
	return n;
}
void solve() {
	int n;
	cin>>n;
	memset(bits,0,sizeof(bits));
	rep(i,0,n)
		cin>>a[i];
	string s;
	cin>>s;
	for(int i=n-1; i>=0; i--) {
		if(s[i]=='0') {
			add(a[i]);
		} else if(mini(a[i])){
			cout<<1<<endl;
			return;
		}
	}
	cout<<0<<endl;

}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(8);
	int t=1;
	cin>>t;
	fr(i,1,t)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include <cmath>

using namespace std;

int main() {
	long long int N;
	cin >> N;

	long long int answer = pow(10, 13);

	long long int Q = pow(10, 6);

	for (long long int i = 1; i <= Q; i++) {


		long long int W = N % i;

		//cout << i << endl;

		if (W == 0) {
			long long int E = N / i;
			long long int R = (i - 1) + (E - 1);

			//cout << R << endl;

			if (R < answer) {
				answer = R;
			}

		}
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[200000];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int ans=0;
	for(int i=1;i<=n+1;i++)ans+=abs(a[i]-a[i-1]);
	for(int i=1;i<=n;i++)cout<<ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

void solve(){
    int N, Y;
    cin >> N >> Y;

    for (int i = 0; i <= Y / 10000 ; i++) {
        for (int j = 0; j <= (Y - 10000*i) / 5000; j++) {
            if (10000*i + 5000*j + (N-i-j)*1000 == Y) {
                cout << i << " " << j << " " << N-i-j << endl;
                return;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define mii map<int,int>
#define nl "\n"

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	string s;
	cin>>s;
	map<char,int> m;
	string ans="yes";
	REP(i,s.length())
	{
		if(m[s.at(i)]!=1)
			m[s.at(i)]=1;
		else
		{
			ans="no";
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256