akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long MAX_N = 2e6;
long long min_factor[MAX_N] = {};
void InitFact(){
    for (long long i = 2; i < MAX_N;i++){
        if (min_factor[i] != 0) continue;
        for (long long j = i; j < MAX_N; j += i) {
            min_factor[j] = i;
        }
    }
    return;
}
void Fast_Factorize(long long n,map<long long,long long>&mp){
    while(n>1){
        mp[min_factor[n]]++;
        n /= min_factor[n];
    }
    return;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll gg = 0;
    map<ll, ll> ans;
    for (ll i = 0; i < n; i++) gg = gcd(gg, a[i]);
    bool flag1 = (gg == 1 ? true : false);
	InitFact();
    for (ll i = 0; i < n; i++) {
        Fast_Factorize(a[i], ans);
    }
    bool flag2 = true;
    for (ll i = 0; i < n; i++) {
        map<ll, ll> tmp;
        Fast_Factorize(a[i], tmp);
        for (auto i:tmp){
            if (i.second - ans[i.first] != 0) {
                flag2 = false;
                goto end;
            }
        }
    }
    end:
    if (flag2) cout << "pairwise coprime" << endl;
    else if(flag1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}


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

const ll mod = 1e9 + 7;
const int INF = 1005;
const int MAXN = 105;
const int MAXM = 1005;

int G[MAXN][MAXN];
int U[MAXM], V[MAXM], W[MAXM];

int main() {
  int n, m;
  cin >> n >> m;
    
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    U[i] = a, V[i] = b, W[i] = c;
    G[a][b] = G[b][a] = c;
  }
  
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        G[i][j] = 0;
      } else if (G[i][j] == 0) {
        G[i][j] = INF;
      }
    }
  }
  
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        G[i][j] = min(G[i][k] + G[k][j], G[i][j]);
      }
    }
  }
  
  int ans = m;
  
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (G[i][U[j]] + W[j] == G[U[j]][V[j]]) {
        ans -= 1; 
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n;
    cin>>n;
    cout<<(n+1)/2;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 2e5+7;
int h[N];
int main()
{
    int n,k;cin >> n >> k;
    for(int i = 0;i < n;++i)    scanf("%d",&h[i]);
    
    sort(h,h+n,greater<int>());
    long long res = 0;
    for(int i = k;i < n;++i)
        res += h[i];
    cout << res;
    return 0;
}


Measured memory_bytes: 1024
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	ww := make([]string, n)
	for i := 0; i < n; i++ {
		ww[i] = getNextString(scanner)
	}

	ans := "Yes"

	if shiritori(n, ww) == false {
		ans = "No"
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func shiritori(n int, ww []string) bool {
	said := make(map[string]int)
	said[ww[0]] = 1
	for i := 1; i < n; i++ {
		_, ok := said[ww[i]]
		if ok == true {
			return false
		}
		said[ww[i]] = 1
		if ww[i-1][len(ww[i-1])-1] != ww[i][0] {
			return false
		}
	}
	return true
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int a,b,c,cnt,n,tmp,kg[200],t[200];
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      kg[i]=-a;
      kg[i+n]=a;
      t[i]=c;
      t[i+n]=b;
    }
    for(int i=n*2-1;i>0;i--){
      for(int j=0;j<i;j++){
    if(t[j]>t[j+1]){
      tmp=t[j];
      t[j]=t[j+1];
      t[j+1]=tmp;
      tmp=kg[j];
      kg[j]=kg[j+1];
      kg[j+1]=tmp;
    }
     
      }
    }
     
    cnt=0;
    for(int i=0;i<n*2;i++){
      // cout<<kg[i]<<' ';
      cnt+=kg[i];
      if(cnt>150){
    break;
      }
    }
    if(cnt>150){
      cout<<"NG"<<endl;
    }else{
      cout<<"OK"<<endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <map>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, p;
    string s;
    cin, n, p, s;
    if (p == 2 || p == 5) {
        ll ans = 0;
        REP(i, 0, n) {
            int num = s[i] - '0';
            if (num % p == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
    } else {
        vector<ll> m(p + 1);
        ll mod = 0, ans = 0, pow = 1;
        reverse(s.begin(), s.end());
        REP(i, 0, n) {
            m[mod]++;
            int num = s[i] - '0';
            mod = (num * pow + mod) % p;
            ans += m[mod];
            pow = (pow * 10) % p;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	rep(i,b,c+1){
		if(i%a==0){
			printf("OK");
			return 0;
		}
	} 
	printf("NG");
} 

Measured memory_bytes: 3732
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

long long a, b, n;
long long ans = 0;

void relax(long long x) {
    if (x > n)
        return;
    chkmax(ans, (a * x) / b - a * (x / b));
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> a >> b >> n;
    relax(n);
    relax(b - 1);
    relax(n / b * b - 1);
    relax((a * n) / b * b);
    long long x = n;
    forn (i, 0, 1e6 + 5) {
        relax(x);
        --x;
        if (x == 0)
            break;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3688
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

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

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let n: usize = util::get();
    let k: usize = util::get();

    let mut ans = 1;
    for _ in 0..n {
        ans = min(2 * ans, ans + k);
    }

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


Measured memory_bytes: 4352
/*input
4 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn],b[maxn];

set<int> st;

int med(int a,int b,int c){
	return a+b+c-max({a,b,c})-min({a,b,c});
}
int ans[maxn]; 
int main()
{
	IOS;
	int n,x;
	cin>>n>>x;
	REP(i,2*n-1) ans[i]=-1;
	if(x==1||x==2*n-1){
		cout<<"No\n";
		return 0;
	}
	if(x==2){
		ans[n-1]=2;
		ans[n-2]=3;
		ans[n]=1;
		ans[n+1]=4;
		int cur=5;
		REP(i,2*n-1) if(ans[i]==-1){
			ans[i]=cur;
			cur++;
		}
	}
	else{
		ans[n-1]=x;
		ans[n-2]=x-2;
		ans[n]=x+1;
		ans[n+1]=x-1;
		int cur=1;
		REP(i,2*n-1) if(ans[i]==-1){
			if(cur==x-2) cur=x+2;
			ans[i]=cur;
			cur++;
		}
	}
	cout<<"Yes\n";
	REP(i,2*n-1) cout<<ans[i]<<'\n';
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};


int main() {

	ll a,b,c,k;
	cin>>a>>b>>c>>k;

	ll t=min(k,a);
	k-=a;
	if(k>0)k-=b;
	if(k>0)t-=k;
	cout<<t<<endl;

	return 0;
}


Measured memory_bytes: 3636
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif


int a,b;
cin>>a>>b;

	int max=a*3+b;
	cout<<max/2<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define NMAX 45

int dp[NMAX];

int Fibonacci(int n){
  if((n == 0) || (n == 1)){
    return dp[n] = 1;
  }
  if(dp[n] != -1){
    return dp[n];
  }
  return dp[n] = Fibonacci(n - 1) + Fibonacci(n - 2);
}

int main(void){
  int i,n;

  for(i = 0;i < NMAX;i++){
    dp[i] = -1;
  }

  scanf("%d",&n);
  printf("%d\n",Fibonacci(n));

  return 0;
}

  



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

using namespace std;

using ll = int;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, w; cin >> h >> w;
    vector<string> m(h); cin >> m;
    const ll n = w/2;
    bool can_pal[12];
    rep(x, w) {
        vector<ll> cnt(26, 0);
        rep(y, h) {
            cnt[m[y][x]-'a']++;
        }
        vector<ll> cnt2(2, 0);
        rep(i, 26) cnt2[cnt[i]%2]++;
        can_pal[x] = cnt2[1] == h % 2;
    }
    vector<int> upper((w+1)/2), lower(n);
    rep(_S, 1<<(w-1)) {
        if (__builtin_popcountll(_S) != (w+1)/2-1) continue;
        ll S = (_S<<1)|1;
        upper.clear();
        lower.clear();
        rep(i, w) {
            if (S>>i & 1) upper.pb(i);
            else lower.pb(i);
        }
        sort(all(upper));
        do {
            // 最後は回文にできるか
            if (upper.size() != n && !can_pal[upper.back()]) continue;
            // マッチングできるか
            map<string, ll> cnt;
            rep(y, h) {
                string s = "";
                rep(i, n) s += m[y][upper[i]];
                rep(i, n) s += m[y][lower[i]];
                cnt[s]++;
            }
            ll odd = 0;
            bool f = true;
            each(p, cnt) {
                string rs = p.first;
                reverse(all(rs));
                if (p.first == rs) {
                    if (p.second % 2 == 1) if (++odd > 1) {
                        f = false;
                        break;
                    }
                }
                else if (cnt[rs] != p.second) {
                    f = false;
                    break;
                }
            }
            if (f) {
                cout << "YES" << endl;
                exit(0);
            }
        } while (next_permutation(all(upper)));
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

x=I()
for i in range(x,x*100):
    fl=True
    for j in range(2,int(x**0.5)+1):
        if i%j==0:
            fl=False
            break
    if fl:
        print(i)
        exit()




Measured memory_bytes: 39404
import java.io.*;

public class Main {

  static int n, pos, ansInp;
  static int[] pre, inp, post;

  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    Tree t = new Tree();

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);

    for(int i = 0; i < n; i++){
      in = br.readLine().split(" ");
      if(in[0].equals("insert")){
        t.insert(new Node(Integer.parseInt(in[1])));
      }else if(in[0].equals("print")){
        t.print();
      }else if(in[0].equals("find")){
        System.out.println(t.find(Integer.parseInt(in[1])) ? "yes" : "no");
      }
    }

    br.close();

  }
}


class Node {
  int v;
  Node p, l, r;

  Node(int v){
    this.v = v;
  }
}

class Tree {

  Node root;

  public Node insert(Node node){
    Node par = null;
    Node now = root;

    while(now != null){
      par = now;
      if(node.v > now.v) now = now.r;
      else now = now.l;
    }
    node.p = par;

    if(par == null) {
      this.root = node;
    }else if(node.v < par.v) {
      par.l = node;
    }else {
      par.r = node;
    }
    return node;
  }

  void print(){
    inorderPrint(this.root);
    System.out.println();
    preorderPrint(this.root);
    System.out.println();
  }

  void preorderPrint(Node node){
    System.out.print(' ');
    System.out.print(node.v);
    if(node.l != null)
      preorderPrint(node.l);
    if(node.r != null)
      preorderPrint(node.r);
    return;
  }

  void inorderPrint(Node node){
    if(node.l != null)
      inorderPrint(node.l);
    System.out.print(' ');
    System.out.print(node.v);
    if(node.r != null)
      inorderPrint(node.r);
    return;
  }

  boolean find(int x){
    boolean ret = false;
    Node now = root;
    while(now != null){
      if(now.v == x){
        ret = true;
        break;
      }else if(now.v > x){
        now = now.l;
      }else{
        now = now.r;
      }
    }
    return ret;
  }
}


Measured memory_bytes: 186368
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
const int N =1e4+5;
map<char , int>mp;
string s[3];
bool a,b,c;
int main(){
    for(int i=0;i<3;i++) 
      {
       cin>>s[i];
       reverse(s[i].begin(),s[i].end());
      }
      char t=s[0][s[0].size()-1];
       s[0].pop_back();
      while (1)
      {
           if(t=='a')
           {
               if(!s[0].empty())
               {
                    {
                         t=s[0][s[0].size()-1];
                         s[0].pop_back();
                    }
               }
               else{printf("A\n");break;}
           }
           else if(t=='b')
           {   
                if(!s[1].empty())
                {
                     t=s[1][s[1].size()-1];
                     s[1].pop_back();
                }
                else{printf("B\n");break;}
           }
           else if(t=='c')
           {
                if(!s[2].empty())
                {
                     t=s[2][s[2].size()-1];
                     s[2].pop_back();
                }
                else{printf("C\n");break;}
           }    
      }
}


Measured memory_bytes: 256
import sys

S = sys.stdin.readline().strip()
ls = len(S)

if ls == 26 and list(S) == sorted(S, reverse=True):
    print(-1)
    sys.exit()

alpha = "abcdefghijklmnopqrstuvwxyz"
exists = set(S)
if ls < 26:
    for a in alpha:
        if a not in exists:
            print(S + a)
            sys.exit()
else:
    for i in range(ls):
        tmp = S[ls-1-i:] 
        if list(tmp) != sorted(tmp, reverse=True):
            break
    last = S[ls-i-1]
    for r in sorted(S[ls-i:], reverse=True):
        if last < r:
            min_a = r
    # min_a = sorted(remain)[0]
    print(S[:ls-i-1] + min_a)

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

ll dp[51][51][2501];
int N,A;

int main() {
	cin >> N >> A;
	dp[0][0][0]=1;
	for (int i=0;i<N;i++) {
		int ai;cin >> ai;
		for (int j=0;j+ai<=2500;j++) for (int k=0;k<50;k++) {
			dp[i+1][k][j]+=dp[i][k][j];
			dp[i+1][k+1][j+ai]+=dp[i][k][j];
		}
	}

	ll r=0;
	for (int num=1;num<=N;num++) r+=dp[N][num][num*A];
	cout << r << endl;
}

Measured memory_bytes: 50048
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,M,a[3]={-1,-1,-1},n=0,s,c;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>s>>c;s--;
		if(a[s]==-1)a[s]=c;
		else if(a[s]!=c){cout<<-1;return 0;}
	}
	for(int i=0;i<N;i++){
		if(a[i]==-1){
			if(i!=0 || (i==0&&N==1))a[i]=0;
			else a[i]=1;
		}
	}
	for(int i=0;i<N;i++){
		n*=10;
		n+=a[i];
	}
	if(N>1&&a[0]==0)cout<<-1;
	else cout<<n;
	return 0;
}

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

using LL  = long long int;

using namespace std;

string S;

string calc(bool flag, int k)
{
  string ret;
  vector<int> vec;
  for (int i = 0; i < 10; i++) {
    vec.push_back(i);
  }

  int N = S.length();
  for (size_t i = 0; i < k; i++) {
    int num = S[i] - '0';

    bool forloop = false;
    for (size_t j = 0; j < vec.size(); j++) {
      if(vec[j] == num){
        forloop = true;
        ret += num + '0';
        vec.erase(vec.begin() + j);
      }
    }

    if(!forloop){
      return "";
    }

  }

  if(k == N){
    return ret;
  }

  int num = S[k] - '0';

  //??§???????????????????????????
  if(!flag){
    auto it = upper_bound(vec.begin(), vec.end(), num);

    if(it == vec.end()){
      return "";
    }

    ret += (*it) + '0';
    vec.erase(it);

    for (size_t j = 0; j < vec.size() && ret.length() < N; j++) {
      ret += vec[j] + '0';
    }

    if(ret.length() != N){
      return "";
    }

    return ret;
  }
  //?°????????\´???????????????
  else{
    auto it = lower_bound(vec.begin(), vec.end(), num);

    if(it == vec.begin()){
      return "";
    }

    it--;
    ret += (*it) + '0';
    vec.erase(it);

    for (int j = vec.size()-1; 0 <= j && ret.length() < N; j--) {
      ret += vec[j] + '0';
    }

    if(ret.length() != N){
      return "";
    }

    return ret;
  }

  return ret;
}

LL convToLL(string str)
{
  LL ret = 0;
  for (size_t i = 0; i < str.length(); i++) {
    ret *= 10;
    ret += str[i] - '0';
  }
  return ret;
}

string convToString(LL num, int k)
{
  string ret;
  while(num){
    ret += (num % 10) + '0';
    num /= 10;
  }
  while(ret.length() < k){
    ret += '0';
  }

  reverse(begin(ret), end(ret));

  return ret;
}

bool comp(const string &A, const string &B)
{
  if(A == ""){
    return false;
  }
  else if(B == ""){
    return true;
  }
  else{
    LL AA = convToLL(A), BB = convToLL(B);
    LL tmpS = convToLL(S);
    if(min(abs(AA - tmpS), (LL)pow((LL)10, S.length()) - (LL)abs(AA - tmpS)) >
    min(abs(BB - tmpS), (LL)pow((LL)10, S.length()) -(LL)abs(BB - tmpS))){
      return false;
    }
    else if(min(abs(BB - tmpS), (LL)pow((LL)10, S.length()) - (LL)abs(BB - tmpS)) >
  min(abs(AA - tmpS), (LL)pow((LL)10, S.length()) - (LL)abs(AA - tmpS))){
      return true;
    }
    else{
      if(A < B){
        return true;
      }
      else{
        return false;
      }
    }
  }
}

int main()
{
  cin >> S;

  LL tmpS = convToLL(S);

  tmpS -= pow(10, S.length())/2;
  if(tmpS < 0){
    tmpS += pow(10, S.length());
  }

  S = convToString(tmpS, S.length());

  vector<string> ans;
  for (size_t i = 0; i <= S.size(); i++) {
    string tmp = calc(false, i);
    if(tmp != ""){
      ans.push_back(tmp);
    }
    tmp = calc(true, i);
    if(tmp != ""){
      ans.push_back(tmp);
    }
  }

  sort(begin(ans), end(ans), comp);

  cout << ans[0] << endl;

  return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int n, m, q, ans = 0;
vector<int> a, b, c, d;

void dfs(vector<int> v){
  if(v.size() == n+1){
    int tmpans = 0;
    rep(i,q){
      if(v[b[i]] - v[a[i]] == c[i]) tmpans += d[i];
    }
    ans = max(tmpans, ans);
    return; //大事
  }
  v.push_back(v.back());
  while(v.back() <= m){
    dfs(v);
    ++v.back();
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    //cout << i << endl;
  }
  dfs({1});
  cout << ans << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <class T>
struct segtree {
    int n;
    T e = 1e9;
    vector<T> node;
    vector<T> lazy;
    vector<bool> flag;
    function<T(T, T)> f = [&](T a, T b) { return min(a, b); };  // node-node
    function<T(T, T)> g = [&](T a, T b) { return min(a, b); };  // node-lazy if add a + b

    segtree() : segtree(0) {}
    segtree(int _n) : segtree(vector<T>(n, e)) {}
    segtree(vector<T> v) {
        n = 1 << (32 - __builtin_clz((int)v.size() - 1));
        node.resize(2 * n - 1, e);
        lazy.resize(2 * n - 1, e);
        flag.resize(2 * n - 1);
        for (int i = 0; i < (int)v.size(); i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = f(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }

    void eval(int x, int l, int r) {
        if (!flag[x]) {
            return;
        }
        node[x] = g(node[x], lazy[x]);
        // node[x] = g(node[x], lazy[x]) * (r - l);  // RSQ
        if (r - l > 1) {
            lazy[x * 2 + 1] = g(lazy[x * 2 + 1], lazy[x]);
            lazy[x * 2 + 2] = g(lazy[x * 2 + 2], lazy[x]);
            flag[x * 2 + 1] = flag[x * 2 + 2] = true;
        }
        lazy[x] = e;
        flag[x] = false;
    }

    void update(int a, int b, T v, int x, int l, int r) {
        eval(x, l, r);
        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            lazy[x] = g(lazy[x], v);
            flag[x] = true;
            eval(x, l, r);
        } else {
            update(a, b, v, 2 * x + 1, l, (l + r) / 2);
            update(a, b, v, 2 * x + 2, (l + r) / 2, r);
            node[x] = f(node[2 * x + 1], node[2 * x + 2]);
        }
    }

    T get(int a, int b, int x, int l, int r) {
        eval(x, l, r);
        if (b <= l || r <= a) {
            return e;
        }
        if (a <= l && r <= b) {
            return node[x];
        }
        T vl = get(a, b, 2 * x + 1, l, (l + r) / 2);
        T vr = get(a, b, 2 * x + 2, (l + r) / 2, r);
        return f(vl, vr);
    }

    void update(int a, int b, T v) {
        update(a, b, v, 0, 0, n);
    }

    T get(int a, int b) {
        return get(a, b, 0, 0, n);
    }

    T get(int a) {
        return get(a, a + 1, 0, 0, n);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<segtree<int>> st(2, segtree<int>(vector<int>(n - 2, n - 2)));
    debug(st[0].get(2));
    long long ans = 1LL * (n - 2) * (n - 2);
    while (q--) {
        int t, x;
        cin >> t >> x;
        t--, x -= 2;
        int y = st[t].get(x);
        ans -= y;
        st[t ^ 1].update(0, y, x);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 16404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  if( s.size()<=3){
    cout << "No"<<endl;
    return 0;
  }
  if( s.at(0)== 'Y' &&s.at(1)=='A'&&s.at(2)=='K'&&s.at(3)=='I'){
    cout << "Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if(n == 1 && m == 0) {
			System.out.println(0);
			System.exit(0);
		}
		int[] seisu = new int[n];
		Map<Integer, Integer> sici = new HashMap<>();
		for(int i = 0; i < m; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();
			if(sici.containsKey(s)) {
				if(sici.get(s) != c) {
					System.out.println(-1);
					System.exit(0);
				}
			}
			sici.put(s, c);
			seisu[s - 1] = c;
		}

		if(!sici.containsKey(1)) {
			seisu[0] = 1;
		}

		if(n != 1 && seisu[0] == 0) {
			System.out.println(-1);
			System.exit(0);
		}

		for(int value : seisu) {
			System.out.print(value);
		}

		sc.close();
	}
}

Measured memory_bytes: 21716
let for_range s e step f =
  let rec loop i =
    if i > e then ()
    else
      begin f i;loop (i + step) end
  in loop s;;
let a =
  let num = 1000000 in
  let p = Array.init (num+1) (fun x -> 1) in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then
          begin
            p.(i*2) <- 0;
            for_range (i*3) num (i*2) (fun x -> p.(x) <- 0);
          end;
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0);
  for_range 4 num 2 (fun x -> p.(x) <- 0);
  loop 3;
  for i = 1 to num-1 do
    p.(i) <- p.(i) + p.(i-1);
  done;
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" p.(n);
        read ()
    with End_of_file -> ()
  in read ();;

Measured memory_bytes: 10268
#include<stdio.h>
#include<string.h>
int main()
{
  int N,len,i,j,sum=0;
  scanf("%d",&N);
  char s[N];
  scanf("%s",s);
  len=strlen(s);
  for(i=0;i<len;i++)
  {
	if(s[i]=='A')
	{
		if(s[i+1]=='B' && s[i+2]=='C')
		{
			sum++;
			i=i+2;
		}
	}
	else continue;
  }
  printf("%d",sum);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005,M=1e9+7;
int n,m,f[N];
int main(){
	scanf("%d%d",&n,&m);
	f[n+1]=1;
	for (int i=1;i<m;i++){
		int sum=f[n-i+2];
		for (int j=n-i+1;j>=2;j--){
			(sum+=f[j])%=M;
			if (j<=n-i+1)f[j]=sum;
		}
	}
	int ans=0;
	if (m==1)ans=1;
	else for (int j=2;j<=n-(m-1)+1;j++)(ans+=f[j])%=M;
	for (int i=1;i<=n-m-1;i++)(ans*=2)%=M;
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define N 800002
typedef long long ll;
vector<int>v[N];
int n,m,a[N][2],rt,id[1002][1002],ie[1002][1002];
bool re[1002][1002],vis[1002],nx[1002][1002];
void dfs(int te)
{
	for(int i=0;i<v[te].size();i++)
	{
		int j=v[te][i];
		if(!re[rt][j])re[rt][j]=1,dfs(j);
	}
}
void df55(int te,int ti)
{//printf("%d ",te);
	for(int i=0;i<v[te].size();i++)
	{
		int j=v[te][i];if(te==rt)ti=i+1;
		if(!vis[j])
		{
			vis[j]=1;
			if(id[rt][j]&&id[rt][j]!=ti)nx[rt][j]=1;
			id[rt][j]=ti;df55(j,ti);
		}
	}
}
void df5(int te,int ti)
{//printf("%d ",te);
	for(int i=((int)v[te].size())-1;~i;i--)
	{
		int j=v[te][i];if(te==rt)ti=i+1;
		if(!vis[j])
		{
			vis[j]=1;
			if(id[rt][j]&&id[rt][j]!=ti)nx[rt][j]=1;
			id[rt][j]=ti;df5(j,ti);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);v[x].push_back(y);
		a[i][0]=x,a[i][1]=y;
	}
	for(int i=1;i<=n;i++)
	{
		rt=i,re[rt][rt]=1,dfs(i);
		for(int j=1;j<=n;j++)vis[j]=0;vis[i]=1;
		df55(i,0);for(int j=1;j<=n;j++)vis[j]=0;vis[i]=1;
		df5(i,0);
	}
	for(int i=1;i<=m;i++)
	{
		if(re[a[i][1]][a[i][0]]^nx[a[i][0]][a[i][1]])puts("diff");
		else puts("same");
	}
}


Measured memory_bytes: 33408
#include <iostream>
using namespace std;
int a[100000];
int main(){
  int n,m;
  cin>>n>>m;
  int s=0;
  for(int i=0;i<m;++i){
    int x=0;
    cin>>x;
    s+=x;
  } 
  if(s>n)  cout<<-1;
  else cout<<n-s;
  
}

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

 using namespace std;
int main() {
    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; ++i) cin >> B[i];
    int res = 0;
    for (int i = 0; i < N; ++i) {
        int sum = C;
        for (int j = 0; j < M; ++j) {
            int a; cin >> a; sum += a * B[j];
        }
        if (sum > 0) ++res;
    }
    cout << res << endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[u]++, a[v]++;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] & 1) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long fact[2001];
void extgcd(int a,int b,int&x,int&y){
	if(b!=0){
		extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
}
int mod_inverse(int a){
	int x,y;
	extgcd(a,mod,x,y);
	return(mod+x%mod)%mod;
}
long long mod_comb(int n,int k){
	if(n<0||k<0||n<k)
		return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%mod)%mod;
}
int main(){
	fact[0]=1;
	for(int i=1;i<=2000;i++)
		fact[i]=fact[i-1]*i%mod;
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++)
		cout<<mod_comb(k-1,i)*mod_comb(n-k+1,i+1)%mod<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;
typedef pair<int, int> pii;
 
 
int main() {
    int N;
    cin >> N;
    int m = INT_MAX;
    int M = 0;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        m = min(a, m);
        M = max(a, M);
    }
    cout << M - m << endl;
    return 0;
}


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

int main(void){
  char str1[8],str2[101],str3[8];
  scanf("%s %s %s",str1,str2,str3);
  printf("%c%c%c\n",str1[0],str2[0],str3[0]);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int f[10]={0,0,9,0,909,0,90909,0};
int getbit(int n){
	if(n<10) return 1;
	else if(n<100) return 2;
	else if(n<1000) return 3;
	else if(n<10000) return 4;
	else if(n<100000) return 5;
	else if(n<1000000) return 6;
}
int main(){
	int n;
	cin>>n;
	int ans=0;
	int bit=getbit(n);
//	cout<<bit<<" ";
	if(bit%2==0){
		ans=f[bit];
	}
	else{
		ans=f[bit-1];
		ans+=n-pow(10,bit-1);
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
         int ans;
         int a,b;
         int S=0,T=0;
         for(int i=0;i<4;i++){
                 cin>>a;
                  S+=a;
          }
         for(int j=0;j<4;j++){
                   cin>>b;
                   T+=b;
          }
          ans=max(S,T);
           cout<<ans<<endl;
           return 0;
}

Measured memory_bytes: 1164
S = input()
N = len(S)
ans = 0
stack = [(0,0,1)]
while stack:
  t,s,g = stack.pop()
  if g >= N:
    ans+=t+int(S[s:g])
  else:
    stack.append((t,s,g+1))
    stack.append((t+int(S[s:g]),g,g+1))
print(ans)

Measured memory_bytes: 62848
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    auto width = [&](const vector<int>& x, const vector<int>& y, double kx) {
        const int n = x.size();
        double lb = INF, ub = -lb;
        for(int i : in(n)) {
            double x1 = x[i], y1 = y[i];
            double x2 = x[(i + 1) % n], y2 = y[(i + 1) % n];
            if((x1 - kx) * (x2 - kx) <= 0 && x1 != x2) {
                double crossy = y1 + (y2 - y1) * (kx - x1) / (x2 - x1);
                lb = min(lb, crossy);
                ub = max(ub, crossy);
            }
        }
        return max(0.0, ub - lb);
    };
    int p1, p2;
    while(cin >> p1 >> p2 && p1) {
        vector<int> x1(p1), y1(p1), x2(p2), y2(p2);
        vector<int> xs;
        for(int i : in(p1)) {
            cin >> x1[i] >> y1[i];
            xs.emplace_back(x1[i]);
        }
        for(int i : in(p2)) {
            cin >> x2[i] >> y2[i];
            xs.emplace_back(x2[i]);
        }
        const int min1 = *min_element(x1.begin(), x1.end()), max1 = *max_element(x1.begin(), x1.end());
        const int min2 = *min_element(x2.begin(), x2.end()), max2 = *max_element(x2.begin(), x2.end());
        
        sort(xs.begin(), xs.end());
        double res = 0;
        for(int i : in(xs.size() - 1)) {
            double l = xs[i], r = xs[i + 1], mid = (l + r) / 2.0;
            if(min1 <= mid && mid <= max1 && min2 <= mid && mid <= max2) {
                const double fa = width(x1, y1, l) * width(x2, y2, l);
                const double fb = width(x1, y1, r) * width(x2, y2, r);
                const double fc = width(x1, y1, mid) * width(x2, y2, mid);
                res += (r - l) / 6 * (fa + 4 * fc + fb);
            }
        }
        cout << fixed << setprecision(10) << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    string str; cin >> str;
    bool a = false;
    bool b = false;
    rep(i, str.size()){
        if(str[i] == 'A') a = true;
        else b = true;
    }
    if(a && b){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
ac = [0] * (N+1)
wa = 0

for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ac[p] != -1:
            wa += ac[p]
            ac[p] = -1


    else:
        if ac[p] != -1:
            ac[p] += 1

print(ac.count(-1), wa)

Measured memory_bytes: 3956
import math
def solve(s):
    a,b = s.split(" ")
    c = int(a + b)
    if c == int(math.sqrt(c)) * int(math.sqrt(c)):
        return "Yes"
    else:
        return "No"

if __name__ == '__main__':
    s = input()
    print(solve(s))


Measured memory_bytes: 3316
n,m=map(int,input().split())
cnt1=[0]*(n+1)
cnt2=[0]*(n+1)
for _ in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if cnt1[p]==1:
    continue
  else:
    if s=='AC':
      cnt1[p]=1
    else:
      cnt2[p]+=1
ans1=0
ans2=0
for i in range(1,n+1):
  if cnt1[i]==1:
    ans1+=1
    ans2+=cnt2[i]
print(ans1,ans2)

Measured memory_bytes: 4596