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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      a: usize,
      b: usize,
    }
    if a <= 5 {
        return println!("{}", 0);
    } else if a <= 12 {
        return println!("{}", b/2)
    } else {
        println!("{}", b);
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mod = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,m,r;
    cin>>n>>m>>r;
    vector<int> ri(r);
    for(auto & a : ri)cin>>a,a--;
    vector<vector<ll>> dp(n,vector<ll>(n,infl));
    for(int i=0;i<n;++i)dp[i][i] = 0;
    for(int i=0;i<m;++i){
        int a,b;ll c;
        cin>>a>>b>>c;
        a--;b--;
        dp[a][b] = min(dp[a][b],c);
        dp[b][a] = min(dp[b][a],c);
    }
    for(int i=0;i<n;++i)for(int j=0;j<n;++j)for(int k=0;k<n;++k){
        dp[j][k] = min(dp[j][k],dp[j][i] + dp[i][k]);
    }
    ll mi = infl;
    sort(ri.begin(),ri.end());
    do{
        ll tmp =0ll;
        for(int i=0;i<r-1;++i)tmp += dp[ri[i]][ri[i+1]];
        mi = min(mi,tmp);
    }while(next_permutation(ri.begin(),ri.end()));
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int a,b,c,d,t,t2;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        if(a<=b)
            t=a;
        else
            t=b;

        if(c<=d)
            t2=c;
        else
            t2=d;
        printf("%d\n",t+t2);
    }

    return 0;
}



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

int main()
{
	long long X, Y;
	scanf("%lld %lld", &X, &Y);
	
	int n;
	long long x;
	for (n = 0, x = X; x <= Y; n++, x *= 2);
	
	printf("%d\n", n);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#define SIZE 200000
using namespace std;
  
struct Queue{
  int table[SIZE];
  int tail,head;
  
  void init(){
    head=tail=0;
  }
  
  bool empty(){
    return head==tail;
  }
    
  void inqueue(int x){
    table[tail]=x;
    tail++;
    tail%=SIZE;
  }
  
  int dequeue(){
    if(empty())return 0;
    int res=table[head];
    head++;
    head%=SIZE;
    return res;
  }
};
  
int main(){
  Queue queue,queue2;
  int n,q,num;
  string table[SIZE];
  cin>>n>>q;
  queue.init();
  queue2.init();
  for(int i=0;i<n;i++){
    cin>>table[i]>>num;
    queue.inqueue(num);
    queue2.inqueue(i);
  }
    
  int now=0,A,B;
  while(!queue.empty()){
    A=queue.dequeue();
    B=queue2.dequeue();
    if(A<=q){
      now+=A;
      cout<<table[B]<<' '<<now<<endl;
    }else{
      now+=q;
      A-=q;
      queue.inqueue(A);
      queue2.inqueue(B);
    }
  }
    
  return 0;
}


Measured memory_bytes: 8412
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back


int main(){
    

    int n;
    int ud=0;
    int ans=0;
    int count=0;



    while(1){
            vector<string> v;

        ans=0;
        ud=0;
            cin>>n;

        if(n==0)break;


        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            v.push_back(s);
        }

        for(int i=0;i<v.size()-1;i++){
            string s,t;
            s=v[i];
            t=v[i+1];

            

            if(s[1]=='u'&&t[1]=='u'&&ud==0){
                ans++;
                ud=1;
                i++;
            }else if(s[1]=='d'&&t[1]=='d'&&ud==1){
                ans++;
                ud=0;
                i++;
            }

            // cout<<s<<" "<<t<<" "<<ud<<" "<<ans<<endl;


        }

        cout<<ans<<endl;

    }
}

