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


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


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


use std::cmp;
use std::collections::HashMap;



fn main() {

    input! { 
       n: usize,
       s : String,
    }

    let mut s= s;
    let mut ans = vec![];

    let mut index = 0;
    let mut cnt = 0;
    let mut braket = 0;

    let tmp = s.chars();
  
    for item in tmp{
        if(item == '('){
            cnt+=1;
        }else{
            cnt-=1;
            if(cnt<0){
               braket = cmp::max(braket , -1*cnt)

            }
        }
    }


    for i in 0..braket{
        ans.push("(");
    }

    ans.push(&s);
    
    let mut s = ans.connect("");




    cnt = 0;
    braket = 0;

    let mut tmp = s.chars();
    
    for item in tmp{
        if(item == '('){
            cnt+=1;
        }else{
            cnt-=1;            
        }
    }
    braket = cnt;
  
  

    for i in 0..braket{
        ans.push(")");
    }



    
    
    println!("{}",ans.connect(""));


}


Measured memory_bytes: 4352
import itertools
cnt=0
z=[]
for n in range(5):
    z.append(int(input()))
k = int(input())
c= list(itertools.combinations(z,2))
for i in c:
    temp = list(i)
    if temp[1]-temp[0]<=k:
        cnt+=1
if cnt==10:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        int[] input = ReadInts();
        int ans = 0;
        int maxH = 0;
        for(int i=0;i<N;i++)
        {
            if(input[i]>=maxH)
            {
                ans++;
                maxH = input[i];
            }
        }
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N ,i;
	scanf("%d", &N);
	char *S = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s", S);
	int *L = (int *)malloc(sizeof(int) * N);
	int *R = (int *)malloc(sizeof(int) * N);
	L[0] = (S[0] == 'E' ? 0 : 1);
	for(i = 1; i < N; i++){
		L[i] = L[i - 1] + (S[i] == 'E' ? 0 : 1);
	}
	R[N - 1] = (S[N - 1] == 'W' ? 0 : 1);
	for(i = N - 2; i >= 0; i--){
		R[i] = R[i + 1] + (S[i] == 'W' ? 0 : 1);
	}
	int ans = min(L[N - 2], R[1]);
	for(i = 1; i < N - 1; i++){
		ans = min(ans, L[i - 1] + R[i + 1]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2816
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
using namespace std;
int main(void){
    // Your code here!
   int a, b;
   cin >> a >> b;
   cout << max(a + b, max(a - b , a * b)) << endl;
    
}


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

int main(){
    int N;
    cin >> N;
    int l[N], r[N];
    int sums = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> l[i] >> r[i];        
        sums += (r[i] - l[i]) + 1;
    }
    cout << sums << endl;
}

Measured memory_bytes: 256
class SegT():
    # originは初期データがあれば渡す
    def __init__(self, size, origin=None):
        self.size = 1
        while self.size < size: self.size *= 2
        self._data_init()
        if origin:
            for i in range(size):
                self.data[i+self.size-1] = origin[i]
            for i in range(self.size-2,-1,-1):
                self.data[i] = self._calc(self.data[i*2+1], self.data[i*2+2])

    def _data_init(self):
        self.e = 0 # 単位元
        self.data = [self.e for _ in range(self.size * 2 - 1)]

    def _calc(self, a, b):
        # ここは独自実装する
        return a + b

    def update(self, i, x):
        i += (self.size - 1)
        self.data[i] += x # ここも書き直す
        while i > 0:
            i = (i - 1) // 2
            self.data[i] = self._calc(self.data[i*2+1], self.data[i*2+2])
        
    def get(self, a, b, node=0, l=0, r=-1):
        if r < 0: r = self.size
        if r <= a or b <= l: return self.e
        if a <= l and r <= b: return self.data[node]
        vl = self.get(a, b, node*2+1, l, (l+r)//2)
        vr = self.get(a, b, node*2+2, (l+r)//2, r)
        return self._calc(vl, vr)

N, Q = map(int, input().split())
origin = [pow(2, 31) - 1 for i in range(N)]
segt = SegT(N)

for i in range(Q):
    t, l, r = input().split()
    if t == "0":
        segt.update(int(l)-1, int(r))
    else:
        x = segt.get(int(l)-1,int(r))
        print(x)



Measured memory_bytes: 14972
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 

// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

# define ll long long int
#define M 1000000007
#define pb push_back
#define ss second
#define ff first
#define inf 1000000000000000


 

													//nestedcode



int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,i,j,ans,fans = 1005;string s,t,d;
    cin>>s>>t;
    n = t.length();
    for(i=0;i<s.length();i++){
    	if(i+n-1 >= s.length())	break;
    	d = s.substr(i,n);
    	ans = 0;
		for(j=0;j<n;j++){
    		if(t[j] != d[j])	ans++;
		}
		fans = min(fans,ans);
	}
	cout<<fans<<endl;
}


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

int main() {
  int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
  if(a==0) cout << 1;
  if(b==0) cout <<2;
  if(c==0) cout << 3;
  if(d==0) cout << 4;
  if(e==0) cout << 5;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,mod=998244353LL,dp[3009][3009];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b>>c>>d;
	dp[a][b]=1;
	for(i=a; i<=c; i++){
		for(j=b; j<=d; j++){
		    if(i==a&&j==b) continue;
		    if(i>a&&j>b){
			dp[i][j]=dp[i-1][j]*j+dp[i][j-1]*i;
			zx=dp[i-1][j-1]*(i-1)*(j-1);zx%=mod;
			dp[i][j]=(dp[i][j]-zx+mod)%mod;
		    }else{
		        dp[i][j]=dp[i-1][j]*j+dp[i][j-1]*i;
		        dp[i][j]%=mod;
		    }
		}
	}
	cout<<dp[c][d];
	return 0;
}

Measured memory_bytes: 74036
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;cin>>a>>b;
    if(b.find(a)==string::npos||b==a||b.length()-1!=a.length())
        cout<<"No";
    else
    {
        auto k=b.find(a);
        if((int)k==0)
        cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

void printV(vector<int> &v);
void printVV(vector<vector<int>> &vv);


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

  int ans = 0;
  for(int i = 1; i <= N; i++) {
    int sum = 0;
    int num = i;
    for(int j = 0; j < 5; j++) {
      sum += num % 10;
      num /= 10;
      if(num == 0) break;
    }

    if(A <= sum && sum <= B) ans += i;
  }
  cout << ans << endl;

  return 0;
}


// ベクターの中身を全部出力
void printV(vector<int> &v) {
  cout << "  [ ";
  for(int i = 0; i < (int)v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << "]" << endl;
}

void printVV(vector<vector<int>> &vv) {
  cout << "{" << endl;
  for(int i = 0; i < (int)vv.size(); i++) {
    cout << "  [ ";
    for(int j = 0; j < (int)vv.at(i).size(); j++) {
      cout << vv.at(i).at(j) << " ";
    }
    cout << "]," << endl;
  }
  cout << "}" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N ;
  cout << (N*(N+1))/2 << endl;

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int fx4[] = {1 , -1 , 0 , 0};
int fy4[] = {0 , 0 , 1 , -1};
int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis
int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis
int fx8[]= {1,1,1,0,0,-1,-1,-1};
int fy8[]= {0,1,-1,1,-1,0,1,-1};
#define ll long long int
#define pii pair<int,int>
#define llu unsigned long long
#define inf 1<<28
#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define all(r)(r).begin(),(r).end()
/*
bool status[mx];
void sieve(){
   long long int  i,j;
    for(i=2;i<=mx;i++)
    {
        status[i]=0;
    }
    for( i=2;i<=sqrt(mx);i++){
        if(status[i]==0)
        {
            for(j=i*i;j<=mx;j+=i){
                status[j]=1;
            }
        }
    }
}*/
ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;

    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}
#define dd double
#define sc scanf
#define pr printf
#define VI vector<int>
#define VS vector<string>
#define VC vector<char>
#define VLL vector<long long int>
#define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout);
#define p_b push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define F(i,a,b) for(i=a;i<=b;i++)
#define sc1(a) scanf("%d",&a)
#define scL1(a) scanf("%lld",&a)
#define scL2(a,b) scanf("%lld%lld",&a,&b)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define sqr(x)           (x)*(x)
#define TEST int test,te=0;cin>>test;
#define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2
#define Mx 100005
#define mx 10005

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);///Beware of use it, if u use it dont use scanf or printf
    ll a,b;
    cin>>a>>b;
    cout<<(a*b)/__gcd(a,b)<<endl;
	
}


Measured memory_bytes: 256
def enough(T, N, A, B, H):
	d = A - B
	cnt = 0
	for i in H:
		cnt += max(0, (i - T * B - 1)//d + 1)
	if cnt <= T:
		return 1
	else:
		return 0


N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
M = (max(H) - 1)//B + 1
hi_z, hi_p = M, 1
low_z, low_p = 0, 0
t = M
while hi_z - low_z > 1:
	mid_z = (hi_z + low_z)//2
	mid_p = enough(mid_z, N, A, B, H)
	if mid_p == 1:
		hi_z, hi_p = mid_z, mid_p
	else:
		low_z, low_p = mid_z, mid_p
print(hi_z)

Measured memory_bytes: 7076
N = int(input())
S = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            ii = S.find(str(i))
            if ii >= 0:
                ij = S[ii+1:].find(str(j))
                if ij >= 0:
                    ik = S[ii+ij+2:].find(str(k))
                    if ik >= 0:
                        # print(i, j, k, ii, ij, ik)
                        ans += 1
print(ans)


Measured memory_bytes: 40644
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		vvi field(h+1,vi(w));
		rep(i,h) rep(j,w)
			cin>>field[i][j];
		
		vvi dp(h+1,vi(w));
		rep(i,w)
			if(field[0][i]==0)
				dp[0][i]=1;
		rep(i,h-1) rep(j,w){
			if(field[i][j]==1)
				dp[i][j]=0;
			else if(field[i][j]==2){
				if(field[i+2][j]!=1)
					dp[i+2][j]+=dp[i][j];
			}
			else{
				if(field[i+1][j]==2)
					dp[i+1][j]+=dp[i][j];
				for(int k=-1;k<=1;k++)
					if(0<=j+k && j+k<w && field[i+1][j+k]==0)
						dp[i+1][j+k]+=dp[i][j];
			}
		}
		ll res=0;
		repi(i,h-1,h+1) rep(j,w)
			if(field[i][j]!='1')
				res+=dp[i][j];
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
def insert(z):
    global root
    y = NIL
    x = root
    #print(x)
    while x != NIL:
        y = x
        if z < x:
            x = TL[x]
        else:
            x = TR[x]
    TP[z] = y

    if y == NIL:
        root = z
    elif z < y:
        TL[y] = z
    else:
        TR[y] = z


def inorder(u):
    if u == NIL:
        return
    inorder(TL[u])
    print(' ', end='')
    print(u, end='')
    inorder(TR[u])


def preorder(v):
    if v == NIL:
        return
    print(' ', end='')
    print(v, end='')
    preorder(TL[v])
    preorder(TR[v])


TR = {}
TL = {}
TP = {}
NIL = None
root = NIL
m = int(input())
data = [input().split() for _ in range(m)]
#print(data)
for i in data:
    if i[0][0] == 'i':
        TR[int(i[1])] = TL[int(i[1])] = NIL
        insert(int(i[1]))
    else:
        inorder(root)
        print()
        preorder(root)
        print()


Measured memory_bytes: 254192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int main()
{

    string s;
    cin>>s;
    
    int n=s.size();
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='2')
            c++;
    }
    cout<<c<<"\n";
  


return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    int a,b,c,d;
    a=b=c=d=0;
    rep(i,n){
        string s; cin>>s;
        if(s=="AC") a++;
        if(s=="WA") b++;
        if(s=="TLE") c++;
        if(s=="RE") d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
}

Measured memory_bytes: 3632
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let c = input_line_str().to_charvec();
    let table1 = String::from("abcdefghijklmnopqrstuvwxyz").to_charvec();
    let table2 = String::from("bcdefghijklmnopqrstuvwxyza").to_charvec();

    for i in 0..table1.len() {
        if c[0] == table1[i] {
            p(table2[i]);
            return;
        }
    }
}


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

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

    int ans = 0;

    for(int i = 1; i <= N; i++){
        int a[5];
        a[1] = i / 10000;
        a[2] = (i - 10000*a[1]) / 1000;
        a[3] = (i - 10000*a[1] - 1000*a[2]) / 100;
        a[4] = (i - 10000*a[1] - 1000*a[2] - 100*a[3]) /10;
        a[5] = (i - 10000*a[1] - 1000*a[2] - 100*a[3] - 10*a[4]);

        int sum = a[1] + a[2] + a[3] + a[4] + a[5];
        if((sum >= A) && (sum <= B)) ans += i;
    }

    cout << ans << endl;
}

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

