akhauriyash/Code-Regression huggingface dataset:
def merge(A, l, m, r):
    n1 = m - l
    n2 = r - m
    
    L = [A[l+i] for i in range(n1)]
    R = [A[m+i] for i in range(n2)]
    L.append(10**10)
    R.append(10**10)
    
    i = 0
    j = 0
    for k in range(l, r):
        if L[i]<=R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global cnt
    cnt += i+j
    #print(cnt)
    return i+j
    
def mergeSort(A, l, r):
    if l+1<r:
        mid = (l + r)//2;
        mergeSort(A, l, mid)
        mergeSort(A, mid, r)
        merge(A, l, mid, r)


n = int(input())
A = list(map(int, input().split()))
#n = 10
#A = [8, 5, 9, 2, 6, 3, 7, 1, 10, 4]
cnt = 0

mergeSort(A, 0, n)
print(*A)
print(cnt)


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

int main(){
  int N,a=300000,b,count=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> b;
    if(a>b)count++;
    a = min (a,b);
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> p(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    p.at(i) = make_pair(b, a);  // b, a の順でペアにする
  }
 
  sort(p.begin(), p.end());
  int time=0;
  int ss=0;
  int y=0;
  for(int i=0;i<N;i++){
    int a,b;
    tie(a,b)=p.at(i);
    time=a;
    ss+=b;
    if(time<ss){
  
      y=1;
      break;
      
    }
  }
  if(y){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }

}


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

int main(void){
    int N;
    cin >> N;
    int P[210000];
    int i;
    for(i=0; i<N; i++){
        cin >> P[i];
    }

    int mi = P[0];
    int res = 1;
    for(i=1; i<N; i++){
        if(mi>=P[i]){
            res++;
            mi = P[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    int a,b,c;
  string s,t;
    
    cin >> s >> t;

    string ss = s + t;
    int num = stoi(ss);

    int sum=0;
    bool isan=false;
    for(int i=1;i<1000;i++){
      if (i*i == num)isan=true;
    }

    cout <<  (isan? "Yes" :"No");
    
    return 0;
}






Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n = in.nextInt
  val as = Array.fill(n)(in.nextInt)
  def gcd(l: Int, r: Int): Int = if (r == 0) l else gcd(r, (l % r))
  println(as.reduceLeft((z, i) => gcd(z, i)))
}

Measured memory_bytes: 54176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const ll MOD=1e9+7;

ll tim(ll a, ll b){
	return (a*b)%MOD;
}
ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_inv(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

int main(){
	
	ll fa[2005];
	fa[0]=1;
	rep1(i,2000){
		fa[i]=tim(fa[i-1], (ll) i);
	}
	
	int N,K;
	cin>>N>>K;
	rep1(i,K){
		ll iv1=mod_inv(fa[i-1],MOD);
		ll iv2=mod_inv(fa[K-i],MOD);
		ll c1=tim(fa[K-1], tim(iv1,iv2));
		ll c2=0;
		if(N-K+1-i>=0){
			ll iv3=mod_inv(fa[i],MOD);
			ll iv4=mod_inv(fa[N-K+1-i],MOD);
			c2=tim(fa[N-K+1], tim(iv3,iv4));
		}
		cout<<tim(c1, c2)<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int,input().split()))
j_dict = {}
ans = 0
for i in range(n):
    if i+a_list[i]+1 not in j_dict.keys():
        j_dict[i+a_list[i]+1] = 0
    j_dict[i+a_list[i]+1] += 1
    if i-a_list[i]+1 in j_dict.keys():
        ans += j_dict[i-a_list[i]+1]


print(ans)

Measured memory_bytes: 40428
#include <iostream>
#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	ld ans = 0 ;
	for(int i=1;i<=n;i++){
		ll num = i ;
		ll p = 1 ;
		while(num<k){
			num *= 2 ;
			p *= 2 ;
		}
		ans += 1.0/p ;
	}
	cout << fixed << setprecision(20) << ans/n << endl ;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 != 0) {
		cout << "No" << endl;
		exit(0);
	}
	string m = s.substr(0, n / 2);
	string u = s.substr(n / 2, n / 2);
	if (m == u) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			IntStream.range(0, n).forEach(i -> scanner.nextInt());
			// ceiling((n-1)/(k-1))
			System.out.println((n - 1 + k - 1 - 1) / (k - 1));
		}
	}
}


