akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = [INT() for _ in range(M)]

b = [0] * (N + 2)
# 壊れているところが1
for i in A:
    b[i] = 1

dp = [0] * (N + 2)
# for i in range():

dp[0] = 1

if b[1] == 1:
    # あなあいてるのでそのルートは考えられない
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, N + 1):
    if b[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]

ans = dp[N] % mod
print(ans)


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

using namespace std;
int N,K;
vector<int> nex;
priority_queue<int> q;
bool cnt(){
  vector<int> tmp;
  for(int i=0;i<K;i++){
    if( q.empty() ) return false;
    int t = q.top(); q.pop();
    if( t == 0 ) return false;
    tmp.push_back( t-1 );
  }
  for(int t : tmp ) q.push( t );
  return true;
}

int main(){
  cin >> N >> K;
  vector<string> S;
  S.resize(N);
  nex.resize(26);
  for(string& s: S) cin >> s;
  sort( S.begin(), S.end() );
  for(int i=N-1;i>-1;i--)
    nex[S[i][0]-'A']++;
  for(int i=0;i<26;i++)
    q.push( nex[i] );
  int res = 0;
  for(int i=0;i<N;i++){
    if( cnt() ) res++;
    else break;
  }
  cout << res << endl;
  
}


Measured memory_bytes: 896
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

struct state {
	int p, t, c;
	state(int p, int t, int c) : p(p), t(t), c(c) {};
	bool operator<(const state &o)const {
		return o.c<c;
	}
};

int main() {
	int c, n, m, s, d;
	while(cin >> c >> n >> m >> s >> d, c) {
		vvi dist(n, vi(n, INF));
		int a, b, f;
		REP(i, m) {
			cin >> a >> b >> f;
			dist[a-1][b-1] = dist[b-1][a-1] = f;
		}
	

		priority_queue<state> Q;
		vvi cost(n, vi(c+1, INF));
		Q.push(state(s-1, 0, 0));
		cost[s-1][0] = 0;
		while(!Q.empty()) {
			state st = Q.top();
			Q.pop();

			if(st.p == d-1) {
				continue;
			}

			REP(i, n) {
				if(st.p != i) {
					if(st.t < c) {
						int nc = st.c + dist[st.p][i]/2;
						if(nc < cost[i][st.t+1]) {
							cost[i][st.t+1] = nc;
							Q.push(state(i, st.t+1, nc));
						}
					}
					int nc = st.c + dist[st.p][i];
					if(nc < cost[i][st.t]) {
						cost[i][st.t] = nc;
						Q.push(state(i, st.t, nc));
					}
				}
			}
		}

		int ans = INF;
		REP(i, c+1) {
			ans = min(ans, cost[d-1][i]);
		}

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

Measured memory_bytes: 1312
print [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
][int(raw_input())-1]

Measured memory_bytes: 27884
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  for(int i = 0;i < 3;i++)cin >>a.at(i);
  sort(a.begin(),a.end());
  cout << a.at(2)*10 + a.at(1) +a.at(0) << endl;
}

Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    while(cin>>n){

        int arr[n];
        f0(n)cin>>arr[i];
        int ans=0;
        for(int i=0;i<n-2;i++){
            //cout << arr[i] << " ";
            for(int j=i+1;j<n-1;j++){
                for(int k=j+1;k<n;k++){
                    if(arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k])
                    {
                        vector<int>vec;
                        vec.pb(arr[i]);
                        vec.pb(arr[j]);
                        vec.pb(arr[k]);
                        sort(ALL(vec));
                        if(vec[0]+vec[1]>vec[2])ans++;
                    }
                }
            }

        }
        cout << ans << endl;
    }

    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

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

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

//ax+by=cの整数解(x,y)のうちの一つ
pll extgcd(ll a, ll b, ll c){
    if(b == 0){
        return pll(c/a, 0);
    }
    else{
        pll p = extgcd(b, a%b, c);
        ll x = p.second, y = p.first;
        return pll(x, y-(a/b)*x);
    }
}

