akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

#define N 100100

//head

int r, c;
int n;
map<int, int> mp;
stack<int> st;

int haji(int i, int j) {
  if(i == 0) return j;
  if(j == c) return c+i;
  if(i == r) return r+c*2-j;
  if(j == 0) return r*2+c*2-i;
  return -1;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> r >> c;
  cin >> n;
  rep(i, n) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int u = haji(x1, y1), v = haji(x2, y2);
    if(u != -1 and v != -1) {
      mp[u] = i;
      mp[v] = i;
    }
  }

  for(P x:mp) {
    if(!st.empty() and st.top() == x.second) st.pop();
    else st.emplace(x.second);
  }

  cout << (st.empty()?"YES":"NO") << '\n';
}

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

#define ll long long

ll n;

int main(){
	scanf("%lld", &n);
	int ans = INT_MAX;
	for (ll i = 1; i * i <= n; ++ i){
		if (n % i){
			continue;
		}
		ll x = n / i, y = i;
		int cnt1 = 0, cnt2 = 0;
		while (x){
			++ cnt1;
			x /= 10;
		}
		while (y){
			++ cnt2;
			y /= 10;
		}
		ans = std::min(ans, std::max(cnt1, cnt2));
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  bool flag = false;
  rep(i,n){
    int a; cin >> a;
    if(a%2){
      flag = true;
    }
  }
  if(flag){
    cout << "first" << endl;
  } else {
    cout << "second" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	int x=700;
	cin>>a;
	if(a=='o') x+=100;
	cin>>a;
	if(a=='o') x+=100;
	cin>>a;
	if(a=='o') x+=100;
	cout<<x;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,x,y,z;
    cin>>a>>b>>c>>d;
    if(a>b)
    {
        x=a-b;
    }
    else
    {
        x=b-a;
    }
    if(b>c)
    {
        y=b-c;
    }
    else
    {
        y=c-b;
    }
    if(c>a)
    {
        z=c-a;
    }
    else
    {
        z=a-c;
    }
    if( (x<=d && y<=d)|| z<=d)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3620
k = io.read("*n")

if k % 2 == 0 then
  print(-1)
  return
end

sevens = 7
step = 1

while sevens % k ~= 0 do
  if step > 10 ^ 6 then
    step = -1
    break
  end

  sevens = sevens * 10 + 7
  sevens = sevens % k
  step = step + 1
end

print(step)


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


const int maxn = 2000+100;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;
LL A[maxn];
int n;
LL x;

LL Min[maxn][maxn];



int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%d %lld",&n,&x);

    for(int i = 0;i < n;++i)
    {
        scanf("%d",&A[i]);
    }



    for(int i = 0;i < n;++i)
        Min[i][0] = A[i];

    for(int len = 1;len < n;++len)
    {
        for(int i = 0;i < n;++i)
        {
            int reach;
            if(i >= len)
                reach = i-len;
            else
            {
                int lft = len-i;
                reach = n-lft;
            }


            Min[i][len] = min(Min[i][len-1],A[reach]);
        }
    }

    LL res = INF;
    for(int len = 0;len < n;++len)
    {
        LL now = len*x;
        for(int i = 0;i < n;++i)
            now += Min[i][len];

       // printf("**** %lld\n",now);
        res = min(res,now);
    }


    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 33152
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int p[n];
  int max = 0,maxi,sum=0;
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=0;i<n;i++){
    if(max < p[i]){
      max = p[i];
      maxi = i;
    }
  }
  p[maxi] /= 2;
  for(int i=0;i<n;i++){
    sum += p[i];
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		while(true)
		{
			int n = sc.nextInt();
			int q = sc.nextInt();
			
			if(n == 0)return;
			
			int[] arr = new int[100];
			
			for(int i = 0; i < n; i++)
			{
				int m = sc.nextInt();
				
				for(int j = 0; j < m; j++)
				{
					arr[sc.nextInt()] += 1;
				}
			}
			
			int bestd = 0;
			int mostn = q-1;
			for(int i = 0; i < 100; i++)
			{
				if(arr[i] > mostn)
				{
					bestd = i;
					mostn = arr[i];
				}
			}
			
			System.out.println(bestd);
		}
	}

}



Measured memory_bytes: 67716
#include <iostream>

#define INF  10000000000

long H, W;

long partition(long height, long width) {
    long res = INF;
    long smax, smin;
    long sa, sb, sc;
    for (int h=1; h<height; ++h) {
        sa = h*width;
        long w = width / 2;
        sb = w * (height - h);
        sc = (width - w) * (height - h);
        smax = std::max(sa, std::max(sb, sc));
        smin = std::min(sa, std::min(sb, sc));
        res = std::min(smax - smin, res);
        sb = ( (height - h) / 2 ) * width;
        sc = height * width - sa - sb;
        smax = std::max(sa, std::max(sb, sc));
        smin = std::min(sa, std::min(sb, sc));
        res = std::min(smax - smin, res);
    }
    return res;
}

long solve() {
    long mh = H % 3, mw = W % 3;
    if (mh == 0 || mw == 0) return 0;
    return std::min( partition(H, W), partition(W, H) );
}

int main() {
    std::cin >> H >> W;
    std::cout << solve() << std::endl;
    return 0;
}

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

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

template<class T> T next() {
	T t;
	cin >> t;
	return t;
}

int main(){
	bool yes[30] = {};
	times(i, 28){
		yes[next<int>()-1]=true;
	}
	times(i,30){
		if(!yes[i]) cout << i+1 << endl;
	}
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    vector<ll> frees;
    ll need = 0;
    int res = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] > B[i]) {
        frees.push_back(A[i] - B[i]);
      }
      if (A[i] < B[i]) {
        need += B[i] - A[i];
        ++res;
      }
    }
    sort(frees.rbegin(), frees.rend());
    for (int i = 0; i < frees.size() && need > 0; i++) {
      ++res;
      need -= min(need, frees[i]);
    }
    if (need > 0) res = -1;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n,a,f=0;
  cin>>n;
  map<ll,ll> mp;
  for(ll i=0;i<n;i++){
	cin>>a;
    mp[a]++;
    if(mp[a]!=1){
      f++;
    }
  }
  if(f>0){
    cout<<"NO\n";
  }else{
    cout<<"YES\n";
  }
  return(0);
}