Measured memory_bytes: 3156
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  
using namespace __gnu_pbds; 
mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {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;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;

typedef tree<
pii,
null_type,
less<pii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int N = 3e5 + 123;

int n, m, l;

int a[N];
map < int , int > cnt;
int dp[104][104];
char ch[103][103];
main(){

	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x,y;
	cin >> x >> y;
	int res = 1;
	while(x * 2ll <= y)
		res++ , x *= 2ll;
	ret(res);
//	3 6 12



}
 


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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;

//iostream::sync_with_stdio(false);

const int maxn = 1e4 + 5;

int main()
{
	int n, k;
	cin >> n >> k;
	set<int>s;
	while(k--)
	{
		int d;
		int x;
		cin >> d;
		for (int i = 1; i <= d; i++)
		{
			cin >> x;
			s.insert(x);
		}
	}
	cout << n - s.size() << endl;
	return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

string S;
int ans;

int main() {
    cin >> S;
    rep(i, S.length()) {
        ans += (S[i] - '0');
        ans %= 9;
        //cout << ans << endl;
    }
    cout << Yes(ans == 0) << endl;
}

Measured memory_bytes: 3736
N = gets.to_i
h_arr = gets.split(" ").map{|s| s.to_i }
memo = [0, 0]

N.times {|n|
    if n == 0
        next
    elsif n == 1
        cost1 = (h_arr[n-1] - h_arr[n]).abs
        memo[1] += cost1
    elsif n % 2 == 0
        cost1 = (h_arr[n-1] - h_arr[n]).abs + memo[1]
        cost2 = (h_arr[n-2] - h_arr[n]).abs + memo[0]
        memo[0] = cost1 < cost2 ? cost1 : cost2
    else
        cost1 = (h_arr[n-1] - h_arr[n]).abs + memo[0]
        cost2 = (h_arr[n-2] - h_arr[n]).abs + memo[1]
        memo[1] = cost1 < cost2 ? cost1 : cost2
    end
}

puts memo[(N+1) % 2]

Measured memory_bytes: 9996
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int x = 0, y = 0;
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      x += s[i] == '0';
      y += s[i] == '1';
    } else {
      x += s[i] == '1';
      y += s[i] == '0';
    }
  }
  cout << min(x, y) << '\n';
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  double a;
  in(a);
  out(a * 2.0 * 3.14159);
  memi;
}

Measured memory_bytes: 3816
#include"stdio.h"
#include"string.h"
#include"algorithm"
   using namespace std;
int main()
{
   char str[11];
   scanf("%s",str);
   int maxlen=0;
   int cnt=0;
   int len=strlen(str);
   str[len++]='B';
   str[len]='\0';
   for(int i=0;i<len;i++)
   {
       if(str[i]=='A'||str[i]=='T'||str[i]=='C'||str[i]=='G')
          {
              cnt++;continue;
          }
       maxlen=max(maxlen,cnt);cnt=0;
   }
   printf("%d\n",maxlen);
}


Measured memory_bytes: 128
def factorize(n):
    fct=[]
    b,e=2,0
    while b*b<=n:
        while n%b==0:
            n=n//b
            e=e+1
        if e>0:
            fct.append((b,e))
        b,e=b+1,0
    if n>1:
        fct.append((n,1))
    return fct
n=int(input())
while True:
    l=factorize(n)
    if len(l)==1 and l[0][1]==1:
        print(n)
        exit()
    else:
        n+=1

Measured memory_bytes: 3064
from collections import Counter

N = int(input())
s = []
for i in range(N):
    s.append(input())

sc = Counter(s)
maxNum = sc.most_common()[0][1]
keys = [k for k , v in sc.most_common() if v == maxNum]
keys.sort()
for word in keys:
    print(word)



Measured memory_bytes: 45040
#include <stdio.h>

int main(void) {
    int a, b;

    scanf("%d %d", &a, &b);

    if (a - 2 * b > 0) {
        printf("%d\n", a - 2 * b);
    } else {
        printf("%d\n", 0);
    }

    return 0;
}


