akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
#define MOD 1000000007
#define INF 1000000000000000007LL


const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int lv[N];
int cap[N];

void precompute(){
    lv[0]=1;
    For(i, 1, N){
        lv[i]=lv[i-1]*2;
        if(lv[i]>INF)
            lv[i]=INF;
    }
}

void solve(){
    int n; cin>>n;
    vector<int> a(n+1);
    precompute();
    For(i, 0, n+1){
        cin>>a[i];
        if(a[i]>lv[i]){
            cout<<-1;
            return;
        }
    }
    cap[0]=1;
    for(int i=1; i<=n; i++){
        cap[i]=(cap[i-1]-a[i-1])*2;
        if(cap[i]>INF)
            cap[i]=INF;
        if(a[i]>cap[i]){
            cout<<-1;
            return;
        }
    }
    int ans = 0;
    int pre = 0;
    for(int i=n; i>=0; i--){
        int v = min(cap[i], pre+a[i]);
        ans += v;
        pre = v;
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



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

#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)

#define M 1000000007
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long

#define con 998244353

int main()
{
  int n,q1;
  cin>>n>>q1;
  int x,y;
  vector<int>adj[200005];
  for(int i=0;i<n-1;i++){
      cin>>x>>y;
      adj[x].pb(y);
      adj[y].pb(x);
  }
  int c[n+1]={0};
  for(int i=0;i<q1;i++){
      cin>>x>>y;
      c[x]+=y;
  }
  queue<int>q;
  q.push(1);
  int vis[n+1]={0};
  vis[1]=1;
  while(!q.empty()){
      int k=q.front();
      q.pop();
      for(int i=0;i<adj[k].size();i++){
          if(vis[adj[k][i]]==0){
              c[adj[k][i]]+=c[k];
              q.push(adj[k][i]);
              vis[adj[k][i]]=1;
          }
      }
  }
  for(int i=1;i<=n;i++){
      cout<<c[i]<<" ";
  }
}

Measured memory_bytes: 16244
n = gets.to_i
ss = gets.chomp.chars
ans = ss.count("R") * ss.count("G") * ss.count("B")

0.upto(n) do |i|
  j = 1

  while i + 2 * j < n
    k = i + 2 * j

    a = ss[i]
    b = ss[i + j]
    c = ss[k]
    ans -= 1 if a != b && b != c && c != a

    j += 1
  end
end

puts ans


Measured memory_bytes: 14288
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd
#define eps 0.0000000000000000001

ll n,a[200005],ans=LINF,s[200005];

int mn(int i, int j){
    int l=i,r=j-1;
    while(l!=r){
        int mid=(l+r)/2;
        if(s[j]-s[mid]>s[mid]-s[i-1]) l=mid+1;
        else r=mid;
    }
    return l;
}

int mx(int i, int j){
    int l=i,r=j-1;
    while(l!=r){
        int mid=(l+r+1)/2;
        if(s[j]-s[mid]<s[mid]-s[i-1]) r=mid-1;
        else l=mid;
    }
    return l;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        s[i]=s[i-1]+a[i];
    }
    for(int i=2;i<n-1;i++){
        int j=mx(1,i);
        int k=mn(i+1,n);
        ll p=s[j],q=s[i]-s[j],r=s[k]-s[i],t=s[n]-s[k];
        ans=min(ans,max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))));
        //cout << j << ' ' << i << ' ' << k << ' ' << max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))) << '\n';
        j=mn(1,i);
        k=mx(i+1,n);
        p=s[j],q=s[i]-s[j],r=s[k]-s[i],t=s[n]-s[k];
        ans=min(ans,max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))));
        //cout << j << ' ' << i << ' ' << k << ' ' << max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))) << '\n';
        j=mn(1,i);
        k=mn(i+1,n);
        p=s[j],q=s[i]-s[j],r=s[k]-s[i],t=s[n]-s[k];
        ans=min(ans,max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))));
        //cout << j << ' ' << i << ' ' << k << ' ' << max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))) << '\n';
        j=mx(1,i);
        k=mx(i+1,n);
        p=s[j],q=s[i]-s[j],r=s[k]-s[i],t=s[n]-s[k];
        ans=min(ans,max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))));
        //cout << j << ' ' << i << ' ' << k << ' ' << max(p,max(q,max(r,t)))-min(p,min(q,min(r,t))) << '\n';
    }
    cout << ans;
}