Measured memory_bytes: 12800
#include <cstdio>



int main() {

    int rez = 0;
    char ch = fgetc(stdin);
    char x = ch;
    ch = fgetc(stdin);
    while (ch != '\n') {
        if(x != ch)
            rez++;
        x = ch;
        ch = fgetc(stdin);
    }
    printf("%d", rez);
    return 0;
}


Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.trim().split('\n');
 
var ret = lines.filter(function(line) {
    var items = line.split(',');
    var w = +items[1];
    var h = +items[2];

    return w / (h * h) >= 25;
});

ret.forEach(function(line) {
    console.log(line.split(',')[0]);
});

Measured memory_bytes: 7636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int W, N;
int w[2000], v[2000];
int dp[2000][2000];

int main() {
	int it = 1;
	while (cin >> W >> N) {
		if (W == 0) break;

		for (int i = 0; i < N; ++i) scanf("%d,%d", &v[i], &w[i]);
		memset(dp, -1, sizeof(dp));

		dp[0][0] = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= W; ++j) {
				int nj = j + w[i];
				if (nj <= W) {
					chmax(dp[i+1][nj], dp[i][j] + v[i]);
				}
				chmax(dp[i+1][j], dp[i][j]);
			}
		}

		int res = -1, wei = -1;
		for (int i = 0; i <= W; ++i)if ( chmax(res, dp[N][i]) ) wei = i;
		cout << "Case " << it << ":" << endl;
		cout << res << endl;
		cout << wei << endl;
		++it;
	}
    
    return 0;
}


Measured memory_bytes: 16892
#abc088d

H,W=map(int,raw_input().split())
maze=[]
for i in xrange(H):
 maze.append(list(raw_input()))
d=[[-1 for i in xrange(W+1)] for j in xrange(H+1)]
dx=[1,0,-1,0]
dy=[0,1,0,-1]

def bfs():
 q=[]
 q.insert(0,(0,0))
 d[sx][sy]=0
 while len(q):
  x,y=q.pop()
  if x==gx and y==gy:
   break
  for i in xrange(4):
   nx,ny=x+dx[i],y+dy[i]
   if 0<=nx<H and 0<=ny<W and maze[nx][ny]!='#' and d[nx][ny]==-1:
    q.insert(0,(nx,ny))
    d[nx][ny]=d[x][y]+1
 return d[gx][gy]
sx,sy=0,0
gx,gy=H-1,W-1