bool isPalindrome(string str) 
{ 
    int l = 0; 
    int h = str.length() - 1; 
  
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
           return false; 
        } 
    } 
    return true;
} 

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

    string s;

    cin >> s;
    int n = s.length();

    if (isPalindrome(s))
    {
        if( isPalindrome( s.substr(0, (n-1)/2) ) )
        {
            if( isPalindrome( s.substr( (n+3)/2 - 1, n - (n+3)/2 + 1) ) )
            {
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";
    return 0;
      

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int check(int x)
{
	int cnt=0;
	while (x) ++cnt,x/=10;
	return cnt;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		int t=check(i);
		if (t%2==1) ++ans;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, Q = list(map(int, input().split()))

M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x

Q = [0]

while Q:
    current = Q.pop()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)
        Q.append(i)

print(' '.join(map(str, ans)))


Measured memory_bytes: 71772
#include <algorithm>
#include <cstdio>
#include <cstring>

#define int long long
#define Accepted 0; 

const int Maxv = 100010; 

int dis[Maxv], x[Maxv], y[Maxv], n, m = 40; 
bool flag1, flag2; 

inline void LiXinLongWalking(int x, int y) {
    for (int i = 1; i <= m; i++) {
        if (y >= abs(x)) {
            printf("U"); 
            y -= dis[i]; 
        }
        else if (y <= -abs(x)) {
            printf("D"); 
            y += dis[i]; 
        }
        else if (x <= -abs(y)) {
            printf("L"); 
            x += dis[i]; 
        }
        else {
            printf("R"); 
            x -= dis[i]; 
        }
    }

    if (x || y)
        puts("ERROR"); 

    puts(""); 
}

signed main() {
    scanf("%lld", &n); 
    for (int i = 1; i <= n; i++) {
        scanf("%lld%lld", &x[i], &y[i]); 

        if ((x[i] + y[i]) & 1) 
            flag2 = true; 
        else 
            flag1 = true; 
    }
    
    if (flag1 && flag2) {
        puts("-1"); 
        return 0; 
    }

    dis[m] = dis[m - 1] = dis[m - 2] = dis[m - 3] = 1; 
    for (int i = m - 4; i >= 1; i--)
        dis[i] = (dis[i + 1] << 1); 

    if (flag2)
        m--; 

    printf("%lld\n", m); 
    for (int i = 1; i <= m; i++) 
        printf("%lld ", dis[i]); 

    puts(""); 
    for (int i = 1; i <= n; i++) {
        LiXinLongWalking(x[i], y[i]); 
    }

    return Accepted
}

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

int main()
{
    string s, c_c;
    getline(cin, s);
    for (char c : s)
    {
        if (islower(c))
            c_c = toupper(c);
        else if (isupper(c))
            c_c = tolower(c);
        else
            c_c = c;
        cout << c_c;
    }
    cout << endl;
    return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	ll ans = -5e18;
	ans = max(ans, 1LL * a * c);
	ans = max(ans, 1LL * a * d);
	ans = max(ans, 1LL * b * c);
	ans = max(ans, 1LL * b * d);
	printf("%lld\n", ans);
	return 0;
}


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

const int MAX = 5e5 + 5;

struct Query
{
    int l, r, idx;
};
bool cmp(Query x, Query y)
{
    return x.r < y.r;
}
void update(int idx, int val, int bit[], int n)
{
    for (; idx <= n; idx += idx & -idx)
        bit[idx] += val;
}
int query(int idx, int bit[], int n)
{
    int sum = 0;
    for (; idx > 0; idx -= idx & -idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
    int bit[n + 1];
    memset(bit, 0, sizeof(bit));
    int last_visit[MAX];
    memset(last_visit, -1, sizeof(last_visit));
    int ans[q];
    int query_counter = 0;
    for (int i = 0; i < n; i++)
    {
        if (last_visit[arr[i]] != -1)
            update (last_visit[arr[i]] + 1, -1, bit, n);
        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);
        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                query(queries[query_counter].r + 1, bit, n) -
                query(queries[query_counter].l, bit, n);
            query_counter++;
        }
    }
    for (int i = 0; i < q; i++)
        cout << ans[i] << "\n";
}

int main()
{

    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int n, q;
    cin >> n >> q;
    int a[n] ;

    for (int i = 0; i < n; i++)
        cin >> a[i];
    Query queries[q];
    int x, y;
    for (int i = 0; i < q; i++)
    {
        cin >> x >> y;
        x--;
        y--;
        queries[i].l = x;
        queries[i].r = y;
        queries[i].idx = i;

    }
    sort(queries, queries + q, cmp);
    answeringQueries(a, n, queries, q);

}

Measured memory_bytes: 17448
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int a, b; cin >> a >> b;
	int t = 0;
	for(int i = 1; i <= (b-a); i++){
		t += i;
	}
	cout << t - b << endl;
}

Measured memory_bytes: 256
//
// Created by yuu on 2019-06-20.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;

#define MAX 10010
#define INF 1<<20

vector<pair<int, int>> adj[MAX];
int N;

void dijkstra(int start){
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> PQ;
    int d[MAX];
    int check[MAX];
    for (int i = 0; i < N; ++i) {
        d[i] = INF;
        check[i] = -1;
    }

    d[0] = 0;
    check[0] = 0;
    PQ.push(make_pair(0, start));

    while(!PQ.empty()) {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        check[u] = 1;

        //　接続先が小さい
        if (d[u] < f.first)continue;

        for (int i = 0; i < adj[u].size(); ++i) {
            int v = adj[u][i].first;
            if (check[v] == 1)continue;

            if (d[v] > d[u] + adj[u][i].second) {
                d[v] = d[u] + adj[u][i].second;
                PQ.push(make_pair(d[v], v));
                check[v] = 0;
            }
        }

    }

    for (int i = 0; i < N; ++i) {
        cout<<i<<" "<< (d[i] == INF? -1 : d[i])<<endl;
    }
}

int main(void){
    int k, u, v, c;
    cin>>N;

    for (int i = 0; i < N; ++i) {
        cin>>u>>k;
        for (int j = 0; j < k; ++j) {
            cin>>v>>c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra(0);






    return 0;
}


Measured memory_bytes: 7980
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

  cout << a[0] << b[0] << c[0] << endl;
}


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

int N;
int A[100005];

int main()
{
	int i;
	
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	sort(A,A+N);

	long long sum = 0;
	int ans = 0;

	for(i=0; i<N-1; i++){
		sum += A[i];
		//cout<<A[i+1]<<" "<<2*sum<<endl;
		if(A[i+1] <= 2*sum)
			ans++;
		else ans = 0;
	}

	ans++;

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    string A, B;
    A = to_string(a);
    B = to_string(b);
    string C = A + B;
    int c = stoi(C);
    for(int i=1; i * i <= 100100; i++){
        if(i * i == c) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define int long long

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int k, a, b;
  cin >> k >> a >> b;
  int x = a / k * k;
  if (a % k) x += k;
  cout << (x <= b ? "OK" : "NG") << '\n';

  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cout<<s[n-1];
    for(int i=n-3;i>=0;i-=2){
        cout<<" "<<s[i];
    }
    if(n%2==0){
        for(int i=0;i<n-1;i+=2)cout<<" "<<s[i];
    }
    else for(int i=1;i<n-1;i+=2)cout<<" "<<s[i];
    cout<<endl;
}


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

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

    int amax=-1e7, amin=1e7;
    long long int asum=0;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        amax = max(amax, tmp);
        amin = min(amin, tmp);
        asum += tmp;
    }
    cout << amin << " " << amax << " " << asum <<endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;


int main()
{
   int n,m;
   cin>>n>>m;
   int ans=0;
   for(int i=(m/n)+1;i>0;--i)
   {
       if(m%i==0&&(m/i)>=n) {ans=i;break;}
   }
   cout<<ans<<endl;
    return 0;
}



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

typedef long long ll;

int main()
{
    
    int a,b,c;
    cin>>a>>b>>c;
    vector<int>res;
    int d = c%b;
    for(int i=a;i<=10000;i=i+a)
	{
		//cout<<"i = "<<i<<endl;
		res.push_back(i);
	}
	int x = res[res.size()-1];
	
	for(auto &xx:res)
	{
		res.push_back(xx+x);
	}
	res.pop_back();
	
	for(auto &xx :res)
	{
		if(xx%b==d)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	
	cout<<"NO"<<endl;
    return 0;
}


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

ll solve() {
    ll N, a;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        a--;
        A[a]++;
    }
    sort(A.begin(), A.end(), greater<>());
    vector<ll> c(N);
    ll ct = 0;
    for ( int i = N-1; i >= 0; i-- ) {
        ct += A[i];
        c[i] = ct;
    }

    auto check = [&](ll k, ll m) {
        // rem c[k]
        ll p = lower_bound(A.begin(), A.end(), m, greater<>()) - A.begin();
        if ( m * (k-p) - (c[p]-c[k]) <= c[k] ) return true;
        else return false;
    };

    for ( ll k = 1; k <= N; k++ ) {
        ll l = 0, r = N+1;
        while ( r-l > 1 ) {
            ll m = (l+r)/2;
            if ( check(k, m) ) l = m;
            else r = m;
        }
        cout << l << "\n";
    }
    return 0;
}

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

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

        if (a[i] % 2 == 1) {
            odd++;
        }
    }

    if (odd % 2 == 1) {
        puts("NO");
    } else {
        puts("YES");
    }
}

