akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
ts = [0] + gets.split.map(&:to_i) + [0]
as = [0] + gets.split.map(&:to_i) + [0]
ans = 1
MOD = 10**9+7
(1..N).each do |i|
    if ts[i-1] < ts[i] && as[i] > as[i+1]
        if ts[i] != as[i]
            puts 0
            exit
        end
    elsif ts[i-1] < ts[i]
        if ts[i] > as[i]
            puts 0
            exit
        end
    elsif as[i] > as[i+1]
        if ts[i] < as[i]
            puts 0
            exit
        end
    else
        ans = ans * [ts[i], as[i]].min % MOD
    end
end
puts ans

Measured memory_bytes: 21764
N=int(input())
v_list=list(map(int,input().split()))
c_list=list(map(int,input().split()))

ans=0
for i in range(N):
    if(v_list[i]-c_list[i]>0):
        ans+=v_list[i]-c_list[i]
    else:
        continue
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll s;
    cin >> s;

    vector<vector<ll>> dp(s+10, vector<ll>(s+10));

    dp[0][0] = 1;
    REP(i, s){
        ll sum = 0;
        REP(j, s){
            sum += dp[i][j];
            sum %= MOD;
            dp[i+1][j] += sum;
            dp[i+1][j] %= MOD;
        }
    }

    ll ans = 0;
    REP(i, s){
        if(s - (i*3) < 0) break;
        ans += dp[i][s - (i*3)];
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  if(s.at(k-1)=='A') s.at(k-1)='a';
  else if(s.at(k-1)=='B') s.at(k-1)='b';
  else s.at(k-1)='c';
  cout<<s<<endl;
}

Measured memory_bytes: 256
S = str(input())

if S == "SUN":
    print("7")
if S == "MON":
    print("6")
if S == "TUE":
    print("5")
if S == "WED":
    print("4")
if S == "THU":
    print("3")
if S == "FRI":
    print("2")
if S == "SAT":
    print("1")


Measured memory_bytes: 3060
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    println!(
        "{}",
        if n % 10 == 9 || n / 10 == 9 {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

struct FenwickTree {
    int length;
    vector<ll> node;
    FenwickTree (int N) : length(N), node(length + 1, 0) {}
    void add(int idx, ll val) {
        ++idx;
        while (idx <= length) {
            node[idx] += val;
            idx += (idx & (-idx));
        }
    }
    ll getsum(int idx) {
        ll ans = 0;
        while (idx) {
            ans += node[idx];
            idx -= (idx & (-idx));
        }
        return ans;
    }
    int lowerBound(ll x) {
        int ans = 0;
        int l = 1;
        while ((l << 1) <= length) l <<= 1;
        while (l) {
            if (ans + l <= length) {
                if (node[ans + l] < x) {
                    x -= node[ans + l];
                    ans += l;
                }
            }
            l >>= 1;
        }
        return ans + 1;
    }
};

int main() {
    int Q;
    cin >> Q;
    vector<ll> a(Q, 0), b(Q, INF), c(Q, INF);
    rep(i, Q) {
        cin >> a[i];
        if (a[i] == 1) cin >> b[i] >> c[i];
    }
    
    vector<ll> S;
    rep(i, Q) {
        if (a[i] == 1) S.push_back(b[i]);
    }
    sort(ALL(S));
    map<ll, int> mp;
    mp[S[0]] = 0;
    REP(i, SZ(S)) {
        if (S[i - 1] == S[i]) continue;
        mp[S[i]] = mp[S[i - 1]] + 1;
    }
    vector<ll> T(Q, 0);
    for (auto p : mp) T[p.second] = p.first;
    
    int cnt = 0;
    vector<int> C(Q, 0);
    FenwickTree FT1(Q), FT2(Q);
    ll sum = 0;
    rep(i, Q) {
        if (a[i] == 1) {
            sum += c[i];
            FT1.add(mp[b[i]], 1);
            FT2.add(mp[b[i]], b[i]);
            ++C[mp[b[i]]];
            ++cnt;
        } else {
            int idx = FT1.lowerBound((cnt + 1) / 2);
            --idx;
            cout << T[idx] << " ";
            cout << sum + FT2.getsum(Q) - FT2.getsum(idx + 1) - (FT1.getsum(Q) - FT1.getsum(idx + 1)) * T[idx] +  FT1.getsum(idx) * T[idx] - FT2.getsum(idx) << "\n";
        }
    }
}


Measured memory_bytes: 20248
#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 ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

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 = "Possible";
const string NO  = "Impossible";

int H,W;
string s[20];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void compute() {
  deque<int> deq;
  if( s[0][0] == '.' || s[H-1][W-1] == '.' ) {
    puts(NO.c_str());
    return;
  }
  s[0][0] = '.';
  deq.push_back(0);
  while( !deq.empty() ) {
    int cur = deq.front(); deq.pop_front();
    int x = cur % W, y = cur / W;
    rep(i,2) {
      int nx = x + dx[i], ny = y + dy[i];
      if( !( 0 <= nx && nx < W && 0 <= ny && ny < H ) ) continue;
      if( s[ny][nx] == '.' ) continue;
      deq.push_back(nx+ny*W);
      s[ny][nx] = '.';
      break;
    }
  }
  bool found = false;
  rep(i,H) rep(j,W) if( s[i][j] == '#' ) found = true;
  puts( !found ? YES.c_str() : NO.c_str());
}



int main() {
  cin >> H >> W;
  rep(i,H) cin >> s[i];
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i*j == n) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
  		double h=sc.nextDouble();
  		double m=sc.nextDouble();
		double mr=Math.toRadians(m*6);
  		double hr=Math.toRadians(30*h+m*0.5);
        double sar=Math.abs(mr-hr);
  		double ans=Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar));

    	System.out.println(ans);
    }
}

