akhauriyash/Code-Regression huggingface dataset:
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(x:i64));
    let mut max = 0;
    for i in 1..1000 {
        for j in 2..11 {
            let n = (i as i64).pow(j as u32);
            if n <= x {
                if max < n {
                    max = n;
                }
            } else {
                break;
            }
        }
    }
    max.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "10" => "9",
    test2: "1" => "1",
    test3: "999" => "961",
}


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

int solve(int y, int m, int d) {
    int res = 0;
    int years = y - 1;
    int y3 = years / 3;
    res += (20 + 19) * 5 * years + 5 * y3;
    int months = m - 1;
    int m2 = months / 2;
    res += months * 20;
    if (y % 3 != 0) res -= m2;
    int days = d - 1;
    res += days;
    return res;
}

int main() {
    int T; cin >> T;
    int now = solve(1000, 1, 1);
    while (T--) {
        int y, m, d; cin >> y >> m >> d;
        cout << now - solve(y, m, d) << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
// #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll>(5, INF));
    rep(j,5)dp[0][j] = 0;
    auto c = [&](ll i, ll j){
        if(j == 0)return a[i];
        if(j == 4)return a[i];
        if(j == 1 || j == 3){
            if(a[i] > 1) return a[i] % 2;
            else return abs(2 - a[i]);
        }
        return (a[i] & 1) ? 0LL : 1LL;
    };
    rep(i,n){
        rep(j,5){
            for(int k = j; k < 5; k++){
                chmin(dp[i+1][k], dp[i][j] + c(i,k));
            }
        }
    }
    debug(dp);

    ll ans = INF;
    rep(j,5)chmin(ans, dp[n][j]);

    cout << ans << endl;
}

Measured memory_bytes: 15996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t,u;
  int a,b;
  cin >> s>>t;
 cin >>a>>b;
  cin >>u;
  if (s == u) cout << a-1 <<" "<< b << endl;
  else cout << a <<" "<< b-1 << endl;
  return 0;
 }

Measured memory_bytes: 3592
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long a, b, c, d;
  cin>>a>>b>>c>>d;
  long long ans;
  ans = max(max(a * c, a * d), max(b * c, b * d));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<ll,int> P;

int main(){
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    double ww = (double)w/2.0;
    double hh = (double)h/2.0;
    bool ans1 = false;
    if(x==ww && y== hh)ans1=true;
    printf("%10f %d\n", w*h/2.0, ans1);
    return 0;
}

Measured memory_bytes: 256
S = input()

pre = int(S[:2])
aft = int(S[2:])

if 0 < pre < 13:
    #MMYY , AMBIGUOUS
    print('AMBIGUOUS') if 0 < aft < 13 else print('MMYY')
else:
    #YYMM, NA
    print('YYMM') if 0 < aft < 13 else print('NA')

Measured memory_bytes: 2940
import bisect
import sys
def input_function():
    return sys.stdin.readline().rstrip()
input=input_function
a,b,q=map(int,input().split())
s=sorted([int(input()) for i in range(a)])
t=sorted([int(input()) for i in range(b)])
for i in range(q):
    ans=999999999999
    x=int(input())
    w=bisect.bisect_left(s,x)
    for j in range(2):
        if not 0<=w-j<len(s):
            continue
        z=bisect.bisect_left(t,s[w-j])
        for k in range(2):
            if not 0<=z-k<len(t):
                continue
            ans=min(ans,abs(x-s[w-j])+abs(s[w-j]-t[z-k]))
    w=bisect.bisect_left(t,x)
    for j in range(2):
        if not 0<=w-j<len(t):
            continue
        z=bisect.bisect_left(s,t[w-j])
        for k in range(2):
            if not 0<=z-k<len(s):
                continue
            ans=min(ans,abs(x-t[w-j])+abs(t[w-j]-s[z-k]))
    print(ans)

Measured memory_bytes: 14368
//
//  main.cpp
//  AOJ1159
//
//  Created by aki33524 on 2014/07/15.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