Measured memory_bytes: 3768
fn main()
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    
    if a + b >= 10 {
        println!("error");
    } else {
        println!("{}", a+b);
    }
}


Measured memory_bytes: 4352
def dfs(str, max, rast):
    if(rast==0):
        return 0
    else:
        for i in range(ord('a'), max+1):
            if(rast==1):
                print(str + chr(i))
            if(i==max):
                dfs(str+chr(i), max+1, rast-1)
            else:
                dfs(str+chr(i), max, rast-1)


def main():
    n = int(input())
    s = 'a'
    if(n==1):
        print(s)
    dfs(s, ord(s[-1])+1, n-1)

main()


Measured memory_bytes: 4404
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int a,b,h;
	cin>>a>>b;
	h=b-a;
	cout<<(h*(h+1)/2-b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};
const int D=365;
const int beam = 150;
int c[26];
int s[D][26];
int ans[D];

struct State{
    ll val = 0;
    int out[D]={0};
    int cnt[26]={0};
};

bool operator< (const State &a, const State &b){
    return a.val<b.val;
}
bool operator> (const State &a, const State &b){
    return a.val>b.val;
}

void itr(){
    priority_queue<State> pq[2];
    pq[0].push(State());
    for (int i = 0; i < D; ++i) {
        int prev=i&1,next = prev^1;
        //cout<<prev<<" "<<next<<endl;
        for (int j = 0; !pq[prev].empty()&&j < beam; ++j) {
            auto state = pq[prev].top();
            pq[prev].pop();
            ll dec=0;
            for (int k = 0; k < 26; ++k) { //開催しなかったときのへる値
                //cout<< state.cnt[k]<<endl;
                state.cnt[k]++;
                dec+=(ll)c[k]*state.cnt[k];
            }
            for (int k = 0; k < 26; ++k) {
                const ll inc = (ll)c[k]*state.cnt[k];
                const int tmp = state.cnt[k];
                const int tmp_val = state.val;
                state.val = state.val-dec+inc+s[i][k];
                state.cnt[k]=0;
                state.out[i]=k;
                pq[next].push(state);
                //cout<<"called"<<endl;
                state.cnt[k]=tmp;
                state.val = tmp_val;
                //if(i==0)cout<<state.val
            }
        }
        pq[prev]=priority_queue<State>();
    }
    auto best = pq[D&1].top().out;
    for (int i = 0; i < D; ++i) {
        ans[i]=best[i]+1;
    }
}