Measured memory_bytes: 37260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}
/*Aをmod2の配列Bに変換 Bのうち1と0の個数をカウント
*/


int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  ll ans = 0;
  if(A > B) ans = 0;
  else if(A != B && N == 1) ans = 0;
  else if(A == B && N == 1) ans = 1;
  else{
      ans = (N-2)*B -(N-2)*A + 1;
  }
  cout << ans << endl;

 }


Measured memory_bytes: 256
import java.util.Scanner;

//Smart Calculator
public class Main {

	static char[] s;
	static int id;
	
	static int exp(){
		int r = term();
		while(true){
			char c = s[id++];
			if(c=='+')r+=term();
			else if(c=='-')r-=term();
			else break;
		}
		return r;
	}
	
	static int term(){
		int r = fact();
		while(true){
			char c = s[id++];
			if(c=='*') r*=fact();
			else if(c=='/')r/=fact();
			else break;
		}
		id--;
		return r;
	}
	
	static int fact(){
		char c = s[id++];
		if(c=='(')return exp();
		if(c=='-'){
			return -fact();
		}
		if(c=='+'){
			return fact();
		}
		int x = c-'0';
		while(true){
			c = s[id++];
			if(Character.isDigit(c)){
				x *= 10;
				x += c-'0';
			}
			else break;
		}
		id--;
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			s = sc.next().toCharArray();
			id = 0;
			System.out.println(exp());
		}
	}
}

Measured memory_bytes: 17168
#include <iostream>
#include <cstring>
 
using namespace std;
 
char field[12][6],tmp[12][6];
bool visited[12][6];
int Bcnt;
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};
 
bool inField(int y,int x){
    return 0 <= y && y < 12 && 0 <= x && x < 6;
}
 
void CountBlock(int y,int x,char B){
    for(int i = 0 ; i < 4 ; i++){
	int nx = x + dx[i], ny = y + dy[i];
	if(!inField(ny,nx)) continue;
	if(visited[ny][nx]) continue;
	if(field[ny][nx] == B){
	    visited[ny][nx] = true;
	    Bcnt++;
	    CountBlock(ny,nx,B);
	}
    }
}
 
void remove(int y,int x,char B){
    for(int i = 0 ; i < 4 ; i++){
	int nx = x + dx[i], ny = y + dy[i];
	if(!inField(ny,nx)) continue;
	if(field[ny][nx] == B){
	    field[ny][nx] = '.';
	    remove(ny,nx,B);
	}else if(field[ny][nx] == 'O'){
	    field[ny][nx] = '.';
	}
    }
}
 
void FallBlock(){
    for(int i = 0 ; i < 12 ; i++){
	for(int j = 0 ; j < 6 ; j++){
	    tmp[i][j] = '.';
	}
    }
 
    for(int j = 0 ; j < 6 ; j++){
	int p = 11;
	for(int i = 11 ; i >= 0 ; i--){
	    if(field[i][j] == '.') continue;
	    tmp[p--][j] = field[i][j];
	}
    }
 
    for(int i = 0 ; i < 12 ; i++){
	for(int j = 0 ; j < 6 ; j++){
	    field[i][j] = tmp[i][j];
	}
    }
}
 