int main(){
    int N;
    cin >> N;
    ll x[N], y[N];
    rep(i, N) cin >> x[i] >> y[i];
    int ans = inf;
    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    rep(i, N){
        rep(j, N){
            if(i == j) continue;
            ll a = x[j]-x[i], b = y[j]-y[i];
            int tmp = 0;
            rep(k, N){
                bool same = false;
                rep(l, N){
                    if(x[l]-x[k] == a && y[l]-y[k] == b) same = true;
                }
                if(!same) tmp++;
            }
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
		String s = sc.next();
		for (int i = 0; i < s.length() -  1; i++) {
			
			if (s.charAt(i) == s.charAt(i+1)) {
				System.out.println((i + 1) + " " + (i + 2));
				return;
			} else if (i < s.length() - 2 && s.charAt(i) == s.charAt(i+2)) {				
				System.out.println((i + 1) + " " + (i + 3));
				return;
			}
		}
		System.out.println("-1 -1");
	}
}

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

int main(void){

    int x,n;

    scanf("%d %d",&x,&n);
    // printf("%d %d",x,n);
    if (n==0){
        printf("%d\n",x);
        return 0;
    }

    int p[n];
    int min=0;
    int ans=0;
    int flag=0;

    for (int i=0;i<n;i++){
        scanf("%d",&p[i]);
        if (x==p[i])
            flag=1;
    }

    if (flag==0){
        printf("%d\n",x);
        return 0;
    }

    for (int i=1;i<100;i++){
        int flag1=0;
        int flag2=0;
        for (int j=0;j<n;j++){
            if (x-i==p[j])
                flag1=1;
            else if (x+i==p[j])
                flag2=1;
        }
        // printf("i=%d flag1=%d flag2=%d\n",i,flag1,flag2);
        if ((flag1==0 && flag2==0) || (flag1==0 && flag2==1)){
            printf("%d\n",x-i);
            break;
        }else if (flag1==1 && flag2==0){
            printf("%d\n",x+i);
            break;
        }

    }
    
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll x,n;cin>>x>>n;
	ll a[n+2];mi mp;
	rep(i,1,n+1)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	ll mini=hell;
	ll ans;
	rep(i,-1000,1001)
	{
		if(mp.find(i)!=mp.end())
			continue;
		ll diff=abs(i-x);
		if(diff<mini)
		{
			mini=diff;
			ans=i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3652
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] A = new long[n+1];
        for(int i=1;i<=n;i++) A[i]=sc.nextLong();
        String ans = help(n,A);
        System.out.println(ans);

    }
    static String help(int n, long[] A){
        if(n==1) return "YES";
        long sum = A[1];
        for(int i=2;i<=n;i++) sum+=A[i];
        long temp = ((long)n)*((long)n+1)/2;
        if(sum%temp!=0) return "NO";
        long K = sum/temp;
        long[] x = new long[n+1];
        long sumx=0;
        for(int i=1;i<=n;i++){
            long dif=i==n?(A[1]-A[i]):(A[i+1]-A[i]);
            if(K==dif) continue;
            if((K-dif)%n!=0||K<dif) return "NO";
            x[i]=(K-dif)/n;
            sumx+=x[i];
        }
        if(sumx!=K) return "NO";
        /*ArrayList<Integer> dic = new ArrayList<>();
        for(int i=1;i<=n;i++){
            for(int k=0;k<x[i];k++) dic.add(i);
        }
        long tar = A[1];
        for(int j=0;j<dic.size();j++){
            int cur = dic.get(j);
            if(cur==1) tar-=n;
            else tar-=(n-(cur-1));
        }*/
        //if(tar==0) return "YES";
        else return "YES";
    }
}


Measured memory_bytes: 52860
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s;
  cin>>s;
  int i(0);
  do{
    if(s[i]==',')s[i]=' ';
    i++;
  }
  while(s[i]!=NULL);
  cout<<s<<endl;
  return 0;
}

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