def cntsharp():
 cnt=0
 for i in xrange(H):
  cnt+=maze[i].count('#')
 return cnt
if bfs()==-1:
 print -1
else:
 print H*W-(bfs()+cntsharp())-1


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

using namespace std;

#define db double
#define ll long long
#define down(i,j,n) for(register int i=j;i>=n;i--)
#define up(i,j,n) for(register int i=j;i<=n;i++)
#define pb push_back
#define se second
#define fi first
#define pa pair<int,int>
#define mp make_pair
#define FILE "dealing"
template<class T> bool cmax(T& a,T b){return a<b?a=b,true:false;}
template<class T> bool cmin(T& a,T b){return a>b?a=b,true:false;}
template<class T> T squ(T a){return a*a;}
int read(){
	int x=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return f*x;
}
const int maxn=52,inf=100000000,mod=1e9+7;
int mul(int a,int b){return 1LL*a*b%mod;}
int sub(int a,int b){return (a-=b)<0  ?a+mod:a;}

ll a[maxn],f[maxn][2];
int p,n;
int main(){
//	freopen(FILE".in","r",stdin);freopen(FILE".out","w",stdout);
	n=read(),p=read();
	up(i,1,n)a[i]=read()%2;
	f[0][0]=1;
	up(i,1,n)up(j,0,1)f[i][j]=f[i-1][(j-a[i]+2)%2]+f[i-1][j];
	cout<<f[n][p]<<endl;
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
	int x,i,j,k,m;
	char a[201],b[101][201];
	j=0;
	while (1) {
		scanf("%s",a );
		if(a[0]=='-')break;
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%d",&x );
			strcpy(b[j],a+x);
			strncat(b[j],a,x);
			strcpy(a,b[j]);

		}	j++;
	}
	for(i=0;i<j;i++)printf("%s\n",b[i]);

	return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
	int H, A;
	scanf("%d %d", &H, &A);
	if(H % A ==0){
		printf("%d\n", H/A);
	}else{
		printf("%d\n", H/A+1);
	}
	return 0;
}