Measured memory_bytes: 58836
#include <iostream>
using namespace std;
int main(void){
    int N,L;
    cin>>N;
    cin>>L;
    if(L>0){
        cout<<N*(L+L+N-1)/2-L<<endl;
    }
    else if (N+L-1<0){
        cout<<N*(L+L+N-1)/2-N-L+1<<endl;
    }
    else{
        cout<<N*(L+L+N-1)/2<<endl;
    }
    return 0;
    // Your code here!
    
}

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

typedef long long ll;

ll N;
vector<ll> A;
ll Sum;
ll R = 1ll << 60;

int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  for (ll a : A) Sum += a;
  ll sum = 0;
  for (ll i = 0; i < N; ++i) {
    sum += A[i];
    if (i != N - 1) R = min(R, abs(Sum - 2 * sum));
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 1792
N, x = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
frag = False
count = 0
for i in range(len(a)):
    if x >= a[i]:
        count += 1
        x -= a[i]
    else:
        frag = True
        break
if not frag and x != 0:
    count -= 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

ll n, k;
ll l, r;
ll a[50];
vector<ll> sum[100];

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

    cin >> n >> k >> l >> r;
    rep(i, n) cin >> a[i];

    ll x = n / 2;
    rep(i, 1 << x) {
        int cnt = __builtin_popcount(i);
        if(cnt > k) continue;
        ll s = 0;
        rep(j, x) if((i >> j) & 1) s += a[j];
        sum[cnt].push_back(s);
    }
    rep(i, k + 1) sort(ALL(sum[i]));

    ll re = 0;
    rep(i, 1 << n - x) {
        int cnt = __builtin_popcount(i);
        if(cnt > k) continue;
        ll s = 0;
        rep(j, n - x) if((i >> j) & 1) s += a[x + j];

        re += upper_bound(ALL(sum[k - cnt]), r - s) -
              lower_bound(ALL(sum[k - cnt]), l - s);
    }

    cout << re << endl;

    return 0;
}


Measured memory_bytes: 12344
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	int n, five = 0, two = 0,ten = 0;
	cin >> n;
	vint s(n);
	int sum = 0, min = 0;
	rep(i, n) {
		cin >> s[i];
		sum += s[i];
	}
	sort(s);
	reve(s);
	int i = 0;
	while (true) {
		if (s[i] % 10 != 0)min = s[i];
		if (n-1==i)break;
		i++;
	}
	if (sum % 10 != 0)cout << sum << rt;
	else {
		if (min == 0)cout << 0 << rt;
		else cout << sum - min << rt;
	}

	please AC;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String S = stdIn.next();
        stdIn.close();

        if (S.equals("AAA") || S.equals("BBB")) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21588
