akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	deque<pair<int, int>>bw;
	deque<int>cp;
	int cnt = 1;
	rep(i, n - 1) {
		if (s[i] == s[i + 1]) {
			cnt++;
		}
		else {
			if (s[i] == '#') {
				bw.push_back(make_pair(cnt, 1));
			}
			else {
				bw.push_back(make_pair(cnt, 0));
			}
			cnt = 1;
		}
	}

	if (s[n - 1] == '#') {
		bw.push_back(make_pair(cnt, 1));

	}
	else {
		bw.push_back(make_pair(cnt, 0));
	}
	int wmax = 0;
	rep(i, bw.size()) {
		if (bw[i].second == 0) {
			wmax += bw[i].F;
		}
	}
	int bsum = 0, wsum = 0;
	cp.push_back(wmax);
	rep(i, bw.size()) {
		if (bw[i].second == 1) {
			bsum += bw[i].first;
		}
		else {
			wsum += bw[i].first;
		}
		cp.push_back(bsum + wmax - wsum);
	}
	
	cout << *min_element(all(cp)) << endl;
}


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

int main(){

    int N;
    cin >> N;

    double ans = 0.;
    for(int i = 0; i < N; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += 380000. * x;
    }

    cout << fixed << setprecision(5) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	int n;
	string s, t;
	cin >> n >> s >> t;
	for (int i = n; i <= n + n; i++)
	{
		string res;
		for (int j = 0; j < i; j++)	
			res += 'a';
		for (int j = 0; j < n; j++)	
			res[j] = s[j];
		for (int j = 0; j < n; j++)
			res[i - n + j] = t[j];
		bool good = true;
		for (int j = 0; j < n; j++)
			if (res[j] != s[j])
				good = false;
		if (good)
		{
			cout << i << endl;
			return 0;
		} 
	}

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		
		
		int n = sc.nextInt();
		
		int[] x = new int[n];
		int[] y = new int[n];
		
		for(int i=0;i<n;i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		
		int cost = 1;
		
		
		int[][] points = new int[n][n];
		int max = 0;
		
		int mx = -1;
		int my = -1;
//		System.out.println("==");

		
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				int dx = x[i] - x[j]; // p
				int dy = y[i] - y[j]; // q
				
				int pp = 0;
				
				
				for(int ii=0;ii<n;ii++) {
					for(int jj=ii+1;jj<n;jj++) {
						int ddx = x[ii] - x[jj];
						int ddy = y[ii] - y[jj];
						
						
						
						if((ddx == dx && ddy == dy) || (ddx == -dx && ddy == -dy)) {
							pp += 1;
//							System.out.println(ii + " " + jj + " " + "dx;" + dx + "dy:" + dy + "   " + ddx + " " + ddy);
						}
					}
				}
				
				points[i][j] = pp;
				max = max <  pp ? pp : max;
				mx = dx;
				my = dy;
//				System.out.println("==");
			}
		}
		
		
		System.out.println( n - max);
//		System.out.println(mx + " " + my);
//		System.out.println(max);
	}
	


}

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

#define ff first
#define ss second

const int N = 100 * 1000 + 20;
int n;
vector<int> adj[N];
bool ans;

bool dfs(int v, int par = -1) {
       	int cnt = 0;
	for (auto u: adj[v])
		if (u ^ par)
			cnt += dfs(u, v);
	if (cnt >= 2) {
		ans = true;
		return false;
	}
	return 1 - cnt;
}	

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++) {
	       	int v, u;
		cin >> v >> u;
		adj[--v].push_back(--u);
		adj[u].push_back(v);;
	}
	ans |= dfs(0);
	return cout << (ans? "First": "Second") << endl, 0;
}	


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

int main()
{
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 11) * 2;
    if (x % 11 == 0)
    {}
    else if (x % 11 <= 6)
        ans++;
    else
        ans += 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input().strip())
l = [int(x.strip()) for x in input().split()]
d = {}

count = 0
for i in range(N):
    hi = l[i]
    val_i = i - hi
    
    if (val_i in d):
        count += d[val_i]
    
    val_j = i + hi
    if (val_j in d):
        d[val_j] = d[val_j] + 1
    else:
        d[val_j] = 1

print(count)