Measured memory_bytes: 128
/*author : Yashvardhan
Sunday, April 12, 2020
5:31 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

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

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

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

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	int ans = 0;
	for(int i = 1; i <= n; i++){
		if((i%3 != 0) && (i%5 != 0)){
			ans += i;
		}
	}

	cout << ans << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



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

int main() {
int a,b,x;
  cin >> a >> b >> x;
  if(a+b >= x && a <=x)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq; 
class Program
    {
        static void Main(string[] args)
        {
            var Array = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int X = Array[0];
            int A = Array[1];

            if (X < A)
                Console.WriteLine("0");
            else if (X >= A)
                Console.WriteLine("10");

        }
    }

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

string S;
ll N;
ll ans = 0;

void dfs(ll now, ll temp, ll sum){
    if(now == N){
        ans += sum;
    }
    else{
        if(now == N-1){
            //tempで受け取った値にくっつけて加算
            dfs(now+1, 0, sum + 10*temp+(S[now]-'0'));
        }
        else{
            //tempで受け取った値にくっつけて加算
            dfs(now+1, 0, sum + 10*temp+(S[now]-'0'));

            // 今は加算せずにtempにくっつけて渡す
            dfs(now+1, 10*temp+(S[now]-'0'), sum);
        }
    }
}

int main()
{
    cout << fixed << setprecision(15);
    cin >> S;

    N = S.length();

    dfs(0, 0, 0);

    cout << ans << endl;
    return 0;
}

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

int main(){
	int N,A,B;
	string S;
	cin>>N>>A>>B;
	cin>>S;
	int a=0,b=0;
	for(int i=0;i<N;i++){
		if(S[i]=='a' && (a+b)<(A+B)){
			cout<<"Yes"<<endl;
			a++;
		}else if(S[i]=='b' && (a+b)<(A+B) && b<B){
			cout<<"Yes"<<endl;
			b++;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const ll MOD = 1000000007;

int main() {
   int n; scanf("%d", &n);
   vector<int> l(n);
   for (int& i : l)
      scanf("%d", &i);
   sort(all(l));
   ll total = 0;
   for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
         int left = j + 1, right = n - 1;
         int ans = j;
         while (left <= right) {
            int mid = left + (right - left) / 2;
            if (l[mid] < l[i] + l[j]) {
               ans = mid;
               left = mid + 1;
            } else {
               right = mid - 1;
            }
         }
         total += ans - j;
      }
   }
   printf("%lld", total);
   return 0;
}

Measured memory_bytes: 256
#1_A
def insertion_sort(a, n):
    for i in range(n-1):
        j = i
        i = i + 1
        v = a[i]
        while j>=0 and a[j]>v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        
        pr = str(a[0])
        for i in range(n-1):
            i = i + 1
            pr += " " + str(a[i])
        print(pr)

n = int(input())
a = list(map(int, input().split()))

pr = str(a[0])
for i in range(n-1):
    i = i + 1
    pr += " " + str(a[i])
print(pr)

insertion_sort(a, n)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
struct rbtree: tree<T,null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>{};
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;

int main(){
    IOS;
    ll a, b; cin>>a>>b;
    cout<<a*b/__gcd(a, b);



    return 0;
}

Measured memory_bytes: 256
ll = list(input())

dp1 = [0 for i in range(len(ll))]
dp2 = [0 for i in range(len(ll))]
for idx, l in enumerate(ll):
    if l == "1":
        if idx == 0:
            dp1[0] = 2
            dp2[0] = 1
        else:
            dp1[idx] = dp1[idx-1] * 2
            dp2[idx] = dp2[idx-1] * 3 + dp1[idx-1]
            dp1[idx] %= 10**9+7
            dp2[idx] %= 10**9+7
    else:
        dp1[idx] = dp1[idx-1]
        dp2[idx] = dp2[idx-1] * 3
        dp2[idx] %= 10**9+7

print((dp1[-1] + dp2[-1]) % (10**9+7))

Measured memory_bytes: 51468
function koch(points, cnt) {
	if (cnt == 0) {
		return points;
	}

	var newPoints = [];
	newPoints.push(points[0]);
	for (var i = 0; i < points.length - 1; i++) {
		var p1 = points[i];
		var p2 = points[i + 1];

		var dx = (p2.x - p1.x) / 3;
		var dy = (p2.y - p1.y) / 3;

		var s = {x: p1.x + dx, y: p1.y + dy};
		var t = {x: p1.x + dx * 2, y: p1.y + dy * 2};
		var u = {x: s.x + dx * Math.cos(Math.PI / 3) - dy * Math.sin(Math.PI / 3), y: s.y + dx * Math.sin(Math.PI / 3) + dy * Math.cos(Math.PI / 3)};

		newPoints.push(s);
		newPoints.push(u);
		newPoints.push(t);
		newPoints.push(p2);
	}
	return koch(newPoints, cnt - 1);
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var n = +(input.split('\n')[0]);

var start = [{x: 0, y: 0}, {x: 100, y: 0}];
var end = koch(start, n);

for (var i = 0; i < end.length; i++) {
	console.log(end[i].x.toFixed(5) + ' ' + end[i].y.toFixed(5));
}

Measured memory_bytes: 11724
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a[4]={},cnt,ans=inf;
  for(int i=0; i<4; i++) {
    cin >> a[i];
  }
  sort(a,a+4);
  do{
    cnt=0;
    cnt+=a[0]+a[1];
    cnt-=a[2]+a[3];
    ans=min(ans,abs(cnt));
  }while(next_permutation(a,a+4));
  cout << ans << endl;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
const int N=26;

int r,c,a[3],b[3],ct[N];
bool flag[N*4][N*4];
char cc;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> r >> c;
	for (int i=1;i<=r;i++){
		for (int j=1;j<=c;j++){
			if (!flag[i][j]){
				int now=0;
				now+=c+1-j>j;
				now+=r+1-i>i;
				a[now]++;
				flag[i][j]++;
				flag[i][c+1-j]++;
				flag[r+1-i][j]++;
				flag[r+1-i][c+1-j]++;
			}
		}
	}
	r*=c;
	while (r--){
		cin >> cc;
		ct[cc-'a']++;
	}
	for (int i=0;i<26;i++){
		b[2]+=ct[i]/4;
		ct[i]%=4;
		b[1]+=ct[i]/2;
		ct[i]%=2;
		b[0]+=ct[i];
	}
	if (b[2]>=a[2]){
		b[1]+=(b[2]-a[2])*2;
		if (b[1]>=a[1]){
			b[0]+=(b[1]-a[1])*2;
			if (b[0]>=a[0]){
				cout << "Yes\n";
			}else{
				cout << "No\n";
			}
		}else{
			cout << "No\n";
		}
	}else{
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,k;
    cin >> n >> k;
    ll ans = n % k ;
    cout << min(ans,abs(ans-k)) << endl;
}

Measured memory_bytes: 256
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
bl.append(0)

mons = 0
b0 = 0

for a, b in zip(al, bl):
    # print('a:{}, b:{}, b0:{}'.format(a, b, b0))
    if a >= (b + b0):
        mons += (b + b0)
        b0 = 0
    else:
        mons += a

        # a <= b0 -> b0=b
        # a > b0 -> b0=b-(a-b0)

        b0 = b - max(0, a-b0)

        # b0 = max(0, b-(b0-a))
    # print('mons:{}'.format(mons))

print(mons)



#
#
#
# for a, b in zip(al, bl):
#     a = max(0, a - b0)
#     if a >= b:
#         mons += b
#     else:
#         mons += a
#         b0 = b - a
#
# print(mons)

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	int count = 0;
	for(int i = 0 ; i < N ; i++){
		int input;  cin >> input;
		if(input == count + 1)  count += 1;
	}

	if(count)   cout << N - count << endl;
	else        cout << -1 << endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  
  return x;
}

Node treeMaximum(Node x){
 while(x->right != NIL){
    x = x->right;
  }
  
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)return u;

  if(k < u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL)x = y->left;
  else x = y->right;

  if(x != NIL)x->parent = y->parent;

  if(y->parent == NIL)root = x;
  else if(y == y->parent->left)y->parent->left = x;
  else y->parent->right = x;

  if(y != z)z->key = y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL)root = z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;

}

void inorder(Node u){
 
  if(u == NIL)return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
 
  if(u == NIL)return;
  
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int main(){
  int N, M;
  cin >> N >> M;
  int A[M];
  rep(i, M) cin >> A[i];

  ll sums = 0;
  rep(i, M) sums += A[i];
  cout << max((ll)-1, N - sums) << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
int mod=1e9+7;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
   int x,y;
   cin>>x>>y;
   if(y&1) {
    puts("No");
    return 0;
   }
   int l=2*x,r=4*x;
   if(y>=l&&y<=r)
   {
       puts("Yes");
   }
   else
     puts("No");
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  string S; cin >> S;
  ll h = 0, t = 0;
  for (ll j=0; j < S.length(); ++j) {
    if (S[j] == 'A') {
      h=j; break;
    }
  }
  for (ll j=S.length()-1; 0 <= j; --j) {
    if (S[j] == 'Z') {
      t=j; break;
    }
  }
  cout << t-h+1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N, C;
	cin >> N >> C;
	vector<unsigned long long> D(C * C);
	vector<int> c(N * N);
	for (auto i = 0; i < C * C; ++i)
	{
		cin >> D[i];
	}
	for (auto i = 0; i < N * N; ++i)
	{
		cin >> c[i];
	}

	vector<vector<int>> list(3);
	for (auto i = 1; i <= N; ++i)
	{
		for (auto j = 1; j <= N; ++j)
		{
			list[(i + j) % 3].push_back((i - 1) * N + j - 1);
		}
	}

	vector<vector<unsigned long long>> diff(3);
	for (auto j = 0; j < 3; ++j)
	{
		auto& tempDiff = diff[j];
		auto& tempList = list[j];
		for (auto i = 1; i <= C; ++i)
		{
			auto sum = 0ull;
			for (auto k = 0; k < tempList.size(); ++k)
			{
				sum += D[(c[tempList[k]] - 1) * C + i - 1];
			}
			tempDiff.push_back(sum);
		}
	}

	auto result = ULLONG_MAX;
	for (auto i = 0; i < C; ++i)
	{
		for (auto j = 0; j < C; ++j)
		{
			if (i == j)
			{
				continue;
			}
			for (auto k = 0; k < C; ++k)
			{
				if (i == k || j == k)
				{
					continue;
				}

				result = min(result, diff[0][i] + diff[1][j] + diff[2][k]);
			}
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 2552
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <vector>
#define R register
#define IN inline
#define gc getchar()
#define ll long long
#define MX 105
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
int n, sum;
std::vector <int> eve, odd;
int main(void)
{
	in(sum), in(n);
	int foo;
	for (R int i = 1; i <= n; ++i)
	{
		in(foo);
		if (foo & 1) odd.push_back(foo);
		else eve.push_back(foo);
	}
	if (n == 1)
	{
		if (sum == 1) printf("1\n1\n1");
		else printf("%d\n2\n%d %d", sum, 1, sum - 1);
		return 0;
	}
	if (odd.size() > 2) return puts("Impossible"), 0;
	else if (odd.size() == 2)
	{
		if (odd[0] > odd[1]) std::swap(odd[0], odd[1]);
		printf("%d ", odd[0]);
		for (auto i : eve) printf("%d ", i);
		printf("%d\n", odd[1]);
		odd[0]--, odd[1]++;
		if (!odd[0]) printf("%d\n", n - 1);
		else printf("%d\n%d ", n, odd[0]);
		for (auto i : eve) printf("%d ", i);
		printf("%d ", odd[1]);
	}
	else if (odd.size() == 1)
	{
		printf("%d ", odd[0]);
		for (auto i : eve) printf("%d ", i);
		puts("");
		odd[0]++, eve[eve.size() - 1]--;
		printf("%d\n", n);
		printf("%d ", odd[0]);
		for (auto i : eve) printf("%d ", i);
	}
	else
	{
		for (auto i : eve) printf("%d ", i);
		eve[0]++, eve[eve.size() - 1]--;
		printf("\n%d\n", n);
		for (auto i : eve) printf("%d ", i);
	}
}

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

ll a[300000];

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin>>n; ll sum = 0;
	for (int i = 1; i <= n; i++) {
		cin>>a[i]; sum += a[i];
	}

	ll cur = 0; ll best = 1e16;

	for (int i = 1; i <= n-1; i++) {
		cur += a[i];
		if (abs(cur - (sum-cur)) < best) {
			best = abs(cur - (sum-cur));
		}
	}

	cout<<best<<endl;
}


Measured memory_bytes: 1792
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn main() {
    let N: usize = read_line().parse().unwrap();
    let mut d = read_vec();
    d.sort();
    println!("{}", d[N/2]-d[N/2-1]);
}


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

int main()
{
	int N,a,num[5]={};
	cin>>N;
	while(N--)
	{
		string str;
		cin>>str;
		if(str=="AC")
		{
			num[1]++;
		}
		if(str=="WA")
		{
			num[2]++;
		}
		if(str=="TLE")
		{
			num[3]++;
		}
		if(str=="RE")
		{
			num[4]++;
		}
	}
	printf("AC x %d\n",num[1]);
	printf("WA x %d\n",num[2]);
	printf("TLE x %d\n",num[3]);
	printf("RE x %d\n",num[4]);
	return 0;
	
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int D[10]={0,2,5,5,4,5,6,3,7,6};
int C[10];

int num[101010];
int best[101010];

int hoge(int L) {
	if(L==0) return 0;
	if(num[L]!=-1) return num[L];
	
	num[L]=-101010;
	int i;
	
	FOR(i,10) if(C[i] && L>=C[i]) {
		int cand=hoge(L-C[i]);
		if(cand+1>=num[L]) num[L]=cand+1, best[L]=i;
	}
	return num[L];
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x;
		C[x]=D[x];
	}
	MINUS(num);
	
	string S;
	hoge(N);
	while(N) {
		x=best[N];
		S.push_back('0'+x);
		N-=D[best[N]];
	}
	sort(ALL(S));
	reverse(ALL(S));
	cout<<S<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 896
/*3.2 hightierra*/
#include <stdio.h>
 
