akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------
pub fn gcd(x: usize, y: usize) -> usize {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

fn main() {
    let (N, M) = read!(usize, usize);
    let S = rl().chars().vec();
    let T = rl().chars().vec();

    let g = gcd(N, M);
    let l = N / g * M;
    let g = l;

    let mut u = BTreeMap::new();
    for i in 0..N {
        u.insert(i * g / N, S[i]);
    }

    let mut ok = true;
    for i in 0..M {
        let j = i * g / M;
        ok = ok && (!u.contains_key(&j) || u[&j] == T[i]);
    }

    println!("{}", if ok { g as isize } else { -1 })
}


Measured memory_bytes: 6396
mod=1000000007
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

xc=0
for i in range(1,n):
    a=x[i]-x[i-1]
    l=min(i,n-i)
    #xc+=a*(l*n-((l*l+l)//2))
    xc+=a*(l*(n-l))
    xc%=mod

yc=0
for i in range(1,m):
    a=y[i]-y[i-1]
    l=min(i,m-i)
    #yc+=a*(l*m-((l*l+l)//2))
    yc+=a*(l*(m-l))
    yc%=mod
print((xc*yc)%mod)


Measured memory_bytes: 19580
"""
python3 a.py < input.txt
"""
import math
import itertools as it
import heapq

N=int(input())
S=input()
K=int(input())

sk=S[K-1]
O=[]
for i in range(0,N):
    if S[i] == sk:
        O.append(S[i])
    else:
        O.append("*")

print("".join(O))


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

int main(){
    int n;
    cin >> n;
    
    int a[n];
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    for(int i = (n-1); i >= 0; i--){
        cout << a[i];
        if(i > 0){
            cout << " ";
        }
    }
    cout << endl;
}



Measured memory_bytes: 3092
#include <stdio.h>

#define NUM 1000

int main(void)
{
	int h[NUM];
	int w[NUM];
	int i, j;
	int s;

	i = 0;
	s = 0;

	while (1){
		scanf("%d %d", &h[i], &w[i]);
		if (h[i] == 0 && w[i] == 0)break;
		i++;
	}

	while (h[s] != 0 && w[s] != 0){
		for (i = 0; i < h[s]; i++){	//???
			for (j = 0; j < w[s]; j++){	//?¨?
				if (i == 0 || i==h[s]-1 || j == 0 || j==w[s]-1)
					printf("#");
				else printf(".");
			}
			printf("\n");
		}
		s++;
		printf("\n");
	}

	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
char a[300];
int main() {
 int N;
 string S,T;
 cin>>N>>S>>T;
 for(int i=0;i<N;i++){
    cout<<S[i]<<T[i];
 }
 cout<<endl;
 return 0;}

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

int main() {
    int64_t N;
    std::cin >> N;

    int64_t ans = 1;
    int64_t A[N];

    for (int64_t i = 0; i < N; ++i) {
        std::cin >> A[i];
        if (A[i] == 0) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    for (int64_t i = 0; i < N; ++i) {
        if (ans > (1000000000000000000 / A[i])) {
            std::cout << -1 << std::endl;
            return 0;
        }        

        ans *= A[i];
    }

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


Measured memory_bytes: 4372
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int x;
    cin>>x;
    if(x)
    cout<<0;
    else
    cout<<1;
}

Measured memory_bytes: 3652
/*

    creator : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define INF 99999999
#define ll long long
#define PII pair<int,int>

int main()
{
    double x,t,ans;

    cin>>x>>t;

    printf("%.10lf\n",x/t);

  //  main();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int main(){
    int n; cin>>n;
    vi a(n);
    rep(0,i,n) cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int alice = 0;
    int bob = 0;
    rep(0,i,n){
        if(i%2==0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }

    cout << alice-bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    int a,b,c,d;
    //char a,b,c;
    int i=0,sum=0;
    //char a,b='.';
    cin>>a>>b;
    cout<<a-b+1;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int ans = 0;

        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(i % 2 == 0 && a % 2 == 1){
                ans++;
            }
        }

        System.out.print(ans);

    }
}


Measured memory_bytes: 35840
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int ans = n;
    for(int i = 1;2*i < n + 1;i++){
        int a = i;
        int b = n - i;
        int sum= 0;
        for(int j = 1;j < n*10;j = j * 10){
            sum += (a/j - a/j/10*10) + (b/j - b/j/10*10);
        }
        ans = min(ans,sum);
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
	double a, b, c, d, e, f, x, y;
	while (cin >> a >> b >> c >> d >> e >> f) {
		x = (c * e - b * f) / (a * e - b * d);
		y = (c - a * x) / b;
		if (x == -0) x = 0;
		if (y == -0) y = 0;
		printf("%.3lf %.3lf\n", x, y);
	}
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort((c).begin(),(c).end())
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;

LL H, W;
VS S;

VVI visited;
LL A, B;   // num of # and ., resp. in a single dfs trace

vector<PII> steps;


void dfs(LL i, LL j) {
	if (S[i][j] == '#') {
		A++;
	} else {
		B++;
	}

	EACH(x, steps) {
		LL ii = i + x.first;
		LL jj = j + x.second;
		if (ii < 0 || ii >= H || jj < 0 || jj >= W) {
			continue;
		}
		
		if (S[i][j] == S[ii][jj]) {
			continue;
		}
		
		if (visited[ii][jj] == 1) {
			continue;
		}
		visited[ii][jj] = 1;
		
		dfs(ii, jj);
	}
}


int main() {
	cin >> H >> W;
	S.resize(H);
	REP(i, H) {
		cin >> S[i];
	}

	visited.resize(H);
	REP(i, H) {
		visited[i].resize(W);
		REP(j, W) {
			visited[i][j] = 0;
		}
	}

	steps.PB(MP(-1, 0));
	steps.PB(MP(1, 0));
	steps.PB(MP(0, -1));
	steps.PB(MP(0, 1));

	LL ans = 0;
	REP(i, H) {
		REP(j, W) {
			if (visited[i][j] == 0) {
				visited[i][j] = 1;
				dfs(i, j);
			}
			ans += A * B;
			A = 0;
			B = 0;
		}
	}

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


Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
    string s;
    int cnt,n,i,j,k,t,ans;
    while(cin>>n>>k)
    {
       int  b[200005]={0};
        set<int>st;
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            st.insert(a[i]);
        }
        int xx=st.size();
        int dif=xx-k;
        if(st.size()<=k)
        {
            cout<<0<<endl;
            continue;
        }
        else
        {
            for(i=1;i<=n;i++)
            {
                b[a[i]]++;
            }
        }
        sort(b+1,b+n+1);
        //for(i=1;i<=n;i++)cout<<b[i];
        int ans=0;
       int  i=1;
        while(b[i]==0)i++;
        for(int l=i;l<i+dif;l++)
        {

            ans+=b[l];
        }
        cout<<ans<<endl;


    }


    return 0;
}


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

int main(){
int n;
cin >> n;
long long a[n+1];

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

long long ans = 0;

for(int i=0;i<n;i++){
  if(i==0) continue;
  else{
    if(a[i]-a[i-1] <0) {
      ans  = ans + (a[i-1] - a[i]);
      a[i] = a[i-1];
    }
  }
}

cout << ans << endl;


}


Measured memory_bytes: 5068
#import heapq
from collections import deque
h,w,k = list(map(int, input().split()))
x1,y1,x2,y2 = list(map(int, input().split()))
x1,y1,x2,y2 = x1-1,y1-1,x2-1,y2-1
dp = [[-1]*w for _ in range(h)]
#que = []
que = deque()
c = [input() for _ in range(h)]

dp[x1][y1] = 0
#heapq.heappush(que, (dp[x1][y1], [x1,y1]))
que.append((x1,y1))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
while que:
  x,y=que.popleft()
  if x==x2 and y==y2:
    exit(print(dp[x][y]))
  for dx,dy in [[1,0],[-1,0],[0,-1],[0,1]]:
    for i in range(1,k+1):
      xx=x+dx*i
      yy=y+dy*i
      if not(0<=xx<h and 0<=yy<w) or c[xx][yy]=="@":break
      if 0<=dp[xx][yy]<=dp[x][y]:break
      if dp[xx][yy]==-1:que.append((xx,yy))
      dp[xx][yy]=dp[x][y]+1
print(-1)


Measured memory_bytes: 36568
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))


int main(){ FastIO;

int h,n;cin>>h>>n;
int s=0;for(int i=0;i<n;i++)
{
	int a;cin>>a;s+=a;
}
if(s>=h) cout<<"Yes";
else cout<<"No";


return 0;
}

Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  A = readint()

  kabu = 0
  kane = 1000

  for i in 1:N-1
    if A[i] < A[i+1]
      a = kane÷A[i]
      kabu += a
      kane -= (a*A[i])
    elseif A[i] > A[i+1]
      kane += kabu*A[i]
      kabu = 0
    end
  end
  
  kane += kabu*A[N]
  println(kane)

end

main()

Measured memory_bytes: 186924
#ABC150-A
if False:
    K,X=map(int,input().split())
    print('Yes' if 500*K>=X else 'No')

#ABC150-B
if False:
    N=int(input())
    S=input()
    print(S.count('ABC'))

#ABC150-C
if False:
    import itertools
    N=int(input())
    dic=list(itertools.permutations(list(range(1,N+1))))
    # print(dic)
    P=tuple(int(i) for i in input().split())
    Q=tuple(int(i) for i in input().split())

    print(abs(dic.index(P)-dic.index(Q)))

#HPC2020-B
if True:
    A,B,M=map(int,input().split())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    M=[tuple(int(j) for j in input().split()) for i in range(M)]
    ans=min(a)+min(b)
    for x,y,c in M:
        ans=min(ans,a[x-1]+b[y-1]-c)
    print(ans)

Measured memory_bytes: 28964
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
ll read()
{
    ll tmp=0; char f=1,c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
    while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
    return tmp*f;
}
using namespace std;
int main()
{
    int n=read(),m=read(),tmp=1<<m;
    printf("%d\n",tmp*(m*1900+(n-m)*100));
    return 0;
}

Measured memory_bytes: 128
def main():
    def f(a, b):
        sa = str(a)
        sb = str(b)
        return max(len(sa), len(sb))
    N = int(input())
    ans = 10**12
    for i in range(1, N+1):
        if N < i*i:
            break
        if N % i != 0:
            continue
        b = N//i
        ans = min(ans, f(i, b))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65120
#include"bits/stdc++.h"
using namespace std;
int main() {
	while (1) {
		int n, n2[100];
		char str[1000];
		memset(n2, 0, sizeof(n2));
		cin >> n;
		if (n == 0)return 0;
		cin >> str;
		int j = 0, ba = 0;
		for (int i = 0; i < 100; i++) {//M??????,S?????????,L????§?
			if (j > n - 1)j = 0;
			if (str[i] == 'M') {
				n2[j]++;
			}
			else if (str[i] == 'S') {
				ba += n2[j] + 1;
				n2[j] = 0;
			}
			else if (str[i] == 'L') {
				n2[j] += ba + 1;
				ba = 0;
			}
			//if (ba == 0)break;
			j++;
		}
		sort(n2, n2 + n);
		for (int i = 0; i < n; i++) {
			cout << n2[i] << " ";
		}
		cout << ba << endl;
	}
}

Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<utility>
#include<set>
#include<stack>
#include<string>
#include<vector>
#define ll long long
#define llu unsigned long long
using namespace std;
const int maxn = 22000010;
int main(void)
{
    int a,b,c,pa;
    scanf("%d%d%d",&a,&b,&c);
    if(a<b) swap(a,b);
    if(c%a) pa = c/a + 1;
    else    pa = c/a;
    if(pa<=b)    printf("%d\n",pa);
    else{
        int m = c - a*pa;
        int pb = 0;
        while(m>0){
            m = m - (b-pa);
            pb++;
        }
        printf("%d\n",pa+pb);
    }
    return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    map<string,int> m;
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n"<<"WA x "<<m["WA"]<<'\n'<<"TLE x "<<m["TLE"]<<"\n"<<"RE x "<<m["RE"];
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int n, m;
  cin >> n >> m;
  vll c(m, -1);
  for(int i = 0; i < m; i++){
    cin >> c.at(i);
  }
  vvll dp(25, vll(55000, INF));
  dp.at(0).at(0) = 0;
  

  for(int i = 0; i < m; i++){
    for(int j = 0; j <= n; j++){
      chmin(dp.at(i+1).at(j), dp.at(i).at(j));
      if(j >= c.at(i)) chmin(dp.at(i+1).at(j), dp.at(i+1).at(j-c.at(i))+1);
    }
  }
  cout << dp.at(m).at(n) << endl;
}


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    string s;
    cin >>s;
    if (s[0]=='9'||s[1]=='9') cout <<"Yes"<<endl;
    else cout <<"No" <<endl;
}

int main(){
/*/Debug by file input
    ifstream fin("input");
    cin.rdbuf(fin.rdbuf());// */
    solve();
    return 0;
}


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


char* reverse(char *A){
	char* save = A;
	while (*A) {
		++A;
	}
	char* p = save;
	--A;
	for (; p < A; --A) {
		char t = *A;
		*A = *p;
		*p = t;
		++p;
	}
	return save;
}


int main() {
	char A[100];
	cin >> A;
	cout << reverse(A) << endl;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define sort(v) sort(v.begin(), v.end())
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}

vector<ll> vec[55];
ll dep[55], par[55], path[55];

void dfs(ll u, ll p){ //cout << u << " " << p << endl;
    dep[u] = dep[p]+1;
    par[u] = p;
    for(auto x: vec[u]){
        if(p!=x){
            dfs(x, u);
        }
    }
}

ll lca(ll x,ll y){
    ll mask = 0; // masking the path from x to lca(x, y) and y to lca(x, y)
    if(dep[x] > dep[y]) swap(x, y);
    while(dep[y] > dep[x]){
        mask |= (1ll << y); y = par[y];
    }
    while(x != y){
        mask |= (1ll << y); y = par[y];
        mask |= (1ll << x); x = par[x];
    }
    return mask;
}

void solve(){
    ll n;
    cin >> n;

    rep(i,n-1)
    {
        ll x, y; cin >> x >> y; edge(vec, x, y);
    }
    dfs(1, 0);
    ll m;
    cin >> m;
    rep(i, m)
    {
        ll x, y; cin >> x >> y;
        path[i] = lca(x, y); // storing the ith mask 
    }
    ll mx = (1ll<< m), ans = 0;
    rep(i, mx)
    {
        ll num = 0, cnt = 0;
        rep(j, m)
        {
            if(i & (1ll<<j)){
                cnt++;
                num |= path[j];
            }
        }
        ans += (1ll << (n-1- __builtin_popcountll(num)))*(cnt%2 ?  -1ll: 1ll);
    }
    cout << ans;

}

int main()
{
    fast();
    ll t = 1;//cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
ll n,ans=0;
void dfs(ll x,int a,int b,int c){
    if(x>n)
        return;
    if(a&&b&&c)ans++;
    dfs(x*10+7,1,b,c);
    dfs(x*10+5,a,1,c);
    dfs(x*10+3,a,b,1);
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    cin>>n;
    dfs(0,0,0,0);
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

ll PowMod(ll N,ll P,ll M){
    ll ans = 1;
    while(P >= 1){
        if(P % 2)ans = ans * N % M;
        N = N*N %M;
        P /= 2;
    }
    ans %= M;
    return ans;
}
void dfs(ll now,ll max_n,ll N,string ans){
    if(N == now){
        cout<<ans<<endl;
        return;
    }
    else{
        rep(i,0,max_n){
            dfs(now+1,max_n,N,ans + char('a'+i));
        }
        dfs(now+1,max_n+1,N,ans + char('a'+max_n));
    }
}

int main(){
    ll N;
    cin>>N;
    string a="";
    dfs(0,0,N,a);
    return 0;
}

Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys


def solve(N: int, v: "List[int]"):
    v.sort()

    result = (v[0] + v[0 + 1]) / 2
    for i in range(2, N):
        result = (result + v[i]) / 2
    print(result)
    return


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
    v = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, v)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if(x == 1 && y == 1) ans += 400000;
    if(x == 1) ans += 300000;
    else if(x == 2) ans += 200000;
    else if(x == 3) ans += 100000;
    if(y == 1) ans += 300000;
    else if(y == 2) ans += 200000;
    else if(y == 3) ans += 100000;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];ll ans[h+1][w+1];
    memset(ans,0,sizeof(ans));
    for(int i=0;i<h;i++)
        a[i][0] = '#';
    for(int i=0;i<w;i++)
        a[0][i] = '#';
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>a[i][j];
    ans[1][1]=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(a[i][j]=='.')
            {
                if(a[i-1][j]=='.')
                {
                    ans[i][j]+=(ans[i-1][j]);
                    ans[i][j] = ans[i][j]%mod;
                }
                if(a[i][j-1]=='.')
                {
                    ans[i][j] +=ans[i][j-1];
                    ans[i][j] = ans[i][j]%mod;
                }

            }
        }
    }
    cout<<ans[h][w]<<endl;
    
    

}
int main() 
{ 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    solve();
    
        
    
    
    return 0; 
} 

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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


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

  // 先頭に9が現れた個数がcntに入る
  int cnt = 0;
  while (S[cnt] == '9' && cnt < S.size()) cnt++;
  // 後方に9が現れなくなるまでのidxがcntに入る
  int idx = S.size() - 1;
  while (S[idx] == '9' && idx >= 0) idx--;

  if (S.size() == 1) { cout << S << endl; return 0; }
  if (idx == -1) { cout << 9*S.size() << endl; return 0; }

  if (cnt == 0) {
    if (idx == 0) cout << (S[0]-'0') + 9*(S.size()-1) << endl;
    else cout << (S[0]-'0'-1) + 9*(S.size()-1) << endl;
    return 0;
  }

  cout << 9*cnt -1 + 9*(S.size()-cnt) << endl;;


  return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n,k = map(int,input().split())