void solve(int ca){
    int waste;
    scanf("%d",&waste);
    for (int i = 0; i < 26; ++i) {
        scanf("%d",c+i);
    }
    for (auto & i : s) {
        for (int & j : i) {
            scanf("%d",&j);
        }
    }

    itr();
    for (int i = 0; i < D; ++i) {
        printf("%d\n",ans[i]);
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 21716
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		//System.out.println("??\???>>");

		Scanner scan = new Scanner(System.in);
		ArrayList<Integer[]> list = new ArrayList<Integer[]>();



		while(scan.hasNext()){

			Integer ary[];
			ary = new Integer[2];
			ary[0] = scan.nextInt();
			ary[1] = scan.nextInt();

			if(ary[0] == 0 && ary[1] == 0 ){

				scan.close();
				break;
			}else{

				list.add(ary);
			}
		}

		for(int i = 0; i < list.size(); i++){

			Integer[] ary = list.get(i);

			if(ary[0] < ary[1]){

				System.out.println( ary[0] + " " + ary[1]);
			}else{

				System.out.println( ary[1] + " " + ary[0]);
			}

			//System.out.println("ary[0]:" + ary[0] + "ary[1]:" + ary[1]);
		}

	}

}

Measured memory_bytes: 26796
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from bisect import bisect_left, bisect_right
def resolve():
    n, m = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB.sort()
    AB.append([INF, 0])
    for i in range(n, 0, -1):
        AB[i][1] ^= AB[i - 1][1]

    E = [[] for _ in range(n + 1)]
    for i in range(m):
        u, v = map(int, input().split())
        l = bisect_left(AB, [u, 0])
        r = bisect_right(AB, [v, 1])
        E[l].append((r, i + 1))
        E[r].append((l, i + 1))

    ans = []
    used = [False] * (n + 1)
    def dfs(v):
        used[v] = True
        res = AB[v][1]
        for nv, i in E[v]:
            if used[nv]:
                continue
            r = dfs(nv)
            if r:
                ans.append(i)
            res ^= r
        return res

    for v in range(n + 1):
        if used[v]:
            continue
        if dfs(v):
            print(-1)
            return

    print(len(ans))
    if ans:
        print(*sorted(ans))