int main(void){
    //変数の定義
    int N,a;
    scanf("%d",&N);
    //iにNの１の位を代入
    a = N % 10;
 
    //iの値で場合わけ
    switch(a){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
          printf("hon");
          break;
        case 0:
        case 1:
        case 6:
        case 8:
          printf("pon");
          break;
        case 3:
          printf("bon");
          break;
    }
    return 0;
}

Measured memory_bytes: 1736
defmodule Main do
  def main do
    a=%{0=>"pon",1=>"pon",2=>"hon",3=>"bon",4=>"hon",5=>"hon",6=>"pon",7=>"hon",8=>"pon",9=>"hon"}
    IO.gets("") |> String.trim |> String.to_integer
    |>Integer.mod(10)
    |>(fn x-> IO.puts(a[x]) end).()
  end
end


Measured memory_bytes: 30528
n = int(input())
ans = '00' if n == 0 else '0'
i = 1
pm = 1
while n != 0:
    a = 2**i
    b = abs(n) % a
    if b == 0:
        ans = ans + '0'
    else:
        ans = ans + '1'
        n -= pm*a/2
    pm = -pm
    i += 1
print(int(ans[i:0:-1]))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    int m, f, r;
    while(cin >> m >> f >> r) {
        int mf = m + f;
        if (m == -1 && f == -1 && r == -1) break;
        string score;
        if ((m == -1 || f == -1) || (mf < 30)) {
            score = "F";
        } else if (mf >= 80) {
            score = "A";
        } else if (mf >= 65 && mf < 80) {
            score = "B";
        } else if (mf >= 50 && mf < 65) {
            score = "C";
        } else if (mf >= 30 && mf < 50) {
            if (r >= 50) score = "C";
            else score = "D";
        }
        cout << score << endl;
    }

    return 0;
}


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