using namespace std;
int main()
{
	int n, s = 0;
	cin >> n;
	int l[10];
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l, l + n);
	for (int i = 0; i < n - 1; i++) {
		s = s + l[i];
	}
	if (l[n - 1] < s) {
		cout << "Yes" << endl;
	}
	if (l[n - 1] > s) {
		cout << "No" << endl;
	}
	if (l[n - 1] == s) {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  ll N; cin>>N;
  map<string, ll> S;
  ll ans=0;
  for(ll i=0; i<N; i++){
    string s; cin>>s;
    sort(s.begin(), s.end());
    if(S.count(s)){
      ans+=S[s];
      S[s]++;
    }
    else S[s]=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
    int d;
    cin>>d;
    if(d==25)
    cout<<"Christmas"<<endl;
    else if(d==24)
    cout<<"Christmas Eve"<<endl;
    else if(d==23)
    cout<<"Christmas Eve Eve"<<endl;
    else if(d==22)
    cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}

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

int main() {

  int N,M,r,q;
  vector <int> t,n,m,s;
 

  while(1) {
    
    cin >> N >> M;
    if(N == 0 && M == 0 ) break;
    
    cin >> r;
  
    t.resize(r);
    n.resize(r);
    m.resize(r);
    s.resize(r);
  
    for(int i=0;i<r;i++) {
      cin >> t[i] >> n[i] >> m[i] >>s[i];
    }

    vector <int> s2;
    cin >> q;
    int ts,te,st;
    for(int Q=0;Q<q;Q++) {
    
      cin >> ts >> te >> st;

      s2.clear();
      s2.resize(N+1);
      for(int i=0;i<=N;i++) s2[i] = 0;

      int count = 0, time = t[0]-5;
      int start=0;
      
      while(1) {
	time++;
	if(time == te) break;
	
	if(t[start] == time){
	  start++;
	  
	  if(m[start-1] == st) {
	    s2[n[start-1]] = s[start-1];
	    //  printf("time:%d comp%d = %d\n",time,n[start-1],s[start-1]);
	    
	  }
	
	  if(t[start-1] == t[start]) {
	    //  cout <<"continue"<< endl;
	    time--;
	    continue;
	  } 
	}
	
	if(ts <= time) {
	  // cout << time <<" " << count<< endl;
	  int sum = 0;
	  for(int i=1;i<=N;i++) sum += s2[i];
	  // cout << "sum = "<<sum << endl;
	  if(sum != 0) count++;
	}
	
	
      }

      cout << count << endl;

    }

    t.clear();
    m.clear();
    s.clear();
    n.clear();
  
  }
  
  return 0;

}

Measured memory_bytes: 1220
/**
 *      ABC 80 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-02 05:27:30
**/

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

int f(int N){//Nの各桁の総和
    int x = 0;
    for (int i = 0; i < 9; ++i){
        x += N % 10; N /= 10;
    }
    return x;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    N % f(N) == 0 ? cout << "Yes" : cout << "No";

    return 0;
}



Measured memory_bytes: 384
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //std::vector<int> v(5);
  char n; cin>>n;
  if (n == 'A') {
    cout << 'T' << endl;
    return 0;
  }
  if (n == 'T') {
    cout << 'A' << endl;
    return 0;
  }
  if (n == 'C') {
    cout << 'G' << endl;
    return 0;
  }
  if (n == 'G') {
    cout << 'C' << endl;
    return 0;
  }
}


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

using namespace std;

const int N = 50 + 1;

int n, p, a[N];
long long f[N][2];

int main() {
  //  freopen("in.txt", "r", stdin);
    cin >> n >> p;
    f[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i]; a[i] %= 2;
        f[i][0] += f[i-1][0];
        f[i][1] += f[i-1][1];
        f[i][(0 + a[i]) % 2] += f[i-1][0];
        f[i][(1 + a[i]) % 2] += f[i-1][1];
    }
    cout << f[n][p];
}


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

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;