int main(){
    int Tc;
 
    cin >> Tc;
    while(Tc--){
	for(int i = 0 ; i < 12 ; i++){
	    for(int j = 0 ; j < 6 ; j++){
		cin >> field[i][j];
	    }
	}
 
	int cnt = 0;
	while(true){
	    bool flg = false;
	    memset(visited,false,sizeof(visited));
	    for(int i = 0 ; i < 12 ; i++){
		for(int j = 0 ; j < 6 ; j++){
		    if(field[i][j] == '.' || field[i][j] == 'O') continue;
		    if(visited[i][j]) continue;
		    visited[i][j] = true;
		    Bcnt = 1; CountBlock(i,j,field[i][j]);
		    if(Bcnt >= 4){
			flg = true;
			remove(i,j,field[i][j]);
		    }
		}
	    }
	    if(!flg) break;
	    cnt++; FallBlock();
	}
	cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3040
adjust_list = ((0,1),(0,-1),(1,0),(-1,0))
h, w = [int(v) for v in input().split()]
field = [list(input()) for i in range(h)]

def bfs(s, t):
    si, sj = s
    ti, tj = t
    if field[si][sj] == "." and field[ti][tj] == ".":

        search_field = [ [ -1 for i in range(w) ] for j in range(h) ]
        search_list = [s]
        turn = 0
        search_field[si][sj] = turn
        
        
        while search_list:
            turn += 1
            new_search_list = []
            for p in search_list:
                pi, pj = p
                
                for q in adjust_list:
                    qi, qj = q
                    if 0 <= pi+qi < h and 0 <= pj+qj < w:
                        if search_field[pi+qi][pj+qj] == -1 and field[pi+qi][pj+qj] == ".":
                            new_search_list.append((pi+qi,pj+qj))
                            search_field[pi+qi][pj+qj] = turn
            search_list = new_search_list
            if search_field[ti][tj] != -1:
                break
        return search_field[ti][tj]
    else:
        return -1
    

ans = 0
coodinate = [ (i, j) for i in range(h) for j in range(w) ]
k = h*w

for i in range(k-1):
    for j in range(i+1, k):
        ans = max(ans, bfs(coodinate[i], coodinate[j]))
print(ans)

Measured memory_bytes: 52316
n = gets.to_i
a = gets.split.map{|n|n.to_i}
array = Array.new
f = true
n.times do |i|
    if f
        array.push(a[i])
    else
        array.unshift(a[i])
    end
    f = !f
end
puts f ? array.join(" ") : array.reverse.join(" ")

Measured memory_bytes: 27104
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int N;
  cin>>N;
  ll a[26]={};
  rep(i,N){
    string s;
    cin>>s;
    a[(int)s[0]-'A']++;
  }
  ll ans=0;
  int t[5]={'M'-'A','A'-'A','R'-'A','C'-'A','H'-'A'};
  rep(i,5)rep(j,5)rep(k,5)if(i>j and j>k) ans+=a[t[i]]*a[t[j]]*a[t[k]];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,a[100010],i,f=0;
	cin >> n;
	for(i=0;i<n;i++)
		cin >> a[i];
	int x=0;
	for(i=0;i<n;i++){
		f++;
		if(a[x]==2)
			break;
		if(a[x]==-1){
			f=-1;
            break;
		}
		int x1=a[x]-1;
		a[x]=-1;
		x=x1;
	}
	cout << f << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__ )
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
//________


signed main()
{
   FAST();
   string a ,b;
   cin >> a >> b;
   a += b;
   int n = stoi(a);

   int r = (int)sqrt((double)n);

   outl( r * r == n ? "Yes" : "No" );

}



Measured memory_bytes: 256
// BROWNIE TK
 
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define osetlli tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;
 
/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
    lli res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        //y must be even now
        y=y>>1; //y=y/2
        x=(x*x)%p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
 kira;
 lli n;
 cin>>n;
 ldb p[n+1];
 ldb dp[n+1][n+1];
 ldb q[n+1];
 for(int i=1;i<=n;i++)
 {
   cin>>p[i];
   q[i]=1-p[i];
 }
 forz(i,n+1)
 {dp[0][i]=0;}
 dp[0][0]=1;
 for(int i=1;i<=n;i++)
 {
   dp[i][0]=dp[i-1][0]*q[i];
 }
 for(int i=1;i<=n;i++)
 {
   for(int j=1;j<=n;j++)
   {
     if(i<j)dp[i][j]=0;
     dp[i][j]=(dp[i-1][j]*q[i])+(dp[i-1][j-1]*p[i]);
     //p0(dp[i][j]);
   }
   //cout<<endl;
 }
 ldb ans=0;
 lli k=(n-1)/2;
 for(int i=k+1;i<=n;i++)
 {ans+=dp[n][i];}
 cout<<deci(10)<<ans;
 return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;
	
	int k;
	cin >> k;

	int n=int(s.size());
	rep(i,n){
		int num=(26-(s[i]-'a'))%26;
		if(num<=k){
			k-=num;
			s[i]='a';
		}
	}

	s[n-1]=(s[n-1]-'a'+k)%26+'a';

	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(void)
{
	int s[4];
	int i,j,temp;

	for(i=0;i<=3;i++){scanf("%d",&s[i]);}
	if(s[1]<=s[2] || s[3]<=s[0]){printf("0");}
	else
	{
		for(i=0;i<=2;i++)
			{
			for(j=0;j<=2-i;j++)
				{
				if(s[j]>s[j+1])
					{
					temp=s[j];
					s[j]=s[j+1];
					s[j+1]=temp;
					}}}
		
	int time=s[2]-s[1];
	printf("%d",time);
	}

	return 0;
}



Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = intScanner()
	}
	ans := make([]int, n)
	f := true
	for i := 0; i < n; i++ {
		idx := -1
		for j := 0; j < len(b); j++ {
			if b[j] == j+1 {
				idx = j + 1
			}
		}
		if idx == -1 {
			f = false
			break
		} else {
			ans[i] = idx
			b = append(b[:idx-1], b[idx:]...)
		}
	}
	if f {
		for i := n - 1; i >= 0; i-- {
			fmt.Println(ans[i])
		}
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k) puts(":(");
    else puts("Yay!");
    return 0;
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> p(n, vector<pair<int, int>>());
    REP(i, n) {
        int a;
        cin >> a;
        int x, y;
        REP(j, a) {
            cin >> x >> y;
            p[i].emplace_back(x, y);
        }
    }

    int ans = 0;
    int x, y;
    for (int i = 0; i < 1 << n; i++) {
        bool all = true;
        for (int j = 0; j < n; j++) {
         	// 指定ビットが立っているか？
            if ((1 & i >> j) == 1) {
                bool ok = true;
                for (auto q : p[j]) {
                    tie(x, y) = q;
                    // cout << i << "/" << j << ":" << y << "-" << (1 & i >> (x - 1)) << EOL;
                    if (y != (1 & i >> (x - 1))) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) {
                    all = false;
                    break;
                }
            }
        }
        if (all) {
            int c = 0;
            for (int j = 0; j < n; j++) {
                if ((1 & i >> j) == 1) c++;
            }
            chmax(ans, c);
        }
    }
    cout << ans << EOL;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main() {
    IN(string, s);
    REP(i, s.length()){
        if (s[i] == '?') {
            cout << 'D';
        }else {
            cout << s[i];
        }
    }
    ENDL;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<unistd.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    ll K;cin>>K;
    vector<ll> A(K);
    REP(i,K) cin>>A[i];
    ll l=1,r=1LL<<50;
    auto f=[&](ll x){
        REP(i,K){
            x=(x/A[i])*A[i];
        }
        if(x==2) return true;
        return false;
    };
    while(l+1<r){
        ll mid=(l+r)/2,tmp=mid;
        bool S=false;
        REP(i,K){
            tmp=(tmp/A[i])*A[i];
            if(tmp<2){//明らかに少ない
                l=mid;
                S=true;
            }
        }
        if(S) continue;
        r=mid;
    }
    if(!f(r)){//rがあり得る下界になる
        cout<<-1<<endl;
        return 0;
    }
    ll L=r,R=1LL<<50;
    while(L+1<R){
        ll MID=(L+R)/2;
        if(f(MID)) L=MID;
        else R=MID;
    }
    cout<<r<<" "<<L<<endl;
}


Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
using LL = long long;

