akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
struct mindol{
    int r, ind, dis;
};

bool operator <(mindol a, mindol b)
{
    if(a.dis==b.dis)return a.r<b.r;
    return a.dis<b.dis;
}

int n, m, C[100005], R[100005], D[100005], Q, a, b, v , d, c;
vector<int> P[100005];
priority_queue<mindol> PQ;
bool check[100005];

int main()
{
    scanf("%d %d", &n, &m);
    for(int i=1;i<=m;i++){
        scanf("%d %d", &a, &b);
        P[a].push_back(b);
        P[b].push_back(a);
    }
    scanf("%d", &Q);
    for(int i=1;i<=Q;i++){
        scanf("%d %d %d", &v, &d, &c);
        PQ.push({i, v, d});
        C[i] = c;
    }

    while(!PQ.empty()){
        mindol k = PQ.top(); PQ.pop();
        int r = k.r, ind = k.ind, dis = k.dis;
        //printf("%d %d %d\n", r, ind, dis);
        if(R[ind]==0){
            R[ind] = r, D[ind] = dis;
        }
        else{
            if(R[ind]>r&&D[ind]>=dis){
                continue;
            }
            if(R[ind]<r){
                R[ind] = r;
                D[ind] = dis;
            }
        }
        if(dis==0)continue;
        for(auto &t : P[ind]){
            if(R[t]==0){
                R[t] = r;
                D[t] = dis-1;
                PQ.push({r, t, dis-1});
            }
            else{
                if(R[t]>=r)continue;
                else{
                    R[t] = r;
                    D[t] = dis-1;
                    PQ.push({r, t, dis-1});
                }
            }
        }
    }

    for(int i=1;i<=n;i++){
        printf("%d\n", C[R[i]]);
    }
    return 0;
}


Measured memory_bytes: 14956
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: u64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut memo = vec![vec![vec![vec![0; 4]; 4]; 4]; n+3];
    for a in 0..4 {
        for b in 0..4 {
            for c in 0..4 {
                if a == 1 && b == 2 && c == 3 { continue; }
                if a == 1 && b == 3 && c == 2 { continue; }
                if a == 2 && b == 1 && c == 3 { continue; }
                memo[0][a][b][c] = 1;
            }}}
    for i in 1..n+1 {
        for a in 0..4 {
            for b in 0..4 {
                for c in 0..4 {
                    for d in 0..4 {
                if b == 1 && c == 2 && d == 3 { continue; }
                if b == 1 && c == 3 && d == 2 { continue; }
                if b == 2 && c == 1 && d == 3 { continue; }
                if a == 1 && b == 2 && d == 3 { continue; }
                if a == 1 && c == 2 && d == 3 { continue; }
                        memo[i][b][c][d] += memo[i-1][a][b][c];
                        memo[i][b][c][d] %= M;
                    }
                }
            }
        }
    }

    // Please Update rustc
    // put!(memo[n-3].iter().flatten().flatten().fold(0, |a,s|(a+s)%M));
    {
        let mut ans = 0;
        for a in 0..4 {
            for b in 0..4 {
                for c in 0..4 {
                    ans += memo[n-3][a][b][c];
                    ans %= M;
                }}}
        put!(ans);
    }

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