int main() {
    int n,x; cin >> n >> x;
    vector<int> vec;
    for(int i = 0;i < n;i++){
        int y; cin >> y; vec.push_back(y);
    }
    ll ans = 0;
    for(int i = 1;i < n;i++){
        if(vec[i-1]+vec[i] > x){
                int total = (vec[i] + vec[i-1])-x;
                ans += total;
            if(vec[i] > total){
                vec[i] -= total;
            }else{
                total -= vec[i];
                vec[i] = 0;
                vec[i-1] -= total;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3908
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n, k;
	cin >> n >> k;
	double ans = 0;
	rep1(i, n+1) {
		if (k <= i) {
			double win = (n-(i-1)) / (double)n;
			ans +=win;
			break;
		}
		else {
			int count = 0;
			int point = i;
			while (point < k) {
				point *= 2;
				count++;
			}
			ans += 1 / (n*pow(2,count));
		}
	}
	cout << fixed;
	cout << setprecision(9) << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int a[10005];
int main()
{
  int k;
  cin>>k;
  int len=1;
  a[0]=1;
  for(int i=2;i<=k;i++){
    int f=0;
    for(int j=len-1;j>=1;j--){
      if(a[j]<=a[j-1]&&a[j]<9){
        a[j]=a[j]+1;
        for(int k=j+1;k<len;k++){
          a[k]=max(0,a[k-1]-1);
        }
        f=1;
        break;
      }
    }
    if(!f){
      if(a[0]<9){
        a[0]++;
        for(int j=1;j<len;j++) a[j]=max(0,a[j-1]-1);
      }
      else {
        len++;
        a[0]=1;
        for(int j=1;j<len;j++) a[j]=0;
      }
    }
  }
  for(int i=0;i<len;i++){
    cout<<a[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <math.h>

using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

void solve() {
	int n, m; cin >> n >> m;
	vector<int> e[100001];

	REP(i, m) {
		int a, b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	int parent[100001] = {0 ,1};
	queue<int> q;
	q.push(1);
	while (!q.empty()) {
		int p = q.front(); q.pop();
		for (auto eg : e[p]) {
			if (parent[eg] == 0) {
				parent[eg] = p;
				q.push(eg);
			}
		}
	}
	int cnt = 0;
	for (int i = 2; i <= n; i++) {
		if (parent[i] == 0)cnt++;
	}
	if (cnt == 0) {
		cout << "Yes" << endl;
		for (int i = 2; i <= n; i++) {
			cout << parent[i] << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 10344
#include <bits/stdc++.h>
using namespace std;
#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; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

int N, M, L, sum;
int A[210];
int B[210];


int main() {
    while (cin >> N >> M) {
        sum = 0;
        int odd = 0;
        for (int i = 0; i < M; ++i) {
            cin >> A[i];
            if (A[i] & 1) {
                swap(A[odd++], A[i]);
            }
        }
        if (odd == 2) swap(A[1], A[M-1]);
        if (odd > 2) puts("Impossible");
        else {
            for (int i = 0; i < M; ++i) cout << A[i] << " ";
            cout << endl;
            vector<int> B;
            if (odd == 0 || M == 1) {
                B.push_back(1);
                for (int i = 0; i < M; ++i) B.push_back(A[i]);
                B.back()--;
            }
            else {
                for (int i = 0; i < M; ++i) B.push_back(A[i]);
                B[0]--; B.back()++;
            }
            for (int i = 0; i < B.size(); ++i) if (B[i] <= 0) B.erase(B.begin() + i--);
            cout << B.size() << endl;
            for (int i = 0; i < B.size(); ++i) cout << B[i] << " ";
            cout << endl;
        }
    }
}




Measured memory_bytes: 256
#include <stdio.h>

int isDefined( int n, int n1, int n2, int sw[ 2 ][ 10000 ] ){
  int i, j, k;
  int care[ 2 ];

  care[ 0 ] = n1;
  care[ 1 ] = n2;

  for( j = 0; j < 2; j++ ){
    for( i = 0; i < n; i++ ){
      if( sw[ j ][ i ] == 0 ){
        sw[ j ][ i ] = -1;
        care[ j ]--;
        return( isDefined( n, care[ 0 ], care[ 1 ], sw ) );
      }
      if( sw[ j ][ i ] == care[ (j+1)%2 ] ){
        sw[ j ][ i ] = -1;
        care[ j ]--;
        for( k = 0; k < n; k++ ){
          if( sw[ (j+1)%2 ][ k ] != -1 ){
            sw[ (j+1)%2 ][ k ]--;
          }
        }
        return( isDefined( n, care[ 0 ], care[ 1 ], sw ) );
      }
    }
  }

  if( !care[ 0 ] && !care[ 1 ] ){
    return 1;
  }else{
    return 0;
  }
}

int main( void ){
  int i, n;
  int sw[ 2 ][ 10000 ];

  while( 1 ){
    scanf( "%d", &n);
    if( !n ) break;

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

    if( isDefined( n, n, n, sw ) ){
      printf( "Yes\n" );
    }else{
      printf( "No\n" );
    }
  }

  return( 0 );
}

Measured memory_bytes: 660
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	if (abs(a - b) - w > 0) {
		cout << abs(a - b) - w << endl;
	}
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(std::string S){
  if(S=="ABC")
    std::cout << "ARC" << std::endl;
  else
    std::cout << "ABC" << std::endl;
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}



Measured memory_bytes: 3028
use proconio::input;
use proconio::marker::{Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: Chars,
    }
    let mut sum = 0;
    for iter in n {
        sum += iter as usize - 48;
    }
    if sum % 9 == 0 {
        println!("Yes");
    }
    else {
        println!("No");
    }
}


Measured memory_bytes: 3028
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int N;
  vector<int> a;

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

  int result = 0;

  for (int i = 0; i < a.size(); i++) {
    if ((i + 1) % 2 == 1 && a[i] % 2 == 1) {
      result++;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3596
from functools import reduce

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

end = max(a)
ansAry = []

b = min(a)
while(True):
    suma = []
    for i in range(0,len(a)):
        if b == a[i]:
            pass
        else:
            suma.append((a[i] - b)*(a[i] - b))

    try:
        ansAry.append(reduce(lambda x,y:x+y,suma))
    except:pass

    if b == end:
        break
    b += 1

if len(ansAry) > 0:
    print(min(ansAry))
else:
    print(0)

Measured memory_bytes: 3956
import java.io.*;
import java.util.*;

// Solution class
class Solution {
    public Solution() { }
    private static final InputReader scan = new InputReader();
    // solve method
    public void solve() throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        // code goes here...
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        String disp = (a<b && b<c) ? "Yes" : "No";
        out.println(disp);

        out.close();
    }
}

// InputReader class
class InputReader {
    private final BufferedReader br;
    private StringTokenizer st = new StringTokenizer("");
    public InputReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
    public String next() throws IOException {
        while (!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ie) { ie.printStackTrace(); }
        }
        return st.nextToken();
    }
    public String nextLine() throws IOException {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException ie) { ie.printStackTrace(); }
        return str;
    }
    public int nextInt() throws IOException { return Integer.parseInt(next()); }
    public long nextLong() throws IOException { return Long.parseLong(next()); }
    public double nextDouble() throws IOException { return Double.parseDouble(next()); }
}

// Main class
public class Main {
    public Main() { }
    // driver method
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}



Measured memory_bytes: 24260
N=int(input())
B={}
T=[]
for i in range(N):
    s=input()
    if s in B:
        B[s]+=1
    else:
        B[s]=1
    T.append(s)

R={}
M=int(input())
for i in range(M):
    s=input()
    if s in R:
        R[s]+=1
    else:
        R[s]=1
    T.append(s)

T=set(T)
ans=0
for t in T:
    if t in B:
        b=B[t]
    else:
        b=0
    if t in R:
        r=R[t]
    else:
        r=0
    now=b-r
    ans=max(ans, now)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  1000005
#define tmod             998244353LL
using namespace std;

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

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//ll P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

int BIT[N+5];

void UP(int ind,int v , int n )
{
    while(ind<=n)
    {
        BIT[ind] += v;
        ind += ind&(-ind);
    }
}

int Q(int ind)
{
    int ans = 0;
    while(ind>0)
    {
        ans += BIT[ind];
        ind -= ind&(-ind);
    }
    return ans;
}

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d=0,e,g=0,p,v,w,x,y,flag=1; int u;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> k;
    string s;
    cin >> s;
    n = s.size();
    if(n<=k) cout << s;
    else cout << s.substr(0,k) << "...";
    return 0;
    n = n%10;
    if(n==2 or n==4 or n==5 or n==7 or n==9) cout << "hon";
    else if(n==3) cout << "bon";
    else cout << "pon";
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

/*void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}

*/


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

int main(){
	int a=0;
	int b=0;
	int c=0;
	int x=0;
	int y=0;
	int z=0;
	cin>>a>>b>>c;
	while(1){
		x=x+a;
		y=x%b;
		if(y==c){
			z=1;
			break;
		}
		if(y==0){
			break;
		}
	}
		
	if(z==1){
		cout<<"YES";
	}else{
		cout<<"NO";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
	int n; cin >> n;
	string s; cin >> s;
	for(int i = 0; i < s.size(); i++){
		int x = s[i] - 'A';
		x += n;
		x %= 26;
		s[i] = char(x + 'A');
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#define scanf_s scanf
#include <stdio.h>
#include <iostream>
using namespace std;
#define MAX 200
int main(void)
{
	double a, b, c, d, e, f, x, y;
	while (scanf_s("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
		x = 0; y = 0;
		if ((e * c - b * f) != 0 && (e * a - b * d) != 0)
			x = (e * c - b * f) / (e * a - b * d);
		if((d * c - a * f) != 0 &&  (d * b - a * e) != 0)
			y = (d * c - a * f) / (d * b - a * e);
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
 
typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
 
const ll INF=(1LL<<50);
 
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
 
const string YES = "Yes";
const string NO = "No";
void p(string s){
  cout<<s<<endl;
  exit(0);
}
map<ll,ll> x;
void inc_x(ll a){
  if(x.count(a)){
    ++x[a];
  }else{
    x[a]=1;
  }
}
void solve(long long N, std::vector<long long> a){
  REP(N)inc_x(a[i]);
  if(x.size()>3)p(NO);
  if(x.size()==2){
    if(N%3!=0)p(NO);
    if(x.count(0)&&x[0]==N/3)p(YES);
    p(NO);
  }
  if(x.size()==1){
    if(x.count(0))p(YES);
    p(NO);
  }
  if(x.size()==3){
    vector<ll> X;
    for (auto &&i : x)
    {
      X.push_back(i.first);
    }
    if(N%3==0&&x[X[0]]==x[X[1]]&&x[X[1]]==x[X[2]]&&X[0]==(X[1]^X[2]))p(YES);
    p(NO);
  }
}
 
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}

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

const int P = 998244353;
int n, A[1 << 18], f[1 << 18], g[1 << 18];

int power(int a, int x) {
	int ans = 1;
	for (; x; x >>= 1, a = 1ll * a * a % P)
		if (x & 1) ans = 1ll * ans * a % P;
	return ans;
}

void fwt(int *A) {
	for (int d = 1; d < 1 << n; d <<= 1)
		for (int i = 0; i < 1 << n; i += d << 1)
			for (int j = 0; j < d; ++j) {
				int a = A[i + j], b = A[i + d + j];
				A[i + j] = (a + b) % P;
				A[i + d + j] = (a + P - b) % P;
			}
}

int main() {
	scanf("%d", &n);
	int sum = 0;
	for (int i = 0; i < 1 << n; ++i)
		scanf("%d", A + i), sum += A[i];
	sum = power(sum, P - 2);
	for (int i = 0; i < 1 << n; ++i)
		A[i] = 1ll * A[i] * sum % P;
	fwt(A);
	A[0] = 0;
	for (int i = 1; i < 1 << n; ++i)
		A[i] = power(A[i] + P - 1, P - 2);
	fwt(A);
	for (int i = 0; i < 1 << n; ++i)
		printf("%d\n", (A[i] + P - A[0]) % P);
}


Measured memory_bytes: 3840
// ３つの整数 a、b、c を読み込み、a から b までの整数の中に、c の約数がいくつあるかを求めるプログラムを作成してください。
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		String[] split = str.split(" ");
		int a = Integer.parseInt(split[0]);
		int b = Integer.parseInt(split[1]);
		int c = Integer.parseInt(split[2]);
		int flg = 0;

		for(int i=a; i<=b; i++){
			if(c%i == 0){
				flg++;
			}
		}
		System.out.println(flg);

	}
}


Measured memory_bytes: 26168
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int dp[(1<<15)+10][18];
int su[(1<<15)];
int co[20][20];
int main()
{
	int n,m,sum=0,a,b,c;
	memset(co,0,sizeof(co));
	cin>>n>>m;
	rep(i,m){
		cin>>a>>b>>c;a--;b--;
		co[a][b]=co[b][a]=c;sum+=c;
	}
	memset(su,0,sizeof(su));
	rep(i,(1<<n)) rep(j,n) REP(k,j+1,n){
		if((i&(1<<j)) && (i&(1<<k))) su[i]+=co[j][k];
	}
	memset(dp,-1,sizeof(dp));dp[1][0]=0;
	rep(i,(1<<n)) rep(j,n){
		if(dp[i][j]<0) continue;
		rep(k,n){
			if(i&(1<<k) || co[j][k]<1) continue;
			dp[i+(1<<k)][k]=max(dp[i+(1<<k)][k],dp[i][j]+co[j][k]);
		}
		int x=(1<<n)-1-i;
		for(int y=x;y>0;y=((y-1)&x)){
			dp[i+y][j]=max(dp[i+y][j],dp[i][j]+su[y+(1<<j)]);
		}
	}
	cout<<sum-dp[(1<<n)-1][n-1]<<endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  long a;
  cin >> a;
  string s = to_string(a);
  long b = 0;
  REP(i, s.size()){
    b += s[i] - '0';
  }
  if(a%b == 0){
    cout << "Yes"<< endl;
  }else{
    cout << "No"<< endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<unsigned int> s;
int n,m;
int cards[100];
bool used[100];
void solve(int cnt,string a){
  string tmp=a;
  if(cnt==m){
    s.insert(atoi(a.c_str()));
    return;
  }
  for(int i=0;i<n;i++){
    if(used[i]==true)continue;
    used[i]=true;
    stringstream ss;
    ss << cards[i];
    a+=ss.str();
    solve(cnt+1,a);
    a=tmp;
    used[i]=false;
  }
}

int main(){
  while(cin>>n,n){
    s.clear();
    cin>>m;
    for(int i=0;i<n;i++){
      used[i]=false;
      cin>>cards[i];
    }
    solve(0,"");
    // for(auto i:s)
    // cout << i << endl;

    cout << s.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1360
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L=new int[N];
        for(int i=0; i<N; i++){
            L[i]=sc.nextInt();
        }
        long res = 0;

        Arrays.sort(L);

        for(int i=N-1; i>1; i--){
            for(int j=0; j<i-1; j++){
                int ok=i;
                int ng=j;
                while(ok-ng>1){
                    int h=(ok+ng)/2;
                    if(L[i]<L[j]+L[h]){
                        ok = h;
                    }else{
                        ng = h;
                    }
                }
                res = res + i - ok;
            }
        }
        System.out.println(res);
        
        }
    }

Measured memory_bytes: 39860
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[10][150][78],x[11][150],d[10][150],m,n;
  int mn;
  while(cin>>n>>m&&n+m){
    memset(x,-1,sizeof(x));
    memset(d,-1,sizeof(d));
    for(i=0;i<n;i++){
      cin>>k;
      for(j=0;j<k;j++){
	int t,u;
	cin>>t>>u;
	t--;
	x[j][i]=t;
	d[j][i]=u;
      }
    }
    memset(a,-1,sizeof(a));
    for(i=0;x[i][0]!=-1;i++)
      a[i][0][0]=0;
    if(m){
      for(i=0;x[i][1]!=-1;i++)
	a[i][1][1]=0;
    }
    for(i=0;i<n-2;i++){
      for(j=0;x[j][i]!=-1;j++){
	for(k=0;k<n/2+3;k++){
	  if(a[j][i][k]!=-1){
	    for(l=0;x[l][i+1]!=-1;l++){
	      if(a[l][i+1][k]==-1||a[l][i+1][k]>a[j][i][k]+(d[j][i]+d[l][i+1])*abs(x[j][i]-x[l][i+1]))
		a[l][i+1][k]=a[j][i][k]+(d[j][i]+d[l][i+1])*abs(x[j][i]-x[l][i+1]);
	    }
	    if(k!=m){
	      for(l=0;x[l][i+2]!=-1;l++){
		if(a[l][i+2][k+1]==-1||a[l][i+2][k+1]>a[j][i][k]+(d[j][i]+d[l][i+2])*abs(x[j][i]-x[l][i+2]))
		  a[l][i+2][k+1]=a[j][i][k]+(d[j][i]+d[l][i+2])*abs(x[j][i]-x[l][i+2]);
	      }
	    }
	  }
	}
      }
    }
    mn=-1;
    for(i=0;x[i][n-2]!=-1;i++){
      for(j=0;j<n/2+3;j++){
	if(a[i][n-2][j]!=-1){
	  if(j==m){
	    for(k=0;x[k][n-1]!=-1;k++){
	      if(a[k][n-1][j]==-1||a[k][n-1][j]>a[i][n-2][j]+(d[i][n-2]+d[k][n-1])*abs(x[i][n-2]-x[k][n-1]))
		a[k][n-1][j]=a[i][n-2][j]+(d[i][n-2]+d[k][n-1])*abs(x[i][n-2]-x[k][n-1]);
	    }
	  }else if(mn==-1||mn>a[i][n-2][j])
	    mn=a[i][n-2][j];
	}
      }
    }
    for(i=0;x[i][n-1]!=-1;i++){
      for(j=0;j<n/2+3;j++){
	if(a[i][n-1][j]!=-1){
	  if(mn==-1||mn>a[i][n-1][j])
	    mn=a[i][n-1][j];
	}
      }
    }
    cout<<mn<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
n,x,y = map(int, input().split())
lis = [0] * n
x -= 1
y -= 1

for i in range(n):
    for j in range(i+1, n):
        t = min(abs(i-j), abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)
        lis[t] += 1

for i in range(1,n):
    print(lis[i])

Measured memory_bytes: 9332
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) { cin >> x; });

  // K+1学期目の点数は1学期の点数と比較すればよい
  for (ll i = K; i < N; i++) {
    string ans = "No";
    if (A[i] > A[i - K]) {
      ans = "Yes";
    }
    cout << ans << endl;
  }
  return 0;
}




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

#define ll long long

int main(){
  
  int n, m, l;
  cin >> n >> m >> l;

  int A[n][m];
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin >> A[i][j];
    }
  }

  int B[m][l];
  for(int i=0; i<m; i++){
    for(int j=0; j<l; j++){
      cin >> B[i][j];
    }
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      ll int ans = 0;
      for(int k=0; k<m; k++){
        ans += A[i][k]*B[k][j];
      }
      cout << ans; 
      if(j!=l-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

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

int main()
{
    int n; cin >> n;
    vector<int> a(n-1);
    for(int i = 0; i < n-1; i++) cin >> a.at(i);

    vector<int> cnt(n);
    sort(a.begin(), a.end());

    int i = 1;
    for(int x: a) {
        if(x == i) {
            cnt.at(i-1)++;
        } else {
            i = x;
            cnt.at(i-1)++;
        }
    }

    for(int x: cnt) cout << x << endl;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
void find_name(long long n) 
{ 
    char ans[50];
    int i=0;
    while (n > 0) 
    { 
        int rem=n % 26; 
        if (rem == 0) 
        { 
            ans[i++]='z'; 
            n = (n / 26) - 1; 
        } 
        else
        { 
            ans[i++] = (rem - 1) + 'a'; 
            n=n/26; 
        } 
    } 
    ans[i] = '\0'; 
    reverse(ans, ans + strlen(ans)); 
    cout << ans <<endl; 
  
    return; 
} 
int main()
{
    long long n;
    cin>>n;
    find_name(n);
    return 0;
}

Measured memory_bytes: 3668
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define N 500500
using namespace std;

int n, p[N], a[N], mi[N];
int stk[N], top;

int main() {

    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%d", p + i);

    p[n + 1] = n + 1, p[0] = 0;
    for (int i = 1; i <= n; ++i) {
        if (p[i - 1] != i - 1 && p[i] != i && p[i + 1] != i + 1)
            return puts("No"), 0;
        a[i] = i == p[i];
    }

    
    for (int i = 1, j; i <= n; i = j + 1) {
        for (j = i; j < n && a[j] != a[j + 1]; ++j);
        top = 0;
        for (int k = i; k <= j; ++k) {
            if (p[k] < i || j < p[k]) return puts("No"), 0;
            if (!a[k]) stk[++top] = p[k];
        }
        mi[top] = stk[top];
        for (int k = top - 1; k >= 1; --k)
            mi[k] = min(mi[k + 1], stk[k]);
        int mx = stk[1];
        for (int k = 2; k < top; ++k) {
            mx = max(mx, stk[k]);
            if (mi[k] < stk[k] && stk[k] < mx)
                return puts("No"), 0;
        }
    }

    return puts("Yes"), 0;
}

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

int main() {
  int a, b, c;
  string result;

  scanf("%d %d %d", &a, &b, &c);

  if (a < b && b < c) {
    result = "Yes";
  } else {
    result = "No";
  }


  printf("%s\n", result.c_str());
}



Measured memory_bytes: 3288
/*
[abc150] B - Count ABC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int N;
string S;

ll solve() {
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S.substr(i, 3) == "ABC") {
            ans++;
        }
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

int sum(int n) {
  int ans = 0;
  while (n) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}

int main() {
  int N;
  scanf("%d", &N);
  int ans = INT_MAX;
  for (int i = 1; i + i <= N; i++) {
    int cand = sum(i) + sum(N-i);
    ans = min(ans, cand);
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(n) for(int i=0;i<n;i++)
#define rf(n) for(int i=n-1;i>=0;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
signed main()
{   
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
	return 0;
}

Measured memory_bytes: 256