int Yakusu_count[100001];

int main() {
	int N;
	LL ans = 1;
	cin >> N;
	for (int i = 2; i <= N; i++) {
		int num = i;
		for (int j = 2; j < 1000; j++) {
			if (num % j == 0) {
				Yakusu_count[j]++;
				num /= j;
				j = 1;
			}
		}
	}
	for (int i = 0; i < 1000; i++) {
		ans = (ans*(Yakusu_count[i] + 1)) % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static Building[] b;
	static HashMap<Integer,Integer> map;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			int N = cin.nextInt();
			if(N==0)break;
			b=new Building[N+1];
			map=new HashMap<Integer,Integer>();
			for(int i = 1;i<=N;i++){
				b[i]=new Building(cin.nextInt(),cin.nextInt(),cin.nextInt());
				map.put(b[i].num, i);
			}
			for(int i = 1;i<=N;i++){
				for(int j = 1;j<=N;j++){
					if(i==j)continue;
					if(b[i].isNeibor(b[j])){
						b[i].neibor.add(b[j]);
						b[i].neiborDist.add(b[i].kyori(b[j]));
					}
				}
			}
			int M = cin.nextInt();
			
			while(M--!=0){
				for(int i = 1;i<b.length;i++){
					b[i].init();
				}
				int start=cin.nextInt();
				start=map.get(start);
				int goal=cin.nextInt();
				goal=map.get(goal);
				PriorityQueue<A> q=new PriorityQueue<A>();
				b[start].min=0.0;
				//b[start].route=""+start;
				b[start].pre=b[start];
				q.add(new A(b[start],0.0));
				
				while(!q.isEmpty()){
					A a = q.poll();
					Building now=a.a;
					now.route=now.pre.route+" "+now.num;
					double dist=a.b; 
					for(int i = 0;i<now.neibor.size();i++){
						Building nei=now.neibor.get(i);
						double dis=now.neiborDist.get(i);
						if(nei.min>dist+dis){
							nei.min=dist+dis;
							nei.pre=now;
							//nei.route=b[now].route+" "+nei.num;
							q.add(new A(nei,dist+dis));
						}
					}
				}
				if(b[goal].route.equals("")){
					System.out.println("NA");
					continue;
				}
				System.out.println(b[goal].route.trim());
			}
		}
	}
	static class A implements Comparable{
		Building a;
		double b;
		A(Building x,double y){
			a=x;b=y;
		}
		@Override
		public int compareTo(Object o) {
			A a = (A)o;
			double d=this.b-a.b;
			if(d<0.0)return -1;
			else if(d==0.0)return 0;
			else return 1;
		}
	}
	static class Building{
		String route;
		Building pre;
		ArrayList<Building> neibor = new ArrayList<Building>();
		ArrayList<Double> neiborDist = new ArrayList<Double>();
		double min=1<<30;
		int num,x,y;
		Building(int c,int a,int b){
			min=1<<30;
			route="";
			num=c;
			x=a;y=b;
		}
		boolean isNeibor(Building b){
			double x = kyori(b);
			if(x<=50.00000000){
				return true;
			}
			else{
				return false;
			}
		}
		double kyori(Building b){
			double d1=(this.x-b.x)*(this.x-b.x);
			double d2=(this.y-b.y)*(this.y-b.y);
			return Math.sqrt((d1+d2));
		}
		void init(){
			route="";
			min=1<<30;
			pre=null;
		}
	}
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    cout<<setprecision(15);
    ll n;
    cin>>n;
    double xx=n/3.0;
    cout<<xx*xx*xx<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    s = input()
    anslist = []
    for i in s:
        if i == 'A' or i == 'T' or i == 'C' or i == 'G':
            anslist.append(1)
        else:
            anslist.append(0)
    anslist.append(0)
    ans = 0
    tmp = 0
    for i in anslist:
        tmp+=i
        if not i:
            ans = max(ans,tmp)
            tmp = 0
    print(ans)