Measured memory_bytes: 128
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0) 
#define inf                   1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};
vector<int> adj[100010],dis(100010,inf),par(100010,0);
vector<vector<int>> vis(15,vector<int> (15,0)),state(15,vector<int> (15,0));

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    vector<int> v(n+1,0);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    vector<int> vis(n+1,0);
    vector<int> ans;
    for(int i=n;i>=1;i--)
    {
        int cnt=0;
        for(int j=2;j*i<=n;j++)
        {
            if(vis[j*i]==1)
            {
                cnt++;
            }
        }
        if(v[i]%2!=cnt%2)
        {
            vis[i]=1;
            ans.pb(i);
        }
    }
    sort(all(ans));
    cout<<(int)ans.size()<<endl;
    for(auto i:ans)
        cout<<i<<" ";
    cout<<endl;
}


Measured memory_bytes: 6264
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

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

  int anser[N] = {};
  rep(i,M){
    int a,b;
    scanf("%d%d",&a,&b);
    anser[a - 1]++;
    anser[b - 1]++;
  }
  
  for(int i : anser) printf("%d\n",i);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a;
  cin>>a;
  int i,j,k=0;
  for(i=0;i<a.length();i++)
  {
    for(j=i;j<a.length();j++)
    {
      if(a[i]!=a[j])
      {
        k=1;
      }
    }
  }
  if(k)
    cout<<"Yes";
  else
    cout<<"No";
}
  


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;