void solve(int n, int p){
    vector<int> cans(n, 0);
    int peb = p;
    int pos = 0;
    
    while(1){
        if(0 < peb){
            cans[pos]++;
            peb--;
            if(cans[pos] == p)
                break;
        }else{
            peb += cans[pos];
            cans[pos] = 0;
        }
        pos = (pos+1)%n;
    }
    cout << pos << endl;
}

int main(int argc, const char * argv[])
{
    int n, p;
    while(cin>>n>>p, n|p){
        solve(n, p);
    }

    return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<string>
int main(void){
    char a[5];
    char c[]="A";
    char d[]="C";
    int b,i;
    scanf("%s",a);
    
    b=0;
    for(i=0;i<5;i++){
        if(a[i]==c[0]){
            if(a[i+1]==d[0]){
            b=b+1;
            }else{
                b=b+0;
            }
        }else{
        b=b+0;
        }
    }
    
    if(b>=1)
    printf("Yes");
    else
    printf("No");

}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong X = ulong.Parse(Console.ReadLine());
            System.Numerics.BigInteger d = 100;
            int cnt = 0;
            while (d < X || d < 0)
            {
                cnt++;
                d = d * 101 / 100;
            }
            Console.WriteLine(cnt);
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28060
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    
    vector<ll> l(90);
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i <= n; i++) {
        l[i] = l[i - 1] + l[i - 2];
    }
    put(l[n]);

    return 0;
}

Measured memory_bytes: 3608
$prime = Array.new(1000000,true)
$prime_flag = Array.new
 
def era
  k = 0
  $prime[0]=$prime[1]=false
  (2..999999).each do |i|
    next unless $prime[i]
    $prime_flag.push i
     
    j = 2 * i
    while j <= 999999
      $prime[j] = false
      j = j + i
    end
  end
end
 
era
while n = gets do
  n = n.to_i
  i = 0
  i = i + 1 while i < $prime_flag.length && n >= $prime_flag[i]
  puts i
end

Measured memory_bytes: 14656
#ABC178-b
import sys,math,collections,itertools
input = sys.stdin.readline

a,b,c,d=list(map(int,input().split()))
A = [a,b]
C = [c,d]
ans = -1*float('inf')
for ta in A:
    for tc in C:
        ans = max(ta*tc,ans)
print(ans)


Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
int n,mod,f[5010],ans=0;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
int main()
{
	scanf("%d%d",&n,&mod);f[0]=1;
	for(int i=2;i<=n;i++) for(int j=min(i-1,n-i+2);j<=n;j++) Add(f[j],f[j-min(i-1,n-i+2)]);
	for(int i=0;i<=n;i++) Add(ans,1ll*(n-i)*f[i]%mod);cout<<ans<<endl;return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    for(int i = 1; i <= n; i++) {cin >> a[i]; a[i] += a[i - 1];}
    for(int i = 1; i <= m; i++) {cin >> b[i]; b[i] += b[i - 1];}
    ll mx = 0;
    for(int i = 0; i <= n; i++){
        ll rem = k - a[i];
        ll left = -1;
        ll right = m + 1;
        while(right - left != 1){
            int middle = (left + right) / 2;
            if(b[middle] <= rem) left = middle;
            else right = middle;
        }
        if(left == -1) continue;
        mx = max(mx, i + left);
    }
    cout << mx << "\n";
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (!str.equals("0")) {
			int n = Integer.parseInt(str);
			int[] dicestate = { 1, 5, 4, 2, 3, 6, 0 };// up,north,west,south,east,down,score
			for (int i = 0; i < n; i++) {
				str = br.readLine();
				if (str.equals("North")) {
					dicestate = North(dicestate);
				} else if (str.equals("East")) {
					dicestate = East(dicestate);
				} else if (str.equals("West")) {
					dicestate = West(dicestate);
				} else if (str.equals("South")) {
					dicestate = South(dicestate);
				} else if (str.equals("Right")) {
					dicestate = Right(dicestate);
				} else {
					dicestate = Left(dicestate);
				}
			}
			System.out.println(dicestate[6]+1);
			str = br.readLine();
		}
	}

	private static int[] North(int[] dice) {
		int temporary = dice[0];
		dice[0] = dice[3];
		dice[3] = dice[5];
		dice[5] = dice[1];
		dice[1] = temporary;
		dice[6] = dice[6] + dice[0];
		return dice;
	}

	private static int[] East(int[] dice) {
		int temporary = dice[0];
		dice[0] = dice[2];
		dice[2] = dice[5];
		dice[5] = dice[4];
		dice[4] = temporary;
		dice[6] = dice[6] + dice[0];
		return dice;
	}

	private static int[] South(int[] dice) {
		int temporary = dice[0];
		dice[0] = dice[1];
		dice[1] = dice[5];
		dice[5] = dice[3];
		dice[3] = temporary;
		dice[6] = dice[6] + dice[0];
		return dice;
	}

	private static int[] West(int[] dice) {
		int temporary = dice[0];
		dice[0] = dice[4];
		dice[4] = dice[5];
		dice[5] = dice[2];
		dice[2] = temporary;
		dice[6] = dice[6] + dice[0];
		return dice;
	}

	private static int[] Right(int[] dice) {
		int temporary = dice[1];
		dice[1] = dice[2];
		dice[2] = dice[3];
		dice[3] = dice[4];
		dice[4] = temporary;
		dice[6] = dice[6] + dice[0];
		return dice;
	}

	private static int[] Left(int[] dice) {
		int temporary = dice[1];
		dice[1] = dice[4];
		dice[4] = dice[3];
		dice[3] = dice[2];
		dice[2] = temporary;
		dice[6] = dice[6] + dice[0];
		return dice;
	}
}