a = [int(i)-1 for i in input().split()]
edg = [[] for i in range(n)]
for i in range(1,n):
  edg[a[i]].append(i)
ans = [0] * n
ans[0] = a[0] != 0
def dfs(now):
  res = 0
  for e in edg[now]:
    res = max(res, dfs(e)+1)
  if res == k - 1 and a[now] != 0:
    ans[now] = 1
    res = -1
  return res
      
dfs(0)
print(sum(ans))


Measured memory_bytes: 207976
#include<bits/stdc++.h>
#define N 100100
using namespace std;
struct node{int x,w;}a[N+N];
bool in[N+N];
bool cmp(node a,node b){return a.x<b.x;}
int n,t,va[N],vb[N],pd[N];
long long mn=1e18,sm;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		int u,v;scanf("%d %d",&u,&v);
		va[i]=u;vb[i]=v;pd[i]=u>v;
		a[++t]=(node){u,i+i};
		a[++t]=(node){v,i+i+1};
	}
	sort(a+1,a+t+1,cmp);
	for(int i=1;i<=n;++i)sm+=a[i].x,in[a[i].w]=1;
	for(int i=1;i<=n;++i)if(in[i+i]&&in[i+i+1]){
		printf("%lld",sm);return 0;
	}
	for(int i=1;i<=n;++i){
		long long tmp=sm+va[i]+vb[i];
		tmp-=in[i+i]?va[i]:vb[i];
		tmp-=a[n].w/2==i?a[n-1].x:a[n].x;
		mn=min(mn,tmp);
	}
	sm=0;
	for(int i=1;i<=n;++i)sm+=va[i];
	mn=min(mn,sm);
	sm=0;
	for(int i=1;i<=n;++i)sm+=vb[i];
	mn=min(mn,sm);
	printf("%lld",mn);
}

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