int main() {
	int X;
	cin >> X;
	int d, r;
	d = X / 100;
	r = X % 100;
	if(d*5<r){
		cout << 0;
	}else{
		cout << 1;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int MOD = (int)1e9 + 7;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    VI ways(7);
    ways[0] = 1;
    ways[1] = 2;
    FOR(i, 2, 6) {
        int way = 0;
        REP(bit, (int)pow(2, i)) {
            REP(j, i - 1) {
                if((bit >> j & 1) == 1 and (bit >> (j + 1) & 1) == 1)
                    break;
                if(j == i - 2) way++;
            }
        }
        ways[i] = way;
    }

    VVL dp(h + 1, VL(w + 2, 0));
    dp[0][1] = 1;
    FOR(i, 1, h)FOR(j, 1, w) {
        dp[i][j] = (dp[i][j] 
            + dp[i - 1][j - 1] * ways[max(j - 3, 0)] * ways[max(w - j - 1, 0)]) % MOD;
        dp[i][j] = (dp[i][j] 
            + dp[i - 1][j] * ways[max(j - 2, 0)] * ways[max(w - j - 1, 0)]) % MOD;
        dp[i][j] = (dp[i][j] 
            + dp[i - 1][j + 1] * ways[max(j - 2, 0)] * ways[max(w - j - 2, 0)]) % MOD;
    }

    cout << dp[h][k] << endl;
    return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  int sum=x1+x2+x3+x4+x5;
  int res=15-sum;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

/*
int main() {
	int checker = 0, counter = 0;
	int N = 10;
	cin >> N;
	int* A = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	while (1) {
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 1) {
				checker = 1;
				break;
			}
		}
		if (checker == 0) {
			counter++;
			for (int i = 0; i < N; i++) {
				A[i] = A[i] / 2;
			}
		}
		else {
			break;
		}
	}
	
	cout << counter << endl;
}
*/

int main() {
	int N, op = 0;
	
	cin >> N;

	int* A = new int[N];
	int* counter = new int[N];

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		counter[i] = 0;
		while (1) {
			if (A[i] % 2 == 0) {
				A[i] = A[i] / 2;
				counter[i]++;
			}
			else {
				break;
			}
		}
	}
	op = counter[0];
	for (int i = 0; i < N-1; i++) {
		if (op > counter[i + 1]) {
			op = counter[i + 1];
		}
	}

	cout << op << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
ll M=1000000007;
char s[200000];
char c;
int t=0;

int top=0;
int a[200000];

ll f[200000][20];
bool flag[200000][20];

ll dp(int now,int r)
{
    if (now>top)
    {
        if (r==0) return 1;
        else return 0;
    }
    if (flag[now][r]) return f[now][r];
    flag[now][r]=1;
    
    for (int i=0; i<=9; ++i)
    {
        ll num = (a[now]*i)%13;
        ll nextr = (r-num+26)%13;
        f[now][r] = (f[now][r] + dp(now+1,nextr))%M;
    }

    return f[now][r];
}

int main()
{
    while (1)
    {
        scanf("%c",&c);
        if ((c>='0' && c<='9') || (c=='?'))
        {
            t++;
            s[t] = c;
        }else
            break;
    }
    for (int i=1; i<=(1+t)/2; ++i)
        swap(s[i],s[t-i+1]);
   // for (int i=1; i<=t; ++i)
   //     cout<<s[i];
   // return 0;
    ll now=0;
    ll totnum=0;
    for (int i=1; i<=t; ++i)
    {
        if (i==1) now=1;
        else now=(now*10)%13;

        if (s[i]!='?')
        {
            int num=(s[i]-'0');
            totnum = (totnum + now*num)%13;
        }else
        {
            top++;
            a[top] = now;
        }
    }

    totnum = 5-totnum;
    while (totnum<0) totnum+=13;
    //cout<<totnum<<endl;
    //for (int i=1; i<=top; ++i)
    //    cout<<a[i]<<' ';
    //cout<<endl;
    ll ans=0;
    ans=(ans + dp(1,totnum))%M;
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 28928
args = list(map(int, input().split()))
processes = []
for i in range(args[0]):
    processes.append(input().split())
    processes[i][1] = int(processes[i][1])
timer, p = 0, 0
while args[0]:
    p %= args[0]
    if processes[p][1] > args[1]:
        processes[p][1] -= args[1]
        timer += args[1]
    else:
        timer += processes[p][1]
        print(processes[p][0], timer)
        args[0] -= 1
        del processes[p]
        p -= 1
    p += 1


Measured memory_bytes: 17112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, r, p, c;
        while(true){
            n = sc.nextInt();
            r = sc.nextInt();
            if (n == 0 && r == 0) break;
            int remain[] = new int[n];
            int tmp[] = new int[n];
            for (int i = 0; i < n; i++) remain[i] = n - i;
            for (int i = 0; i < r; i++){
                p = sc.nextInt();
                c = sc.nextInt();
                System.arraycopy(remain,p-1, tmp,0, c);
                System.arraycopy(remain,0, remain, c, p-1);
                System.arraycopy(tmp,0, remain,0, c);
            }
            System.out.println(remain[0]);
        }
    }
}

Measured memory_bytes: 37384
#include <bits/stdc++.h>
using namespace std;
int n,t,a[100001],mx[100001],s,ans=0;
int main(){
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;++i)	scanf("%d",a+i);
	mx[n]=a[n];
	for(int i=n-1;i>=0;--i)	mx[i]=max(mx[i+1],a[i]);
	for(int i=1;i<=n;++i){
		if(s<mx[i]-a[i])		s=mx[i]-a[i],ans=1;
		else if(s==mx[i]-a[i])	ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val a = readInputLine().toInt()
    val b = readInputLine().toInt()
    val c = readInputLine().toInt()
    val x = readInputLine().toInt()
    
    var ans = 0
    
    for (i in 0..a) {
        if (500 * i > x) {
            break
        }
        for (j in 0..b) {
            if (500 * i + 100 * j > x) {
                break
            }
            for (k in 0..c) {
                if (500 * i + 100 * j + 50 * k == x) {
                    ans++
                    break
                }
            }
        }
    }
    
    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ab = new List<int[]>();
            for(var i=0;i<N;i++)
            {
                ab.Add(Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray());
            }
            var sorted = ab.OrderBy(x => x[1]).ToArray();
            var lim = 0;
            for(var i=0;i<N;i++)
            {
                lim += sorted[i][0];
                if(sorted[i][1]<lim)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 34116
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N,K;
vector<vector<int>> g;

int main(){
    cin >> N >> K;
    g.resize(N);
    rep(i,N-1){
        int a,b;cin>>a>>b;
        a--;
        b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    int ans = 0;

    int kk = K/2;
    for(int c=0;c<N;c++){
        int cnt=1;
        int mx=-1;
        for(int s : g[c]){
            vector<int> d(N,INF);
            queue<pii> que;
            que.push(make_pair(s,1));
            d[c]=0;
            d[s]=1;
            while(!que.empty()){
                pii p = que.front(); que.pop();
                int v = p.fi;
                int k = p.se;
                if(k+1 > kk+1) continue;
                for(int nv : g[v]){
                    if(d[nv]<INF) continue;
                    d[nv] = k+1;
                    que.push(make_pair(nv,k+1));
                }
            }
            int a=0,b=0;
            for(int i=0;i<N;i++){
                if(i==c) continue;
                if(d[i]<=kk) a++;
                if(d[i]==kk+1) b++;
            }
            cnt += a;
            mx = max(mx,b);
        }
        if(K%2==1) cnt+=mx;
        ans=max(ans,cnt);
    }
    cout << N - ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[m],sum=0;
  for(int i=0;i<m;i++){
    cin>>a[i];
    sum+=a[i];
  }
  if(n-sum<0)cout<<"-1"<<endl;
  else cout<<n-sum<<endl;
    
  return 0;
}

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

int main(void) {
  double x1,y1,x2,y2;
  scanf("%lf %lf %lf %lf\n",&x1,&y1,&x2,&y2);
  printf("%.8lf\n", sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
  return 0;
}

Measured memory_bytes: 660
def main():
    k, a, b = map(int, input().split())
    if a >= b - 2 or a >= k:
        print(k + 1)
        return
    k -= a - 1
    v = a + (b - a) * (k // 2) + int(k % 2)
    print(v)


if __name__ == "__main__":
    main()


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

int main() {
    string N;
    cin >> N;
    if(N.at(N.size()-1) == '3')cout << "bon" << endl;
    else if(N.at(N.size()-1) == '0'||N.at(N.size()-1) == '1'
    ||N.at(N.size()-1) == '6'||N.at(N.size()-1) == '8')
    cout << "pon"<< endl;
    else 
    cout << "hon" << endl;
}

Measured memory_bytes: 3624
import heapq

x,y,a,b,c = map(int, input().split())
pl = list(map(int, input().split()))
ql = list(map(int, input().split()))
rl = list(map(int, input().split()))

pl.sort(reverse=True)
pl = pl[:x]
heapq.heapify(pl)
ql.sort(reverse=True)
ql = ql[:y]
heapq.heapify(ql)
rl.sort(reverse=True)

for r in rl:
    dp = r-pl[0]
    dq = r-ql[0]
    if dp<=0 and dq<=0:
        break
    if dp>dq:
        heapq.heappushpop(pl,r)
    else:
        heapq.heappushpop(ql,r)

print(sum(pl)+sum(ql))

Measured memory_bytes: 107432
# -*- coding: utf_8 -*-
level = False
def debug(v):
    if level:
        print(v)

n = int(input())
g = []

for i in range(n):
    v = input().split()
    g.append([int(x) for x in v]) 

debug(g)

def prim(n):
    visited = [False] * n
    d = [0] + [2001] * (n - 1)
    p = [-1] * n

    while True:
        mincost = 2001

        for i in range(n):
            if (not visited[i]) and (d[i] < mincost):
                mincost = d[i]
                u = i
        if mincost == 2001:
            break
        visited[u] = True

        for v in range(n):
            if (not visited[v]) and (g[u][v] != -1):
                if g[u][v] < d[v]:
                    d[v] = g[u][v]
                    p[v] = u

    print(sum(d))

prim(n)

Measured memory_bytes: 7824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int N, K;
    string S, res = "";
    
    cin >> N >> S >> K;
    
    for (int i = 0; i < N; ++i) {
        if (S[i] != S[K-1]) S[i] = '*';
    }
    cout << S << endl;
}


Measured memory_bytes: 256
from fractions import gcd
A, B, C, D = map(int, input().split())

l = C * D //gcd(C, D)
x = (A - 1) - (A - 1) // C - (A - 1) // D + (A - 1) // l
y = B - B // C - B // D + B // l
print(y - x)

Measured memory_bytes: 5048
N,T=map(int,input().split())
X=0
t=list(map(int,input().split()))
t1=t[0]
for i in range(N-1):
    t2=t[i+1]
    if t2-t1>=T:
        X+=T
    else:
        X+=t2-t1
    t1=t2
X+=T
print(X)


Measured memory_bytes: 85456
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,a[N],cnt;
void solve(){
  cin>>n;
  rep(i,1,n){cin>>a[i];if(a[i]&1 and i&1)cnt++;}
  cout<<cnt;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

int main(){
    int n; 
    cin >> n;
    int ans = pow(n, 3);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back

int main(){
	int a,b,c,d;
	int count=0;
	int time_a[101]={0};
	int time_b[101]={0};
	cin>>a>>b>>c>>d;

	for(int i=a;i<=b;i++){
		time_a[i]=1;
	}

	for(int i=c;i<=d;i++){
		time_b[i]=1;
	}

	for(int i=0;i<101;i++){
		if(time_a[i]==1&&time_b[i]==1){
			count++;
		}
	}

	if(count==0){
		cout<<0<<endl;
	}else{
		cout<<count-1<<endl;
	}
	// cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	}
	if (a == c) {
		cout << b << endl;
	}
	if (b == c) {
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
 
int calc(int x,int y){
    if(y == 0){
        return x;
    }else{
        return calc(y,x%y);
    }
}
 
int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    if(x >= y)
        printf("%d\n",calc(x,y));
    else{
        printf("%d\n",calc(y,x));
    }
}


Measured memory_bytes: 2684
#include<stdio.h>
int main(void){
	int n,m,i,sum=0,temp1,temp2,min,max;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d",&temp1,&temp2);
		if(i==1){
			min=temp2;
			max=temp1;
		}
		if(min>temp2){
			min=temp2;
		}
		if(max<temp1){
			max=temp1;
		}
	}
	
	for(i=max;i<=min;i++){
		sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
from sys import stdin
import sys

X = int(input())
for i in range(-5000, 5001):
    for k in range(-5000, 5001):
        if i-k != 0 and (X/(i-k)).is_integer():
            if i**5-k**5 == X:
                print(i, k)
                sys.exit()


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

p = 1

flag = False
zero = False
n = input().split()
for i in n:
    x = int(i)
    p = p * x
    if p == 0:
        zero = True

    if p > 1000000000000000000:
        flag = True
        p = 1

if zero:
    print(0)
else:
    if flag:
        print(-1)
    else:
        print(p)


Measured memory_bytes: 19356
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007 
#define rep(i,j,l) for(int i=j;i<=l;i++)
#define dec(i,j,l) for(int i=j;i>=l;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 



int main() {  
   ll n,a,b,i;
   cin>>a>>b;
      
      n=b*10;
         for( i=0;i<=9;i++)
          { 
              if( ((n+i)*2/25) ==a)
              break;
              
          } 
          if(i==10)
          cout<<-1;
          else 
         cout<<n+i; 
      
}


Measured memory_bytes: 256
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int[][] grid = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				grid[i][j] = sc.nextInt();
			}
		}
		int[] a = new int[3];
		int[] b = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = grid[0][(i + 2) % 3] - grid[0][(i + 1) % 3];
			b[i] = grid[(i + 2) % 3][0] - grid[(i + 1) % 3][0];
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i] != grid[j][(i + 2) % 3] - grid[j][(i + 1) % 3]
				|| b[i] != grid[(i + 2) % 3][j] - grid[(i + 1) % 3][j]) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23764
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,W = map(int,readline().split())
m = map(int,read().split())
WV = list(zip(m,m))

# 重さ -> 最大価値

dp = np.zeros(W+1,np.int64)

for w,v in WV:
    np.maximum(dp[w:],dp[:-w].copy()+v,out=dp[w:])

answer = dp.max()
print(answer)

Measured memory_bytes: 15488
import java.util.*;

class Main {
    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        int a, b;

        while (true) {

            try {
                a = sc.nextInt();
                b = sc.nextInt();
            } catch (NoSuchElementException e) {
                break;
            }

            System.out.println( (int)(Math.log10(a+b) + 1));

        }


    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m,X,l=0,r,x=0,k=1,s=-1,tmp=0,tim,A,a[maxn];
inline int calc(int l,int r,int x){
    return max(l,min(r,x));
}
int main(){
    scanf("%d%d",&X,&n);
    for (int i=1; i<=n; i++) scanf("%d",&a[i]);
    r=X;
    scanf("%d",&m);
    for (int i=1; i<=m; i++){
        scanf("%d%d",&tim,&A);
        while(k<=n && a[k]<=tim){
            int d=s*(a[k]-tmp);
            tmp=a[k];
            x+=d;
            k++;
            s*=-1;
            l=calc(0,X,l+d);
            r=calc(0,X,r+d);
        }
        int p=tim-tmp;
        A=calc(l,r,A+x);
        A=calc(0,X,A+s*p);
        printf("%d\n",A);
    }
    return 0;
}


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

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


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

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

int main() {

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

    set<ll> ans;
    for (ll i = 0; i < k; i++) {
        if ((a + i) > b) break;
        ans.insert(a + i);
    }

    for (ll i = 0; i < k; i++) {
        if ((b - i) < a) break;
        ans.insert(b - i);
    }

    for (ll i : ans) {
        cout << i << endl;
    }


}

Measured memory_bytes: 256
#include<stdio.h>

int main (){

  int i,j,k;

  scanf("%d",&i);
  int d[i];
  for(j=0;j<i;j++){
    scanf("%d",&d[j]);
          }
      for(k=i-1;k>0;k--){
        printf("%d ",d[k]);
      }
      printf("%d",d[0]);

    printf("\n");
  return 0;
}

Measured memory_bytes: 600
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


N = int(input())

cnt = 0

for n in range(1, N+1):
    if n % 2 == 1:
        divisors = make_divisors(n)
        if len(divisors) == 8:
            cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include "iostream"
using namespace std;
int main()
{
  bool y=true;
  int a[5];
  int k;
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  cin>>k;
  for(int i=4;i>=1;i--){
    for(int j=i-1;j>=0;j--){
      if((a[i]-a[j])<=k){
        
        continue;
      }
      else{
        y=false;
        break;

      }
    }

    if(y==false){
      break;
    }
  }
  if(y==true){
    cout<<"Yay!"<<endl;

  }
  else{
    cout<<":("<<endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(void) {
    int n,k;
    char c;
    cin >> n >> k;
    while(1) {
        cin >> c;
        if( cin.eof() ){
            break;
        }
        cout << (char) (--k?c:(c+'a'-'A'));
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}


int main(){
	ll n;
	cin >> n;
	ll h[100010];
	REP(i,n) cin >> h[i];
	
	const ll INF = 1LL << 60;
	ll dp[100010];
	REP(i,100010) dp[i] = INF;
	dp[0] = 0;
	for(int i=1; i<n; ++i){
		chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
		if(i > 1)
			chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
	}
	
	cout << dp[n-1] << endl;
	
	return 0;
}

Measured memory_bytes: 5136
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	int h[100001];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int ans = 0;
	for (int i = n - 1; i > 0; i--) {
		if (h[i] < h[i - 1]) {
			if ((h[i - 1] - h[i]) == 1) { h[i - 1]--; }
			else ans = 1;
		}
	}
	if (ans == 1)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
    Vi a(n);
    int ans=1;
    REP(i,0,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    REP(i,0,n){
        if(LLONG_MAX/ans<=a[i]){
            cout<<-1<<endl;
            return 0;
        }
        ans*=a[i];
    }
    if(ans<=1000000000000000000) cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3996
import math
A, B = map(int, input().split())

A_list = []
for i in range(1500):
  if math.floor(i * 0.08) == A:
    A_list.append(i)

B_list = []
for i in range(1500):
  if math.floor(i * 0.10) == B:
    B_list.append(i)   
    
common = set(A_list) & set(B_list)

if common:
  print(min(common))
else:
  print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;

// Author - Kevin Mathew
// Birla Institute of Technology, Mesra

ll h, w, dp[1010][1010]; char grid[1010][1010];

ll dfs(ll x, ll y){
	// cout << x << " " << y << "\n";
	if(x >= h || y >= w) return 0;
	if(x == h-1 && y == w-1) return 1;
	if(dp[x][y] != -1)
		return dp[x][y];
	if(grid[x][y] == '#')
		return 0;

	return dp[x][y] = (dfs(x+1, y) + dfs(x, y+1)) % MOD;
}

void te(){
	cin >> h >> w;
	for(ll i=0;i<h;i++)
		for(ll j=0;j<w;j++){
			cin >> grid[i][j];
			dp[i][j] = -1;
		}

	cout << dfs(0, 0) << "\n";
}

int main()
{
	//freopen("input.txt", "r", stdin);		//Comment
	//freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	te();

	return 0;
}

Measured memory_bytes: 9216
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 700;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == 'o') {
                ans += 100;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
n, d = map(int, input().split())
p = []
for _ in range(n):
  p.append(list(map(int, input().split())))
d2 = d*d
a = 0
for i in range(n):
  if(p[i][0]**2+p[i][1]**2 <= d2):
    a += 1
print(a)

Measured memory_bytes: 45460
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 5010, INF = 0x3f3f3f3f;
char s[N], t[N];
int n,ans,pla[N << 1],cnt,rec[N << 1];
int solve(int p) {
  int tmp = 0;
  rep (i, 1, p) pla[++tmp] = 0;
  int ret = 0;
  if (p >= 0) pla[++tmp] = 0;
  else ++ p;
  for (int i = 1; i < n; ++ i) {
    if (s[i] != s[i+1]) {
      if (p < 0) ++ p, ret += i;
      else pla[++tmp] = i;
    }
  }
  while (tmp < cnt) pla[++tmp] = n;
  rep (i, 1, tmp) {
    if (i <= cnt) ret += abs(pla[i] - rec[i]);
    else ret += abs(pla[i] - n);
  }
  return ret;
}
int main() {
  read(n);
  scanf("%s", s+1);
  scanf("%s", t+1);
  rec[++cnt] = 0;
  rep (i, 1, n-1) if (t[i] != t[i+1])
    rec[++ cnt] = i;
  while (cnt < n) rec[++cnt] = n;
  int key = 0;
  if (s[1] != t[1]) key = 1;
  ans = INF;
  rep (i, -n-1, n+1) if ((abs(i)&1) == key)
    ans = min(ans, solve(i));
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)



int main() {
    int n;
    set<int> s;
    bool f[200] = {};
    vector<pair<int, int>> v;
    
    cin >> n;
    REP(i, n){
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
        f[a] = true;
    }
    REP(i, n){
        int c, d;
        cin >> c >> d;
        v.push_back({c, d});
    }
    
    sort(v.begin(), v.end());
    
    int ans = 0;
    REP(i, 2 * n){
        if(f[v[i].first]){
            s.insert(v[i].second);
        }
        else{
            int t = -1;
            for(auto x : s){
                if(x < v[i].second){
                    t = max(t, x);
                }
            }
            if(t != -1){
                s.erase(t);
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256