Measured memory_bytes: 25192
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL

using namespace std;
using llong = long long;

int main()
{
	IOS; 
	
	int n;
	cin >> n;
	cout << n * n + n + n * n * n;

	return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll A,B;
  cin>>A>>B;
  if(abs(A-B)>1)print("Alice");
  else print("Brown");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	
	int k, n;
	cin >> k >> n;
	
	int a[n+3];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int mn = 1e9;	
	mn = min (mn, a[n-1] - a[0]);
	
	for (int i = 1; i < n; ++i) {
		mn = min (mn, k - a[i] + a[i - 1]);
	}
	
	cout << mn << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
	const int days = 365;
	int d;
	std::cin >> d;

	int c[26];
	int s[days][26];

	for (int i = 0; i < 26; ++i)
		std::cin >> c[i];

	for (int i = 0; i < days; ++i)
		for (int j = 0; j < 26; ++j)
			std::cin >> s[i][j];

	int t[days];
	for (int i = 0; i < days; ++i)
	{
		std::cin >> t[i];
		t[i]--;
	}

	// 満足度の計算
	//int score = 0;
	for (int i = 0; i < days; ++i)
	{
		int maxDelta = 0;

		for (int f = 0; f < 26; ++f)
		{
			int delta = s[i][f];
			//score += s[i][t[i]];

			for (int j = 0; j < 26; ++j)
			{
				for (int k = i; k >= 0; --k)
				{
					if (t[k] != j)
						delta -= c[j];
				}
			}

			if (maxDelta == 0 || maxDelta < delta)
			{
				maxDelta = delta;
				t[i] = f;
			}
		}	
	}

	// 最適化
	/*for (int i = 0; i < days; ++i)
	{
		int maxDelta = 0;

		for (int f = 0; f < 26; ++f)
		{
			int delta = s[i][f];

			for (int j = 0; j < 26; ++j)
			{
				for (int k = i; k >= 0; --k)
				{
					if (t[k] != j)
						delta -= c[j];
				}
			}

			if (maxDelta == 0 || maxDelta < delta)
			{
				maxDelta = delta;
				t[i] = f;
			}
		}
	}*/


	for (int i = 0; i < days; ++i)
		std::cout << t[i] + 1 << std::endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
constexpr int MAX = 5000000;

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

	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll res = -INF;
	chmax(res, a * c);
	chmax(res, a * d);
	chmax(res, b * c);
	chmax(res, b * d);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3668
/* Next Alphabet */

#include <iostream>
#include <string>
using namespace std;

int main(){
  string abc[100]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
  string C;
  cin >> C;

  for(int i=0;i<100;i++){
    if(C==abc[i]){
      cout << abc[i+1] << endl;
    }
  }
}


Measured memory_bytes: 256
grade=[]
while True:
	m,f,r = map(int, input().split())
	if m==-1 and f==-1 and r==-1: break
	if m+f >= 80: grade.append("A")
	elif m+f >= 65 and m+f < 80: grade.append("B")
	elif (m+f >= 50 and m+f <65) or r >= 50: grade.append("C")
	elif m+f < 30 or m == -1 or f== -1: grade.append("F")
	elif m+f >= 30 and m+f < 50 : grade.append("D")
	

for item in grade:
	print(item)	


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
map<string,int>m;
signed main()
{
	int n;
	cin>>n;
	int ans=0;
	for (int i=0;i<n;i++){
		string s;
		cin>>s;
		if (!m[s])  m[s]=1,ans++;
	}
	cout<<ans;
	re 0;
}

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

typedef pair<int, int> pii;

int N, L, T;

vector<pii> A;
vector<int> B, C, P;

int f(int x, vector<int> &a) {
    int s = 0, e = a.size() - 1;
    int ret = -1;
    while(s <= e) {
        int m = (s + e)>>1;
        if(a[m] <= x) {
            ret = m;
            s = m + 1;
        }
        else e = m - 1;
    }
    return ret + 1;
}

int main() {
    scanf("%d %d %d", &N, &L, &T);

    A.resize(N);

    for(int i = 0; i < N; i++) {
        scanf("%d %d", &A[i].first, &A[i].second);
        if(A[i].second == 1) B.push_back(A[i].first);
        else C.push_back(A[i].first);
    }

    P.resize(N);

    for(int i = 0; i < N; i++) {
        long long q = 2*T / L;
        long long r = 2*T % L;
        int s, e;
        long long cnt;

        if(A[i].second == 1) {
            s = A[i].first;
            e = (A[i].first + r) % L;
        }
        else {
            s = (A[i].first + L - r) % L;
            e = A[i].first;
        }
        cnt = q * (long long)(A[i].second == 1? C.size() : B.size());

        if(s <= e) cnt += f(e, A[i].second == 1? C : B) - f(s - 1, A[i].second == 1? C : B);
        else {
            cnt += f(L - 1, (A[i].second == 1? C : B)) - f(s - 1, (A[i].second == 1? C : B));
            cnt += f(e, (A[i].second == 1? C : B));
        }
        P[ ((long long)i + (A[i].second == 1? cnt : (long long)N - cnt % N)) % N ] = (A[i].first + (A[i].second == 1? T : L - T % L)) % L;
    }

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


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

int main()
{
    int price[25]={},cost[25]={};
    int num;
    cin >> num;

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

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

    int sum=0;
    for(int i=0;i<25;i++){
        if(price[i]>cost[i]){
            sum += price[i]-cost[i];
        }
    }

    cout << sum << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b;
	int d,r;
	double f;
	
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define repf(i,s,e)  for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve(){
	int h1,s1,h2,s2;
	cin>>h1>>s1>>h2>>s2;

	int i=0;
	while(1){
		if(h1<=0 || h2<=0) break;
		if(i%2==0){
			h2-=s1;
		}
		else{
			h1-=s2;
		}
		i++;
	}

	if(h2<=0){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	if(fopen("input.txt", "r")){
	    freopen("input.txt", "r", stdin),
	    freopen("output.txt", "w", stdout);
	}
	
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <limits>
#include <cmath>

#define lli long
#define minimum(a,b) ((a)<(b)?(a):(b))
#define maximum(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)<0?-(a):(a))

using namespace std;

template <typename T>
class dijekstra {
	public:
		T *res;
		struct edge{
			int to;
			T cost;
		};
		vector<edge> *g;
		bool *use;
		int node_size;
		typedef pair<T,int> pdd;
		priority_queue<pdd,vector<pdd>,greater<pdd> > queue;
		dijekstra(int size){
			node_size = size;
			res = (T*)calloc(sizeof(T),size);
			g = (vector<edge>*)calloc(sizeof(vector<edge>),size);
			use = (bool*)calloc(sizeof(bool),size);
			T limit = numeric_limits<T>::max();
			for(int i = 0;i < size;i++){
				res[i] = limit;
			}
		}
		void reset(){
			T limit = numeric_limits<T>::max();
			for(int i = 0;i < node_size;i++){
				res[i] = limit;
				use[i] = false;
			}

		}
		void set_edge(int from,int to,T cost){
			edge e;
			e.to = to;
			e.cost = cost;
			g[from].push_back(e);
		}
		void start(int i){
			int k;
			res[i] = 0;
			queue.push(make_pair(res[i],i));
			while(!queue.empty()){
				k = queue.top().second;
				queue.pop();
				if(use[k]) continue;
				use[k] = true;
				for(auto x : g[k]){
					if(use[x.to]) continue;
					if(res[x.to] > res[k] + x.cost){
						res[x.to] = res[k] + x.cost;
						queue.push(make_pair(res[x.to],x.to));
					}
				}
			}
		}
};

struct circle {
	double x,y,r;
};
vector<circle> c;
int n;

double dist(circle a,circle b){
	double x = a.x-b.x;
	double y = a.y-b.y;
	double d = sqrt(x*x+y*y)-a.r-b.r;
	return d<0.0?0.0:d;
}

int main(){
	circle cir;
	cir.r = 0;
	cin >> cir.x >> cir.y;
	c.push_back(cir);
	cin >> cir.x >> cir.y;
	c.push_back(cir);
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> cir.x >> cir.y >> cir.r;
		c.push_back(cir);
	}
	dijekstra<double> dij(n+2);
	for(int i = 0;i < n+2;i++){
		for(int j = i + 1;j < n+2;j++){
			double d = dist(c[i],c[j]);
			dij.set_edge(i,j,d);
			dij.set_edge(j,i,d);
		}
	}
	dij.start(1);
	printf("%.10lf\n", dij.res[0]);
	return 0;
}

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


int key[100001],rev_key[100001];

int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) {cin>>key[i]; rev_key[key[i]] = i; }
  int c = 1,l=n;
  int p = key[1];
  while(l--)
  {
    if(p==2)
    {
      cout<<c<<"\n";
      return 0;
    }
    c++;
    p = key[p];
  }

  cout<<"-1\n";


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ff first
#define ss second
#define MAX 10005
#define endl "\n"
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define read(x) scanf("%lld",&x)
#define all(a) a.begin(),a.end()
#define write(x) printf("%lld",x)
#define rep(i,a) for(int i=0;i<a;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define pset(x,y) fixed<<setprecision(y)<<x
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#define trace1(x)							cerr << #x << ": " << x << endl;
#define trace2(x, y)						cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)						cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) 			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);	
	cin.tie(0);
	cout.tie(0);
 // 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	int n,d,a;
	cin>>n>>d>>a;
	vector<pii> v(n);
	rep(i,n) {
		cin>>v[i].ff>>v[i].ss;
	}
	sort(all(v));
	int ans = 0;
	vi pehle_ke_girane_ka_effect(n,0);
	for(int i=0,j=0;i<n;i++){
		
		while(j<n && v[j].ff <= v[i].ff + 2ll*d) j++;
		int need = max((v[i].ss - pehle_ke_girane_ka_effect[i]*a + a-1)/a,0ll);
		ans += need;
		pehle_ke_girane_ka_effect[i] += need;
		pehle_ke_girane_ka_effect[j] -= need;
		pehle_ke_girane_ka_effect[i+1] += pehle_ke_girane_ka_effect[i];
	}
	cout<<ans<<endl;
	return 0;
}


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

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

// 無限大の値
const long long INF = 1LL << 60;
int N;
long long h[100000];
bool done[100000];
long long memo[100000];

long long rec(int i){
    if(i==0) return 0;
    if(done[i] == true) return memo[i];
    else{
        long long res1 = INF;
        long long res2 = INF;
        res1 = rec(i-1) + abs(h[i] - h[i-1]);
        if(i > 1) res2 = rec(i-2) + abs(h[i] - h[i-2]);
        memo[i] = min(res1, res2);
        done[i] = true;
        return min(res1, res2);
    }
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        done[i] = false;
        memo[i] = 0;
    }

    cout << rec(N-1) << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, ll> pill;

#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 4e3 + 5;
const ll mod = 1e9+7;
const double PI = acos(-1.0);

int n;
int u[200005],v[200005];
ll fac[2*maxn],infac[2*maxn];
ll cnt[maxn][maxn];

ll po(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1)
		{
			res =(res*x)%mod;
		}
		x=x*x%mod;
		y=y>>1;
	}
	return res;
}