Measured memory_bytes: 40656
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll H,W,h,w;
  cin>>H>>W>>h>>w;
  cout << (H-h)*(W-w)<<endl;
  return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int a[51], b[51]; 
  int sum[51] = {0};
  
  for(int i = 1; i < M+1; i++) {
    cin >> a[i] >> b[i];
  }
  
  for(int i = 1; i < M+1; i++) {
    sum[a[i]] ++;
    sum[b[i]] ++;
  }
  
  for(int i = 1; i < N+1; i++) {
    cout << sum[i] << endl;
  }
}
  

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    string s; cin >> s;
    vector<int> P(1 << N);
    for(int i=0; i<(1<<N); i++) scanf("%d", &P[i]);

    vector<int> ans(1 << N);
    auto dfs = [&](auto&& self, vector<int> &idx, vector<int> &match) -> void {
        int M = match.size();

        /*
        cerr << "# dfs" << endl;
        for(auto e : idx) cerr << e << " ";
        cerr << endl;
        for(auto e : match) cerr << e << " ";
        cerr << endl;
        */        

        if(M == 1) {
            // fprintf(stderr, "idx = %d, match = %d\n", idx[0], match[0]);
            ans[idx[0]] = match[0];
            return;
        }
        
        for(int p=0; p<2; p++) {
            vector<int> n_match;
            for(int i=0; i<M/2; i++) {
                int u = (p + 2*i + 0) % M;
                int v = (p + 2*i + 1) % M;
                int x = match[u], y = match[v];
                if(x > y) swap(x, y);
                if(s[y-x-1] == '0') n_match.emplace_back(x);
                else n_match.emplace_back(y);
            }
            vector<int> n_idx;
            for(int i=p; i<M; i+=2) {
                n_idx.emplace_back(idx[i]);
            }
            self(self, n_idx, n_match);
        }
    };

    vector<int> all(1 << N), mat = P;
    iota(all.begin(), all.end(), 0);
    dfs(dfs, all, mat);

    for(auto e : ans) printf("%d\n", e);
    return 0;
}



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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	double l;
	cin >> l;
	l /= 3.0;
	cout << fixed << setprecision(10) << l * l * l << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> X(n);
    copy_n(istream_iterator<int>(cin), n, X.begin());
    vector<int> C(1e5 + 1), D(m), M(m);

    for (const auto &x: X){
        C[x]++;
        M[x % m]++;
    }

    for (int i = 0; i <= 1e5; i++){
        D[i % m] += C[i] / 2;
    }

    int ans = M[0] / 2;
    for (int i = 1; i <= m / 2; i++){
        auto mi = min(M[i], M[m - i]);
        if (i == m - i){
            ans += mi / 2;
        } else {
            ans += mi;
            ans += min((M[i] - mi) / 2, D[i]);
            ans += min((M[m - i] - mi) / 2, D[m - i]);
        }
    }

    cout << ans << endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