main()




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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int p, q, r; cin >> p >> q >> r;
        cout << min({p + q, p + r, q + r});
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run() {
		while (true) {
			String str = sc.nextLine();
			if( str.equals(".") )break;
			System.out.println( isClosed(str)? "yes":"no" );
		}
	}
	
	boolean isClosed( String str ) {
		LinkedList<Character> kakko = new LinkedList<Character>();
		for(int i=0;i<str.length();i++) {
			char c = str.charAt(i);
//			System.out.print(c);
			if( c == '(' || c == '[' ) kakko.addLast(c);
			else if( c == ')' ) {
				if( kakko.isEmpty() || kakko.removeLast() != '(' ) return false; 
			}
			else if( c == ']' ) {
				if( kakko.isEmpty() || kakko.removeLast() != '[' ) return false; 
			}
		}
		if ( !kakko.isEmpty() ) return false;
		return true;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
}

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

template<class Monoid> 
class SegmentTree {
private:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func f;
  const Monoid unity;
  int siz;
  vector<Monoid> dat;

public:
  SegmentTree(int _n, const Func _f, const Monoid &_unity) : f(_f), unity(_unity) { init(_n);}
  void init(int _n) {
    siz = 1;
    while (siz < _n) siz <<= 1;
    dat.assign(siz * 2, unity);
  }

