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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pub(a) push_back(a)
#define pob() pop_back()
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

        
//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;


int main(){
  ll X,Y,A,B,C;cin>>X>>Y>>A>>B>>C;
   vl p(A),q(B),r(C);
  rep(i,A)cin>>p[i];
  rep(i,B)cin>>q[i];
  rep(i,C)cin>>r[i];
  
  sort(all(p));
  sort(all(q));
  sort(all(r));
  vl che;
  for(ll i=A-1; i>=A-X;i--){
    che.pub(p[i]);
  }
  for(ll i=B-1; i>=B-Y;i--){
    che.pub(q[i]);
  }
  
  sort(all(che));
  vl we(C);
  we[0]=r[C-1];
  rep(i,C-1){
    we[i+1]=we[i]+r[C-2-i];
  }
  vl wc(X+Y);
  wc[0]=che[0];
  
    rep(i,X+Y-1){
    wc[i+1]=wc[i]+che[i+1];
  }

  ll tot =wc.back();
  ll ans =tot;
  rep(i,min(X+Y,C)){
    ans =max(tot-wc[i]+we[i],ans);
  }
  cout<<ans<<endl;
}






Measured memory_bytes: 9344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String T = sc.next();
		sc.close();
		int l1 = s.length();
		int l2 = T.length();
		String ans = "";
		for(int i = 0; i <= l1 - l2; i++) {
			boolean flag = true;
			for(int j = 0; j < l2; j++) {
				char c1 = s.charAt(i + j);
				char c2 = T.charAt(j);
				if(c1 != '?' && c1 != c2) {
					flag = false;
					break;
				}
			}
			if(flag) {
				StringBuilder sb = new StringBuilder(s);
				for(int j = 0; j < l2; j++) {
					char c1 = s.charAt(i + j);
					char c2 = T.charAt(j);
					if(c1 == '?') {
						sb.replace(i + j, i + j + 1, String.valueOf(c2));
					}
				}
				for(int j = 0; j < l1; j++) {
					if(sb.charAt(j) == '?') {
						sb.replace(j, j + 1, "a");
					}
				}
				//System.out.println(sb);
				String t = sb.toString();
				if(ans.length() == 0) {
					ans = sb.toString();
				}else {
					if(ans.compareTo(t) > 0) {
						ans = t;
					}
				}
			}
		}
		if(ans.length() == 0) {
			System.out.println("UNRESTORABLE");
		}else {
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 23636
N, K = map(int, input().split())
D = list(map(int, input().split()))

while 1:
  flag = True
  for i in range(K):
    if str(D[i]) in str(N):
      flag = False
      break
  if flag:
    print(N)
    exit()
  else:
    N += 1

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

    vector<P> keta;
    for (int i = 0; i < m; i++) {
        int s;
        cin >> s;
        s--;
        int c;
        cin >> c;
        keta.push_back(make_pair(s, c));
    }

    auto isOK = [&](int num) {
        string s = to_string(num);
        for (int i = 0; i < m; i++) {
            if (s.at(keta[i].first) != (char)(keta[i].second + '0')) {
                return false;
            }
        }
        return true;
    };

    int start
        = 1;
    int end = 10;
    for (int i = 0; i < n - 1; i++) {
        start *= 10;
        end *= 10;
    }
    if (n == 1)
        start = 0;

    for (int num = start; num < end; num++) {
        if (isOK(num)) {
            cout << num << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
  input! {
        a: usize,
        s: String,
    }
    if  a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

char c[20];
int p[20];
bool alive[20];
vector<int> now[110];
vector<int> nxt[110];

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

	int n, l;
	while(cin >> n >> l, n | l) {
		for(int i = 0; i < n; i++) {
			cin >> c[i] >> p[i];
			alive[i] = true;
			now[p[i]].push_back(i);
		}

		int rem = n, last = -1, t = 0;
		while(rem) {
			for(int i = 1; i < l; i++) {
				if(now[i].size() == 2) {
					if(c[now[i][0]] == 'R') {
						c[now[i][0]] = 'L';
						c[now[i][1]] = 'R';
						nxt[i - 1].push_back(now[i][0]);
						nxt[i + 1].push_back(now[i][1]);
					}
					else {
						c[now[i][0]] = 'R';
						c[now[i][1]] = 'L';
						nxt[i + 1].push_back(now[i][0]);
						nxt[i - 1].push_back(now[i][1]);
					}
				}
				else if(now[i].size() == 1) {
					if(c[now[i][0]] == 'R') {
						nxt[i + 1].push_back(now[i][0]);
					}
					else {
						nxt[i - 1].push_back(now[i][0]);
					}
				}
			}
			if(nxt[l].size()) {
				rem--;
				last = nxt[l][0];
				nxt[l].clear();
			}
			if(nxt[0].size()) {
				rem--;
				last = nxt[0][0];
				nxt[0].clear();
			}
			for(int i = 0; i <= l; i++) {
				now[i] = nxt[i];
				nxt[i].clear();
			}
			t++;
		}

		cout << t << " " << last + 1 << endl;
	}
}

Measured memory_bytes: 3096
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define INF (1e18)

const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

int main(void) {
    cin >> h >> w >> n;

    a = (h > w) ? h : w;
    b = (h < w) ? w : h;

    for (i = 1; i <= b; ++i) {
        if (i * a >= n) {
            cout << i << endl;
            return 0;
        }
    }


    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int[] hand = new int[5];
			hand[0] = stdIn.nextInt();
			if(hand[0] == 0)
			{
				break;
			}
			for(int i = 1; i < 5; ++i)
			{
				hand[i] = stdIn.nextInt();
			}
			int rockCount = 0;
			int paperCount = 0;
			int scissorsCount = 0;
			for(int i = 0; i < 5; ++i)
			{
				if(hand[i] == 1)
				{
					++rockCount;
				}
				else if(hand[i] == 2)
				{
					++scissorsCount;
				}
				else
				{
					++paperCount;
				}
			}
			if((rockCount >= 1 && scissorsCount >= 1 && paperCount >= 1)
				|| (rockCount == 0 && scissorsCount == 0) 
				|| (scissorsCount == 0 && paperCount == 0) 
				|| (paperCount == 0 && rockCount == 0))
			{
				for(int i = 0; i < 5; ++i)
				{
					System.out.println("3");
				}
			}
			else if(rockCount == 0)
			{
				for(int i = 0; i < 5; ++i)
				{
					if(hand[i] == 2)
					{
						System.out.println("1");
					}
					else
					{
						System.out.println("2");
					}
				}
			}
			else if(scissorsCount == 0)
			{
				for(int i = 0; i < 5; ++i)
				{
					if(hand[i] == 3)
					{
						System.out.println("1");
					}
					else
					{
						System.out.println("2");
					}
				}
			}
			else if(paperCount == 0)
			{
				for(int i = 0; i < 5; ++i)
				{
					if(hand[i] == 1)
					{
						System.out.println("1");
					}
					else
					{
						System.out.println("2");
					}
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
 
int main() {
  int K;
  int A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){

std::string S;
cin>>S;
if(S[1]=='R'){
    cout<<"ABC"<<"\n";
}
else{
    cout<<"ARC"<<"\n";
}

return 0;
}


Measured memory_bytes: 3624
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N,K] = nextIntArray()
    const tmp = N.toString(K).split("")
    console.log(tmp.length)
}
Main()


Measured memory_bytes: 29428
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




int main() {
  int n;
  cin >> n;
  int v[n+1],c[n+1];
  rep (i,n){
    cin >> v[i];
  }
  rep (i,n){
    cin >> c[i];
  }
  int sum[n],ans=0;
  rep (i,n){
    sum[i]=v[i]-c[i];
    if (sum[i]>0) ans+=sum[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		x -= a;
		x -= (x/b)*b;
		System.out.println(x);
		
		sc.close();

	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(uniqu7e(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int len_s = s.size();
	int ct_a = 0, ct_b = 0, ct_c = 0;
	REPx(x, s)
	{
		if (x == 'a') ct_a++;
		else if (x == 'b') ct_b++;
		else if (x == 'c') ct_c++;
	}
	bool flg = false;
	if (len_s % 2)
	{
		if (ct_a == ((len_s/2)/3)*2 + 1) {if (ct_b == ct_c) flg = true;}
		else if (ct_b == ((len_s/2)/3)*2 + 1) {if (ct_a == ct_c) flg = true;}
		else if (ct_c == ((len_s/2)/3)*2 + 1) {if (ct_b == ct_a) flg = true;}
	}
	else
	{
		if (((len_s)/2) % 3 == 0) {if (ct_a == ct_b && ct_b == ct_c) flg = true;}
		else if (((len_s)/2) % 3 == 1)
		{
			if (ct_a == ct_b) {if (ct_c == ct_a - 1) flg = true;}
			else if (ct_c == ct_b) {if (ct_a == ct_b - 1) flg = true;}
			else if (ct_a == ct_c) {if (ct_b == ct_a - 1) flg = true;}
		}
		else if (((len_s)/2) % 3 == 2)
		{
			if (ct_a == ct_b) {if (ct_c == ct_a + 1) flg = true;}
			else if (ct_c == ct_b) {if (ct_a == ct_b + 1) flg = true;}
			else if (ct_a == ct_c) {if (ct_b == ct_a + 1) flg = true;}
		}
	}
	if (flg) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 512
from itertools import combinations_with_replacement

def point(A):
    res = 0
    for i in range(Q):
        if x[i][1] > len(A):
            continue
        else:
            if A[x[i][1]-1] - A[x[i][0]-1] == x[i][2]:
                res += x[i][3]
    return res


N, M, Q = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    ans = max(ans, point(A))

print(ans)


Measured memory_bytes: 9208
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

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

    int A[110], B[110];

    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
        cin >> B[i];

    int ans = -1;
    for (int i = 0; i < N; i++)
    {
        int sum = 0;
        for (int j = 0; j <= i; j++)
        {
            sum += A[j];
        }
        for (int k = i; k < N; k++)
        {
            sum += B[k];
        }
        ans = max(sum, ans);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
#define int long long
const int INF = 1000000007;


int a[500001];
signed main(){
    int  a,b;
    cin>>a>>b;
    if(a>=13)cout<<b;
    else{
        if(a>=6)cout<<b/2;
        else cout<<0;
    }
    
    
   
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
L = [1 if c=="L" else 0 for c in S]
R = [1 if c=="R" else 0 for c in S]
Ans = [0] * N
for i, c in enumerate(S):
    if c=="R":
        if S[i+1]=="L":
            Ans[i] += R[i]
        else:
            R[i+2] += R[i]
    else:
        Ans[i] += R[i]

for i, c in zip(range(N-1, -1, -1), S[::-1]):
    if c=="L":
        if S[i-1]=="R":
            Ans[i] += L[i]
        else:
            L[i-2] += L[i]
    else:
        Ans[i] += L[i]

print(" ".join(map(str, Ans)))


Measured memory_bytes: 15268
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
import math
print(math.ceil(n/1000)*1000 - n)


Measured memory_bytes: 10464
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll a,v,b,w,t; cin >> a >> v >> b >> w >> t;
  if(abs(b-a)<=(v-w)*t){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 3632
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val s = sc.next

    val ans = new Array[Int](s.length - 2)

    for (i <- 0 to s.length - 3) {
      val m = s(i).toString + s(i + 1).toString + s(i + 2).toString
      ans(i) = math.abs(m.toInt - 753)
    }

    println(ans.min)
  }
}


Measured memory_bytes: 25644
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())
T = T1 + T2
C = A1*T1+A2*T2
D = B1*T1+B2*T2
if C == D:
    print("infinity")
    exit()
if C > D:
    A1,B1=B1,A1
    A2,B2=B2,A2
    C,D  = D,C
if A1 < B1:
    print(0)
    exit()
ok = 0
ng = pow(10,30)
while ng - ok > 1:
    md = (ok + ng)//2
    if A1*T1+C*md>=B1*T1+D*md:
        ok = md
    else:
        ng = md
ans = 2*ok + 1
if A1*T1+C*ok == B1*T1+D*ok:
    ans -= 1
print(ans)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();

            AtCoderMain at = new AtCoderMain();
            Console.WriteLine(at.abc051_b_Run(s1));
            Console.ReadKey();

        }
    }

    public partial class AtCoderMain
    {
        /// <summary>
        /// B - Sum of Three Integers
        /// https://atcoder.jp/contests/abc051/tasks/abc051_b
        /// </summary>
        /// <param name="p1"></param>
        /// <returns></returns>
        public string abc051_b_Run(string p1)
        {
            int cnt = 0;

            List<int> tmp = p1.Split(' ').Select(x => int.Parse(x)).ToList();

            for (int i = 0; i <= tmp[0]; i++)
            {
                for (int t = 0; t <= tmp[0]; t++)
                {
                    int s = tmp[1] - (i + t);
                    if (0 <= s && s <= tmp[0])
                    {
                        cnt++;
                    }
                }
            }

            return cnt.ToString();
        }
    }
}


Measured memory_bytes: 13268
use proconio::{input,fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
  input!{n: usize, k: usize};
  let mut snuke = vec![false; n];
  for _ in 0..k {
    input!{d: usize, a: [Usize1; d]};
    for aa in a {
      snuke[aa] = true;
    }
  }
  println!("{}", snuke.iter().filter(|&x| !x).count());
}


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

#define ll long long

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  
  ll q = N/B;
  
  if (B == 1) {
    cout << 0 << endl;
  } else if (N < B) {
    cout << A * N/ B << endl;
  } else {
    cout << A * (B-1) / B << endl;
  }
}

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

/*............................*/

#define uint uint64_t
#define mx 5001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define printcase(p) printf("Case %d: ", p)
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#include <bits/stdc++.h>
using namespace std;
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
   ll a,b,c,d,x,y,w,z;
   sccl(a,b);
   sccl(c,d);
   x=a*c;
   y=a*d;
   w=b*c;
   z=b*d;
   pfl(max(max(max(x,y),z),w));
   return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    char x;
    cin >> x;
    loop(i, 26)
    {
        char check = (char)('a' + i);
        if (x == check)
        {
            putout("a");
            return 0;
        }
    }
    putout("A");
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
   int n, a = 1;
   long long int ans = 0;
   cin >> n;
   vector<int> v(3*n);
   for (int i = 0; i < 3*n; i++){
       cin >> v[i];
   }
   sort(v.begin(),v.end(),greater<int>());
   for(int i = 0; i < n; i++){
       ans += v[a];
       a += 2;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1408
# AOJ 0149: Eye Test
# Python3 2018.6.17 bal4u

tbl = [[0 for j in range(4)] for i in range(2)]
while True:
	try: p = list(map(float, input().split()))
	except: break
	for i in range(2):
		if p[i] >= 1.1: tbl[i][0] += 1
		elif p[i] >= 0.6: tbl[i][1] += 1
		elif p[i] >= 0.2: tbl[i][2] += 1
		else: tbl[i][3] += 1
for i in range(4):
	print(tbl[0][i], tbl[1][i])


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

int main(){

  int N;  cin >> N;
  long long int A[200];

  for(int i = 0;i < N;i++)cin >> A[i];

  long long int count = 0;

  while(true){

    for(int i = 0;i < N;i++){

      if(A[i] % 2 == 0)A[i] = A[i]/2;

      else{
        cout << count << endl;
        return 0;
      }

    }

    count++;

  }


}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int digit(int n)
{
    int count = 0;
    while (n > 0)
    {
        count++;
        n /= 10;
    }
    return count;
}

int main()
{
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (digit(i) % 2 == 1)
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
def isCLKWISE(ph):
    a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]
    b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]
    crs = a[0]*b[1] - a[1]*b[0]
    if crs < 0 :
        return False
    else :
        return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) :
                break
            else :
                del phU[-2]
                if len(phU) == 2 :
                    break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) :
                break
            else :
                del phL[-2]
                if len(phL) == 2 :
                    break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P += [[int(x) for x in input().split()]]
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33916
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int sol(string &a, string &b){
  int n = a.size();
  string A = a+a;
  string B = b+b;

  vector<int> acc(2*n+1, 0);
  rep(i,2*n) acc[i+1] = acc[i] + (B[i]=='1');
  vector<int> rev(2*n, 0), fwd(2*n, 0);
  rep(i,1,2*n){
    if(B[i]=='1') rev[i] = 0;
    else rev[i] = rev[i-1]+1;
  }
  for(int i=2*n-2; i>=0; i--){
    if(B[i]=='1') fwd[i] = 0;
    else fwd[i] = fwd[i+1]+1;
  }

  int ans = 2*n;
  rep(i,n){
    int cnt = 0;
    vector<pair<int,int>> vec;
    rep(j,n) if(A[i+j] != B[j]){
      cnt++;
      if(acc[i+j+1] - acc[j] == 0){
        vec.pb(mp(fwd[i+j], rev[n+j]));
      }
    }

    int padd = 0;
    if(vec.size()){
      sort(all(vec));
      reverse(all(vec));
// dbg(vec);
      int minxy = 2*n;
      int maxy = 0;
      rep(j,vec.size()){
        minxy = min(minxy, vec[j].first + maxy);
        maxy = max(maxy, vec[j].second);
      }
      minxy = min(minxy, maxy);

      padd = minxy;
    }
    // dbg(i,cnt,padd);
    ans = min(ans, i+cnt+2*padd);
  }
  return ans;
}

int solve(){
  string a,b;
  cin>>a>>b;

  auto isall = [](string &s, const char c){
    for(auto ch : s) if(ch!=c) return false;
    return true;
  };

  if(a == b) return 0;
  if(isall(b,'0')) return -1;
  if(isall(b,'1')){
    int ans = 0;
    for(auto c : a) if(c=='0') ans++;
    return ans;
  }

  int ans = sol(a,b);
  reverse(all(a));
  reverse(all(b));
  ans = min(ans, sol(a,b));

  return ans;
}

int main(){
  cout << solve() << endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  string a,b;
  cin >> a >> b;
  a = a + b;
  int num = toInt(a);
  if((int)sqrt(num) * (int)sqrt(num) == num)  cout << "Yes" << endl;
  else                                        cout << "No" << endl;
  return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    int bars[N];

    for(int i = 0; i < N; ++i) cin >> bars[i];

    sort(bars, bars + N, greater<int>());

    int res = 0;

    for(int i = 0; i < K; ++i){
        res += bars[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int max=0, tmp=0;
    char a='\0';
    while(a != '\n'){
        scanf("%c", &a);
    switch(a){
        case 'A':
        case 'T':
        case 'G':
        case 'C':
        tmp++;
        break;
        default:
        if(max < tmp) max = tmp;
        tmp=0;
    }
    }
    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;


#define at(x) operator[](x)

int MAXN = 2e5 + 1;
vector<long long> st;

void update_tree( int pos, long long value, int root, int tleft, int tright) {
  if (pos < tleft || pos > tright || tleft > tright) return;

  if (tleft == tright) {
    st[root] = value;
    return;
  } 

  int mid = (tleft + tright) / 2;
  
  update_tree(pos, value, root*2, tleft, mid);
  update_tree(pos, value, root*2+1, mid+1, tright);
  
  st[root] = max(st[root], value);
}

long long query( int qleft, int qright, int root, int tleft, int tright) {
    if (  qleft > qright ) return -1;
    if ( tleft == qleft && tright == qright) return st[root];

    int mid = (tleft + tright)/2;

    return max(
      query(qleft, min(qright, mid), root*2, tleft, mid),
      query(max(mid+1, qleft), qright, root*2+1, mid+1, tright)
    );
}


// https://atcoder.jp/contests/dp/tasks/dp_q
int main() {
  int N;
  cin >> N;

  vector<int> H(N+1);
  vector<int> A(N+1);

  st.assign(N*4 + 10, -1);

  // input H
  for(auto i=1; i<=N; i++) cin >> H.at(i);
  // input A
  for(auto i=1; i<=N; i++) cin >> A.at(i);
    
  vector<long long> F(N+1, 0);

  long long myres = -1;
  for (auto i = 1; i <= N; i++) {
      auto res = query(1, H.at(i)-1, 1, 1, N);
      F.at(i) = (  (res==-1)?(0):(res) ) + A.at(i);
      myres = max(myres, F.at(i));
      update_tree(  H.at(i), F.at(i), 1, 1, N);
  }
  cout << myres << endl;
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,m; cin>>n>>m;
    vector<int> edge[n+1];
    rep(i,m){
        int a,b; cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    bool vertex[n+1]={};
    deque<int> path;
    path.push_back(1);
    vertex[1]=1;
    bool flg=1;
    while(flg){
        flg=0;
        int from=path.front();
        for(auto e:edge[from]){
            if(!vertex[e]){
                flg=1;
                vertex[e]=1;
                path.push_front(e);
                break;
            }
        }
    }
    flg=1;
    while(flg){
        flg=0;
        int to=path.back();
        for(auto e:edge[to]){
            if(!vertex[e]){
                flg=1;
                vertex[e]=1;
                path.push_back(e);
                break;
            }
        }
    }
    int x=path.size();
    cout<<x<<endl;
    rep(i,x) cout<<path[i]<<(i==x-1?"\n":" ");
    return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pie 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-7
#define mod ((ll)1e9+7)
#define maxlg 18
const int maxn = ((int) 4e5) +5 ;
#define left(i) ((i)<<1)
#define right(i) ((i)<<1)+1
vi adj[maxn];
int INDEX = 0;
bool onStack[maxn];
int index_[maxn], lowLink[maxn];
stack<int> stk;
vector<vi> components;//0 -> lowest in topological order
void getConnectedComponent(int i);
void getConnectedComponent(int i) {
    index_[i] = INDEX;
    lowLink[i] = INDEX;
    INDEX++;
    stk.push(i);
    onStack[i] = true;
    for(int nxt : adj[i] ) {
        if(index_[nxt] == -1) {
            getConnectedComponent(nxt);
            lowLink[i] = min(lowLink[i] , lowLink[nxt]);
        } else if (onStack[nxt]){
            lowLink[i] = min(lowLink[i] , index_[nxt]);

        }
    }

    if(lowLink[i] == index_[i]) {
        vi comp;
        int poped ;
        do {
            poped = stk.top();
            stk.pop();
            onStack[poped] = false;
            comp.pb(poped);
        } while(poped!=i);
        if (comp.size() > 0) {
            components.push_back(comp);
        }
    }
}

void tarjan(int n) {

    memset(onStack, false, sizeof(onStack));
    fill(index_,index_ + n , -1);

    for(int i=0;i<n;i++) {
        if(index_[i] == -1) {
            getConnectedComponent(i);
        }
    }
}
int p[maxn];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
  // freopen("input", "r", stdin);
    //freopen("/home/arasmus/output", "w", stdout);
#endif
    int n,m;
    cin>>n>>m;
    rep (i,0,n)
        cin>>p[i];
    rep (i,0,m) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        adj[a].push_back(b);
        adj[b].push_back(a);

    }
    tarjan(n);
    int ans=0;
    for (vi comp: components) {
        set<int> temp;
        for (int vert : comp) {
            temp.insert(vert);
        }

        for (int vert : comp) {
            if (temp.find(p[vert]-1)!=temp.end()) {
                ans++;
            }
        }
    }

    cout<<ans;

}




//cout<<"Case #"<<++T<<": ";

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, x;
  cin >> n >> x;
  vll m(n);
  vin(m);
  cout << (x - accumulate(all(m), 0)) / *min_element(all(m)) + n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
 
const int INF = 100000000;
 
int main()
{
    int n;
    while(scanf("%d", &n), n){
        pii data[200];
        rep(i, n){
            int m, a, b;
            scanf("%d%d%d", &m, &a, &b);
            data[i*2] = pii(a, m);
            data[i*2+1] = pii(b, -m);
        }
        sort(data, data+2*n);
         
        int w = 0;
        bool ok = true;
        rep(i, 2*n){
            w += data[i].second;
            if(w > 150){
                ok = false;
                break;
            }
        }
        puts(ok ? "OK" : "NG");
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N;
    int L;
    int m,res=0;
    cin >> N >> L;

    m = L;
    for(int i=1;i<=N;i++){
        if(abs(m)>abs(L+i-1))
            m = L + i -1;    
        res += L + i - 1;
    }

    cout << res - m << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a == 0)
    cout<<"1"<<endl;
  if(b == 0)
    cout<<"2"<<endl;
  if(c == 0)
    cout<<"3"<<endl;
  if(d == 0)
    cout<<"4"<<endl;
  if(e == 0)
    cout<<"5"<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, maxW;
int weight[105], value[105];
long long dp[105][(int)1e5 + 3];

long long solve(int item, int weightSoFar)
{
    if(item == n)
    {
        if(weightSoFar > maxW)
            return INT_MIN;
        return 0;
    }
    if(weightSoFar > maxW)
        return INT_MIN;
    long long& ret = dp[item][weightSoFar];
    if(~ret)
        return ret;
    ret = INT_MIN;
    ret = max(ret, solve(item + 1, weightSoFar));
    ret = max(ret, solve(item + 1, weightSoFar + weight[item]) + value[item]);
    return ret;

}

int main()
{
    IO;
    cin >> n >> maxW;
    for(int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, d, x, y;
  cin >> n >> d;
  ll ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> x >> y;
    if (x*x + y*y <= d*d) ans++;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,i;
    cin>>n>>t;
    map<int,int>mp;
    for(i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        mp[x]=y;
    }
    for(auto x:mp)
    {
        if(x.second<=t)
        {
            cout<<x.first;
            return 0;
        }
    }
    cout<<"TLE";

}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define For(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>  
#define vf vector<float>
#define vb vector<bool>
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vs vector<string>
#define mp make_pair
#define ll long long
#define vc vector<char>
#define rng(x) x.begin(),x.end()
#define b(x) x.begin()
#define e(x) x.end()
#define F first
#define S second
#define me max_element
#define ne min_element  
const int N = int(1e5+3);
using namespace std;

int main()
{ 
  ios::sync_with_stdio(0);
  cin.tie(0);
     
  int x;
  cin>>x;
  if(x>=400 && x<600) cout<<8;
  else if(x>=600 && x<800) cout<<7;
  else if(x>=800 && x<1000) cout<<6;
  else if(x>=1000 && x<1200) cout<<5;
  else if(x>=1200 && x<1400) cout<<4;
  else if(x>=1400 && x<1600) cout<<3;
  else if(x>=1600 && x<1800) cout<<2;
  else if(x>=1800 && x<2000) cout<<1;
}

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

int main(int argc, char const *argv[])
{
    vector<int> v,v2;
    int t,k;
    for(int i=0;i<5;++i){
        cin >> t;
        v.push_back(t);
        if(t%10!=0)v2.push_back(t%10);
    }
    int sum=0;
    for(int i=0;i<5;++i){
        float temp = (float)v[i]/10.0;
        sum +=ceil(temp)*10;
    }
    if(!v2.empty()){
        sort(v2.begin(),v2.end());
        sum +=(v2[0]-10);}
    cout << sum <<endl;
    
    return 0;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 200000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	cin >> s;

	rep(i, 3) {
		if (s[i] == '1')s[i] = '9'; 
		else if (s[i] == '9')s[i] = '1';
	}

	cout << s << endl;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and L[i] + L[j] + L[k] > 2 * max(L[i], L[j], L[k]):
                ans += 1
                # print(i, j, k)

print(ans)

Measured memory_bytes: 68460
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int N; LL M;
std::vector<LL> A;

LL Count(int v) {
	LL count = 0;
  for (const LL Ax : A) {
		int Ay = v - Ax;
		int idx = std::lower_bound(A.begin(), A.end(), Ay) - A.begin();
		count += N - idx;
	}
	return count;
}

LL Sum(int v) {
  std::vector<LL> As = A;
	for (int i = N-2; i >= 0; --i) As[i] += As[i + 1];

	LL sum = 0;
  for (const LL Ax : A) {
		int Ay = v - Ax;
		int idx = std::lower_bound(A.begin(), A.end(), Ay) - A.begin();
		int cnt = N - idx;
    if (cnt == 0) continue;

		sum += Ax * cnt;
		sum += As[idx];
	}
	return sum;
}

int main() {
  std::cin >> N >> M;
  A.resize(N);
	for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::sort(A.begin(), A.end());

	int l = 0, r = 2 * A[N-1] + 1;
	while (l + 1 != r) {
		int mid = (l + r) / 2;
		if (M <= Count(mid)) l = mid;
		else r = mid;
	}

	LL ans = (M - Count(l + 1)) * l + Sum(l + 1);
  std::cout << ans << std::endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------



int main() {

  int a, p;
  cin >> a >> p;

  p += a*3;

  cout << p/2 << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
aa = list(map(int, input().split()))
ans=0
while True:
    bb = list(map(lambda x:x%2, aa))
    if sum(bb)==0:
        aa = list(map( lambda x:x/2, aa))
        ans+=1
    else:
        break
print(ans)

Measured memory_bytes: 12380
#include <bits/stdc++.h>
using namespace std;
bool DEBUG = false;

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

    int A[N];
    int max = 0, max2 = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];

        if(max < A[i]){
            max2 = max;
            max = A[i];
        }else if(max2 < A[i]){
            max2 = A[i];
        }
    }

    if(DEBUG){
        cout << max << endl;
        cout << max2 << endl;
    }

    for(int i = 0; i < N; i++) {
        if(A[i] == max){
            cout << max2 << endl;
        }else{
            cout << max << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432