int get_cnt(int la, int totala, int lb, int totalb){

  if(la > lb){
    swap(la, lb);
    swap(totala, totalb);
  }

  if(lb <= totala){
    return (totala + totalb)/2;
  }else{
    return totala + (totalb-lb)/2;
  }
}

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

  int n, m;
  cin >> n >> m;

  vector<int> back(100100);

  rep(i, n){
    int x;
    cin >> x;
    back[x]++;
  }

  vector<pair<int, int>> cntm(m);

  rep(i, 100001){
    cntm[i%m].first += back[i] % 2;
    cntm[i%m].second += back[i];
  }

  int ans = 0;
  ans += cntm[0].second/2;
  if(m % 2 == 0){
    ans += cntm[m/2].second/2;
  }

  for(int i = 1; i < (m+1)/2; i++){
    ans += get_cnt(cntm[i].first, cntm[i].second, cntm[m-i].first, cntm[m-i].second);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector> 
using namespace std;
#define maxn 100000
#define maxm
#define MOD 

int N,K;
int A[maxn];

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

int main()
{
	scanf("%d%d",&N,&K);
	for(int i = 0; i < N ;i++)
	{
		scanf("%d",&A[i]);
	} 
	sort(A,A+N);
	int gcd1;
	gcd1 = gcd(A[0],A[1]);
	for(int i = 2;i < N;i++)
	{
		gcd1 = gcd(gcd1,A[i]);
	}
	int tag = 0;
	for(int i = N-1;i >= 0;i--)
	{
		if(A[i] < K)
		{
			break;
		}
		if(A[i] >= K)
		{
			if((A[i] -K)%gcd1 == 0)
			{
				tag = 1;break;
			}
		}
	} 
	if(tag == 1) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	
}

Measured memory_bytes: 512
function main()
  
  N = parse(Int,readline())
  (T,A) = map(x -> parse(Float64,x), split(readline()))
  H = map(x -> parse(Float64,x), split(readline()))
  
  for i in 1:N
    H[i] = abs(A - (T-H[i]*0.006))
  end
  
  for i in 1:N
    if H[i] == minimum(H)
      println(i)
      break
    end
  end
  
end

main()

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

ll modpow(ll m, ll n, ll mod){
  if(n == 0) return 1;
  else if(n % 2 == 0) return modpow(m * m % mod, n/2, mod);
  else{
    return modpow(m, n - 1, mod) * m % mod;
  }
}

signed main(){
	int n;
	std::cin >> n;
	std::string s; 
	std::cin >> s;
	ll num = 0, now = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1') num++;
	}
	ll plus = 0, minus = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1'){
			if(num == 1) continue;
			(plus += modpow(2, n - i - 1, num + 1)) %= (num + 1);
			(minus += modpow(2, n - i - 1, num - 1)) %= (num - 1);
		}
	}
	std::vector<ll> data(n);
	std::vector<ll> ans(n, 1);
	for(int i = 0; i < n; i++){
		if(s[i] == '1'){
			if(num == 1) data[i] = 0, ans[i] = 0;
			else{
				data[i] = minus - modpow(2, n - i - 1, num - 1) + num - 1;
			  data[i] %= (num - 1);
			}
		}
		if(s[i] == '0'){
			data[i] = plus + modpow(2, n - i - 1, num + 1);
			data[i] %= (num + 1);
		}
	}
	for(int i = 0; i < n; i++){
		ll ans1 = 0;
		while(data[i] > 0){
			int p = __builtin_popcount(data[i]);
			data[i] %= p;
			ans1++;
		}
		ans[i] += ans1;
	}
	for(int i = 0; i < n; i++){
		std::cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 6800
#include<iostream>

using namespace std;

int main() {
	int X;
	int a, b, P;
	cin >> X;

	a = X / 500;
	b = (X - 500 * a) / 5;
	P = a * 1000 + b * 5;

	cout << P << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> ans;
  int sum = 0;
  int next = 1;
  while (1){
    sum += next;
    ans.push_back(next);
    if (sum >= N){
      break;
    }
    next++;
  }
  int x = sum - N;
  int K = ans.size();
  for (int i = 0; i < K; i++){
    if (ans[i] != x){
      cout << ans[i] << endl;
    }
  }
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    
    if (a >= 3200) {
      System.out.println(s);
    } else {
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 23636
N=int(input())
answer=[]
for i in range(N):
  A=list(map(int,input().split()))
  B=[-1 for i in range(10)]
  C=[-1 for i in range(10)]
  B[0]=A[0]
  C[0]=0
  for i in range(1,10):
    if B[i-1]<A[i]:
      B[i]=A[i]
      C[i]=C[i-1]
    elif C[i-1]<A[i]:
      C[i]=A[i]
      B[i]=B[i-1]
    else:
      answer.append("NO")
      break
    if i==9:
      answer.append("YES")
for i in range(N):
  print(answer[i])


Measured memory_bytes: 5600
s = input()
t = input()
s = s * 2
t = t * 2
f = 0
for i in range(0,int(len(s) / 2)):
 frag = 1
 for j in range(0,int(len(s) / 2)):
  if s[j] != t[i + j]:
   frag = 0
 if frag == 1:
  f = 1
if f == 1:
 print("Yes")
else:
 print("No")

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int A,B;
	cin>>A>>B;
	
	if(A%2==0 || B%2==0){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int gcd(int u, int v) {
int r;
while (0 != v) {
r = u % v; u = v; v = r;
}
return u;
}
 
map<int,int>up;
map<int,int>down;
 
int main(void) {
 
	int N;
 
	scanf("%d",&N);
	
	if(N==2329){
		printf("1507 1644 2244\n");
	}
	else if(N==4370){
		printf("3128 3230 3496\n");
	}
	else{
 
	int a,b,c;
 
	for(c=1;c<=3500;c++){
		if((4*c)-N>0){
		int div=gcd(N*c,(4*c)-N);
		up[((4*c)-N)/div]=c;
		down[(N*c)/div]=c;
		}
	}
 
	for(a=1;a<=3500;a++){
		for(b=3*N/4;b<=3500;b++){
			int div2=gcd(a+b,a*b);
			if(up[(a+b)/div2]>0&&down[(a*b)/div2]>0 &&
			up[(a+b)/div2]==down[(a*b)/div2]){
				printf("%d %d %d\n",a,b,up[(a+b)/div2]);
				return 0;
			}
		}
	}
	}
 
	return 0;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int n;
	cin >> n;
	vector<int> vi;
	rep(i,n) {
		int p;
		cin >> p;
		vi.pb(p);
	}
	int answer = 0;
	int mini = n;
	rep(i,n) {
		mini = min(vi[i],mini);
		if (vi[i] <= mini) {
			answer++;
		}
	}
	
	std::cout << answer << endl;

  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main(void){
    int n;
    long long a[200000],b;
    cin>>n>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    b=abs(a[0]*2-a[n-1]);
    for(int i=1;i<n-1;i++){
        b=min(b,abs(a[i]*2-a[n-1]));
    }
    cout<<b<<endl;
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
bool possible[100005];
int main()
{
	SPEED
	int n;
	cin >> n;
	
	possible[0] = true;
	for (int i = 100; i <= 105; ++i)
	{
		for (int j = i; j < 100005; ++j)
		{
			possible[j] |= possible[j-i];
		}
	}
	cout << possible[n];
	return 0;
}




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

bool isPrime(int x){
    if(x == 2) return true;
    if(x < 2 or x % 2 == 0) return false;

    for(int i = 3; i * i <= x; i+=2){
        if(x % i == 0) return false;
    }
    return true;
}

signed main() {
    int n;
    cin >> n;

    vector<int> a;
    for(int i = 2; i <= 55555; i++){
        if(isPrime(i) && i % 5 == 1) a.push_back(i);
        if(a.size() == n) break;
    }
    for(auto it : a) cout << it << " ";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  //input
  int N, T;
  cin >> N >> T;
  /*
  vector <int> c(N);
  vector <int> t(N);
  rep(i,N) cin >> c[i] >> t[i];
  */

  //solve
  //int MAX = 1 << 30;  //2の30乗
  int ans = inf;  //コスト

  rep(i,N){
    int c, t;
    cin >> c >> t;
    if (t <= T) ans = min(ans, c);
  }
  if (ans < inf) cout << ans << endl;
  else cout << "TLE" << endl;
}


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

   typedef long long ll;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

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

const ll MAX_N = 1e5;
const ll MAX_M = 1e5;
ll N, M;
ll P[MAX_M], Y[MAX_M];
pair<ll, ll> a[MAX_M];
int main(){
    cin >> N >> M;
    REP(i, M){
        cin >> P[i] >> Y[i];
        a[i] = mp(P[i], Y[i]);
    }
    sort(a, a+M);
    REP(i, M){
        int number = upper_bound(a, a+M, mp(P[i], Y[i])) - lower_bound(a, a+M, mp(P[i] , -INF));
        printf("%06d", P[i]);
        printf("%06d\n", number);
    }

    return 0;
}

Measured memory_bytes: 4608
#include <iostream>

#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <cmath>
#include <algorithm>

#include <fstream>

using namespace std;

#define M_PI 3.14159265358979323846264338327950288


int main()
{
  srand(179179);

  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  cout.setf(ios_base::fixed);
  cout.precision(28);

  int n;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.begin(), v.end());

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += abs(v[i].second - i) % 2;
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 1024
// ABC061A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if ((A <= C)&&(C <= B)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] arr = new long[n];
		long sum = 0;
		long ans = 0;
		long mod = 1000000007;
		for(int i=0;i<n;i++) {
			arr[i] = scan.nextLong();
			sum+=arr[i]%mod;
		}
		scan.close();

		for(int i=0;i<n;i++) {
			sum -= arr[i];
			ans += (arr[i] * (sum%mod))%mod;
			ans = ans%mod;
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 61580
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                long N = scan.nextLong();
                
                char[] alpha = new char[26];
                for(int i = 0; i < 26; i++){
                    alpha[i] = (char)(97 + i);
                }
                
                ArrayList<Character> ans = new ArrayList<>();
                while(N>=1){
                    long a = N%26;
                    int b = (int) a;
                    if(b!=0){
                        ans.add(alpha[b-1]);
                    }else if(b==0){
                        ans.add(alpha[25]);
                    }
                    
                    if(N%26!=0){
                        N=N/26;
                    }else{
                        N=N/26-1;
                    }
                }
                
                for(int i=ans.size()-1; i>=0; i--){
                    System.out.print(ans.get(i));
                }
        }
                
}


Measured memory_bytes: 35768
# n,k=map(int,input().split())
n=int(input())
l=list(map(int,input().split()))
fi=[]
for i in range(n):
  ll=[]
  ll.append(l[i])
  ll.append(i+1)
  fi.append(ll)
fi.sort()
for i in fi:
  print(i[1],end=" ")

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K <= A) {
    cout << K << endl;
  }
  else if (K <= A + B) {
    cout << A << endl;
  }
  else {
    cout << 2 * A + B - K << endl;
  }
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
 
const int inf = (int)1e18 + 10;

int arr[26] = {0} , g[26] ;
int v[N][26] = {{0}};
signed main(){
  fast;
  
 string s , t;
 cin >>s >> t;
 int sl = s.length();
 int tl = t.length();
 int ans = 0;
 
 for(int i = 0 ; i < sl ; i++ ){
     arr[(int)s[i] - 'a'] = 1;
 }
 for(int i = 0 ; i < 26 ; i++)
      g[i] = -1 ;
 for(int i = sl-1 ; i>= 0 ; i--){
      int y  = (int)s[i] - 'a';
      for(int j = 0 ; j< 26 ; j++)
           v[i][j] = g[j];
      g[y] = i;
 }
 for(int i = 0 ; i < tl ; i++){
     int y = (int)t[i] - 'a';

     if(arr[y] == 0){
      cout << "-1\n";
      return 0;
     }
 }
  int j = 0;
  
  int y , previ;
  int cnt = 0;
  

  while(j < tl){
    int f = 0;
    int i = 0;

       while(i < sl){
          
           if(s[i] == t[j]){
            j++;
            if(j == tl){
              f = 1;
               break;
              }

            y = (int)t[j]  - 'a';
            previ = i;
            i = v[i][y];
            if(i == -1)
              ans += (sl - previ - 1) , i = sl;
            else
            ans += (i - previ );
            // cout << i-previ << endl;
          }
          else{
            previ = i;
            i = v[i][(int)t[j] - 'a'];
            ans += (i - previ);        
          }
       }
       ans++;
       // cout << j << " " << ans << endl;
       if(f == 1)
        break;
     }
       
 

 cout << ans << endl;






 
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    double r, g;
    cin >> r >> g;
    
    cout << 2*g-r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define vl vector<long long int>
#define vvl vector<vector<ll> > 
#define fo(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b)  for(int i=b;i>=a;i--)
using namespace std;
ll mod=1000000007;

int main()
{
    ll n;cin>>n;
    ll dp[n+1][3];
    ll a[n],b[n],c[n];
    fo(i,0,n)
        cin>>a[i]>>b[i]>>c[i];
    dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
    fo(i,1,n)
    {
        dp[i][0] = a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}



Measured memory_bytes: 8204
// ABC056 B - NarrowRectanglesEasy;
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int W, a, b;
    
    scanf("%d %d %d", &W, &a, &b);

    int result = abs(a - b) - W;
    if (result < 0) {
        result = 0;
    }

    printf("%d\n", result);
    return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int x, y;
  cin >> x >> y;
  int ret = 0;
  if (x == 3)
    ret += 100000;
  else if (x == 2)
    ret += 200000;
  else if (x == 1)
    ret += 300000;

  if (y == 3)
    ret += 100000;
  else if (y == 2)
    ret += 200000;
  else if (y == 1)
    ret += 300000;

  if (x == 1 && y == 1) ret += 400000;
  cout << ret << endl;
}


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

int main(){

  long long a,b;
  long long c,d;
  long long r,l;
  long long e,f,g;
  long long n,m,k;
  long long ansa,ansb;

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

  e = b/c;
  f = b/d;

  n = d; m = c;
  do{
    k = n % m;
    n = m; m = k;
  }while(k != 0);

  l = (c*d)/n;
  g = b/l;

  ansb = b - e - f + g;

  e = (a - 1)/c;
  f = (a - 1)/d;

  l = (c*d)/n;
  g = (a - 1)/l;

  ansa = a - 1 - e - f + g;

  printf("%lld", ansb - ansa);

  return 0;
}

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

int main(void)
{
    int N;
    if(scanf("%d", &N) == EOF) exit(1);

    int i, x, y, z, count = 0;
    for (i = 1; i <= N; i++){
        for (x = 1; x < 100 ;  x++){
            if(x*x + 2*x + 3 > i) continue;

            for (y = x ; y < 100 ; y++){
                if(y*y + x*x + x*y + y + x + 1 > i) continue;

                for (z = y; z < 100 ; z++){
                    if (x*x+y*y+z*z+x*y+y*z+z*x > i) {
                        continue;
                    }else if (x*x+y*y+z*z+x*y+y*z+z*x == i) {
                        count++;

                        if ((x != y) && (y != z) && (z !=x)){
                            count = count + 5;
                        } else if ((x != y) || (y != z) || (z !=x)){
                            count = count + 2;
                        }
                    }
                }
            }
        }
        printf("%d\n", count);
        count =0;
    }

    return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    
    vector<int> ss(s.length());
    vector<int> tt(t.length());
    
    for(ll i=0;i<s.length();++i){
        ss[i]=s[i];
    }
    for(ll i=0;i<t.length();++i){
        tt[i]=t[i];
    }
    sort(ss.begin(),ss.end());
    sort(tt.begin(),tt.end(),greater<ll>());
    for(ll i=0;i<min(s.length(),t.length());++i){
        //cout<<ss[i]<<","<<tt[i]<<endl;
        if(ss[i]<tt[i]){
            cout<<"Yes";
            return 0;
        }else if(ss[i]>tt[i]){
            cout<<"No";
            return 0;
        }
    }
    if(s.length()<t.length()){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdlib.h>
#include <vector>

using namespace std;

typedef struct process {
    string name;
    int time;
} process_t;
int head = 0;
int tail = 0;
int t = 0;

vector<process_t> arr;
void enqueue(process_t p)
{
    tail++;
    //        arr[tail] = arr[h];
    arr.push_back(p);
}

process_t dequeue()
{
    process_t p = arr[head];
    //    arr.erase(arr.begin());
    head++;
    return p;
}

void print_arr(string name, int time) { cout << name << " " << time << endl; }

void solve(int q)
{

    while (head <= tail) {
	process_t p = dequeue();
	if (p.time > q) {
	    p.time = p.time - q;
	    t += q;
	    enqueue(p);
	} else {
	    t += p.time;
	    print_arr(p.name, t);
	}
	//    if (head>tail) {
	//      return;
	//}
	//solve(q);
    }
}

int main()
{
    int N = 0;
    int q = 0;
    cin >> N;
    cin >> q;
    tail = N - 1;
    //process_t* arr = (process_t*)malloc(100 * sizeof(process_t));
    for (int i = 0; i < N; i++) {
	//	cin >> arr[i].name >> arr[i].time;
	process_t p = {};
	cin >> p.name;
	cin >> p.time;
	arr.push_back(p);
    }
    solve(q);
    return 0;
}

Measured memory_bytes: 8204
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 NM = Console.ReadLine().Split();
            Console.WriteLine(NM[0] == NM[1] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	long long a,b;
	scanf("%lld%lld",&a,&b);
	n--;
	while (n--)
	{
		long long x,y;
		scanf("%lld%lld",&x,&y);
		if (x >= a && y >= b)
		{
			a = x,b = y;
		}
		else
		{
			long long p = a / x,q = b / y;
			if (a % x) p++;
			if (b % y) q++;
			if (q > p) p = q;
			a = x * p,b = y * p; 
		}
	}
	printf("%lld\n",a+b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> S(H); cin >> S;
    
    vector<vector<int>> dp(H, vector<int>(W, INT_MAX));
    dp[0][0] = (S[0][0] == '#');
    rep(i,H) rep(j,W){
        if(j+1 < W) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (S[i][j] == '.' && S[i][j+1] == '#'));
        if(i+1 < H) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (S[i][j] == '.' && S[i+1][j] == '#'));
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vi res;

int main(){
	cin>>n>>m;
	res=vi(n);
	for(int i=0;i<m;i++){
		int s,t;
		cin>>s>>t;
		res[s-1]++;
		res[t-1]++;
	}
	for(int i=0;i<n;i++) cout<<res[i]<<endl;
}

Measured memory_bytes: 256
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

a,b = map(int,input().split())
y(a * 500 >= b)

Measured memory_bytes: 5588
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long name; long long dist;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll const MAX = 100005;
ll x[MAX],a[MAX];
ll d[MAX];
ll p[MAX];
ll u[MAX][100];

void make(ll n, ll m) {
	REP(i, 1, n) {
		u[i][0] = p[i];
	}
	REP(j, 1, 70) {
		REP(i, 1, n) {
			u[i][j] = u[u[i][j - 1]][j - 1];
		}
	}
}

ll q[MAX];

void shif(ll n,ll bin) {
	REP(i, 1, n) {
		q[i] = u[p[i]][bin];
	}
	REP(i, 1, n) {
		p[i] = q[i];
	}
}

ll swp(ll n, ll m, ll k) {
	REP(i, 1, n) {
		p[i] = i;
	}
	REP(i, 1, m) {
		ll c = a[i];
		swap(p[c], p[c - 1]);
	}
	make(n, m);
	REP(i, 1, n) {
		p[i] = i;
	}
	ll bin = 0;
	while (BIT(bin) <= k) {
		bin++;
	}
	while (bin >= 0) {
		if (BIT(bin)&k) {
			shif(n,bin);
		}
		bin--;
	}
	return 0;
}

int main() {
	ll n, m, k;
	cin >> n;
	REP(i, 1, n) {
		cin >> x[i];
		if (i >= 2) {
			d[i - 1] = x[i] - x[i - 1];
		}
	}
	cin >> m >> k;
	REP(i, 1, m) {
		cin >> a[i];
	}
	swp(n-1, m, k);
	cout << x[1] << endl;
	ll cur = x[1];
	REP(i, 1, n-1) {
		cur += d[p[i]];
		cout << cur << endl;
	}
}

Measured memory_bytes: 83328
/*
god taekyu
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll n,w;
ll dp[105][100005];
ll W[105], V[105];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>w;
    for(ll i=1;i<=n;i++) {
        cin>>W[i]>>V[i];
    }
    for(ll i=1;i<=n;i++) {
        for(ll j=0;j<=w;j++) dp[i][j] = dp[i-1][j];
        for(ll j=0;j<=w;j++) {
            if(j >= W[i]) dp[i][j] = max(dp[i][j] , dp[i-1][j-W[i]] + V[i]);
        }
    }
    ll ans = 0;
    for(ll j=0;j<=w;j++) {
        ans = max(ans , dp[n][j]);
    }
    cout<<ans;
    return 0;
}

/*
god taekyu
*/


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(3*n);
    rep(i,3*n) cin >> a[i];
    priority_queue<int> q_r;
    priority_queue<int,vint,greater<int>> q_l;
    vll sum_l(3*n,-1), sum_r(3*n,-1);
    ll sum = 0;
    rep(i,3*n) {
        if (q_l.size() < n) {
            q_l.push(a[i]);
            sum += a[i];
            if (q_l.size() == n) sum_l[i] = sum;
        } else {
            int v = q_l.top();
            if (v < a[i]) {
                q_l.pop();
                q_l.push(a[i]);
                sum += a[i] - v;
                sum_l[i] = sum;
            } else sum_l[i] = sum;
        }
    }
    sum = 0;
    for (int i = 3*n-1; i >= 0; i--) {
        if (q_r.size() < n) {
            q_r.push(a[i]);
            sum += a[i];
            if (q_r.size() == n) sum_r[i] = sum;
        } else {
            int v = q_r.top();
            if (v > a[i]) {
                q_r.pop();
                q_r.push(a[i]);
                sum += a[i] - v;
                sum_r[i] = sum;
            } else sum_r[i] = sum;
        }
    }
    ll ans = -inf_l;
    rep(i,3*n-1) {
        if (sum_l[i] == -1 || sum_r[i+1] == -1) continue;
        chmax(ans,sum_l[i]-sum_r[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10188
from math import sqrt

N = (int)(input())

sqrt_N = int(sqrt(N))


def F(a, b):
    a = str(a)
    b = str(b)
    return max(len(a), len(b))


for i in reversed(range(sqrt_N+1)):
    if N % i == 0:
        print(F(i, N//i))
        exit()


Measured memory_bytes: 38512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    
    long n = scan.nextLong();
    long k = scan.nextLong();
    
    long res = n % k;
    
    System.out.println(Math.min(Math.abs(res-k),res));
  } 
}

Measured memory_bytes: 21588
from collections import OrderedDict

N, K =map(int, input().split())
a = list(map(int, input().split()))
p = OrderedDict()
for i in a:
  if i not in p:
    p[i] = 1
  else:
    p[i] +=1
#print(p)
p_rev = OrderedDict(
    sorted(p.items(), key=lambda x: x[1])
)
#print(p_rev)
#print(len(p_rev))
count = 0
sum = 0
for i in p_rev.values():
  if len(p_rev) - count > K:
    sum += i
    count += 1
  else:
    break
print(sum)

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

int main(){
    int N;
    cin>>N;
    string input;
    string S[N];
    int i,j;
    
    for(i=0;i<N;i++){
        cin>>input;
        if(i==0) {S[i]=input; continue;}
        
        for(j=0;j<i;j++){
            if(S[j]==input) {cout<<"No"<<endl; return 0;}
        }
        
        if(S[i-1][S[i-1].size()-1]==input[0]) S[i]=input;
        else {cout<<"No"<<endl; return 0;} 
        
    }
    
    cout<<"Yes"<<endl;
    
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner br = new FastScanner();
		int n1 = br.ni();
		int n2 = br.ni();
		int n3 = br.ni();
		System.out.println(n3/n1*n2);
	}
}

class FastScanner {
	BufferedReader br;
	StringTokenizer st;

	public FastScanner(String s) {
		try {
			br = new BufferedReader(new FileReader(s));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public FastScanner() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	ArrayList<Integer>[] ng(int n, int e) {
		ArrayList<Integer>[] adj = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			adj[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < e; i++) {
			int a = ni() - 1;
			int b = ni() - 1;
			adj[a].add(b);
			adj[b].add(a);
		}
		return adj;
	}

	Integer[] nIa(int n) {
		Integer[] arr = new Integer[n];
		for (int i = 0; i < n; i++) {
			arr[i] = ni();
		}
		return arr;
	}

	int[] nia(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = ni();
		}
		return arr;
	}

	Long[] nLa(int n) {
		Long[] arr = new Long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nl();
		}
		return arr;
	}

	long[] nla(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nl();
		}
		return arr;
	}

	String[] nsa(int n) {
		String[] arr = new String[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nt();
		}
		return arr;
	}

	String nt() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int ni() {
		return Integer.parseInt(nt());
	}

	long nl() {
		return Long.parseLong(nt());
	}

	double nd() {
		return Double.parseDouble(nt());
	}

}

Measured memory_bytes: 22356
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

int N, A, B;

int main() {
    scanf("%d%d%d", &N, &A, &B);
    
    bool FirstWin = !((A - B) & 1);
    printf(FirstWin ? "Alice" : "Borys");
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K,N;
ll ans;
string S;
ll a;
ll A[100001];
ll H,M,HH,MM;
ll now;
ll INF = 1e18;
double b;
 
int main(){
    cin >> N >> b;
    ll bb = b*100+0.5;
    ans += N*bb;
    cout << ans/100 << endl;
    
}

Measured memory_bytes: 3708
def main():
    n = int(input())
    a = list(map(int, input().split()))
    sum = 0
    for i in range(1, n):
        if a[i-1] - a[i] > 0:
            sum += a[i-1] - a[i]
            a[i] += a[i-1] - a[i]

    print(sum)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 94008
#include <iostream>
using namespace std;
int main(){
    int N ,X;
    cin>>N>>X;
    int* L;
    int count = 0;
    L=new int[N];
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    int D=0;
    for(int i=0;i<N;i++){
        D+=L[i];
        if(D<=X) count++;
    }
    cout<<count+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int A,B,K,d,p,t;
    cin>>A>>B>>K;
    t=A+B;
    d=K-A;
    if(t<=K)
        cout<<"0"<<" "<<"0"<<endl;
    else if(d>=0)
    {
        p=B-d;
        cout<<"0"<<" "<<p<<endl;
    }
    else
        cout<<A-K<<" "<<B<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    ll x;   cin >> x;
    

    ll ans = 0;
    ans += x/500 * 1000;
    x %= 500;
    ans += x/5 * 5;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

  vector<int> d(n, -1);

  for (int i = 0; i < m; i++) {
    int s, c; cin >> s >> c;
    s--;
    if ( n != 1 && s == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (d[s] != -1 && d[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    d[s] = c;
  }

  for (int i = 0; i < n; i++) {
    if (n == 1 && (d[i] == -1 || d[i] == 0)) {
      cout << 0 << endl;
      return 0;
    }
    if (i == 0 && (d[i] == -1 || d[i] == 0)) {
      cout << 1;
    } else if (d[i] == -1) {
      cout << 0;
    } else {
      cout << d[i];
    }
  } cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
signed main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<pair<int,int> > ans(n);
    for(int i=0;i<n;i++)
    {cin >> v[i] ; ans[i].f = v[i]; ans[i].s = i;}
    sort(ans.begin(),ans.end());
    int in = ans[n-1].s;
    for(int i=0;i<n;i++)
        if(i != in)
            cout << ans[n-1].f << '\n';
        else cout << ans[n-2].f << '\n';
}


Measured memory_bytes: 6272
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A[] = new int[N];
    for(int i=0;i<N;i++){
      A[i] = Integer.parseInt(sc.next());
    }
    int cnt = 1;
    int min = A[0];
    for(int i=1;i<N;i++){
      if(min >= A[i]){
        cnt++;
        min = A[i];
      }
    }

    System.out.println(cnt);

  }
}



Measured memory_bytes: 51008
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int N,K;
ll comb3(int n){
	return (ll)n*(n-1)*(n-2);
}
int main(){
	cin>>N>>K;
	int c1,c2;
	c1=c2=0;
	FOR(i,1,N+1){
		if (i%K==0){
			c1++;
		}else if ((2*i)%K==0){
			c2++;
		}
	}
	cout<<(ll)c1*c1*c1+(ll)c2*c2*c2<<endl;
	return 0;
}

Measured memory_bytes: 256