  void set(int idx, const Monoid &val) { dat[siz + idx] = val;}

  void build() {
    for (int idx = siz - 1; idx > 0; idx--) {
      dat[idx] = f(dat[idx * 2], dat[idx * 2 + 1]);
    }
  }

  void update(int idx, const Monoid &val) {
    idx += siz;
    dat[idx] = val;
    while (idx >>= 1) {
      dat[idx] = f(dat[idx * 2], dat[idx * 2 + 1]);
    }
  }

  Monoid get(int left, int right) {
    Monoid val_left = unity, val_right = unity;
    for (int l = left + siz, r = right + siz; l < r; l >>= 1, r >>= 1) {
      if (l & 1) val_left = f(val_left, dat[l++]);
      if (r & 1) val_right = f(val_right, dat[--r]);
    }
    return f(val_left, val_right);
  }

  inline Monoid operator[] (int idx) {return dat[idx + siz];}

  void print() {
    for (int i = 0; i < siz; i++) {
      cout << (*this)[i];
      if (i != siz - 1) cout << ", ";
    }
    cout << endl;
  }
};

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  while (cin >> n) {
    vector<int> in(n);
    for (int i = 0; i < n; i++) {
      cin >> in[i];
    }
    auto func = [](pair<long long, long long> x, pair<long long, long long> y) {return max(x, y);};
    SegmentTree<pair<long long, long long>> sgt(100005, func, make_pair(-LLONG_MAX / 2, -LLONG_MAX / 2));
    sgt.update(0, make_pair(0, 0));
    for (int i = 0; i < n; i++) {
      pair<long long, long long> p = sgt.get(0, in[i]);
      sgt.update(in[i], make_pair(p.first + 1, p.second + in[i]));
    }
    pair<long long, long long> ans = make_pair(0, -LLONG_MAX / 2);
    for (int i = 0; i < 100004; i++) {
      ans = max(ans, sgt.get(i, i + 1));
    }
    cout << ans.second << endl;
  }
  return 0;	
}


Measured memory_bytes: 7308
#include<bits/stdc++.h>
using namespace std;
int n,a[202],i,s;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(i=1;i<=2*n;i++)
		cin>>a[i];
	sort(a+1,a+2*n+1);
	for(i=1;i<=2*n;i+=2)
		s+=a[i];
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
import collections
n=int(input())
m=n//2
v1=list(map(int,input().split()))
v2=[]
for j in range(m):
    v2.append(v1.pop(j))
a1=sorted((collections.Counter(v1)).items(),key=lambda x:x[1],reverse=True)
a2=sorted((collections.Counter(v2)).items(),key=lambda x:x[1],reverse=True)
if a1[0][1]<a2[0][1]:a1,a2=a2[:],a1[:]
if a1[0][0]!=a2[0][0]:
    print(n-a1[0][1]-a2[0][1])
elif len(a2)==1:
    print(m)
elif a1[1][1]<a2[1][1]:
    print(n-a1[0][1]-a2[1][1])
else:
    print(n-a1[0][1]-a1[1][1])

Measured memory_bytes: 20392
N = int(input())
F = [[int(f) for f in input().split()] for _ in range(N)]
P = [[int(p) for p in input().split()] for _ in range(N)]

saidai_rieki = -1*(10**10)
for i in range(1,2**10):
    C = [0]*N
    for time in range(10):
        if (i>>time)%2==1:
            for j in range(N):
                C[j] += F[j][time]    
    saidai_rieki = max(saidai_rieki,sum([P[j][C[j]] for j in range(N)]))
print(saidai_rieki)


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

int main() {
    int A,B,C; 
    cin >> A >> B >> C;

    int ret = 0;

    ret = C -(A - B);

    if (ret > 0){
        cout << ret << endl;
    } else {
        cout << 0 << endl;
    }


}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

LL N, Q, cnt[200002] = {}, vis[200002] = {};
vector<LL>con[200002];
queue<int> que;