void init()
{
	int i,j,k;
	
	fac[0]=1;
	
	repp(i,1,8000)
	{
		fac[i]=(fac[i-1]*i)%mod;
		infac[i]=po(fac[i],mod-2);
	}
}

ll cal(int x,int y)
{
	return ((fac[x+y]*infac[x])%mod*infac[y])%mod;
}

void solve()
{
	int i,j,k;
	
	memset(cnt,0,sizeof(cnt));

	repp(i,1,n)
	{
		sa(u[i]),sa(v[i]);
		cnt[2000-u[i]][2000-v[i]]++;
	}
	for(i=0;i<=4000;i++)
	{
		for(j=0;j<=4000;j++)
		{
			if(i>0)
			{
				cnt[i][j] = (cnt[i][j]+cnt[i-1][j])%mod;
			}
			if(j>0)
			{
				cnt[i][j] = (cnt[i][j]+cnt[i][j-1])%mod;
			}
		}
	}
	ll r=0;
	repp(i,1,n)
	{
		r = (r+cnt[2000+u[i]][2000+v[i]])%mod;
		r = ((r-cal(2*u[i],2*v[i]))%mod+mod)%mod;
	}
	r = (r*po(2,mod-2))%mod;
	printf("%lld\n",r);
}

int main()
{
    init();
    while(scanf("%d",&n)!=EOF)
    {
    	solve();
    }
    return 0;
}