Measured memory_bytes: 3328
S = input()
Ans = 0
if S == 'SUN':
  Ans = 7

if S == 'MON':
  Ans = 6

if S == 'TUE':
  Ans = 5

if S == 'WED':
  Ans = 4

if S == 'THU':
  Ans = 3

if S == 'FRI':
  Ans = 2

if S == 'SAT':
  Ans = 1

print(Ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  int a_max, b_max, a_min, b_min;
  b_min = 10*B; //10%がB円になる最小
  b_max = 10*B+9; //+10はギリアウト
  if(A%2==0){
    a_min = 25*A/2;
    a_max = 25*(A+1)/2;
  }
  else{
    a_min = 25*A/2+1;
    a_max = 25*(A+1)/2 -1;
  }
  int ans;
  if(a_max < b_min || a_min > b_max){
    ans = -1;
  }
  else if(a_min < b_min){
    ans = b_min;
  }
  else{
    ans = a_min;
  }
  cout << ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    string A;
    ll ans = 0;
    ll count[10][10]={0};
    for(int i=1;i<=N;i++){
        A = to_string(i);
        int head = A[0] - '0';
        int tail = A[A.size()-1] - '0';
        count[head][tail]++;
    }
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            ans+=count[i][j]*count[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;


int main() {
	ll A, B;
	cin >> A >> B;
	if ((A >= 9) || (B >= 9))cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;

		Console.WriteLine("{0}",(s[0]*s[1])/Gcd(s[0],s[1]));
	}
	static long Gcd(long a,long b){
		long c=Math.Max(a,b)%Math.Min(a,b);
		b=Math.Min(a,b);
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
program abc129d
  implicit none
  character(2000),dimension(:),allocatable :: s
  integer :: h, w, i, j, ans = 0
  integer,dimension(:,:,:),allocatable :: grid

  read *, h, w
  allocate(s(h),grid(w,h,3))
  read *, s

  do i = 1,h
     do j = 1,w
        grid(j,i,:) = merge(0,1,s(i)(j:j)=='#')
     end do
  end do

  do j = 2,w
     grid(j,:,2) = merge(grid(j,:,2)+grid(j-1,:,2),grid(j,:,2),grid(j,:,1)/=0)
  end do

  do j = w-1,1,-1
     grid(j,:,2) = merge(grid(j+1,:,2),grid(j,:,2),grid(j,:,1)/=0.and.grid(j+1,:,1)/=0)
  end do

  do i = 2,h
     grid(:,i,3) = merge(grid(:,i,3)+grid(:,i-1,3),grid(:,i,3),grid(:,i,1)/=0)
  end do

  do i = h-1,1,-1
     grid(:,i,3) = merge(grid(:,i+1,3),grid(:,i,3),grid(:,i,1)/=0.and.grid(:,i+1,1)/=0)
  end do

  do i = 1,h
     do j = 1,w
        ans = max(ans,grid(j,i,2)+grid(j,i,3))
     end do
  end do

  print *, ans-1
end program abc129d


Measured memory_bytes: 51584
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    SORT(a);
    vector<int> b(3);
    b[0] = b[1] = 5;
    b[2] = 7;
    if (a == b) cout << "YES";
    else cout << "NO";
    rn 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    ll K; cin >> K;
    vector<string> vec = {"0","1","2","3","4","5","6","7","8","9"};
    vector<string> lis = vec;
    ll q = 10;
    ll n = 0;
    while(q <= 100100){
        vector<string> lis_2 = {};
        for(auto x:lis){
            if(x[0] == '0'){
                lis_2.push_back('0' + x);
                lis_2.push_back('1' + x);
                vec.push_back('0' + x);
                vec.push_back('1' + x);
                q+= 2;
            }
            else if(x[0] == '9'){
                lis_2.push_back('8' + x);
                lis_2.push_back('9' + x);
                vec.push_back('8' + x);
                vec.push_back('9' + x);
                q+=2;
            }
            else{
                char p = x[0];
                string j = "";
                j = j+p;
                int h = stoi(j);
                string a,b,c;
                a = to_string(h-1);
                b = to_string(h);
                c = to_string(h+1);
                lis_2.push_back(a + x);
                lis_2.push_back(b + x);
                lis_2.push_back(c + x);
                vec.push_back(a + x);
                vec.push_back(b + x);
                vec.push_back(c + x);
                q+=3;
            }
        }
        n++;
        if(n>0){lis = lis_2;}
    }
    ll num = vec.size();
    vector<ll> res(num);
    for(int i=0; i<num; i++){
        res[i] = stoll(vec[i]);
    }
    sort(res.begin(), res.end());
    vector<ll> vec_2 = {};
    vec_2.push_back(res[0]);
    for(int i=1; i<num; i++){
        if(res[i] != res[i-1]){
            vec_2.push_back(res[i]);
        }
    }
    vi f = {1,2,3,4,5,6,7,8,9,10,11,12,21};
    cout << vec_2[K];
}

Measured memory_bytes: 27388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    ll n,q;cin>>n>>q;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(kk,q){
        ll l,x,m;cin>>l>>x>>m;l--;
        vi p=v;
        rep(i,n){
            p[i]%=m;
            if(!p[i])p[i]=m;
        }
        x%=m;
        ll a=0,b=0;
        rep(i,n){
            if(l%n==i)a=b;
            b+=p[i];
        }
        ll sum=b*(l/n)+a+x;
        out(l-sum/m);
    }
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ans := 0
	for i := 1; i <= N-1; i++ {
		for j := i; j <= (N-1)/i; j++ {
			if i*j < N {
				if i == j {
					ans++
				} else {
					ans += 2
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1788
a_list=[]
a_list+=(list(map(int,input().split())))
a_list+=(list(map(int,input().split())))
a_list+=(list(map(int,input().split())))

N=int(input())

b_list=[False]*9
for i in range(N):
    b=int(input())
    for j,a in enumerate(a_list):
        if a==b:
            b_list[j]=True

kumi=[
    [0,1,2],
    [3,4,5],
    [6,7,8],
    [0,3,6],
    [1,4,7],
    [2,5,8],
    [0,4,8],
    [2,4,6]
]

ans="No"
for k in kumi:
    if b_list[k[0]]*b_list[k[1]]*b_list[k[2]]:
        ans="Yes"

print(ans)

Measured memory_bytes: 3064
def pow_mod(x, y, mod=10**9 + 7):
    if y == 0:
        return 1
    res = 1
    for i in range(y.bit_length()):
        if y & (1 << i):
            res *= x
            res %= mod
        x *= x
        x %= mod
    return res


n = int(input())

ans = pow_mod(10, n) - pow_mod(9, n) * 2 + pow_mod(8, n)
ans %= 10**9 + 7
print(ans)

Measured memory_bytes: 61716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int w,h,x,y;cin>>w>>h>>x>>y;
    double maxi=(w*h)/2.0;
    cout<<PSET(maxi,8)<<" ";
    if(w%2==0 and h%2==0 and x==w/2 and y==h/2)
        cout<<1;
    else
        cout<<0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
		int arg = 0;
        String ans = "NG";

        for (int i = 0; i <= 1000; i++) {
		arg = K*i;
            if (A <= arg && arg <= B) {
                ans = "OK";
				break;
            } else if (B < arg) {
				break;
			}
        }

        System.out.println(ans);

        sc.close();
    }    
}


Measured memory_bytes: 27008
#include <stdio.h>

int main()
{
	int a,b,c,i = 0;
	int count;
	scanf("%d %d %d",&a,&b,&c);
	for(count = a; count <= b; count++)
	{
		if(c%count == 0)
		{
			i++;
		}
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		
		if(n == 1) {
			System.out.println(in.next());
			return;
		}
		
		int[] b = new int[n];
		int R = 0, L = 0;
		if(n % 2 == 0) {
			R = n / 2;
			L = R - 1;
		}else {
			L = n / 2;
			R = L + 1;
		}
		
		for(int i = 0; i < n; i++) {
			int a = in.nextInt();
			if(n % 2 == i % 2) {
				b[R] = a;
				R++;
			}else {
				b[L] = a;
				L--;
			}
		}
		
		for(int j = 0; j < b.length-1; j++) {
			System.out.print(b[j] + " ");
		}
		System.out.println(b[b.length-1]);
		
		/*
		LinkedList<Integer> b = new LinkedList<Integer>();
		for(int i = 0; i < n; i++) {
			if(i % 2 != n % 2) b.addFirst(in.nextInt());
			else b.addLast(in.nextInt());
		}
		
		for(int j = 0; j < b.size()-1; j++) {
			System.out.print(b.get(j) + " ");
		}
		System.out.println(b.get(b.size()-1));
		*/
	}
}

Measured memory_bytes: 93616
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]c = S.toCharArray();

    Arrays.sort(c); 	    

    if(c[0]==c[1] && c[2]==c[3] && c[0]!=c[3]){
 	System.out.println("Yes");
    }else{
    System.out.println("No");    
      }
    }
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    string str;
    cin>>str;
    int n=str.size();
    reverse(str.begin(), str.end());
    int a[200000];
    int x=1;
    rep(i, n){
        a[i]=((str[i]-'0')*x)%2019;
        x=(x*10)%2019;
    }
    int s[200001];
    s[0]=0;
    rep(i, n){
        s[i+1]=(a[i]+s[i])%2019;
    }
    //rep(i, n+1) cout<<s[i]<<" ";
    //cout<<endl;
    map<int, int> cnt;
    rep(i, n+1){
        cnt[s[i]]++;
    }
    int ans=0;
    repit(it, cnt){
        int m=it->second;
        ans+=m*(m-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5236
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
 
int main() {
  int N, M; cin >> N >> M;
  vector<long long> Bit(M,0);
  vector<long long> mod(M,0);
  for (int i=0; i<M; i++) {
    int k; cin >> k;
    for(int j=0; j<k; j++) {
      int s; cin >> s;
      Bit[i] ^= 1<<(s-1);
    }
  }
  for (int i=0; i<M; i++) cin >> mod[i];

  long long ans=0;
  
  for (long long i=0; i<(1<<N); i++) {
    bool flg=false;
//    cout << bitset<3>(i) << "\n";
    for (int j=0; j<M; j++) {
//      cout << j << ' ' << __builtin_popcount(Bit[j]&i)%2 << ' ' << mod[j] << "\n";
      if(__builtin_popcountll(Bit[j]&i)%2!=mod[j]) {flg=true;break;}
    }
    if(!flg) ans++;
  }
 
  cout << ans << "\n";
  
//  for (int i=0; i<M; i++) {
//    cout << bitset<3>(Bit[i]) << "\n";
//  }
  
}

Measured memory_bytes: 256
package main

import "fmt"

func Comb2(n int) int {
	return n * (n - 1) / 2
}

func main() {
	var M, N int
	fmt.Scan(&M, &N)
	switch {
	case M >= 2 && N >= 2:
		fmt.Println(Comb2(M) + Comb2(N))
	case M >= 2:
		fmt.Println(Comb2(M))
	case N >= 2:
		fmt.Println(Comb2(N))
	default:
		fmt.Println(0)
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long i,j,k,n;
	string a,b,c;
	cin>>n;
	c="";
	cin>>a>>b;
	for (i=0;i<n;i++)
	{
		c=c+a[i];
		c=c+b[i];
	}
	cout<<c<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    long t1 = Long.parseLong(sl[0]);
    long t2 = Long.parseLong(sl[1]);

    s = r.readLine();
    sl = s.split(" ");
    long a1 = Long.parseLong(sl[0]);
    long a2 = Long.parseLong(sl[1]);

    s = r.readLine();
    sl = s.split(" ");
    long b1 = Long.parseLong(sl[0]);
    long b2 = Long.parseLong(sl[1]);

    a1 -= b1;
    a2 -= b2;

    if(a1 < 0)
    {
      a1 = - a1;
      a2 = - a2;
    }

    long v = a1 * t1 + a2 * t2;

    if(v == 0)
    {
      System.out.println("infinity");
      System.exit(0);
    }

    if(v > 0)
    {
      System.out.println("0");
      System.exit(0);
    }

    long a = a1 * t1;
    long b = a2 * t2;
//    System.out.println(a);
//    System.out.println(b);
//    System.out.println(v);
//    System.out.println(a / (- v));
//    System.out.println((- b + v + (- v - 1)) / (- v));

    System.out.println(a / (- v) + (- b + v + (- v - 1)) / (- v));

  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}


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

int arr[1010];

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", arr + i);
    }
    std::sort(arr, arr + n);
    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += arr[i];
    }
    printf("%d", sum);
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  
  double Ha= (T-A)/0.006;
  int ans = 0;
  double sub_min = abs(Ha-H.at(0));
  
  for(int i=1;i<N;i++){
    double work = abs(Ha-H.at(i));
    if(abs(Ha-H.at(i))<sub_min){
      ans = i;
      sub_min = work;
    }
  }
  cout << ans+1 <<endl;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
vector<string> dic;

ll ltmp;
string stmp;
double dtmp;

/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll cntmax=1;
    map<string,ll> count_map;


    cin >> N;
    rep(ni,N){
        cin >> stmp;
        if(count_map.count(stmp)==0){
            count_map[stmp]=1;
        }else{
            count_map[stmp]++;
            if(count_map[stmp]>cntmax){
                cntmax = count_map[stmp];
            }
        }
    }

    for(auto cmi : count_map) {
        string key = cmi.first;
        ll value = cmi.second;
        if(value == cntmax){
            dic.push_back(key);
        }
    }

    sort(dic.begin(),dic.end());

    //cout << "" << endl;
    rep(si,dic.size()){
        cout << dic[si] << endl;
    }

    

}

Measured memory_bytes: 25584
#!/usr/bin/env python3
import sys
from math import gcd

def f(A):
    ret = [0]
    for a in A:
        ret.append(gcd(ret[-1], a))
    return ret

def solve(N: int, A: "List[int]"):    
    return  max(gcd(g0, g1) for g0, g1 in zip(f(A), f(A[::-1])[-2::-1]))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 29768
#include<iostream>
using namespace std;
int a[25];
int main(){
  int n,i,sum=0,max=0;
  cin>>n;
  for(i=1;i<=n;i++){
    cin>>a[i];
    if(a[i]>=max){
      sum++;
      max=a[i];
    }
  }
  cout<<sum;
  return 0;
}

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

int main() {

  int n;
  while( cin >> n, n ) {
    for(int i=0; i<n; i++) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      int ave = (pm + pe + pj) / 3;
      
      if( pm == 100 || pe == 100 || pj == 100 ) cout << 'A' << endl;
      else if( (pm + pe) / 2 >= 90 ) cout << 'A' << endl;
      else if( ave >= 80 ) cout << 'A' << endl;
      else if( ave >= 70 ) cout << 'B' << endl;
      else if( ave >= 50 && ( pm >= 80 || pe >= 80 ) ) cout << 'B' << endl;
      else cout << 'C' << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	string S,T;
	cin >> S >> T;

	vector<vector<int>> DP(S.size() + 1, vector<int>(T.size() + 1,0));

	for(int i = 1; i <= int(S.size()); i++){
		for(int j = 1; j <= int(T.size()); j++){
			if(S[i-1] == T[j-1]) DP[i][j] = DP[i-1][j-1] + 1;
			else DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
		}
	}

	string ans = "";

	int j = T.size() - 1;

	for(int i = (int)S.size() - 1; i >= 0; i--){
		if(j < 0) break;
		if(S[i] == T[j]) ans += S[i], j--;
		else{
			if(DP[i][j+1] == DP[i+1][j+1]) continue;
			else{
				j--;
				i++;
			}
		}
	}

	reverse(ans.begin(), ans.end());

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 38544
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll A[100010], mx=1000000000000000000;

int main(void){
    int N;
    cin >> N;
    bool zero=false;
    for(int i=0; i<N; ++i){
        cin >> A[i];
        zero=zero or A[i]==0;
    }
    if(zero){
        cout << 0 << endl;
        return 0;
    }
    ll ans=1;
    for(int i=0; i<N; ++i){
        if(mx/ans<A[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    long a = Long.parseLong(sl[0]);

    s = r.readLine();
    sl = s.split(" ");
    long b = Long.parseLong(sl[0]);

    Set<Long> hs = new HashSet<Long>();
    hs.add(1L);
    hs.add(2L);
    hs.add(3L);
    hs.remove(a);
    hs.remove(b);
    for(Long e: hs)
      System.out.println(e);

  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 21204
#include<stdio.h>

int max(int a,int b){
  if(a>=b){
    return a;
  }else{
    return b;
  }
}
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int q=max(a,b);
  int s=max(q,c);
  printf("%d\n",a+b+c-s);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL keta;
	LL flag=false;

	for (keta = 1;keta<=1000000000; keta *= 10) {
		cout << "? " << keta << endl;
		fflush(stdout);
		char s;
		cin >> s;
		if (s == 'N') {
			flag = true;
			keta /= 10;
			break;
		}
	}
	if (flag) {

		LL upper = keta * 10 - 1;
		LL lower = keta;

		LL count = 0;
		while (lower < upper)
		{
			count++;
			if (count == 50) {
				break;
			}
			LL mid = ((upper + lower) / 2) * 10;
			cout << "? " << mid << endl;
			fflush(stdout);

			char s;
			cin >> s;
			if (s == 'Y') {
				upper = mid / 10;
			}
			else {
				lower = mid / 10 + 1;
			}
		}

		cout << "! " << lower << endl;
		fflush(stdout);
	}
	else {
		for (keta = 2; keta <= 2000000000; keta *= 10) {
			cout << "? " << keta << endl;
			fflush(stdout);
			char s;
			cin >> s;
			if (s == 'Y') {
				cout << "! " << keta/2 << endl;
				fflush(stdout);
			}
		}
	}

}


Measured memory_bytes: 648
//#define GBN_USE_C
#ifdef GBN_USE_C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#else
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#endif

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const ll INF_LONG = 1LL << 62;
const ll INF_LONG_NEG = INF_LONG * -1;

#define MAX_N 2020

int main()
{
    int N, X, Y; cin >> N >> X >> Y;

    int **matrix = new int*[MAX_N];
    rep(i, MAX_N) matrix[i] = new int[MAX_N];
    
    for (int i = 1; i <= N; ++i) matrix[i][i] = 0;

    for (int row = 1; row <= X; ++row){ // スタートが枝分かれ前
        for (int cmn = row + 1; cmn <= N; ++cmn){
            if (cmn <= X) matrix[row][cmn] = matrix[cmn][row] = cmn - row;
            else if (cmn >= Y) matrix[row][cmn] = matrix[cmn][row] = cmn - row - (Y - X - 1);
            else { // ゴールがが枝の中
                matrix[row][cmn] = matrix[cmn][row] = 
                    min(cmn - row, (X + 1 - row) + (Y - cmn)); // X + 1 - row: Y までの最短距離
            }
        }
    }
    for (int row = X + 1; row <= Y - 1; ++row){ // スタートが枝の中
        for (int cmn = row + 1; cmn <= N; ++cmn){
            if (cmn < Y){ // ゴールが枝の中
                matrix[row][cmn] = matrix[cmn][row] = 
                        min(cmn - row, Y - cmn + 1 + row - X);
            } else {
                matrix[row][cmn] = matrix[cmn][row] = 
                        min(cmn - row, cmn - Y + 1 + row - X);
            }
        }
    }
    for (int row = Y; row <= N; ++row){ // 
        for (int cmn = row + 1; cmn <= N; ++cmn){
            matrix[row][cmn] = matrix[cmn][row] = cmn - row;
        }
    }
//#define GBN_DEBUG
#ifdef GBN_DEBUG
    for (int row = 1; row <= N; ++row){
        for (int cmn = 1; cmn <= N; ++cmn){
            cout << matrix[row][cmn];
        }
        puts("");
    }
#endif

    int ans[N]; rep(i, N + 1) ans[i] = 0;
            
    for (int i = 1; i <= N; ++i){
        for (int j = 1; j <= N; ++j){
            ++ans[matrix[i][j]];
        }
    }
    for (int i = 1; i < N; ++i)
        cout << ans[i] / 2 << endl;

    rep(i, MAX_N) delete[] matrix[i];
    delete[] matrix;
    return 0;
}


Measured memory_bytes: 16128
S = input()

if S == 'SUN':
    print("7")

elif S == 'MON':
    print("6")

elif S == 'TUE':
    print("5")

elif S == 'WED':
    print("4")

elif S == 'THU':
    print("3")

elif S == 'FRI':
    print("2")

elif S == 'SAT':
    print("1")

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  char c='a';
  for(int i=0;i<26;i++){
    for(int j=0;j<s.size();j++){
      if(s.at(j)==c)
        break;
      if(j==s.size()-1){
        cout<<c;
        return 0;
      }
    }
    c++;
  }
  cout<<"None";
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

std::deque<int> deq;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        int a;
        std::cin >> a;
        
        if(i % 2 == 0){
            deq.push_front(a);
        }else{
            deq.push_back(a);
        }
    }

    for(int i=0;i<N;++i){
        int x;
        
        if((N - 1) % 2 == 0){
            x = deq.front();
            deq.pop_front();
        }else{
            x = deq.back();
            deq.pop_back();
        }

        std::cout << x << " \n"[i+1==N];
    }
}


Measured memory_bytes: 3072
#include <iostream>

int main(void){
  int count=0;
  std::string a, b;
  std::cin >> a;
  std::cin >> b;
  const char* ca = a.c_str();
  const char* cb = b.c_str();
  
  for(int i=0;i<a.length();i++){
    if(ca[i]!=cb[i]) count++;
  }
  std::cout << count;
  
}

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

int main() {
  string num;
  cin >> num;
  
  if (num.at(0) == num.at(1) && num.at(0) == num.at(2)) {
    cout << "Yes" << endl;
  }
 
  else if (num.at(1) == num.at(2) && num.at(1) == num.at(3)){
    cout << "Yes" << endl;
  }
           
  else {
    cout << "No" << endl;
  }
}


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

int main()
{
       char s[6];
       int i;

       scanf("%s" , s);

       for( i = 0; i <= 4; i++ )
       {
              if( s[i] == 'A' && s[i+1] == 'C' )
                     {
                            puts("Yes");
                            return 0;
                     }
              else continue;
       }
       puts("No");
       return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)

int N;

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

    cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    rep(i,1,N+1){
        REP(i,N) cout << a[i] << (i!=N-1 ? ' ' : '\n');
        int key = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > key){
            a[j+1] = a[j];
            --j;
        }
        a[j+1] = key;
    }
    return 0;
}


Measured memory_bytes: 3176
h,w = map(int,input().split())
sl = []
for _ in range(h):
    s = list(input())
    sl.append(s)


al_l = [["#" for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        if sl[i][j] == "#":
            continue
        ans = 0
        for v in range(i-1, i+2):
            for p in range(j-1, j+2):
                if 0 > v or v > h-1:
                    continue
                if 0 > p or p > w-1:
                    continue
                if sl[v][p] == "#":
                    ans += 1
        al_l[i][j] = str(ans)

for al in al_l:
    print("".join(al))






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

int GetDigitsCount(int N) {
	int digitsCount = 0;
	while (N != 0) {
		digitsCount++;
		N /= 10;
	}
	return digitsCount;
}

int main()
{
	long long n, k; cin >> n >> k;
	
	int ans = 1;

	if (k == 10) {
		ans = GetDigitsCount(n);
	}
	else {
		
		long long tmp = 1;
		while (true) {

			if (n < tmp) {
				ans--;
				break;
			}

			tmp *= k;
			ans++;

		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(void){
	char a[1010];
	int b;
	char c[20];
	int d;
	int z;
	int x;
	x = 0;
	for (int i = 0; i < 1010; i++)a[i] = 0;
	for (int i = 0; i < 20; i++)c[i] = 0;
	scanf("%s", c);
	d = strlen(c);
	for (;;){
		scanf("%s", a);
		if (a[0]=='E'&&a[1]=='N'&& a[9]=='X'&&a[10]=='T')break;
		b = strlen(a);
		if (b == d){
			z = 0;
			for (int i = 0; i < d; i++){
				if ((a[i]-c[i]+32)%32==0)z++;
			}
			if (z == d)x++;
		}
		for (int i = 0; i < b; i++)a[i] = 0;
	}
	printf("%d\n",x);

	return 0;
}

Measured memory_bytes: 2684
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

const [n, x]: number[] = input[0].split(' ').map((x: string): number => +x);
const l: number[] = input[1].split(' ').map((x: string): number => +x);

let ans: number = 1;
let num: number = 0
for(let i = 0; i < n; i++){
    num += l[i];
    if(num > x){break;}
    ans++
}

console.log(ans);

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

typedef long long LL;

int main()
{
    LL a, b;
    cin >> a >> b;

    LL g = __gcd(a, b), ans = 1;
    for (LL i=2; i*i<=g; ++i) {
        if (g%i == 0) {
            ans++;
            while (g%i == 0) g/= i;
        }
    }
    if (g != 1) ans++;
    cout << ans << "\n";
}

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

ll N, A[100010], B[100010], C[100010];

int main()
{
  cin >> N;
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N) cin >> C[i];
  
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);
  
  ll ans = 0;
  rep(i,N)
  {
    ll aj = lower_bound(A, A+N, B[i])-A;
    ll cj = upper_bound(C, C+N, B[i])-C;
    ans += aj*(N-cj);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
using System;

class Atcoder78
{
    public static void Main()
    {
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        string c = Console.ReadLine();

        char a0 = a[0];
        char b1 = b[1];
        char c2 = c[2];

        string a00 = a0.ToString();
        string b01 = b1.ToString();
        string c02 = c2.ToString();

        Console.WriteLine(a00 + b01 + c02);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n){
    Int res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
    return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
    Int g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

vector<vector<int>> K;


int main(){
    int N, M;
    cin >> N >> M;
    UnionFind uf(M+N+1);
    for (int i = 0; i < N; i++){
        int K;
        cin >> K;
        for (int j = 0; j < K; j++){
            int L;
            cin >> L;
            uf.unite(M+1+i, L);
        }
    }
    for (int i = 1; i < N; i++){
        if(!uf.same(M+1+i, M+i)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int k; string s; cin>>k>>s;
	int len = s.length();
	if(len<=k){ cout<<s; return 0; }
	forn(i,k) cout<<s[i]; cout<<"...";
	
	return 0;
}


Measured memory_bytes: 3616
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		int val[]=new int[n];
		int cost[]=new int[n];
		
		for(int i=0;i<n;i++)
			val[i]=s.nextInt();
		
		for(int i=0;i<n;i++)
			cost[i]=s.nextInt();
		
		int ans=0;
		
		for(int i=0;i<n;i++)
			ans+=Integer.max(val[i]-cost[i], 0);
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 23380
import bisect as bi
import sys
N = int(sys.stdin.readline())
C = [int(sys.stdin.readline()) for i in range(N)]
inf = 10000000000
lis = [inf] * N
for c_i in C:
    lis[bi.bisect_left(lis, c_i)] = c_i
print(bi.bisect_left(lis, inf))

Measured memory_bytes: 12480