int main() {
	cin >> N >> Q;
	for (int i = 1; i < N; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		con[a].push_back(b);
	}
	for (int i = 0; i < Q; i++){
		LL p, x;
		cin >> p >> x; p--;
		cnt[p] += x;
	}
	vis[0]++;
	que.push(0);
	while (!que.empty()) {
		int top = que.front(); que.pop();
		for (int i = 0; i < con[top].size(); i++) {
			if (vis[con[top][i]] == 0) {
				cnt[con[top][i]] += cnt[top];
				vis[con[top][i]]++;
				que.push(con[top][i]);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (i)cout << " ";
		cout << cnt[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans;
    ans = 0;
    int cnt;
    for( int i=1; i<=N; i++){
        cnt = 0;
        for( int j=1; j<=i; j++){
            if( i%j == 0){
                cnt++;
            }
        }
        if( i%2 == 1 && cnt == 8){
            ans++;
            //cout << i << endl;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll mod=1e9+7;
vector<int> adj[100003];
vector<int> dp(100003,-1);
int solve(int i)
{
  if(dp[i]!=-1)
  return dp[i];
  if(adj[i].empty())
  return dp[i]=0;
  int best=0;
  for(int x: adj[i])
  best=max(best,solve(x)+1);
  return dp[i]=best;
}
int main()
{
  int n,m,x,y;
  cin>>n>>m;
  for(int i=0;i<m;i++)
  {
    cin>>x>>y;
    adj[x].push_back(y);
  }
  for(int i=1;i<=n;i++)
  solve(i);
  cout<<*max_element(dp.begin(),dp.end())<<endl;
  return 0;
}

Measured memory_bytes: 11020
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double
#define ss(x) (int) x.size()
#define FOR(i, n) for(int i = 1; i <= n; ++i)
#define fi first
#define se second
#define cat(x) cout << #x << " = " << x << endl
	
using namespace std;

const int nax = 1e5 + 111;
const long long inf = 1e18;
const int pod = (1 << 17);

int n, m;
int l[nax], r[nax], c[nax];

vector <pair<pair<int,int>,int>> ad[nax];

ll dp[nax];

ll t[2 * pod];

void add(int l, int r, ll cost) {
	r += 1;
	for(l += pod, r += pod; l < r; l /= 2, r /= 2) {
		if(l & 1) {
			t[l] = min(t[l], cost);
			l += 1;
		}
		if(r & 1) {
			r -= 1;
			t[r] = min(t[r], cost);
		}
	}
}

ll query(int pos) {
	ll res = inf;
	pos += pod;
	while(pos) {
		res = min(res, t[pos]);
		pos /= 2;
	}
	return res;
}

int main() {	
	for(int i = 1; i < 2 * pod; ++i)
		t[i] = inf;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; ++i) {
		scanf("%d %d %d", l + i, r + i, c + i);
		ad[r[i]].pb(mp(mp(l[i], r[i]), c[i]));
	}
	dp[n] = 0;
	for(int i = 1; i < n; ++i) dp[i] = inf;
	for(int i = n; 1 <= i; --i) {
		dp[i] = ((i < n) ? query(i) : 0);
		for(auto it : ad[i]) 
			add(it.fi.fi, it.fi.se, dp[i] + it.se);
	}
	if(dp[1] == inf)
		printf("-1\n");
	else
		printf("%lld\n", dp[1]);
	
	
		
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>

int getdigit(int n)
{
    int digit = 1;
    while(std::pow(10, digit) <= n) digit++;
    return digit;
}

int gethighest(int n)
{
    return n / std::pow(10, getdigit(n) - 1);
}

int getlowest(int n)
{
    return n % 10;
}

int main()
{
    int N;
    std::cin >> N;
    int pairs = 0;

    for(int a = 1; a <= N; ++a)
    {
        int digitcount = getdigit(a);
        int low = getlowest(a);
        int high = gethighest(a);
      	//std::cout << digitcount << std::endl;
      	//std::cout << low << std::endl;
      	//std::cout << high << std::endl;
      	//std::cout << std::endl;

        if(low == high) pairs += 1;
      	if(low == 0) continue;

        int digit = 1;
        while(low * std::pow(10, digit) + high <= N)
        {
            int maxnum = low * std::pow(10, digit) + high;
            for(int x = digit - 1; x > 0; --x)
            {
                int y = 9;
                for(; y > 0; --y)
                {
                    if(y * std::pow(10, x) + maxnum <= N) break;
                }
                pairs += y * std::pow(10, x - 1);
                maxnum += y * std::pow(10, x);
            }
            pairs += 1;
            digit++;
        }
    }

    std::cout << pairs << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>t(N);
  vector<int>x(N);
  vector<int>y(N);
  
  for (int i = 0; i < N; i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  int T = 0;
  int X = 0;
  int Y = 0;
  
  for (int i = 0; i < N; i++) {
    if (t.at(i)-T < abs(x.at(i)-X) + abs(y.at(i)-Y) || (t.at(i)-T)%2 != (abs(x.at(i)-X) + abs(y.at(i)-Y))%2){
      cout << "No" << endl;
      return 0;
    }
    T = t.at(i);
    X = x.at(i);
    Y = y.at(i);
  }
  cout << "Yes" << endl;
}
      

Measured memory_bytes: 4212
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define DEBUG 1
#define ll         long long
#define REP(i, n) for (long long i = 0; i < (n); i++) 
static const ll INF = 1000000000000000000LL;
static const int MOD = 1000000007;


int N;
string s;

bool findNum(string num)
{
    int t = 0;
    for(int i = 0; i < N; ++i)
    {
        if(t == 3)break;
        if(s[i] == num[t])++t;
    }
    return t == 3;
}

string getNum(int i)
{
    //string numList = "0123456789";
    string  res = "";
    res += to_string(i / 100);
    res += to_string((i % 100) / 10);
    res += to_string(i % 10);

    return res;

}

int main(){
    //その暗証番号が使用できるか


    cin >> N;
    cin >> s;
    int res = 0;

    for(int i = 0; i < 1000; ++i)
    {
        string num = getNum(i);
        if(findNum(num))++res;
    }


    cout << res << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;
int MOD = 1e9 + 7;

int w, a, b;
int main() {
	cin >> w >> a >> b;
	if (a >= b)swap(a, b);
	cout << max(0, b - a - w) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import combinations_with_replacement as comb

def get_nums(n, pos):
    N = [1 for _ in range(n)]
    a = sum(N[:pos[0]])
    b = sum(N[pos[0]:pos[1]])
    c = sum(N[pos[1]:pos[2]])
    d = sum(N[pos[2]:])
    if a > 9 or b > 9 or c > 9 or d > 9:
        return None
    return (a,b,c,d)

def run():
    for _n in sys.stdin:
        n = int(_n)
        probs = [get_nums(n, p) for p in comb(range(n+1), 3)]
        probs = [p for p in probs if p != None]
        print(len(probs))

if __name__ == '__main__':
    run()




Measured memory_bytes: 5872
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 3; i++){
            char s = sc.next().charAt(0);
            int diff = 'a' - 'A';   //diff == 32; ASCIIコードで大文字小文字を変換
            System.out.print((char)(s - diff));
        }
    }
}


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

const long long mod = 1000000007;

long long powmod(long long x, long long y) {
        long long res = 1;
        for (long long i = 0; i < y; i++) {
            res = res * x % mod;
        }
        return res;
    }

int main() {
    int n;
    cin >> n;
    long long ans;
    ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans %= mod;
    ans = (ans + mod)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<map>
#define ll long long
using namespace std;
const int Mod=1e9+7;
map<ll,ll> dp;
ll dfs(ll x){
    if(dp[x])return dp[x];
    return dp[x]=(dfs(x>>1)+dfs(x-1>>1)+dfs(x-2>>1))%Mod;
}
int main(){
    ll n;
    scanf("%lld",&n);
    dp[0]=1;
    dp[1]=2;
    ll res=dfs(n)%Mod;
    printf("%lld\n",res);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        long sum = 0;
        long [] x = new long[m];
        for (int i = 0 ;i < m; ++i) {
            x[i] = scanner.nextLong();
        }
        if (n >= m) {
            System.out.println(0);
            return;
        }
        Arrays.sort(x);
        sum = x[m - 1] - x[0];
        PriorityQueue<Long> diff = new PriorityQueue<>(Collections.reverseOrder());
        for (int i = 1; i < m; ++i) {
            long currentDiff = x[i] - x[i - 1];
            diff.add(currentDiff);
        }
        for (int i = 0; i < n - 1; ++i) {
            long currentDiff = diff.poll();
            sum -= currentDiff;
        }
        System.out.println(sum);


    }

}


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

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
int n;
string s,t;
cin>>n>>s>>t;
rep(i,0,n-1)
{
	ol(s[i]);ol(t[i]);
}
return 0;
}



Measured memory_bytes: 256