Measured memory_bytes: 127232
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  string s[] = {"fly", "bantam", "feather", "light"};
  double x;
  while(cin >> x) {
    if (x<=48) cout << "light fly";
    else if (x>60&&x<=64) cout << "light welter";
    else if (x>64&&x<=69) cout << "welter";
    else if (x>69&&x<=75) cout << "light middle";
    else if (x>75&&x<=81) cout << "middle";
    else if (x>81&&x<=91) cout << "light heavy";
    else if (x>91) cout << "heavy";
    else
      REP(i,4)
        if (x > 48+i*3 && x <= 48+(i+1)*3)
          cout << s[i];
    cout << endl;
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Garden
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = A_B[0];
            int B = A_B[1];
            int ans = (A - 1) * (B - 1);

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 10007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[1005];
signed main() {
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++) {
        int X = i;
        for(int j = 2; j*j <= i; j++) {
            if(X%j == 0) {
                int res = 0;
                while(X%j == 0) {
                    X/=j;
                    res++;
                }
                cnt[j]+=res;
            }
        }
        if(X != 1) {
            cnt[X]++;
        }
    }
    int ans = 1;
    for(int i = 1; i <= N; i++) {
        ans*=cnt[i]+1;
        ans%=INF;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ab(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }
    queue<int> que;
    que.push(0);
    vector<int> pred(n, -1);
    while(!que.empty()) {
        int now = que.front(); que.pop();
        for (auto p: ab[now]) {
            if (pred[p] != -1) continue;
            que.push(p);
            pred[p] = now;
        }
    }
    cout << "Yes" << endl;
    rep(i, (int)pred.size()) {
        if (i == 0) continue;
        cout << pred[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10072
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    S=str(input())
    l=len(S)
    """
    print(S[(l + 3) // 2-1:])
    print(S[l-1:(l + 3) // 2-2:-1])
    """

    if S[:(l-1)//2+1-1]==S[(l-1)//2-1::-1] and S[(l + 3) // 2-1 :]==S[l-1:(l + 3) // 2-2:-1] and \
        S==S[::-1]:
        print('Yes')
    else:
        print('No')


resolve()

Measured memory_bytes: 38384
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        var line=System.Console.ReadLine().Split();
        var line2=System.Console.ReadLine().Split();
        
        int[] data1=Array.ConvertAll(line,int.Parse);
         int[] data2=Array.ConvertAll(line2,int.Parse);
        
          Array.Sort(data2);
          int result=0;
          for(var i=0;i<data1[1];i++)
          {
              result=result+data2[i];
          }
          
          
          System.Console.WriteLine(result);
          

       
    }
}


Measured memory_bytes: 27660
N,M = map(int,input().split())
gate_list = []
while True:
  try:
    gate_list.append(list(map(int,input().split())))
  except:
    break

left_ = []
right_ = []

for i in gate_list:
  left_.append(i[0])
  right_.append(i[1])

min_ = max(left_)
max_ = min(right_)

counter = 0
for i in range(1,N+1):
  if i >= min_ and i<= max_:
    counter += 1
print(counter)

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

int main() {
  long long N;
  cin>>N;
  vector<long long>A(N);
  for(long long i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<long long>B=A;
  sort(B.begin(),B.end());
  long long C=0;
  for(long long i=0;i<N;i++){
    if(A.at(i)==B.at(N-1)){
      C=i;
    }
  }
  for(long long i=0;i<N;i++){
    if(i==C){
      cout<<B.at(N-2)<< endl;
      continue ;
    }
    cout<<B.at(N-1)<< endl;
  }
}

Measured memory_bytes: 4736
def insertionSort(A,N):
    for i in range(1,N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        show(A)
        
     
def show(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i],end=' ')
        else:
            print(nums[i])
A = []
N = int(input())
A = list(map(int,input().split()))

show(A)
insertionSort(A,N)



Measured memory_bytes: 5976
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll dx[2]={1,0};
ll dy[2]={0,1};

int main(){
    IOS;
    make(ll,n);
    make(string,s);
    ll ans=0;
    for(ll i=0;i+2<n;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

        long double l,d,ans,b=3;
        cin>>l;

        d=l/b ;
        ans= d*d*d;
        preciset(7);
        cout<<ans;
        return 0;
    }





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n, m;
    cin >> n >> m;
    vll a(n);
    rep(i, n) cin >> a[i];

    priority_queue<double> q;    
    rep(i, n) q.push(a[i]);
    rep(i, m){
        double e = q.top();
        q.pop();
        q.push(e/2);
    }
    ll s = 0;
    rep(i, n){
        double e = q.top();
        q.pop();
        s += (ll)e;
    }
    cout << s << endl;
}


Measured memory_bytes: 2168
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std; 
  
int main(){
  int n,x;
  while(1){
  int count=0;
  cin >> n >> x;
  if(n==0 && x==0)
    break;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      for(int k=j+1;k<=n;k++){
        if(i+j+k==x)
          count++;
      }
    }
  }
  cout << count << endl;
  }
}

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


int main(){
  ll l, r;
  cin >> l >> r;
  if(r-l>=2019LL){cout << 0 << endl;}
  else{
    bool f = false;
    ll min = 2018LL;
    for(ll i = l; i < r; i++){
      for(ll j = i+1; j <= r; j++){
        ll k = (i % 2019LL) * (j % 2019LL);
        if(k % 2019LL < min){min = k % 2019LL;}
        if(min == 0){f = true; break;}
      }
      if(f){break;}
    }
    cout << min << endl;
  }
}

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

typedef struct {
    int a;
    int b;
} sword_t;

int sorta(const void *a, const void *b){
    return ((sword_t*)b)->a -((sword_t*)a)->a ;
}

int sortb(const void *a, const void *b){
    return ((sword_t*)b)->b -((sword_t*)a)->b ;
}

int main(void){
    int n,h,ans=0;
    scanf("%d%d",&n,&h);
    sword_t sword[n];
    for (int i=0; i<n; i++){
        scanf("%d%d",&sword[i].a,&sword[i].b);
    }
    qsort (sword,n,sizeof(sword_t),sorta);
    int s=sword[0].a;
    qsort (sword,n,sizeof(sword_t),sortb);
    for (int i=0; i<n; i++){
        if (sword[i].b>=s){
            h-=sword[i].b;
            ans++;
        }
        if (h<=0){
            break;
        }
    }
    while (h>0){
        h-=s;
        ans++;
    }
    printf("%d\n",ans);
	return 0 ;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  string ans = "Good";
  for(int i = 1; i < n; i++){
  	if(s[i] == s[i-1]){
    	ans = "Bad";
      	break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256