vector<int>ans[100005];

void filling(int idx, int jdx, int n, int k){
    if(n == 3 && k == 3){
        ans[idx].push_back(jdx+1);
        ans[idx].push_back(jdx+2);
        ans[idx+1].push_back(jdx+1);
        ans[idx+1].push_back(jdx+3);
        ans[idx+2].push_back(jdx+2);
        ans[idx+2].push_back(jdx+3);
        return ;
    }
    else{
        rep(i, k-1){
            ans[idx].push_back(i+jdx+1);
        }
        rep(i, k-1){
            ans[idx+i+1].push_back(i+jdx+1);
        }
        filling(idx+1, jdx+k-1, n-k+1, k-1);
    }
}
 
int main(void){
    int n;
    cin>>n;
    int now = 3;
    int i = 3;
    while(now<n){
        now += i;
        i++;
    }
    if(now == n) {
        cout<<"Yes"<<endl;
        filling(0, 0, n, i);
        cout<<i<<endl;
        rep(idx, i){
            cout<<ans[idx].size()<<" ";
            rep(j, ans[idx].size()) cout<<ans[idx][j]<<" ";
            cout<<endl;
        }
    }
    else{
        if(n == 1){
            cout<<"Yes"<<endl;
            cout<<2<<endl;
            rep(i, 2) cout<<1<<" "<<1<<endl;
        }
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 4736
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cmath>
#include <tuple>
using namespace std;
#define fio ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N,M,K;
int a,b,c;
int inp[300005];
int main(){
	scanf("%d %d %d",&a,&b,&c);
	printf("%d\n",min(c,b/a));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll a, b, h[100010];

int main() {
    cin >> n >> a >> b;
    rep(i, n) cin >> h[i];

    ll diff = a - b;
    ll ng = -1, ok = 2e9;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;

        ll sum = 0;
        rep(i, n) {
            ll rem = max(h[i] - b * mid, 0ll);
            sum += (rem + diff - 1) / diff;
        }

        if (sum <= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll b1 = 1009, b2 = 10007;

ll Pow(ll a, ll b) {
	ll res = 1; a %= mod;
	while (b) {
		if (b & 1) {
			res = (res * a) % mod;
		}
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}

class RollingHash {
	int N;
	string s;
	vector<ll> r1, r2, h1, h2, rh1, rh2;
public:
	RollingHash(const string& s_)
		: N((int)s_.size()), s(s_), r1(N + 1), r2(N + 1), h1(N + 1), h2(N + 1), rh1(N + 1), rh2(N + 1) {
		r1[0] = r2[0] = 1;
		for (int i = 1; i <= N; i++) r1[i] = r1[i - 1] * b1 % mod;
		for (int i = 1; i <= N; i++) r2[i] = r2[i - 1] * b2 % mod;

		h1[0] = h2[0] = 1;
		for (int i = 1; i <= N; i++) h1[i] = (h1[i - 1] * b1 + s[i - 1]) % mod;
		for (int i = 1; i <= N; i++) h2[i] = (h2[i - 1] * b2 + s[i - 1]) % mod;
	}
	P get(int l, int r) {
		return P((h1[r + 1] - h1[l] * r1[r - l + 1] % mod + mod) % mod, (h2[r + 1] - h2[l] * r2[r - l + 1] % mod + mod) % mod);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int Q;
	string S;
	cin >> S >> Q;
	int N = S.size();
	RollingHash rh(S);
	vector<P> dis;
	for (int i = 0; i < N; i++) {
		for (int j = -25; j <= 25; j++) {
			dis.push_back(P(Pow(b1, i) * (mod + j) % mod, Pow(b2, i) * (mod + j) % mod));
		}
	}
	sort(dis.begin(), dis.end());
	for (int i = 0, l, r, t; i < Q; i++) {
		cin >> l >> r >> t; l--; r--;
		auto lrh = rh.get(l, r - t), rrh = rh.get(l + t, r);
		ll d1 = (lrh.first - rrh.first + mod) % mod, d2 = (lrh.second - rrh.second + mod) % mod;
		if (r - l + 1 > t * 2) {
			if (binary_search(dis.begin(), dis.end(), P(d1, d2))) {
				puts("Yes");
			}
			else {
				int w = r - l + 1 , fl = (r - l + 1) / t * t;
				if (w == fl && rh.get(l, l + t - 1) != rh.get(r - t + 1, r)) {
					puts("No");
					continue;
				}
				if (w != fl && (rh.get(l, l + w - fl - 1) != rh.get(r - (w - fl - 1), r) || rh.get(l + w - fl, l + t - 1) != rh.get(r - t + 1, r - (w - fl)))) {
					puts("No");
					continue;
				}
				ll lb = t - 1, ub = r - l + 1 - t;
				while (lb + 1 < ub) {
					ll c = (lb + ub) / 2;
					lrh = rh.get(l, l + c - 1), rrh = rh.get(l + t, l + t + c - 1);
					d1 = (lrh.first - rrh.first + mod) % mod, d2 = (lrh.second - rrh.second + mod) % mod;
					if (binary_search(dis.begin(), dis.end(), P(d1, d2))) {
						lb = c;
					}
					else {
						ub = c;
					}
				}
				ll tmp = lb;
				lb = t - 1, ub = r - l + 1 - t;
				while (lb + 1 < ub) {
					ll c = (lb + ub) / 2;
					lrh = rh.get(r - t - c + 1, r - t), rrh = rh.get(r - c + 1, r);
					d1 = (lrh.first - rrh.first + mod) % mod, d2 = (lrh.second - rrh.second + mod) % mod;
					if (binary_search(dis.begin(), dis.end(), P(d1, d2))) {
						lb = c;
					}
					else {
						ub = c;
					}
				}
				puts(tmp + lb == r - l || lb == r - l + 1 - t ? "Yes" : "No");
			}
		}
		else {
			puts(binary_search(dis.begin(), dis.end(), P(d1, d2)) ? "Yes" : "No");
		}
	}
	return 0;
}

Measured memory_bytes: 139108
#include <iostream>

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

int n, ans = 0;
int main() {
    cin>>n;
    int a[n] = {0};
    rep (i, n)
        cin >> a[i];
    while (true) {
        bool exist_odd = false;
        rep (i, n) {
            if (a[i]%2 != 0)
                exist_odd = true;
        }
        if (exist_odd == true) break;
        rep (i, n) {
            a[i] = a[i] / 2;
        }
        ans++;
    }
    cout << ans << endl;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> l;
	for(int i=0; i<n; i++){
		int t;
		cin >> t;
		l.pb(t);
	}

	sort(l.begin(), l.end(), greater<int>());

	ll ans = 0;
	for(int i=0; i<k; i++){
		ans += l[i];
	}

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


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;


    vector<int> numbers(n);
    int p_max = 0;
    int p_max_index = 0;
    int m_min = 0;
    int m_min_index = 0;
    rep(i, n) {
        int a;
        cin >> a;
        numbers[i] = a;
        if (a > 0) {
            if (a > p_max) {
                p_max = a;
                p_max_index = i;
            }
        } else {
            if (a < m_min) {
                m_min = a;
                m_min_index = i;
            }
        }
    }

    if (m_min + p_max < 0) {

        vector<P> ans;

        for (int i = 0; i < n; i++) {
            if (numbers[i] > 0) {
                ans.push_back(P(m_min_index, i));
                numbers[i] += m_min;
            }
        }


        for (int i = n - 2; i >= 0; i--) {
            if (numbers[i + 1] < numbers[i]) {
                ans.push_back(P(i + 1, i));
                numbers[i] += numbers[i + 1];
            }
        }

//    rep(i, n) {
//        cout << numbers[i] << endl;
//    }

        cout << endl;

        cout << ans.size() << endl;

        for (auto p : ans) {
            printf("%d %d\n", p.first + 1, p.second + 1);
        }


    } else {

        vector<P> ans;

        for (int i = 0; i < n; i++) {
            if (numbers[i] < 0) {
                ans.push_back(P(p_max_index, i));
                numbers[i] += p_max;
            }
        }


        for (int i = 1; i < n; i++) {
            if (numbers[i - 1] > numbers[i]) {
                ans.push_back(P(i - 1, i));
                numbers[i] += numbers[i - 1];
            }
        }

//    rep(i, n) {
//        cout << numbers[i] << endl;
//    }

        cout << endl;

        cout << ans.size() << endl;

        for (auto p : ans) {
            printf("%d %d\n", p.first + 1, p.second + 1);
        }

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e16;
	const ll MOD = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];

	signed main(){
		IOS;
		ll h, w, n;
		cin >> h >> w >> n;
		vec<ll> a(n + 1);
		REP(i, n)cin >> a[i + 1];
		vec<vec<ll>> col(h,vec<ll>(w));
		int use = 1;
		bool dir = 1;
		for(int i = 0;i < h;i++){
			if(a[use] == 0)use++;
			if(dir){
				for(int j = 0; j < w;j++){
					if(a[use] == 0)use++;
					col[i][j] = use;
					a[use]--;
				}
				dir = 0;
			}
			else {
				for(int j = w - 1; j >= 0;j--){
					if(a[use] == 0)use++;
					col[i][j] = use;
					a[use]--;
				}
				dir = 1;
			}
		}
		REP(i, h){
			REP(j, w){
				if(j)cout << " ";
				cout << col[i][j];
			}
			cout << endl;
		}
	}

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

using namespace std;

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N);
  vector<int> w(N);
  for (int i=0; i<N; i++) {
    cin >> w.at(i) >> v.at(i);
  }
  vector<vector<long long int>> totV;
  totV.resize(N+1);
  for(int i=0; i<=N; i++) {
    totV[i].resize(W+1);
  }

  for(int j=0; j<W; j++) {
    totV[0][j] = 0;
  }

  for (int i=1; i<=N; i++) {
    for (int j=0; j<=W; j++) {
      if (w[i-1] <= j) {
        totV[i][j] = max(totV[i-1][j-w[i-1]] + v[i-1], totV[i-1][j]);
      } else {
        totV[i][j] = totV[i-1][j];
      }
    }
  }
  cout << totV[N][W] << endl;
  return 0;
}

Measured memory_bytes: 79488
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int h, w, n, sr, sc;
	cin >> h >> w >> n >> sr >> sc;
	string s, t;
	cin >> s >> t;
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	//kill zone
	int l = 0, r = w + 1, u = 0, d = h + 1;
	bool fall = 0;
	for (int i = 0; i < n; i++)
	{
		fall |= l+1 == r || u+1 == d;
		if (t[i] == 'L') r = min(r+1, w+1);
		if (t[i] == 'R') l = max(l-1, 0);
		if (t[i] == 'U') d = min(d+1, h+1);
		if (t[i] == 'D') u = max(u-1, 0);
		if (s[i] == 'L') l = min(l+1, w+1);
		if (s[i] == 'R') r = max(r-1, 0);
		if (s[i] == 'U') u = min(u+1, h+1);
		if (s[i] == 'D') d = max(d-1, 0);
	}
	fall |= l + 1 == r || u + 1 == d;
	fall |= sr >= d || u >= sr || sc >= r || l >= sc;

	cout << (!fall ? "YES" : "NO") << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, i, j, k, t, a, b;
	priority_queue<pair<int, int>> q;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		q.push({ -b, a });
	}

	bool valid = true;
	t = 0;
	while (!q.empty()) {
		a = q.top().second;
		b = -q.top().first;
		q.pop();
		if (t + a > b) 
			valid = false;
		t += a;
		//cout << b << " " << a << " " << t << "\n";			 
	}

	if (valid) cout << "Yes\n";
	else cout << "No\n";


	return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll longinf=1LL<<60;
const int mod=1000000007;    
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
  ll n,x;cin>>n>>x;
  ll a[n+1];
  rep(i,n)cin>>a[i+1];
  ll mi[n+1];
  rep(i,n+1)mi[i]=longinf;
  ll ans=longinf;
  rep(j,n){
    ll sum=0;
    rep(i,n){
      mi[n-i]=min(a[n-i],mi[n-i-1]);
      sum+=mi[n-i];
      }
    mi[0]=mi[n];
    ans=min(ans,sum+j*x);
    }
  cout<<ans<<endl;
  return 0; 
  }
       

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const mod = 10^^9 + 7;

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(long n, long k, long mod) {
    long x = 1;
    for (int i = 0; i < k; i++) {
        x = (x * (n - i)) % mod;
    }

    long kk = 1;
    for (int i = 1; i <= k; i++) {
        kk = (kk * i) % mod;
    }
    x = (x * modPow(kk, mod - 2, mod)) % mod;
    return x;
}

long calc(long n, long a, long b) {
    long ans = modPow(2, n, mod);
    ans -= nck(n, a, mod);
    ans = (ans + mod) % mod;
    ans -= nck(n, b, mod);
    ans = (ans + mod) % mod;
    ans -= 1;
    return ans;
}

void main() {
    int n, a, b; scan(n, a, b);
    writeln(calc(n, a, b));
}


Measured memory_bytes: 256
N = int(input())
X = input().split()
X = [int(s) for s in X]
if N == 1 or len(list(set(X)))==1:
    print(0)
else:
    X = sorted(X)
    range_X = X[-1] - X [0]

    E_min = 10000000000000000000000
    for p in range(range_X):
        E = 0
        for x in X:
            E += (x-p)**2
        if E < E_min:
            E_min = E
    print(E_min)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 100005
#define ll long long
#define mod 1000000007
int f[205][N],n,a[205],X,ans;
int main()
{
	scanf("%d%d",&n,&X);f[0][X]=1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=0,now=0;j<=X;j++)if(f[i-1][j])
		{
			while(now<n&&a[now+1]<=j)now++;
			if(n-now-i+1>0)f[i][j]=(f[i][j]+(ll)(n-now-i+1)*f[i-1][j])%mod;
			for(int k=1;k<=now;k++)(f[i][j%a[k]]+=f[i-1][j])%=mod;
		}
	for(int i=0;i<=X;i++){ans=(ans+(ll)f[n][i]*i)%mod;}
	printf("%d\n",ans);
}


Measured memory_bytes: 78848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  set<int> s;
  rep(i,3) {
    int a;
    cin >> a;
    s.insert(a);
  }
  
  int cnt = 0;
  for(auto i=s.begin(); i!=s.end(); ++i) {
    cnt++;
  }
  
  cout << cnt << endl;
  

}

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

int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main() {
  int number[3];
  scanf("%d %d %d", &number[0], &number[1], &number[2]);
  qsort(number, 3, sizeof(int), desc);
  printf("%d\n", number[0] * 10 + number[1] + number[2]);
  return 0;
}


Measured memory_bytes: 128
*d=0;*c=0,2,5,5,4,5,6,3,7,6;eval"N,_,*A="+`dd`.split*?,;1.upto(N){|i|q=A.map{|x|i>=c[x]&&d[t=i-c[x]]?d[t]*10+x:p}.compact;d.<<q[0]&&q.max};p d[N]

Measured memory_bytes: 36228
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :x, :y, :s ,:t

  def initialize
    @n = gets.to_s.to_i
  end

  def solve
    1.upto(9) do |i|
      1.upto(9) do |j|
        return true if i * j == n
      end
    end
    false
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14384