resolve()

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

int a[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

int main(){

    cin >> k;
    cout << a[k-1];

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;


int main(){

    int h,w;
    cin >> h >> w;

    vector<vector<int>> red(h);
    vector<vector<int>> blue(h);

    rep(i,h){
        rep(j, w){
            int tmp;
            cin >> tmp;

            red[i].pback(tmp);
        }
    }

    rep(i,h){
        rep(j, w){
            int tmp;
            cin >> tmp;

            blue[i].pback(tmp);
        }
    }

    bool dp[h][w][25601] = {};

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int k = 0; k <= 25600; k++){
                dp[i][j][k] = false;
            }
        }
    }

    int ans = 12801;

    dp[0][0][12800] = true;
    int count = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int k = 0; k <= 25600; k++){
                //count++;
                if(i == h - 1 && j == w - 1){
                    if(dp[i][j][k]){
                        int tmp1 = k + red[i][j] - blue[i][j] - 12800;
                        int tmp2 = k - red[i][j] + blue[i][j] - 12800;
                        ans = min(ans, min(abs(tmp1), abs(tmp2)));
                    }
                }else{
                    if(dp[i][j][k]){
                        if(i != h - 1){
                            dp[i + 1][j][k + red[i][j] - blue[i][j]] = true;
                            dp[i + 1][j][k - red[i][j] + blue[i][j]] = true;
                        }
                        if(j != w - 1){
                            dp[i][j + 1][k - red[i][j] + blue[i][j]] = true;
                            dp[i][j + 1][k + red[i][j] - blue[i][j]] = true;
                        }
                    }
                }
            }
        }
    }

    cerr << count << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 160384