#include <iostream>
    #include <array>
    #include <algorithm>
     
    using namespace std;
     
    using ll = long long int;
     
    const ll INF = 0x3FFFFFFFFFFFFFFFLL;
     
    ll cost[2000][2000];
     
    int main(){
        
        ll N, M;
        cin >> N >> M;
        for(ll i = 0; i < N; ++i){
            for(ll j = 0; j < i; ++j){
                cost[i][j] = INF;
            }
            cost[i][i] = 0;
            for(ll j = i + 1; j < N; ++j){
                cost[i][j] = INF;
            }
        }
        for(ll i = 0; i < M; ++i){
            ll A, B, C;
            cin >> A >> B >> C;
            cost[A - 1][B - 1] = -C;
        }
        for(ll k = 0; k < N; ++k){
            for(ll i = 0; i < N; ++i){
                for(ll j = 0; j < N; ++j){
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }
        for(ll i = 0; i < N; ++i){
            if(cost[0][i] < INF / 2 && cost[i][N - 1] < INF / 2 && cost[i][i] < 0){
                cout  << "inf" << endl;
                return 0;
            }
        }
        cout << -cost[0][N - 1] << endl;
        return 0;
    }

Measured memory_bytes: 16128
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;
const int maxn=100010;
const LL INF=10000000000ll;
map<LL,int>mp;
void read(LL& x){
	x=0;
	char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
}
LL n;
LL a[maxn],b[maxn];
int prime[maxn],isprime[maxn];
int tot;
void init(){
	for(int i=2;i<=3000;i++){
		if(!isprime[i]) prime[++tot]=i;
		for(int j=1;j<=tot && i*prime[j]<=3000;j++){
			isprime[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
}
int p[maxn],q[maxn];
int ans;
int main(){
	read(n);
	init();LL t=1;
	for(int i=1;i<=n;i++){
		read(a[i]);t=1;int cnt=0;
		for(int j=1;j<=tot;j++)if((a[i]%prime[j])==0){
			p[++cnt]=prime[j];q[cnt]=0;
			//printf("a[i]=%d ",q[cnt]);
			while(a[i]%prime[j]==0){
				a[i]/=prime[j];q[cnt]++;
			}
			q[cnt]%=3;
			//printf("q=%d",q[cnt]);
			for(int k=1;k<=q[cnt];k++){
				//printf("t=%lld\n",t);
				t*=p[cnt];
			}
			if(!q[cnt]) cnt--;
		}
		//printf("t=%lld\n",t);
		if(a[i]>1){
			int tmp=sqrt((double)a[i]);t*=a[i];
			if(1ll*tmp*tmp==a[i]){
				p[++cnt]=tmp;q[cnt]=2;
			}else{
				p[++cnt]=a[i];q[cnt]=1;
			}
		}
		//printf("t=%lld\n",t);
		mp[a[i]=t]++;
		LL z=1;
		for(int j=1;j<=cnt && z<=INF;j++){
			for(int k=1;k<=3-q[j] && z<=INF;k++) z*=p[j];
		}
		if(z>INF) z=-1;if(z!=-1) b[i]=z;
	}
	//for(int i=1;i<=n;i++) printf("%lld ",b[i]);puts("");
	for(int i=1;i<=n;i++){
		if(a[i]==1){
			if(mp[1]) ans++,mp[1]=0;continue;
		}
		ans+=max(mp[a[i]],mp[b[i]]);
		mp[a[i]]=mp[b[i]]=0;
	}
	printf("%d",ans);
	return 0;
}

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

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1)
        a=14;
    if(b==1)
        b=14;
    
    if(a>b)
        printf("Alice\n");
    else if(a==b)
        printf("Draw\n");
    else
        printf("Bob\n");

    return 0;
}

Measured memory_bytes: 128
def fn(n):
    if n % 2 == 0:
        n /= 2
    else:
        n = 3 * n + 1
    return int(n)
s = int(input())
l = []
while s not in l:
    l.append(s)
    s = fn(s)
print(len(l) + 1)

Measured memory_bytes: 3060
judge = True

while judge:
    h,w = map(int, input().split(" "))
    if h == 0 and w == 0:
        judge = False
    else:
        for i in range(h):
            if i == 0 or i+1 == h:
                print("#"*w)
            else:
                print("#"+"."*(w-2)+"#")
        print()

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  string turn = "takahashi";
  
  while(1){
    if(turn == "takahashi"){
      C -= B; 
      if(C <= 0){
        cout << "Yes" << endl;
        break;
      }
      turn = "aoki";
      
    } else if(turn == "aoki"){
      A -= D;
      if(A <= 0){
        cout << "No" << endl;
         break;
       }
      turn = "takahashi";
    }
  }
  
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int r;

signed main() {
    cin >> r;
    cout << r*r << endl;
}




Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(0,n):
    bx=a[i]-i-1
    b.append(bx)
b.sort()
for i in range(n):
    a[i]=abs(a[i]-(b[n//2]+i+1))
print(sum(a))


Measured memory_bytes: 98132
package main
 
import "fmt"
 
func judgeStatusSummary(s []string) map[string]int {
	c := map[string]int{
		"AC": 0,
		"WA": 0,
		"TLE": 0,
		"RE": 0,
	}
 
	for _, v := range s {
		c[v]++
	}
 
	return c
}
 
func main() {
	var n int
	fmt.Scan(&n)
	s := make([]string, n)
	for i := range s {
		fmt.Scan(&s[i])
	}
 
	ans := judgeStatusSummary(s)
	fmt.Println(fmt.Sprintf("AC x %v", ans["AC"]))
	fmt.Println(fmt.Sprintf("WA x %v", ans["WA"]))
	fmt.Println(fmt.Sprintf("TLE x %v", ans["TLE"]))
	fmt.Println(fmt.Sprintf("RE x %v", ans["RE"]))
}

Measured memory_bytes: 6852
n,m,x = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
ans = float("inf")
for i in range(1 << n):
    money = 0
    skill = [0]*m
    for j in range(n):
        if ((i >> j) & 1) == 1:
            money += c[j][0]
            for k in range(1,m+1):
                skill[k-1] += c[j][k]
    if all(l >= x for l in skill):
        ans = min(ans,money)
print(-1 if ans==float("inf") else ans)

Measured memory_bytes: 9228
n = int(input())
a = input().split()

sum_a = 0
for i in a:
    sum_a += int(i)

avg = sum_a / n

sa = []

for i in a:
    if avg - int(i) >= 0:
        sa.append(avg - int(i))
    elif avg - int(i) < 0:
        sa.append(int(i) - avg)

sa_answer = min(sa)

for i in range(len(a)):
    if sum_a / n + sa_answer == int(a[i]) or sum_a / n - sa_answer == int(a[i]):
        print(i)
        break


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

int main()
{
  string s;
  cin >> s;
  if (s[0] >= 'a' && s[0] <= 'z')
    cout << "a" << endl;
  else if (s[0] >= 'A' && s[0] <= 'Z')
    cout << "A" << endl;
  return 0;
}

Measured memory_bytes: 3604
# coding: utf-8
def solve(li):
    cnt = 1
    ans = []
    for i in range(len(li)-1):
        tar = int(li[i])
        if tar==int(li[i+1]):
            if cnt>=10:
                ans.append(cnt//10)
                cnt = cnt%10
            cnt+=1
        else:
            if cnt>=10:
                ans.append(cnt//10)
                ans.append(cnt%10)
            else:
                ans.append(cnt)
            ans.append(tar)
            cnt = 1
    tar = int(li[i+1])
    ans.append(cnt)
    ans.append(tar)
    return ans

while True:
    n = int(input())
    if n ==0: break
    a = input()
    la = list(a)
    i=0
    while i<n:
        la = solve(la)
        i+=1
    for x in la:
        print(x, end='')
    print() 

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    string s;
    cin>>n>>s;
    int count=0;
    for (int i=0;i<n;i++) {
        if (s[i]=='R') {
            count++;
        }
    }
    if (n-count<count) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int num=scan.nextInt();
        for(int i=0;i<num;i++){
            int[] data=new int[3];
            for(int j=0;j<data.length;j++){
                data[j]=scan.nextInt();
            }
            System.out.println(millennium(data));
        }
    }
    private static int millennium(int[] data){
        int count=0;
        while(true){
            boolean flag=false;
            if(data[0]==1000){
                break;
            }
            data[2]++;
            if(data[0]%3==0){
                flag=true;
            }
            if(data[1]%2==1){
                flag=true;
            }
            if(data[2]>=20){
                if(!flag){
                    data[1]++;
                    data[2]=1;
                }
                else if(data[2]==21){
                    data[1]++;
                    data[2]=1;
                }
            }
            if(data[1]>=11){
                data[0]++;
                data[1]=1;
            }
            count++;
        }
        return count;
    }
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long D = inputArray[1];

			var tuples = createLongTuppleList(N);
			var Distance = D * D;

			var count = 0;

			foreach (var tp in tuples) {
				var dis = tp.Item1 * tp.Item1 + tp.Item2 * tp.Item2;

				if (dis <= Distance) {
					count++;
				}
			}

			//答えの出力
			var ans = count;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 49816
#include<cstdio>
inline int in();
inline void wr(int);
int main(int argc,char**argv){
	register int n=in(),m=in();
	register int ans=0;
	for(register int i=1;i<n;++i)
		for(register int j=i+1;j<=n;++j)
			++ans;
	for(register int i=1;i<m;++i)
		for(register int j=i+1;j<=m;++j)
			++ans;
	wr(ans),putchar('\n');
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


Measured memory_bytes: 128
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const int big=1e9+1e8;
const llint red=0xE869120;
const llint pro=1002001;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int n,i,j,co,uni=0;cin>>n;
	vector<int>so(n);
	for(i=0;i<n;i++){cin>>so[i];}
	sort(so.begin(),so.end());
	co=so.back();
	for(i=0;i<n;i++){if(so[i]!=co){uni++;}}
	if(so[0]+1<co){cout<<"No"<<endl;return 0;}
	if(n<so.back()){cout<<"No"<<endl;return 0;}
	if(co==so[0]){
		if(co==n-1){cout<<"Yes"<<endl;return 0;}//all unique
		if(co<=n/2){cout<<"Yes"<<endl;return 0;}//not unique
		else{cout<<"No"<<endl;return 0;}
	}
	if(co<uni+1){cout<<"No"<<endl;return 0;}
	if(uni+(n-uni)/2<co){cout<<"No"<<endl; return 0;}
	cout<<"Yes"<<endl;return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int map[101][101];
int all = 0;
int start[101];
int end_2[101];
int n;
void dps(int k) {
	start[k] = ++all;
	for (int i = 1; i <= n; i++) {
		if (map[k][i] && start[i] == 0) {
			dps(i);
		}
	}
	end_2[k] = ++all;
}
int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int m;
		cin >> m;
		for (int j = 0; j < m; j++) {
			int b;
			cin >> b;
			map[a][b] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (start[i] == 0) {
			dps(i);
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << i << " " << start[i] <<" "<< end_2[i]<<endl;
	}
}


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

int main()
{
    long long t=0, i, s=0, n, l, f=0;
    vector <long long> N;
    cin >> t;
    long long x[t+1];

    for(i=0;i<t+1;i++)
    {
        if(i!=t)
        {
            cin >> x[i];
        }
        if(i==t)
        {
            x[t] = x[t-1] + 1;
        }
        if(i!=0)
        {
            if(x[i]<=x[i-1])
            {
                s++;
            }
            else if(x[i]>x[i-1])
            {
                if(s>f)
                {
                    f = s;
                }
                s = 0;
            }
        }
    }
    cout << f << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d=a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y -= (a/b)*x;
    }else{
        x=1;
        y=0;
    }
    return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (x%m+m)%m;
}

int main(){
    int n;
    cin >> n;
    ll m1 = 999979, m2 = 999983;
    ll t1=0,t2=0;
    int op,y;
    for(int i=0;i<n;i++){
        cin >> op >> y;
        if(op == 1){
            t1 = (t1+y)%m1;
            t2 = (t2+y)%m2;
        }else if(op == 2){
            t1 = (t1-y%m1+m1)%m1;
            t2 = (t2-y%m2+m2)%m2;
        }else if(op == 3){
            t1 = (t1*y)%m1;
            t2 = (t2*y)%m2;
        }else{
            t1 = (t1*mod_inverse(y,m1))%m1;
            t2 = (t2*mod_inverse(y,m2))%m2;
        }
    }
    ll a,b;
    extgcd(m1,m2,a,b);
    ll res = (m1*t2*a+m2*t1*b)%((ll)m1*m2);
    if(res >= (1ll<<31)){
        res -= (ll)m1 * m2;
    }
    cout << res << endl;
}

Measured memory_bytes: 844
#include <bits/stdc++.h>
using namespace std; 
long long MOD = 998244353; 
long long power(long long a, long long n){
	long long ans = 1; long long mul = a;
	while(n){
		if(n & 1){
			ans *= mul; ans %= MOD;
		}
		n >>= 1;
		mul = mul * mul % MOD;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	string S; cin >> S; 
	bool all = true; 
	bool different = true; 
	int inv = 0; 
	int L = S.size();
	for(int i = 0; i < L - 1; i++){
		if(S.at(i) != S.at(i+1)) all = false; 
		else different = false; 
		inv += S.at(i) - 'a'; 
	}
	inv += S.at(L - 1) - 'a'; inv %= 3; 
	if(all){
		cout << 1 << "\n"; return 0; 
	}
	if(L == 2){
		cout << 2 << "\n"; return 0; 
	}
	if(L == 3 && S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) == S.at(0)){
		cout << 7 << "\n"; return 0; 
	}
	if(L == 3 && S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) != S.at(0)){
		cout << 3 << "\n"; return 0; 
	}
	if(L == 3){
		cout << 6 << "\n"; return 0; 
	}
	int total = power(3, L - 1); // mod3の不変量で最後は一意
	long long dp[200010][3][3] = {}; // 同じ文字が連続しないことを前提にして，dp[i文字目まで][最後がj][和がk]
	dp[1][0][0] = 1; dp[1][1][1] = 1; dp[1][2][2] = 1;
	for(int i = 1; i < L; i++){
		dp[i+1][1][1] += dp[i][0][0]; 
		dp[i+1][2][2] += dp[i][0][0]; 
		dp[i+1][1][2] += dp[i][0][1]; 
		dp[i+1][2][0] += dp[i][0][1]; 
		dp[i+1][1][0] += dp[i][0][2]; 
		dp[i+1][2][1] += dp[i][0][2]; 
		dp[i+1][0][0] += dp[i][1][0]; 
		dp[i+1][2][2] += dp[i][1][0]; 
		dp[i+1][0][1] += dp[i][1][1]; 
		dp[i+1][2][0] += dp[i][1][1]; 
		dp[i+1][0][2] += dp[i][1][2]; 
		dp[i+1][2][1] += dp[i][1][2]; 
		dp[i+1][0][0] += dp[i][2][0]; 
		dp[i+1][1][1] += dp[i][2][0]; 
		dp[i+1][0][1] += dp[i][2][1]; 
		dp[i+1][1][2] += dp[i][2][1]; 
		dp[i+1][0][2] += dp[i][2][2]; 
		dp[i+1][1][0] += dp[i][2][2]; 
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				dp[i+1][j][k] %= MOD; 
			}
		}
	}
	long long ans = (total + MOD * 3 - dp[L][0][inv] - dp[L][1][inv] - dp[L][2][inv]) % MOD; 
	if(different) ans = (ans + 1) % MOD; 
	cout << ans << "\n";  
}

Measured memory_bytes: 17860
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  char c[h][w];
  REP(i,h) {
    REP(j,w) {
      cin >> c[i][j];
    }
  }
  int ans=0;
  REP(i,pow(2,h)) {
    vi row_check;
    REP(x,h) {
      if((i>>x)&1) row_check.push_back(x);
    }
    REP(j,pow(2,w)) {
      vi column_check;
      REP(y,w) {
        if((j>>y)&1) column_check.push_back(y);
      }
      int cnt=0;
      REP(a,h) {
        REP(b,w) {
          if(find(ALL(row_check),a)==row_check.end()) continue;
          if(find(ALL(column_check),b)==column_check.end()) continue;
          if(c[a][b]=='#') cnt++;
        }
      }
      if(cnt==k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4044
#include<iostream>
#include<map>
using namespace std;
const long long mod=1e9+7;
map<long long,long long> d;
long long dx(long long x)
{
    if(d[x]!=0){
        return d[x];
    }
    else{
        return d[x]=((dx(x>>1)+dx((x-1)>>1)+dx((x-2)>>1)))%mod;
    }
}
int main()
{
    d[0]=1;
    d[1]=2;
    long long n;
    cin>>n;
    cout<<dx(n)<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=list(input())
l=[s[i] for i in range(n)]
r=[s[i] for i in range(n,2*n)]
r=r[::-1]
from collections import defaultdict
ld=defaultdict(int)
rd=defaultdict(int)
for i in range(2**n):
    ls=['', '']
    rs=['', '']
    for j in range(n):
        if (i>>j)%2==0:
            ls[0]+=l[j]
            rs[0]+=r[j]
        elif (i>>j)%2==1:
            ls[1]+=l[j]
            rs[1]+=r[j]
    ls=tuple(ls)
    rs=tuple(rs)
    ld[ls]+=1
    rd[rs]+=1

cnt=0
for k in ld.keys():
    a=ld[k]
    b=rd[k]
    cnt+=a*b
print(cnt)

Measured memory_bytes: 204020
using System;
using System.IO;
using System.Linq;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        private string L;
        private long Mod = 1000000007;
        public void Solve()
        {
            sc = new Scanner();
            L = new string(sc.Next().ToArray().Reverse().ToArray());
            int len = L.Length;
            var dp1 = new long[len];
            var dp2 = new long[len + 1];
            dp1[0] = 1;
            dp2[0] = 1;
            for (int i = 1; i < len; i++)
            {
                dp1[i] = (dp1[i - 1] * 3) % Mod;
            }

            for (int i = 1; i <= len; i++)
            {
                if (L[i - 1] == '1')
                {
                    dp2[i] = dp2[i - 1] * 2 + dp1[i - 1];
                    dp2[i] %= Mod;
                }
                else
                {
                    dp2[i] = dp2[i - 1];
                }
            }
            Console.WriteLine((dp2[len]) % Mod);
        }


        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 15200
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int N, T, A, ans = 0;
double dif = 1000000;
cin >> N >> T >> A;
int H[N];
for (int i = 0; i < N; ++i) cin >> H[i];

for (int i = 0; i < N; ++i) {
        double temp = T - H[i] * 0.006;
        double c = abs(temp - A); 
        if (c < dif) {
                ans = i + 1;
                dif = c;
        }   
}
cout <<  ans << endl;
}

Measured memory_bytes: 888
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    string s;
    fi>>s;
    int n = s.length();
    int ans = 0;
    for (int i = 0;i < n - 1;++i)
        ans += s[i] != s[i + 1];
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k ;
    vector<ll>vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];
    vector<ll>dp(n,INT_MAX);
    dp[0]=0;
    loop(1,n) {
        for(int j=1;j<=k;j++){
            if(i-j<0) continue;
            dp[i]=min(dp[i],dp[i-j]+abs(vec[i]-vec[i-j]));
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 4760
#include <stdio.h>

int main(void) {
  int a[4], b[4], hit, blow, i, j;
  while (scanf("%d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
    hit = 0;
    blow = 0;
    for (i = 0; i < 4; i++)
      for (j = 0; j < 4; j++)
	if (a[i] == b[j]) {
	  if (i == j) hit++;
	  else blow++;
	}
    printf("%d %d\n", hit, blow);
  }

  return 0;
}

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

int main() {
	int n,a,b,c;
	cin>>n;
	a=n%10;
	b=(n/10)%10;
	c=n/100;
	
	if(a!=7&&b!=7&&c!=7)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
using ll =long long;
ll n;
vector<pair<ll,ll> >e;
vector<ll>size;
map<ll,ll>mp;
int main(){
    ll tmp;
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&tmp);
        mp[tmp]=i;
        e.push_back(make_pair(tmp,i));   
    }
    sort(e.rbegin(),e.rend());
    vector<pair<ll,ll>>ans;
    vector<ll>size(n,1);
    vector<ll>dp(n,0);
    ll x = e.back().first;
    for(auto c:e){
        if(c.first!=x){
            if(size[c.second]*2>=n){
                cout<<"-1";
                return 0;
            }
            ll pre = c.first - n + 2 * size[c.second];
            if(!mp.count(pre)){
                cout<<"-1";
                return 0;
            }
            ll par = mp[pre];
            dp[par] += dp[c.second] + size[c.second];
            size[par] += size[c.second];
            ans.push_back(make_pair(c.second+1,par+1));
        }
    }
     if(dp[e.back().second]!=x){
        cout<<"-1";
        return 0;
    }
    for(auto c: ans){
        if(c.second < c.first)cout<<c.second <<' '<<c.first<<endl;
        else cout<<c.first <<' '<<c.second <<endl;
    }
    return 0;
}

Measured memory_bytes: 12656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1e9,MOD=1e9+7;

int main(){
	int n; cin>>n;
	string s[n]; rep(i,n) cin>>s[i];
	string t; cin>>t;
	int up=0,down=0;
	rep(i,n){
		string x=s[i]; int y=x.size();
		rep(j,y){
			if(x[j]=='?') x[j]='a';
		}
		if(x<=t) up++;
		x=s[i];
		rep(j,y){
			if(x[j]=='?') x[j]='z';
		}
		if(x>=t) down++;
	}
	// cout<<up<<" "<<down<<endl;
	for(int i=n-down+1;i<=up+1;i++){
		cout<<i<<(i!=up+1?" ":"\n");
	}
	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  string s;
  cin >> s;
  set<char> S;
  rep(i,(int)s.size()) S.insert(s[i]);
  if( S.size() == 1 ) puts("No");
  else puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;

inline void chk_max(int &a,int b){ if(a<b) a=b;}

char s[MAXN];
int pre[MAXN],suf[MAXN];
ll dif[MAXN];
inline void update(int l,int r){ ++dif[l]; --dif[r+1];}

int main(void)
{
	int n,d,c;
	scanf("%d%d%d%s",&n,&d,&c,s+1);
	
	for(int i=1; i<=n; ++i)
	{
		pre[i] = pre[i-1];
		if(s[i]=='x') continue;
		chk_max(pre[i],1);
		if(i-c-1 >= 1) chk_max(pre[i], pre[i-c-1]+1);
	}
	for(int i=n; i>=1; --i)
	{
		suf[i] = suf[i+1];
		if(s[i]=='x') continue;
		chk_max(suf[i],1);
		if(i+c+1 <= n) chk_max(suf[i], suf[i+c+1]+1);
	}
	
	for(int i=1; i<=n; ++i)
	{
		if(pre[i-1]>=d || suf[i+1]>=d)
			update(i,i);
	}
	
	if(c)
	{
		for(int i=1; i+c-1<=n; ++i)
		{
			int j = i+c-1;
			if(pre[i-1] + suf[j+1] >= d)
				update(i,j);
		}
	}
	else
	{
		for(int i=1; i<=n; ++i)
			if(pre[i-1] + suf[i+1] >= d)
				update(i,i);
	}
	
	for(int i=1; i<=n; ++i) dif[i] += dif[i-1];
	
	for(int i=1; i<=n; ++i)
		if(s[i]=='o' && !dif[i])
			printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int n,q;
  int pro[100000];
  char name[100000][10];
  int i;
  int head;
  int tail;
  int time=0;

  scanf("%d%d",&n,&q);

 
  

  for(i=0;i<n;i++) scanf("%s%d",name[i],&pro[i]);
  head=0;
  tail=n;
  while(head%(n+1)!=tail%(n+1)){
    if(pro[head%(n+1)]>q){
      pro[head%(n+1)]-=q;
      pro[tail%(n+1)]=pro[head%(n+1)];
      strcpy(name[tail%(n+1)],name[head%(n+1)]);
      head++;
      tail++;
      time+=q;
    }
    else{
      time+=pro[head%(n+1)];
      printf("%s %d\n",name[head%(n+1)],time);
      head++;
    }
  }
}
    
    



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

using namespace std;

int main() {
  int N, _max = -1, ans = 0;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int _in;
    
    cin >> _in;
    
    if (_max <= _in) {
      ans++;
    }
    _max = max(_max, _in);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A1,A2,A3,M;
    scanf("%d%d%d",&A1,&A2,&A3);
    M=A1+A2+A3;
    if(M>=22)
    {
        printf("bust");
    }
    else
        printf("win");
    return 0;

}


Measured memory_bytes: 128
n, a, b = map(int, input().split())
ans = 0
def head_sum(x):
    sum = 0
    while x != 0:
        sum += x % 10
        x = int(x/10)
    return sum

for i in range(1, n+1):
    x = head_sum(i)
    if a <= x and x <= b:
        ans += i
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll k,a,b;
    cin>>k>>a>>b;
    ll val=(a/k)+1;
    if (k*val<=b||a%k==0)
    {
        cout<<"OK";
    }
    else
    {
        cout<<"NG";
    }
    
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		
		int[] a = new int[N];
		int count = 0;
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if (A % 2 == 0){
				a[count] = A;
				count++;
			}
		}
		int ans = 0;
		for (int i = 0; i < count; i++) {
			int num = a[i];
			while(num%2==0){
				num = num/2;
				ans++;
			}
		}
		
		System.out.println(ans);
	}
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> ord(N);
  rep(i, 0, N) {
    cin >> A[i];
    ord[i] = i;
  }

  sort(ord.begin(), ord.end(),  [&](int a, int b) {
    return A[a] < A[b];
  });

  rep(i, 0, N) {
    if (i == N - 1) {
      cout << ord[i] + 1 << endl;
    } else {
      cout << ord[i] + 1 << " ";
    }
  }
};


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

S = [0]
for i in range(N):
        S.append(S[i]+A[i])

a_before = 1
c_before = 3
ans_tmp = []
for b in range(2,N-1):
        if S[a_before] > S[b] - S[a_before]:
                a=a_before
        else:
                for i in range(a_before,b):
                        if S[i] > S[b] - S[i]:
                                if abs(S[b]-S[i-1]-S[i-1]) < abs(S[b]-S[i]-S[i]):
                                        a=i-1
                                        a_before = i-1
                                        break
                                else:
                                        a=i
                                        a_before = i
                                        break
                else:
                        a=b-1
                        a_before = b-1

        if S[c_before] - S[b] > S[N] - S[c_before]:
                c=c_before
        else:
                for i in range(c_before,N):
                        if S[i] - S[b] > S[N] - S[i]:
                                if abs((S[N]-S[i-1]) - (S[i-1]-S[b])) < abs((S[N]-S[i]) - (S[i]-S[b])):
                                        c=i-1
                                        c_before = i-1
                                        break
                                else:
                                        c=i
                                        c_before = i
                                        break
                else:
                        c=N-1
                        c_before = N-1

        ans_tmp.append(max(S[N]-S[c],S[c]-S[b],S[b]-S[a],S[a]-S[0])-min(S[N]-S[c],S[c]-S[b],S[b]-S[a],S[a]-S[0]))

print(min(ans_tmp))

Measured memory_bytes: 29012