int main() {
double a;
string s;
int  n;
  double sum;
cin >> n;
for(int i = 0;i < n;i++){
  cin >>a;
  cin >> s;
  if(s == "JPY"){
    sum += a;
    //cout << sum <<endl;
  }
  else{
    sum += a*380000;
  //  cout << sum <<endl;
  }
}
cout << sum << endl;
}



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

{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    int i,j,x,y,s=0,hp;
    for(i=1;i<=n;i++)
    {
        x=0;
        y=i;
        for(j=0;;j++)
        {
            if(pow(10,j)>y)
            {
                hp=j-1;
                break;
            }
        }
        for(j=hp;j>=0;j--)
        {
            int power=pow(10,j);
            x=x+y/power;
            y=y%power;
        }



        if(x>=a&&x<=b)
        {
            s=s+i;
        }
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String n = in.next();
            int max = 9 * (n.length() - 1), sum = 0;
            for (int i = 0; i < n.length(); i++) {
                sum += n.charAt(i) - '0';
            }
            max = Math.max(max, sum);
            for (int i = n.length() - 1; i >= 0; i--) {
                int curr = n.charAt(i) - '0';
                sum -= curr;
                if (curr > 0) {
                    max = Math.max(max, sum + curr - 1 + 9 * (n.length() - 1 - i));
                }
            }
            out.println(max);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 87;
pair<int,int> a[N];
long long ans[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a+1,a+1+n);
    int mi = N;
    for (int i = n; i >= 1; --i) {
        mi = min(a[i].second,mi);
        ans[mi] += (a[i].first - a[i-1].first) * (n-i+1LL);
    }
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 2688
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int dp[45] = {};
int fib(int a) {
	if (a == 0 || a == 1) return 1;
	if (dp[a] != 0) return dp[a];
	return dp[a] = fib(a - 1) + fib(a - 2);
}
int main() {
	int n = 0;
	scanf("%d", &n);
	printf("%d\n", fib(n));
}


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

int M,C,N;
int D[20][111];
int Ds[20];
int used[111];
int pl[111];
int res;
const int MAX = 101;
vector<int> B[111];
void init(){
  memset( D, 0, sizeof( D ) );
  memset( Ds,0,sizeof( Ds ) );
  memset( pl,0,sizeof( pl ) );
  memset(used,0,sizeof(used));
  res = 0;
  used[MAX] = (1<<29);
}

void put(int q,int id){
  Ds[id]++;
  D[id][q] = 1;
  pl[q] = id;
  res += id+1;
}

void take(int q,int id){
  Ds[id]--;
  D[id][q] = 0;
  pl[q] = -1;
  res += id+1;
}
bool pcheck(int id){
  if( id==M ) return true;
  return Ds[id] < C;
}

int main(){
  while( cin >> M >> C >> N && (M||C||N) ){

    init();
    for(int i=0;i<N;i++){
      int k; cin >> k;
      B[i].resize(k);
      for( int &b : B[i] ) {
        cin >> b;
        D[M][b] = 1;
        pl[b] = M;
      }
    }
    vector<int> query;
    for(int j=0;j<=50;j++){
      for(int i=0;i<N;i++){
        if( (int)B[i].size() <= j ) continue;
        query.push_back( B[i][j] );
      }
    }

    int cnt=1;
    res = 0;
    for( int q: query ){
      used[q] = cnt++;
      for(int i=0;i<=M;i++){
        if( pcheck( i ) || i == pl[q] ){
          take( q, pl[q] );
          put( q, i );          
          break;
        }
      }
      if( pl[q] == 0 ) continue;
      int maxid = MAX;
      for(int i=0;i<=100;i++){
        if( D[0][i] )
          if( used[maxid] > used[i] ) maxid = i;        
      }
      for(int i=1;i<=M;i++){
        if( pcheck( i ) ){          
          take( maxid, pl[maxid] );
          put( maxid, i );    
          break;
        }        
      }
      take( q, pl[q] );
      put( q, 0 );
    }
    cout << res << endl;

  }
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
  int n, m;
  cin >> n;
  map<string, int> list;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    list[s]++;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    list[s]--;
  }

  int ans = 0;
  for (auto i = list.begin(); i != list.end(); i++) {
    if (ans < i->second) {
      ans = i->second;
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define ll long long
typedef pair<ll, ll> P;

int main(){
    ll X,A,B,N, K,sum=0,l=0,r=0, tmp = 1000000000000000000LL;;
    cin >> N;
    vector<int> a(N);
    vector< set<ll> > E(N); 
    P p;
    queue<P> pairs;
    vector<ll> dist1(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        a[i]--;
        E[i].insert(a[i]);
    }

    for(int i = 0; i < N; i++){
        dist1[i] = -1;
    }
    dist1[0] = 0;

    //cul dist1
    for(auto i: E[0]){
        // cout << i << endl;
        pairs.push(make_pair(i,1));
    }
    while(pairs.size()){
        p = pairs.front();
        pairs.pop();
        int d = p.second;
        int n = p.first;
        if(dist1[n] == -1){
            dist1[n] = d;
            for(auto i: E[n]) pairs.push(make_pair(i, d+1));
        }
    }
    cout << dist1[1] << endl;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
const int N=3005;
const int MOD=1e9+7;
int n,dp[N][N],ans; 
char s[N];
int main() {
	scanf("%d%s",&n,s+1);
	dp[0][1]=1;
	for(int i=1;s[i];i++){
		int pre[N]={0};
		for(int j=1;j<=i+1;j++)pre[j]=(pre[j-1]+dp[i-1][j])%MOD;
		if(s[i]=='<'){
			for(int j=1;j<=i+1;j++){
				dp[i][j]=pre[j-1];
			}
		} else {
			for(int j=1;j<=i+1;j++){
				dp[i][j]=(pre[i+1]-pre[j-1]+MOD)%MOD;
			}
		}
		if(i==n-1)for(int j=1;j<=n;j++)(ans+=dp[i][j])%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 34176
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    let Rstock = 0;
    let Lstock = 0;
    let splitPoint;
    let splitCount = 0;
    
    let answer = [...Array(S.length)].fill(0);

    for(let i=0; i<S.length-1; i++) {
        if(S[i] === "R") Rstock++;
        if(S[i] === "L") Lstock++;
        
        // RL の部分であるかどうか
        if(S[i] !== S[parseInt(i) + 1]) {
            splitCount++;
            
            if(splitCount === 1) {
                splitPoint = i;
            }
        }
        
        if(splitCount === 2) {
            if((Rstock + Lstock) % 2 === 0) {
                answer[splitPoint]     = (Rstock + Lstock) / 2;
                answer[splitPoint + 1] = (Rstock + Lstock) / 2;
            } else {
                answer[splitPoint]     = Math.floor(Lstock / 2) + 1 + Math.floor((Rstock - 1) / 2) ;
                answer[splitPoint + 1] = Math.floor(Rstock / 2) + 1 + Math.floor((Lstock - 1) / 2);
            }
            
            splitCount = 0;
            
            Rstock = 0;
            Lstock = 0;
        }
        
        if(i === S.length - 2) {
            Lstock++;
            
           if((Rstock + Lstock) % 2 === 0) {
                answer[splitPoint]     = (Rstock + Lstock) / 2;
                answer[splitPoint + 1] = (Rstock + Lstock) / 2;
            } else {
                answer[splitPoint]     = Math.floor(Lstock / 2) + 1 + Math.floor((Rstock - 1) / 2);
                answer[splitPoint + 1] = Math.floor(Rstock / 2) + 1 + Math.floor((Lstock - 1) / 2);
            }
        }
    }
    
    console.log(answer.join(" "));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 16424
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M; cin >> M;
    cout << 48 - M << endl;

    return 0;
}


Measured memory_bytes: 256