#include<iostream>
#include<map>
using namespace std;
int main()
{   
    int N;
    cin >> N;
    map<int, int> m;
    for(int i=0; i<N; i++){
        int d;
        cin >> d;
        if(m.find(d)==m.end()){
            m[d] = 0;
        }
        m[d]++;
    }
    int s = 0;
    int nb = 0;
    for(auto j=m.begin(); j!=m.end(); ++j){
      if(nb>0){
        cout << j->first - nb << endl;
        return 0;
      }
      s += j->second;
      if(s==N/2){
        nb = j->first;
      }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  ll n, m;
  cin >> n >> m;
  if(min(n, m) == 1){
    if(max(n, m) == 1){
      cout << 1 << endl;
    }else{
      cout << max(n, m) - 2 << endl;
    }
  }else{
    cout << (n - 2)*(m - 2)<< endl;
  }
}


Measured memory_bytes: 256
n = int(input())

div, mod = divmod(n, 4)
ans = []

if n == 3:
    print(2, 5, 63)
    exit()
if n == 4:
    print(2, 5, 20, 63)
    exit()
if n == 5:
    print(2, 5, 20, 30, 63)
    exit()
    
cnt = 0
i = 0
for i in range(div):
    cnt += 15
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)
    ans.append(6*i + 6)