int main()
{
    long long unsigned int H, W;
    std::cin >> H >> W;

    if (H==1 || W==1){
      std::cout << 1 << std::endl;
      return 0;
    }

    long long unsigned int ans = (W / 2 * 2 + W % 2) * (H / 2);
    if (H % 2 == 1)
    {
        ans += W / 2 + W % 2;
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    s.append(input())
    
print('AC x %s' % s.count('AC'))
print('WA x %s' % s.count('WA'))
print('TLE x %s' % s.count('TLE'))
print('RE x %s' % s.count('RE'))

Measured memory_bytes: 16272
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int q;
    cin >> q;
    while(q--) {
        int k;
        cin >> k;

        cout << binary_search(all(a), k) << '\n';
    }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#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 mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {


	int n ;
	cin >> n;

	mk(a, n, int);
	int val = 0 ;
	for (int i  = 0 ; i < n ; i++) {
		cin >> a[i];
		val = (val ^ a[i]);
	}
	for (int i = 0 ; i < n ; i++) {
		cout << (val ^ a[i]) << " ";
	}


	return 0;
}

Measured memory_bytes: 5152
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	string s;
	cin >> s;
	ll maxx = 0;
	ll temp = 0;
	for (auto u : s)
	{
		if (u == 'R')
			temp++;
		else
			temp = max(0ll, temp - 1);
		maxx = max(maxx, temp);

	}
	cout << maxx << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

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

appr = True

for k in A:
  if k % 2 == 1:
    continue
  elif k % 3 == 0:
    continue
  elif k % 5 == 0:
    continue
  else:
    appr = False
    break

if appr:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=(n)-1;i>j-1;i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,a=1;
    vector<lli> mod;
    lli i,j,k;
    cin>>n;
    while(1){
        if(pow(26,a)<n){
            n-=pow(26,a);
            a++;
        }
        else{
            break;
        }
    }
//    cout<<"桁数は"<<a<<endl<<"数字は"<<n<<endl;
    n--;
    rep(i,0,a){
        mod.push_back(n%26);
        n/=26;
    }
    rrep(i,0,a){
        char c='a'+mod[i];
        cout<<c;
    }
    cout<<endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	int K;
	cin >> K;
	rep(i,K){
		cout << "ACL";
	}
	cin >> K;
	
	return 0;	
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<63)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<string> A, B;

  rep(i, N) { string a; cin >> a; A.push_back(a); }
  rep(i, M) { string b; cin >> b; B.push_back(b); }

  rep(i, N - M + 1) {
    rep(j, N - M + 1) {
      bool matched = true;
      rep(k, M) {
        std::string::size_type found_pos = A[i+k].find(B[k], j);
        matched = matched && (found_pos != string::npos);
        matched = matched && (found_pos == j);
      }
      if (matched) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


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

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

    

    vector<string> song(N); // N個の数学の点数データ
    vector<int> time(N); // N個の英語の点数データ

    // 数学の点数データを受け取る
    for (int i = 0; i < N; i++) {
        cin >> song.at(i);
        cin >> time.at(i);
    }

    string last_song;
    cin >> last_song;

    bool check = false;
    int sum = 0;

    rep(i, N) {
        if (check == false) {
            if (song.at(i) == last_song) {
                check = true;
            }
        }
        else {
            sum += time.at(i);
        }

    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B;
  string S;
  cin >> A >> B >> S;
  bool ok = true;
  REP(i, A + B + 1) {
    if (i == A) {
      ok = ok && S[i] == '-';
    } else {
      ok = ok && '0' <= S[i] && S[i] <= '9';
    }
  }
  if (ok) {
    print("Yes");
  } else {
    print("No");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD=998244353;


int main() {
  ll N,K,ans=MOD;
  cin>>N>>K;
  ll X[N];
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  ll x0=lower_bound(X,X+N,0)-X;
  ll x1=N-x0;
  //cout<<x0<<x1;
  for(int i=0;i<=K;i++){
    if(K-i>x0){
     
      continue;
    }
    if(i>x1){
       
      continue;
    }
    if(i==0){
      ans=min(ans,abs(X[x0+i-K]));
    }
    //cout<<ans;
    if(i==K){
      ans=min(ans,X[x0+i-1]);
    }
    ans=min(ans,abs(X[x0+i-K])*2+abs(X[x0+i-1])*2-max(abs(X[x0+i-K]),abs(X[x0+i-1])));
    //cout<<i<<" "<<x0+i-K<<" "<<x0+i-1<<" "<<ans<<endl;
  }
  cout<<ans;
            
    
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        int x=0,mx=0;
        loop(i,0,2)
        {
            if(s[i]=='R') x++;
            else
            {
                mx=max(mx,x);
                x=0;
            }
        }
        cout<<max(mx,x);

    }
    return 0;
}


Measured memory_bytes: 3648
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
          
            //??¨???????????°????????????
            var read = Console.ReadLine();
            var temp_string = read.Split(' ');

            //????????¨????????????
            var cell = new int[int.Parse(temp_string[0]), int.Parse(temp_string[1])];
            //for?????¨?????° ?¨??????¨?????°???
            int r = int.Parse(temp_string[0]), c = int.Parse(temp_string[1]),temp=0,count=0;;
            var sum=new int[c+1];

            //???????????°????????\??????
            for(var i=0;i<r;i++)
            {
                read=Console.ReadLine();
                temp_string=read.Split(' ');

                for (var j = 0; j < c;j++ )
                {
                    cell[i, j] = int.Parse(temp_string[j]);
                }
            }

            //??°?????¨???
            for (var i = 0; i < r; i++)
            {

                for (var j = 0; j < c; j++)
                {
                    //?????¨??????????¨??¨??????¨???????????¨???
                    temp+=cell[i,j];
                    sum[j] += cell[i, j];
                    Console.Write(cell[i, j]+" ");

                }
                //????????¨???????¨???¨?????¨???????¨??¨????
                Console.WriteLine(temp);
                sum[sum.Length - 1] += temp;
                temp = 0;
            }

            //?????¨???????¨??????????????????¨??¨???
            foreach(int date in sum)
            {   
                Console.Write(date);
                if(count<sum.Length-1)
                {
                    Console.Write(" ");
                }
                count++;
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9380
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c[109][109];
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<h*2;i++){
    for(int j=0;j<w;j++){
      cout<<c[i/2][j];
    }
    cout<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
	string s;
	int a=1;
	cin>>s;
	for(int i=0; i<(int)s.size(); i++){
		if(a==1&&s[i]!='L'){
			a=0;
			continue;
		}
		if(a==0&&s[i]!='R'){
			a=1;
			continue;
		}
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
}


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

  int main()
  {
    int a, b, source = 0, count = 0;
    cin >> a >> b;
    if(b == 1)
    {
      cout << 0 << endl;
      return 0;
  	}
    if(a >= b) {
      cout << 1 << endl;
      return 0;
    }
    while(source < b){
      source += a;
      count++;
//      cout << source  << " " << count << endl;
      //もし口がbより少なかったらループを続けるので口を一つ減らす
      if(source < b) source -= 1;
    }
    source += 1;
    cout << count << endl;
    return 0;
  }


Measured memory_bytes: 256
#include<iostream>

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

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

    int price = 700;
    if (S[0] == 'o') price += 100;
    if (S[1] == 'o') price += 100;
    if (S[2] == 'o') price += 100;

    cout << price << endl;
    return 0;
}


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

int main(){

	string S;
	cin >> S;
	int flag = 2;
  	for(int i = 1; i <= S.length(); i++){
     	//cout << S.length() <<endl;
      	if((S.length()-i)%2==0){
          flag = 0;
          //cout << "abb" <<endl;
	    	for(int j = 0; j < (S.length()-i)/2;j++){
    	 		//cout << "a" <<endl;
              	if(S[j]!=S[(S.length()-i)/2+j]){
                  flag = 1;
                }   	
        	}
          	
        }
      	if(flag == 0){
          	cout <<S.length()-i<< endl;
 			return 0;
        }
      	flag = 2;
    }

}

Measured memory_bytes: 256
h,w = map(int,input().split())
lst = [[0]*w for _ in range(h)]
tile = []
for i in range(h):
    tile.append(list(input()))
if tile[0][0] == '#':
    lst[0][0] = 1
for j in range(1,w):
    if tile[0][j] == '.':
        if lst[0][j-1] % 2 == 0:
            lst[0][j] = lst[0][j-1]
        else:
            lst[0][j] = lst[0][j-1] + 1
    else:
        if lst[0][j-1] % 2 == 0:
            lst[0][j] = lst[0][j-1] + 1
        else:
            lst[0][j] = lst[0][j-1]
for i in range(1,h):
    if tile[i][0] == '.':
        if lst[i-1][0] % 2 == 0:
            lst[i][0] = lst[i-1][0]
        else:
            lst[i][0] = lst[i-1][0] + 1
    else:
        if lst[i-1][0] % 2 == 0:
            lst[i][0] = lst[i-1][0] + 1
        else:
            lst[i][0] = lst[i-1][0]
for i in range(1,h):
    for j in range(1,w):
        if tile [i][j] == '.':
            if lst[i][j-1] % 2 == 0:
                a = lst[i][j-1]
            else:
                a = lst[i][j-1] + 1
            if lst[i-1][j] % 2 == 0:
                b = lst[i-1][j] 
            else:
                b = lst[i-1][j] + 1
            lst[i][j] = min(a,b)
        else:
            if lst[i][j-1] % 2 == 0:
                a = lst[i][j-1] + 1
            else:
                a = lst[i][j-1]
            if lst[i-1][j] % 2 == 0:
                b = lst[i-1][j] + 1 
            else:
                b = lst[i-1][j]
            lst[i][j] = min(a,b)
print(-(-lst[h-1][w-1]//2))



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void solve()
{ll n,m,x,y,z,d,p=0,b=0,q,l=INT_MAX,k,mini=0,prev;
 cin>>n>>m;
 vector<vector<ll> > v(n,vector<ll>(m,0)),a(n,vector<ll>(m,0));
for(ll i=0;i<n;i++)
for(ll j=0;j<m;j++)
{
	char c;
	cin>>c;
	if(c=='.')
	a[i][j]=1;
	else
	a[i][j]=0;
}
v[0][0]=1;
for(ll i=1;i<m;i++)
{
	if(a[0][i])
	v[0][i]=v[0][i-1];
} 
for(ll i=1;i<n;i++)
if(a[i][0])
v[i][0]=v[i-1][0];
for(ll i=1;i<n;i++)
{
	for(ll j=1;j<m;j++)
	{
		if(a[i][j])
		v[i][j]=((v[i-1][j]%hell)+(v[i][j-1]%hell))%hell;
	}
}
cout<<v[n-1][m-1];  
}

int main()
{

ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 16000
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000
int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}


void solve(){

    int n;
    cin >> n;

    int a[n+1];


    for(int i = 1;i<=n;i++){
        cin >> a[i];
    }
    int ans = 0;
     
    for (int i = 0; i <= 60; i++)  
    { 
        
        int z = 0, o = 0;  
           
        int isum = 0;  
        for (int j = 1; j <= n; j++) 
        { 
            if (a[j] % 2 == 0) 
                z++; 
            else
                o++; 
            a[j] /= 2; 
        } 
          
         
        isum = ((((o%mod) * (z%mod))%mod) * ((1LL << i)%mod))%mod;  
            
        ans = (ans + isum)%mod;
        ans%=mod;  
    } 
    cout << ans << endl;
}

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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


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

    int ans = -1;
    for (int i=1; i<=1009; i++) {
        int a = (i *  8) / 100;
        int b = (i * 10) / 100;
        if ((a == A) && (b == B)) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define LL long long

#define MAX_N 100005
#define MAX_Q 100005
#define MAX_M 50

int N;
LL X[MAX_N];
LL L;
int Q;
int A[MAX_N], B[MAX_Q];

void input()
{
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  cin >> L;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    if(A[i] > B[i]){
      swap(A[i], B[i]);
    }
  }
}

int m_next[MAX_N][MAX_M];

int calc(int pos)
{
  int l = pos, r = N;
  while(r-l > 1){
    int mid = (l+r)/2;
    if(X[mid] - X[pos] <= L){
      l = mid;
    }
    else{
      r = mid;
    }
  }
  return l;
}

int main()
{
  input();

  for (int i = 0; i < N; i++) {
    m_next[i][0] = calc(i);
  }

  m_next[N-1][0] = -1;

  for (int j = 0; j < MAX_M-1; j++) {
    for (int i = 0; i < N; i++) {
      int n = m_next[i][j];
      if(n == -1){
        m_next[i][j+1] = -1;
      }
      else{
        m_next[i][j+1] = m_next[n][j];
      }
    }
  }

  for (int i = 0; i < Q; i++) {
    LL ans = 0;
    int pos = A[i];
    //cerr << A[i] << " " << B[i] << endl;
    while(pos < B[i]){
      if(pos == -1){
	cerr << "unk " << endl;
	return 0;
      }
      int _N = -1;
      bool flag = false;
      for (size_t j = 0; j < MAX_M; j++) {
	if(m_next[pos][j] >= B[i] ||
           m_next[pos][j] == -1){
	  _N = j;
	  if(m_next[pos][j] == B[i]){
	    flag = true;
	  }
	  break;
	}
      }
      if(flag){
	ans += ((LL)1 << (_N));
	pos = m_next[pos][_N];
	break;
      }
      if(_N == 0){
	ans++;
	pos = m_next[pos][_N];
	}
      else{
	ans += ((LL)1 << (_N-1));
	pos = m_next[pos][_N-1];
      }
      
    }
    cout << ans << endl;
  }
  
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a; string s;
  	cin >> a >> s;
	if(a>=3200) cout << s << endl;
  	else cout << "red" << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,ans,p,q;

main(){
	cin>>n;
	int a[n],b[n],use[n]={};
	int dif[n];
	rep(i,n){
		cin>>a[i];
		p+=a[i];
	}
	rep(i,n){
		cin>>b[i];
		q+=b[i];
	}
	if(p<q){
		dump(-1);
		return 0;
	}
	rep(i,n){
		int t=a[i]-b[i];
		dif[i]=t;
	}
	sort(dif,dif+n);
	int mdi=n-1;
	rep(i,n){
		if(dif[i]>=0)break;
		use[i]++;use[mdi]++;
		while(dif[i]!=0){
			if(-dif[i]>dif[mdi]){
				dif[i]+=dif[mdi];
				dif[mdi]=0;
				
				mdi--;
				use[mdi]++;
			}else{
				dif[mdi]+=dif[i];
				dif[i]=0;
				
			}
		}
		//for(auto x:dif)debug(x);
	}
	rep(i,n)if(use[i])ans++;
	dans;
}


Measured memory_bytes: 3328
S = input()

if int(S[0:2]) >= 1 and 12 >= int(S[0:2]):
    if int(S[2:4]) >= 1 and 12 >= int(S[2:4]):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if int(S[2:4]) >= 1 and 12 >= int(S[2:4]):
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3064
B=[0]*2**19;
s=->i{
	r=0;
	(r=[r,B[i]].max;i-=i&-i)while i>0;
	r
}
d=->i,x{
	(B[i]=[B[i],x].max;i+=i&-i)while i<2**19;
}
n,*a=`dd`.split.map &:to_i;
a.pop(n).zip(a){|a,h|
	d[h,s[h]+a]
}
p s[n]

Measured memory_bytes: 41472
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j, k;
	int a[1003], b[1003], c[1003];
	for (i = 0; i < m; i++)
	{
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		a[i]--;
		b[i]--;
	}
	int d[102][102];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			if (i == j)
				d[i][j] = 0;
			else
				d[i][j] = 1000000009;
		}
	}
	for (i = 0; i < m; i++)
		d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	for (k = 0; k < n; k++)
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				if (d[i][j] > d[i][k] + d[k][j])
					d[i][j] = d[i][k] + d[k][j];
	int ans = 0;
	for (i = 0; i < m; i++)
		if (d[a[i]][b[i]] < c[i])
			ans++;
	printf("%d\n", ans);
	return 0;
}

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

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

    char ans = '1';
    rep(i,min(k, (ll)s.size())){
        if(s[i] != '1'){
            ans = s[i];
            break;
        }
    }

    cout << ans << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  n <<= 1;

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

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

  int answer = 0;
  for (int i = 0; i < n; i += 2) {
    answer += a[i];
  }
  cout << answer << endl;

  return 0;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    if(s + 'a' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'b' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'c' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'd' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'e' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'f' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'g' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'h' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'i' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'j' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'k' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'l' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'm' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'n' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'o' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'p' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'q' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'r' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 's' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 't' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'u' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'v' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'w' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'x' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'y' == t){
        cout << "Yes";
        return 0;
    }
    if(s + 'z' == t){
        cout << "Yes";
        return 0;
    }
    cout << "No";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> A){
  double ans = 0;
  for (int i = 0; i < N; i++) {
    ans += 1/(double)A[i];
  }
  cout << syo(6) << 1/ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
}


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

long long N;
long long n[4];

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

bool solve(){
    long long c1 = 0;
    long long c4 = 0;
    long long c7 = 0;
    long long c9 = 0;
    
    for(int i=0;i<4;i++){
        if(n[i]==1){
            c1++;
        }else if(n[i]==4){
            c4++;
        }else if(n[i]==7){
            c7++;
        }else if(n[i]==9){
            c9++;
        }
    }
    return (c1==1)&&(c4==1)&&(c7==1)&&(c9==1);
}

int main(void){
    // Your code here!
    input();
    bool ret = solve();
    string ans = (ret)?"YES":"NO";
    cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut x2: i64 = 0;
    for i in 0..a.len() {
        x2 += if i % 2 == 0 { a[i] } else { -1 * a[i] };
    }

    let mut ans = vec![0; n];
    ans[0] = x2 / 2;
    for i in 0..n - 1 {
        ans[i + 1] = a[i] - ans[i];
    }

    for item in &ans {
        print!("{} ", item * 2);
    }
    println!();
}


Measured memory_bytes: 4536
#include <stdio.h>
#include <math.h>

int main(void)
{
    int i, d, t;
    int sum;
    int max = 72000000;

    while (fscanf(stdin,"%d", &d) != EOF){
        sum = 0;

        for (i = 1; i <= max; i++){
            t = d * i;
            sum += pow(t, 2) * d;
            if (sum > max){
                //sum += (600 - d) * d;
                break;
            }
            //printf("%d\n", sum);
        }

        sum -= pow(t, 2) * d;
        printf("%d\n", sum);
    }

    return (0);
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;


ve<vi> A;

struct edge { int to, cost; };
struct dijkstra {
    vector<vector<edge>> g;
    vector<int> d;
    vector<int> from_edge;
    int V;
    
    dijkstra(int v){
        V = v;
        d.resize(V);
        g.resize(V);
        from_edge.assign(V,-1);
    }
    
    void solve_d(int s){
        from_edge[s] = s;
        pq1<pii> que;
        rep(i,V) d[i] = infi;
        d[s] = 0;
        que.push({0,s});
        
        while (!que.empty()) {
            pii p = que.top();
            que.pop();
            int v = p.se;
            if(d[v] < p.fi) continue;
            rep(i,int(g[v].size())){
                edge e = g[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    from_edge[e.to] = v;
                    que.push({d[e.to],e.to});
                }
            }
        }
    }
    
    int dis(int a){
        return d[a];
    }
};



int main()
{
    int N,M;
    cin >> N >> M;
    dijkstra G(N);
    A.assign(N,vi(N,0));
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        G.g[a].pb({b,c});
        G.g[b].pb({a,c});
        A[a][b] = 1;
        A[b][a] = 1;
    }
    rep(i,N){
        G.solve_d(i);
        //outve(G.from_edge);
        rep(i,N) A[i][G.from_edge[i]] = -1, A[G.from_edge[i]][i] = -1;
    }
    int ans = 0;
    rep(i,N) reps(j,i+1,N) if(A[i][j] == 1) ans++;
    

    cout << ans << endl;
    
    
    //outmat(A);
    
    

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>Fac,Rac;void setF(int n,int mod){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
bool ask(ll a){
  cout << "? " << a << endl << flush;
  string s;
  cin >> s;
  return s[0]=='Y';
}
void ans(ll a){
  cout << "! " << a << endl << flush;
  exit(0);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  if(ask(1e10)){
    ll a = 1e9;
    FOR(_, 0, 9){
      if(!ask(a-1)) ans(a);
      a /= 10;
    }
    ans(1);
  }
  ll l, r, m;
  l=0;
  r=9;
  while(r-l>1){
    m = (l+r)/2;
    if(ask(modPow(10, m, LINF))){
      l = m;
    }else{
      r = m;
    }
  }
  l = modPow(10, l, LINF);
  r = l*10;
  while(r-l>1){
    m = (l+r)/2;
    if(!ask(m*10)){
      l = m;
    }else{
      r = m;
    }
  }
  ans(r);
}

Measured memory_bytes: 596
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        int a = sc.Int;
        int b = sc.Int;

        Console.WriteLine(a + b < 10 ? (a + b).ToString() : "error");
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Line { get { return Console.ReadLine(); } }

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Line.Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public string[] StrArr { get { return Line.Split(' '); } }
    public int Int { get { return int.Parse(Str); } }
    public int[] IntArr { get { return Line.Split(' ').Select(int.Parse).ToArray(); } }
    public long Long { get { return long.Parse(Str); } }
    public long[] LongArr { get { return Line.Split(' ').Select(long.Parse).ToArray(); } }
    public double Double { get { return double.Parse(Str); } }
    public double[] DoubleArr { get { return Line.Split(' ').Select(double.Parse).ToArray(); } }
}

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

int main(){
  string s;
  int q;
  cin >> s >> q;
  int cnt = 0;
  rep(i,q){
    int a;
    cin >> a;
    if(a == 1) cnt ++;
    else{
      int f;
      cin >> f;
      string t;
      cin >> t;
      if(f == 1){
        if(cnt%2 == 0) s = t + s;
        else s += t;
      }
      else{
        if(cnt%2 == 0) s += t;
        else s = t + s;
      }
    }
  }
  if(cnt%2 == 0) cout << s << endl;
  else{
    reverse(s.begin(),s.end());
    cout << s << endl;
  }
}


Measured memory_bytes: 4688
a = list(input()) 
for i in range(len(a)):
    a[i] = int(a[i])
ue = a[0]*10 + a[1]
sita = a[2]*10 + a[3]
if (ue > 12) & (sita > 12):
    print('NA')
elif (ue <= 12) & (sita <= 12):
    if (sita + ue) == 0:
        print('NA')
    elif (ue == 0):
        print('YYMM')
    elif (sita == 0):
        print('MMYY')
    else:
        print('AMBIGUOUS')
elif ue > 12:
    if (sita <= 12) & (sita > 0):
        print('YYMM')
    else:
        print('NA')
elif sita > 12:
    if (ue <= 12) & (ue > 0):
        print('MMYY')
    else:
        print('NA')

Measured memory_bytes: 3064
# ABC138D - Ki
import sys

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


def dfs(v: int, p: int) -> None:
    x = cnt[v]
    for u in T[v]:
        if u != p:  # p: parent -> skip
            cnt[u] += x  # cumulative sum
            dfs(u, v)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q = tuple(map(int, input().rstrip().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().rstrip().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, N+1: 1-idx
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

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

int main(){
	using namespace std;
	while(1){
		int n;
		long long int a[3] = { 0 };
		cin >> n;
		if(cin.eof() || n == 0) break;
		for(int i = 0;i<n;i++){
			cin >> a[0] >> a[1] >> a[2];
			sort(a,a+3);
			if((a[2]*a[2]) == (a[0]*a[0])+(a[1]*a[1])) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
def gcd (a, b):
	while a:
		a, b = b % a, a
	return b

def lcm (a, b):
	return a // gcd(a, b) * b

n = int(input())
g = 1
for _ in range(n):
	t = int(input())
	g = lcm(t, g)
print(g)


Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {x:isize, a:isize, b:isize}
    if (x - a).abs() < (x - b).abs() {
        println!("A");
    } else {
        println!("B");
    }
}


Measured memory_bytes: 4352