if mod == 1:
    i += 1
    cnt += 2
    ans.append(6*i + 2)
if mod == 2:
    i += 1
    cnt += 5
    ans.append(6*i + 2)
    ans.append(6*i + 3)
if mod == 3:
    i += 1
    cnt += 9
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)

if cnt % 6 == 0:
    pass
if cnt % 6 == 2:
    ans = ans[0:4] + ans[5:] + [ans[-1] - ans[-1] % 6 + 6]
if cnt % 6 == 3:
    ans = ans[0:5] + ans[6:] + [ans[-1] - ans[-1] % 6 + 6]
if cnt % 6 == 5:
    ans = ans[0:5] + ans[6:] + [6 * (ans[-1] // 6) + 4]
print(*ans)

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

vector<int> S;

bool binarySearch(int key) {
  int left = -1;
  int right = S.size();
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (S[mid] >= key) {
      right = mid;
    }
    else {
      left = mid;
    }
  }
  if (S[right] == key) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  int n;
  cin >> n;
  S.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  int q;
  cin >> q;
  int ans = 0;
  int key;
  for (int i = 0; i < q; i++) {
    cin >> key;
    if (binarySearch(key)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3152
#


def main():
    k, n  = map(int, input().split(" "))
    a = [int(s) for s in input().split(" ")]
    max_distance = a[0] + k - a[-1]
    p = 0
    for t in a:
        if t - p > max_distance:
            max_distance = t - p
        p = t
    print(k - max_distance)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26436
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void A(){
    ll k,a,b; cin >> k >> a >> b;
    ll i = k;
    while(i<a){
        i+=k;
    }

    if(i<=b) cout << "OK" << endl;
    else           cout << "NG" << endl;
    
}
void B(){
    ll x; cin >> x;
    ll sum = 100;
    ll i = 0;
    while(sum<x){
        sum *=1.01;
        i++;
    }
    cout << i << endl;
    
}

void C(){

}

void d(){
    ll a,b,n; cin >> a >> b >> n;
    cout << (a*min((b-1),n))/b << endl;
}
void e(){}

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

Measured memory_bytes: 3600
Scanf.scanf "%d" (fun n ->
    let c = Array.init (n + 1) (fun i -> if i = 0 then (-1) else Scanf.scanf " %d" (fun c -> c)) in
    let dp = Array.make (n + 1) 0 in
    let asm = Array.make 200001 0 in
    dp.(0) <- 1;
    let (+@) a b = (a + b) mod 1000000007 in

    for i = 1 to n do
        if c.(i) = c.(i - 1) then dp.(i) <- dp.(i - 1) else (
            asm.(c.(i)) <- asm.(c.(i)) +@ dp.(i - 1);
            dp.(i) <- asm.(c.(i))
        )
    done;
    Printf.printf "%d\n" dp.(n)
)

Measured memory_bytes: 10728