akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

const int N = 3 * 1e3 + 123;
int dp[N][N];
bool was[N][N];
#define next asda
pair<int , int> next[N][N];
string s , t;
int solve(int pos1 , int pos2){
	if(was[pos1][pos2])
		return dp[pos1][pos2];
	if(s[pos1] == t[pos2]){
		next[pos1][pos2] = {pos1 - 1 , pos2 - 1};
		dp[pos1][pos2] = 1 + solve(pos1 - 1 , pos2 - 1);
	}
	else{
		int a = solve(pos1 - 1, pos2 ) ;
		int b = solve(pos1 , pos2 - 1);
		if(a > b)
			next[pos1][pos2] = {pos1 - 1,pos2};
		else
			next[pos1][pos2] = {pos1 , pos2 - 1};
		dp[pos1][pos2] = max(a , b);
	}
	was[pos1][pos2] = 1;
	return dp[pos1][pos2];
}
void get(int p1 = sz(s) - 1, int p2 = sz(t) - 1){
	if(next[p1][p2].fi == 0 && next[p1][p2].se == 0){
		if(s[p1] == t[p2])
			cout<<s[p1];
		return;}
	pair<int,int> tmp = next[p1][p2];
	get(tmp.fi , tmp.se);
	if(s[p1] == t[p2])
		cout<<s[p1];
}
main(){
	//scanf("%lld%lld" , &n , &W);
	for(int i = 0 ; i <= 3000 ; i++)
		was[i][0] = was[0][i] = 1;
	cin >> s >> t;
	s = '#' + s;t = '#' + t;
	solve(sz(s) - 1, sz(t) - 1);
	get();
}

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

int main(){
    long long N,a,b,minB=1000000000,sum=0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a >> b;
        sum+=a;
        if(a>b && minB>b)
        minB=b;
    }
    if(minB==1000000000)
    cout << 0 << endl;
    else
    cout << sum-minB << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())
txy = list(list(map(int, input().split())) for _ in range(N))
dt = 0
dx = 0
dy = 0
for i in range(N):
    if abs(txy[i][1]-dx)+abs(txy[i][2]-dy) > txy[i][0]-dt or (txy[i][1]+txy[i][2])%2 != txy[i][0]%2:
        print("No")
        break
    dt = txy[i][0]
    dx = txy[i][1]
    dy = txy[i][2]
else:
    print("Yes")

Measured memory_bytes: 27244
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
mihon = a.sort
count = 0
n.times do |i|
	if a[i] != mihon[i]
      count += 1
    end
end
if count <= 2
  puts "YES"
else
  puts "NO"
end



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

class dice
{
    public:
    int num[6], new_num[6];
    int checkside(int top, int front);
};

int dice::checkside(int top, int front){
    switch(top){
        case 0:
            switch(front){
                case 1:
                    return 2;
                case 2:
                    return 4;
                case 4:
                    return 3;
                case 3:
                    return 1;
            }
            break;
        case 1:
            switch(front){
                case 5:
                    return 2;
                case 2:
                    return 0;
                case 0:
                    return 3;
                case 3:
                    return 5;
            }
            break;
        case 2:
            switch(front){
                case 0:
                    return 1;
                case 1:
                    return 5;
                case 5:
                    return 4;
                case 4:
                    return 0;
            }
            break;
        case 3:
            switch(front){
                case 0:
                    return 4;
                case 4:
                    return 5;
                case 5:
                    return 1;
                case 1:
                    return 0;
            }
            break;
        case 4:
            switch(front){
                case 0:
                    return 2;
                case 2:
                    return 5;
                case 5:
                    return 3;
                case 3:
                    return 0;
            }
            break;
        case 5:
            switch(front){
                case 1:
                    return 3;
                case 3:
                    return 4;
                case 4:
                    return 2;
                case 2:
                    return 1;
            }
            break;
    }
}


int main(){
    
    dice a;
    int ans, n, top_num, front_num, top, front;
    for(int i=0;i<6;i++){
        cin >> a.num[i];
    }
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> top_num >> front_num;
        for(int j=0;j<6;j++){
            if(top_num == a.num[j]){
                top = j;
                break;
            }
        }
        for(int j=0;j<6;j++){
            if(front_num == a.num[j]){
                front = j;
                break;
            }
        }
        
        ans = a.checkside(top, front);
        cout << a.num[ans] << endl; 
    }
    
    return 0;
}


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

int N, M, K, S, P, Q;
queue< int > zombie;
vector< int > graph[100001];
int danger[100001];

void preBFS()
{
  while(!zombie.empty()) {
    int p = zombie.front(); zombie.pop();
    if(danger[p] == S) return;
    for(int to : graph[p]) {
      if(~danger[to]) continue;
      danger[to] = danger[p] + 1;
      zombie.push(to);
    }
  }
}

long long Dijkstra()
{
  typedef pair< long long, int > Pi;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  long long v[100001];
  fill_n(v, 100001, 1LL << 58);
  v[1] = ~danger[N] ? -Q : -P;
  que.emplace(v[1], 1);
  while(!que.empty()) {
    long long cost, now;
    tie(cost, now) = que.top(); que.pop();
    if(cost > v[now]) continue;
    if(now == N) return(cost);
    for(int to : graph[now]) {
      if(danger[to] == 0) continue;
      long long next = cost + (~danger[to] ? Q : P);
      if(next >= v[to]) continue;
      v[to] = next;
      que.emplace(next, to);
    }
  }
  return(-1);
}
int main()
{
  scanf("%d %d %d %d", &N, &M, &K, &S);
  scanf("%d %d", &P, &Q);

  memset(danger, -1, sizeof(danger));
  while(K--) {
    int C;
    scanf("%d", &C);
    zombie.push(C);
    danger[C] = 0;
  }
  while(M--) {
    int A, B;
    scanf("%d %d", &A, &B);
    graph[A].push_back(B);
    graph[B].push_back(A);
  }
  preBFS();
  printf("%lld\n", Dijkstra());
}

Measured memory_bytes: 11124
#include<bits/stdc++.h>
#define ll long long int
const int mod= 1e9+7;
using namespace std;


int main(){

/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif*/
int h,w;
cin>>h>>w;
ll dp[h][w];
for(int i=0;i<h;i++)
	for(int j=0;j<w;j++){
		char c;
		cin>>c;
		if(c=='.')
			dp[i][j] =0;
		else
			dp[i][j] = -1;
	}
	for(int i=0;i<h;i++)
		if(dp[i][0]==-1)
			break;
		else
			dp[i][0] = 1;
	for(int i=0;i<w;i++)
		if(dp[0][i]==-1)
			break;
		else
			dp[0][i] = 1;
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(dp[i][j]!=-1){
				if(dp[i-1][j]!=-1)
					dp[i][j]=(dp[i-1][j]+dp[i][j])%mod;
				if(dp[i][j-1]!=-1)
					dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
		
			
		}
	}
	cout<<dp[h-1][w-1];
}
		

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

char ch[N];
int sum;

int main() {
	cin>>(ch + 1);
	rep(i, 1, (int) strlen(ch + 1)) 
	    sum += ch[i] - '0';
	if(sum%9) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3752
S = input()
T = input()
ind = len(S)-1
if(S == T):
  print('Yes')
  exit()
for _ in range(len(S)):
  if(S[ind]+S[:ind] == T):
    print('Yes')
    break
  else:
    S = S[ind] + S[:ind]
else:
  print('No')

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

constexpr int INF = (1LL << 31) - 1;

template<typename T, int MAX_N>
struct segment_tree_min {
    int N;
    T arr[MAX_N << 1];

    segment_tree_min(int n, T INF) {
        N = 1;
        while (N < n) N *= 2;

        for (int i = 0; i < 2*N-1; ++i) {
            arr[i] = INF;
        }
    }

    void update(int i, T v) {
        int j = i + N-1;

        arr[j] = v;
        while (j > 0) {
            j = (j-1) / 2;
            arr[j] = min(arr[2*j+1], arr[2*j+2]);
        }
    }

    T query(int a, int b) {
        return query(a, b, 0, 0, N);
    }

    T query(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) return INF;
        if (a <= l && r <= b) return arr[k];

        const int m = (l+r)/2;
        return min(query(a, b, 2*k+1, l, m), query(a, b, 2*k+2, m, r));
    }
};

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    segment_tree_min<int, 202020> segt(N, INF);
    for (int j = 0; j < Q; ++j) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            segt.update(x, y);
        } else {
            cout << segt.query(x, y+1) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int num;
		if(k - a > 0) {
			num = a;
			if(k - a - b > 0) {
				num-=(k-a-b);
			}
		}else {
			num = k;
		}
		System.out.println(num);
		sc.close();
	}
}


Measured memory_bytes: 35776
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, P[20];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> P[i];

	int ans = 0;
	rep(i, 1, N - 1) {
		int mi = min({ P[i - 1], P[i], P[i + 1] });
		int ma = max({ P[i - 1], P[i], P[i + 1] });
		if (mi != P[i] and ma != P[i]) ans++;
	}
	cout << ans << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define MP make_pair

typedef double db;

const db EPS = 1e-8;

inline int sign(db a) {
	return a < -EPS ? -1 : a > EPS;
}

struct P {
	db x, y;
	P() {
	}
	P(db _x, db _y) :
			x(_x), y(_y) {
	}
	P operator+(P p) {
		return P(x + p.x, y + p.y);
	}
	P operator-(P p)  {
		return P(x - p.x, y - p.y);
	}
	P operator*(db d) {
		return P(x * d, y * d);
	}
	P operator/(db d) {
		return P(x / d, y / d);
	}
	bool operator<(P p) const {
		int c = sign(x - p.x);
		if (c)
			return c == -1;
		return sign(y - p.y) == -1;
	}
	db dot(P p) {
		return x * p.x + y * p.y;
	}
	db det(P p) {
		return x * p.y - y * p.x;
	}
	db distTo(P p) { return (*this-p).abs(); }

	db alpha() {
		return atan2(y, x);
	}
	void read() {
		cin>>x>>y;
	}
	db abs() {
		return sqrt(abs());
	}
	db abs2() {
		return x * x + y * y;
	}
	P rot90(){
		return P(-y,x);
	}
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

P isSS(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
}

bool isMiddle(db a, db m, db b) {
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
 
bool isMiddle(P a, P m, P b) {
    return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}

bool onSegment(P p1, P p2, P q){
	return crossOp(p1,p2,q) == 0 && isMiddle(p1, q, p2);
}

P proj(P p1, P p2, P q) {
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}

P reflect(P p1, P p2, P q){
	return proj(p1,p2,q) * 2 - q;
}

db nearest(P p1,P p2,P q){
	P h = proj(p1,p2,q);
	if(isMiddle(p1,h,p2))
		return q.distTo(h);
	return min(p1.distTo(q),p2.distTo(q));
}

db getrad(P p1,P p2){
	return atan2l(p1.det(p2),p1.dot(p2));
}

db incircle(P p1, P p2, P p3){
	db A = p1.distTo(p2);
	db B = p2.distTo(p3);
	db C = p3.distTo(p1);
	return sqrtl(A*B*C/(A+B+C));
}

int main(){
	P p1, p2;
	p1.read(),p2.read();
	int n;cin>>n;
	rep(i,0,n){
		P q; q.read();
		int op = crossOp(p1,p2,q);
		if(op == 1){
			puts("COUNTER_CLOCKWISE");
		} else if(op == -1){
			puts("CLOCKWISE");
		} else {
			if(onSegment(p1,p2,q)){
				puts("ON_SEGMENT");
			} else if(onSegment(p1,q,p2)){
				puts("ONLINE_FRONT");
			} else {
				puts("ONLINE_BACK");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3200
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N,M; cin>>N>>M;
  vi P(M); vs S(M);
  REP(i,M) cin>>P[i]>>S[i];

  int acNum = 0, waNum = 0;
  vb ac(N+1, false); // ac[p] : 問題 p に AC したか
  vi wa(N+1,0); // wa[p] : 問題 p で、AC 前に WA を出した回数
  REP(i,M) {
    if (ac[P[i]]) continue; // AC 済み

    assert(ac[P[i]] == false); // 未 AC 問題のみを扱う
    
    if (S[i] == "AC") { // 初 AC
      acNum++;
      ac[P[i]] = true;
      waNum += wa[P[i]];
    } else if(S[i]=="WA") { // 未 AC で WA
      wa[P[i]]++;
    }
  }

  cout << acNum << " " << waNum << endl;


  return 0;
}


Measured memory_bytes: 6528
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC optimize "-O3"
# define int long long
  
using namespace std;
  
const int N = 1e5 + 7;
const int mod = 1e9 + 7;

vector < int > adj[N];

void solve() {
	int x;
	cin >> x;
	map < int, int > mp;
	for ( int i = -1000; i <= 1000; i++ ) {
		int A = i * i * i * i * i;
		for ( int j = -1000; j <= 1000; j++ ) {
			int B = j * j * j * j * j;
			if ( A - B == x ) {
				cout << i << ' ' << j;
				return;
			}
		}
	}
}

int32_t main() {
	speed;
	int T = 1;
	// cin >> T;
	while ( T-- ) {
		solve();
	}
}

Measured memory_bytes: 6004
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T>
class weight_uft{
private:
    typedef pair<ull,T> parent_weight;
    vector<pair<parent_weight,ull>> uft; //{parent_weight,node}
    ull size;
    T err;
public:
    weight_uft(ull size,T err=(T)(1e9)):size(size),err(err){
        uft.resize(size);
        for(int i=0;i<size;i++){
            uft[i]={{i,(T)0},1};
        }
    }
    
    parent_weight search(ull where){
        if(uft[where].F.F==where){return uft[where].F;}
        parent_weight P=search(uft[where].F.F);
        uft[where].F.F=P.F;
        uft[where].F.S+=P.S;
        return uft[where].F;
    }
    
    bool same(ull a,ull b){
        if(search(a).F==search(b).F){return true;}
        return false;
    }
    
    T dist(ull from,ull to){
        if(!same(from,to)){return err;}
        return search(from).S-search(to).S;
    }
    
    bool add(ull from,ull to,T d){
        if(same(from,to) && dist(from,to)!=d){return false;}
        if(same(from,to)){return true;}
        parent_weight f=search(from);
        parent_weight t=search(to);
        if(uft[t.F].S>uft[f.F].S){
            uft[f.F].F.F=t.F;
            uft[f.F].F.S=d-f.S+t.S;
            uft[t.F].S=uft[t.F].S+uft[f.F].S;
        }
        else{
            uft[t.F].F.F=f.F;
            uft[t.F].F.S=f.S-t.S-d;
            uft[f.F].S=uft[f.F].S+uft[t.F].S;
        }
        return true;
    }
};



int main(){
    ll n,q;
    cin>>n>>q;
    weight_uft<ll> uft(n,E);
    while(q--){
        ll c;
        cin>>c;
        if(c){
            ll a,b;
            cin>>a>>b;
            if(!uft.same(a,b)){cout<<"?"<<endl;}
            else{cout<<uft.dist(a,b)<<endl;}
        }
        else{
            ll a,b,d;
            cin>>a>>b>>d;
            uft.add(a,b,d);
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 5224
#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int binpow(int a, int b) {
	int ans = 1;
	while (b > 0) {
		if (b & 1) ans = (long long)(ans) * a % mod;
		a = (long long)(a) * a % mod;
		b >>= 1;
	}
	return ans;
}
int main() {
	int D, S;
	cin >> D;
	vector<int> L(D);
	for (int i = 0; i < D; ++i) cin >> L[i];
	cin >> S;
	vector<int> dp(S + 1); dp[S] = 1;
	for (int i = 0; i < D; ++i) {
		for (int j = 0; j <= S - L[i]; ++j) {
			dp[j] -= dp[j + L[i]];
			if (dp[j] < 0) dp[j] += mod;
		}
	}
	int ans = 0;
	for (int i = 1; i <= S; ++i) {
		ans = (ans + (long long)(dp[i]) * binpow(i, D)) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3188
/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.
Do not pray for an easy life, pray for the strength to endure a difficult one.
When something is important enough, you do it even if the odds are not in your favor.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.
No matter how hard it gets, NEVER GIVE UP*/

#include <bits/stdc++.h>

#define pb push_back
#define MP make_pair
#define ALL(r) (r).begin(),(r).end()

typedef long long int ll;

#define FOR(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; ++i )
#define FORN(i,m,n) for(ll i=(ll)(m-1) ; i >= (ll) (n) ; --i )

#define RUN_FAST ios::sync_with_stdio(false);

using namespace std;



void solve()
{
    ll a,b,c,d,m,n,p,q,r,x,y,z,aa,bb,cc,dd; //variable
    ll i,j,k,l; //pointer
    ll cnt=0,cnt1=0,cnt2=0,cnt3=0,sum=0,mx=LLONG_MIN,mn=LLONG_MAX; //counter
    ll flag=0,flag2=0; //flag
    vector <ll> vec1,vec2,vec3;
    string s1,s2,s3;

    //PULOK SAHA
    //BMO

    cin >> s1 >> s2 >> s3;

    cout << s1[0] << s2[1] << s3[2] << endl;

}

int main()
{
    RUN_FAST
    //PULOK SAHA
    //BMO

    ll t=1;//test case

    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}






//PULOK SAHA


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=500050;
char s[N];
int l[N],r[N];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='<') l[i]=l[i-1]+1;
		else l[i]=0;
	}
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='>') r[i]=r[i+1]+1;
		else r[i]=0;
	}
	ll ans=0;
	for(int i=0;i<=n;i++) ans+=max(l[i],r[i+1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    L = I()
    l3 = L / 3
    print(l3 ** 3)
    

main()



Measured memory_bytes: 66924
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
 
int main(){
    int N,ans=999999999,temp;
    int X[110];
    cin >> N;
    for(int i = 0;i < N;i++) cin >> X[i];
    for(int i = 1;i <= 100;i++){
        temp = 0;
        for(int j = 0; j < N;j++){
            temp += (X[j] - i)*(X[j] - i);
        }
        if(temp<ans) ans = temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(s) for s in input().split()]
x = 1
for i in range(n):
    if a[i] == 0:
        x = 0
if x == 0:
    print(0)
    exit(0)
inf = 10 ** 18
for i in range(n):
    if x * a[i] > inf:
        print(-1)
        exit(0)
    x *= a[i]
print(x)

Measured memory_bytes: 21660
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll x, y;
    cin >> x >> y;

    ll ans = 0;
    while(x <= y) {
        x *= 2;
        ans++;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, k, n) for (int i = k; i < n; ++i)

using namespace std;

template<class T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

int main(){
  // input
  int N, W;
  cin >> N >> W;
  vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0LL));

  // dp
  rep(i, 0, N){
    long long v, w;
    cin >> w >> v;
    rep(j, 0, W + 1) {
      if (j - w >= 0) chmax(dp[i + 1][j], dp[i][j - w] + v);
      chmax(dp[i + 1][j], dp[i][j]);
    }
  }
  // rep(i,0,N+1) {rep(j,0,W+1) {cout << dp[i][j] << " ";} cout << endl;}

  // output
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
  mint p(int n, int k) { return fact[n] * ifact[n - k]; }
} c(1000005);

int main(void) {
  int n, m;
  cin >> n >> m;
  mint ans = 0;
  for (int i = 0; i <= n; i++) {
    mint now = c(n, i);
    now *= c.p(m - i, n - i);
    if (i & 1) now = -now;
    ans += now;
  }
  ans *= c.p(m, n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18620
function main(input) {
  input = input.trim();
  const [a, b, c] = input.split(" ").map(n => Number(n));
  let result;
  if (b + c <= a) {
    result = 0;
  } else {
    result = c - (a - b);
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/*{{{*/
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define cout (c_?cerr:cout)
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_;\
__VA_ARGS__;--c_;if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define flg() __LINE__, __PRETTY_FUNCTION__
#define dprt(...) dbg(prt(__VA_ARGS__))
#define drprt(...) dbg(rprt(__VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__,'=',__VA_ARGS__)
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
#define rdmp(...) dbg(cerr<<#__VA_ARGS__<<": ";rprt(__VA_ARGS__))
using namespace std; using ll = long long;template< typename t > using V = vector< t >;
template< typename t > void prt(const t& a){cout<<a<<'\n';}template
< typename t, typename... v >void prt(const t& a, v&&... b){cout<<a<<' ';prt(b...);}
template< typename t > void rprt(t a, const t& b){while(a!=b)cout<<(*a++)<<' ';cout << '\n';}
/*}}}*/

int n;
string sl;
map< pair< string, string >, int > M;

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

    cin >> n >> sl;

    for (int i = 0; i < (1 << n); ++i)
    {
        V< string > tb(2);

        for (int k = 0; k < n; ++k)
            tb[(bool)((1 << k) & i)].push_back(sl[k]);

        reverse(all(tb[1]));

        ++M[make_pair(tb[0], tb[1])];
    }

    ll res = 0;

    for (int i = 0; i < (1 << n); ++i)
    {
        V< string > tb(2);

        for (int k = n; k < 2 * n; ++k)
            tb[(bool)((1 << (k - n)) & i)].push_back(sl[k]);

        reverse(all(tb[0]));

        res += M[make_pair(tb[0], tb[1])];

    }

    prt(res);
}

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

using namespace std;

int main(){
  int w,h;
  char c;
  cin>>w>>h>>c;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char a='.';
      if((!i||i==h-1)&&(!j||j==w-1))a='+';
      else if(!i||i==h-1)a='-';
      else if(!j||j==w-1)a='|';
      else if(i==h/2&&j==w/2)a=c;
      cout<<a;
    }
    cout<<endl;
  }
  return 0;
}

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

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

    ll ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (i % 3 == 0)
            continue;
        if (i % 5 == 0)
            continue;
        ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <cmath>
typedef long long LL;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  LL A,B;
  cin >> A>>B;
  if((A+B)%2==1){
    cout <<"IMPOSSIBLE";
  }else{
  	cout << (A+B)/2;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,tmp;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if(b<a){
        tmp=a;
        a=b;
        b=tmp;
    }
    
    if(c<b){
    tmp=b;
    b=c;
    c=tmp;
    }
    
    if(b<a){
    tmp=a;
    a=b;
    b=tmp;
    }
    
    printf("%d %d %d\n",a,b,c);
    return 0;
    
    
    }
        
 
    


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    char a, b;
    cin >> a >> b;
    string s="", t="";
    REP(i, b-'0'){
    	s += a;
    }
    REP(i, a-'0'){
    	t += b;
    }
    string mi = min(s, t);
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;

string point;
int p;
typedef pair<int, int> P;
queue<P> que;
vector<P> v[6];
string dijkstra();

int main(){
  v[0].push_back(P(0, 1)); v[0].push_back(P(1, 5));
  v[1].push_back(P(1, 2));
  v[2].push_back(P(1, 3)); v[2].push_back(P(0, 4));
  v[3].push_back(P(1, 1)); v[3].push_back(P(0, 5));
  v[4].push_back(P(0, 3)); v[4].push_back(P(1, 5));
  v[5].push_back(P(0, 1));
  while(1){
    cin >> point;
    p = point.size();
    if(point[0] == '#') break;
    que.push(P(0, 0));
    cout << dijkstra() << endl;
  }
}

string dijkstra(){
  bool flug = false;
  while(!que.empty() && flug == false){
    P now = que.front(); que.pop();
    if(now.f == 3 && now.s == p){
      flug = true;
      break;
    }
    else if(now.s >= p) break;
    
    for(int i = 0; i < v[now.f].size(); i++){
      if(v[now.f][i].f == point[now.s] - '0'){
	que.push(P(v[now.f][i].s, now.s + 1));
      }
    }
  }
  if(flug) return "Yes";
  return "No";
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int h,w,m,h1,w1,maxr,maxc,row[300005],col[300005];
vector<int> vr;
vector<int> vc;
set<pair<int,int> > st;
int main(){
	cin>>h>>w>>m;
	for(int i=1;i<=m;i++){
		cin>>h1>>w1;
		st.insert(make_pair(h1,w1));
		row[h1]++;
		if(row[h1]==maxr){
			vr.push_back(h1);
		}
		if(row[h1]>maxr){
			maxr=row[h1];
			vr.clear();
			vr.push_back(h1);
		}
		col[w1]++;
		if(col[w1]==maxc){
			vc.push_back(w1);
		}
		if(col[w1]>maxc){
			maxc=col[w1];
			vc.clear();
			vc.push_back(w1);
		}
	}
	for(vector<int>::iterator it=vr.begin();it!=vr.end();it++)
		for(vector<int>::iterator ite=vc.begin();ite!=vc.end();ite++){
			if(st.find(make_pair(*it,*ite))==st.end()){
				cout<<maxr+maxc<<endl;
				return 0;
			}
		}
	cout<<maxr+maxc-1<<endl;
	return 0;
} 

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans;
	ans = min(a*n, b);
	cout << ans << endl;
	return 0;
}


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

int main(){
  string s;
  cin>>s;
  rep(i,s.size())
    cout<<'x';
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 in (a, b):
    r -= c * pow(f, M - 2, M)
print(r % M)


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

int main(){
	int mark[26]={0};
	string word;
	cin >> word;
	int len=word.size();
	for (int i=0; i<len; i++){
		mark[word[i]-'a']++;
	}
	for (int i=0; i<26; i++){
		if (mark[i]==0){
			cout << (char)(i+'a') << "\n";
			return 0;
		}
	}
	cout << "None\n";
	return 0;
}

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

#define all(x)        (x).begin(),(x).end()
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int,int>
#define vi            vector<int>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;

int ar[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
void solve() {
  int k; cin >> k;
  cout << ar[--k] << "\n";
}

int main() {
  // freopen("input.in", "r", stdin);
  // freopen("input.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// cout<<setprecision(15);
	// int t; cin>>t; while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream &s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  vector<int> a(3); REP (i, 3) cin >> a[i];
  REP (i, 3) if (a[i] != a[0]) {
    cout << "No" << endl; return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

#define reps(i, f, n) for (int i = (f); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

const int INF = 1111111111;
const double EPS = 1e-9;

using namespace std;

void init()
{
}

void solve()
{
	int n, k;
	cin >> n >> k;

	const int N = 1111;
	int p[N];

	rep(i, n)
	{
		cin >> p[i];
	}

	sort(p, p + n);

	int sum = 0;
	rep(i, k)
	{
		sum += p[i];
	}

	cout << sum << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int arr[m];
  long int sum = 0;
  for(int i=0; i<m; i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
  if(sum>n)
    cout<<"-1\n";
  else
    cout<<n-sum<<"\n";
}
  


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

int main(){
  int n,m,l;
  cin>>n>>m>>l;
  int a[n][m],b[m][l];
  long c[n][l];


  for(int i=0;i<n;i++){
  for(int j=0;j<m;j++){
  for(int k=0;k<l;k++){
    a[i][j] = 0;
    b[j][k] = 0;
    c[i][k] = 0;
  }}}

  for(int i=0;i<n;i++){
  for(int j=0;j<m;j++){
    cin>>a[i][j];
  }}
  for(int j=0;j<m;j++){
  for(int k=0;k<l;k++){
    cin>>b[j][k];
  }}



  for(int i=0;i<n;i++){
  for(int j=0;j<l;j++){
  for(int k=0;k<m;k++){
    c[i][j] += a[i][k] * b[k][j];
  }}}

  for(int i=0;i<n;i++){
  for(int j=0;j<l;j++){
    if(j) cout<<' ';
    cout<<c[i][j];
  }
  cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3188
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static Map<Long, Long> map = new HashMap<>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			map.put(a, map.getOrDefault(a, 0L) + 1);
		}
		long ans = sumListA();
		int Q = sc.nextInt();
		for (int i = 0; i < Q; i++) {
			long b = sc.nextLong();
			long c = sc.nextLong();
			ans = changeKey(b, c, ans);
			System.out.println(ans);
		}
	}

	public static long sumListA() {
		long ret = 0L;
		for (Entry<Long, Long> entry : map.entrySet()) {
			ret += entry.getKey() * entry.getValue();
		}
		return ret;
	}

	public static long changeKey(long b, long c, long sum) {
		long count = map.getOrDefault(b, 0L);
		map.put(b, 0L);
		map.put(c, map.getOrDefault(c, 0L) + count);
		sum += (c - b) * count;
		return sum;
	}

}


Measured memory_bytes: 65560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace a{
    class Program
{
   public static void Main(string[] args)
    {
        while(true){
            int t=int.Parse(Console.ReadLine());
            if(t==0)break;
            int n=int.Parse(Console.ReadLine());
            int sum=0;
            for(int i=0;i<n;++i){
               	
                string[] input = Console.ReadLine().Split(' ');
                int s=int.Parse(input[0]);
                int f=int.Parse(input[1]);
                sum+=f-s;
            }
            if(sum>=t){
                Console.WriteLine("OK");
            }else{
                Console.WriteLine(t-sum);
            }
        }
    }
}
}

Measured memory_bytes: 9084
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int le[3640],ri[3640],nz[3640],no[3640];
int dp[3640][3640];
int main()
{
	int n,m,mo=1000000007,l,r;string s;
	cin>>n>>m;cin>>s;
	nz[0]=no[0]=0;
	rep(i,n){
		no[i+1]=no[i]+(s[i]-'0');
		nz[i+1]=i+1-no[i+1];
	}
	rep(i,n) le[i]=ri[i]=i;
	rep(i,m){
		cin>>l>>r;l--;r--;
		REP(j,l,r+1) le[j]=min(le[j],le[l]),ri[j]=max(ri[j],ri[r]);
	}
	//rep(i,n+1) cout<<nz[i]<<' '<<no[i]<<endl;
	//rep(i,n) cout<<le[i]<<' '<<ri[i]<<endl;
	//rep(i,n) cout<<nz[ri[i]+1]<<' '<<no[ri[i]+1]<<endl;
	memset(dp,0,sizeof(dp));dp[0][0]=1;
	rep(i,n+1) rep(j,n+1){
		if(i+j>n) dp[i][j]=0;
		if(i+j>0 && i>nz[ri[i+j-1]+1]) dp[i][j]=0;
		if(i+j>0 && j>no[ri[i+j-1]+1]) dp[i][j]=0;
		if(dp[i][j]>=mo) dp[i][j]-=mo;
		dp[i+1][j]+=dp[i][j];dp[i][j+1]+=dp[i][j];
	}
	cout<<dp[nz[n]][no[n]]<<endl;
}


Measured memory_bytes: 52096
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    internal static void Main(string[] args)
    {
        var inp = ReadLine().Split(' ').Select(s => long.Parse(s)).ToList();
        var X = inp[0];
        var Y = inp[1];
        var ans = 0;

        var hoge = X;
        do {
            ans++;
            hoge *= 2;
        } while (hoge <= Y);

        WriteLine(ans);
    }
}


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

const ll INF= 1LL << 60;

//入力
ll N;
ll K;
ll a[100010][3];
//dp
ll dp[100010][3];


void chmin(ll& a, ll b){
  if(a>b){
    a=b;
  }
}


void chmax(ll& a, ll b){
  if(a<b){
    a=b;
  }
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j]; 
    }
  }

  for(int i=0;i<100010;i++){
    for(int j=0;j<3;j++){
          dp[i][j]=0;
    } 
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k) continue;
      	chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  
  for(int i=1;i<3;i++){
    chmax(dp[N][0],dp[N][i]);
  }
  cout << dp[N][0] << endl;
}

Measured memory_bytes: 4992
/* D - Div Game */

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

int main(void){
  long long N, num;
  int ans = 0;
  cin >> N;
  num = N;
  for(long long p = 2; p <= sqrt(num); p++){
    int cnt = 0;
    while(num % p == 0){
      num /= p;
      cnt++;
    }
    for(int i = 1; ; i++){
      if(cnt - i >= 0){
        cnt -= i;
        ans++;
      }else{
        break;
      }
    }
  }
  // num > 1のときにp <= sqrt(num)を満たすpが存在なければnumは素数
  if(num > 1) ans++;
  cout << ans << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define v(T) vector<T>
#define imposs {cout<<"-1\n";return 0;}
#define LL_MAX LLONG_MAX
#define LL_MIN LLONG_MIN

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef multiset<int> msi;
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

int n;
int a[200000];
vi nexts[200000];

int ans[200000];
int l[200000];

void solve(int i, int bef_i, int d) {
  int up_i;
  int d_add = 0;
  if (d==0 || l[d-1] < a[i]) {
    up_i = d;
    d_add = 1;
  } else {
    int ll=-1;
    int rr=d;
    while (ll+1<rr) {
      int cc = (ll+rr)/2;
      if (l[cc] < a[i]) ll = cc;
      else rr = cc;
    }
    up_i = rr;
  }
  int bef_v = l[up_i];
  l[up_i] = a[i];
  d += d_add;
  ans[i] = d;
  for(auto n : nexts[i]) {
    if (n==bef_i) continue;
    solve(n, i, d);
  }
  d -= d_add;
  l[up_i] = bef_v;
  return;
}

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

  cin >> n;
  rep(i,n) cin >> a[i];
  int u, v;
  rep(i,n-1) {
    cin >> u >> v;
    --u;--v;
    nexts[u].pb(v);
    nexts[v].pb(u);
  }
  rep(i,n) l[i] = INT_MAX;
  solve(0, -1, 0);
  rep(i,n) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 31156
float x,p[8];i;float o(float*a,float*b,float*c){return a[1]*(*c-*b)+c[1]*(*b-*a)+b[1]*(*a-*c);}main(){for(;~scanf("%f,",p+i++%8);)i%8||puts(x*o(p+2,p+4,p+6)>0&x*o(p+4,p+6,p)>0&x*o(p+6,p,p+2)>0?"YES":"NO",x=o(p,p+2,p+4));}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
int main()
{
  while(true)
  {
    int n, sum = 0;
    int zero_item = 0;
    bool is_na = true;
    
    std::cin >> n;
    if(!n)
      break;
    for(int i = 0; i < n; i++)
    {
      int v;
      std::cin >> v;
      if(v > 1)
        is_na = false;
      if(v == 0)
        zero_item++;
    }
    if(is_na)
    {
      std::cout << "NA\n";
      continue;
    }
    std::cout << n - zero_item + 1 << std::endl;
  }
}

Measured memory_bytes: 1164
w, h, n = map(int, input().split())

pos = []
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if (x1 in [0, w] or y1 in [0, h]) and (x2 in [0, w] or y2 in [0, h]):
        pos.append((x1, y1, i))
        pos.append((x2, y2, i))

pos.sort(key=lambda v: v[0]) # top →
edge = [v[-1] for v in pos if v[1] == 0 and v[0] != 0]

pos.sort(key=lambda v: v[1]) # left ↓
edge += [v[-1] for v in pos if v[0] == w and v[1] != 0]

pos.sort(key=lambda v: v[0], reverse=True) # bottom ←
edge += [v[-1] for v in pos if v[1] == h and v[0] != w]

pos.sort(key=lambda v: v[1], reverse=True) # right ↑
edge += [v[-1] for v in pos if v[0] == 0 and v[1] != h]

# for i in range(len(edge) - 1):
#     if edge[i] == edge[i + 1]:
#         break
# for j in range(len(edge) // 2):
#     if edge[(i + j + 1) % n] != edge[(i - j + n) % n]:
#         print("NO")
#         break
# else:
#     print("YES")

# print(edge)
hist = [None] * n
step = 0
for v in edge:
    if hist[v] is None:
        hist[v] = step + 1
        step += 1
    else:
        if hist[v] != step:
            print("NO")
            break
        step -= 1
else:
    print("YES")



Measured memory_bytes: 39492
#include<bits/stdc++.h>
using namespace std;int c[100020];bool isp(int n){if(n==1)return false;for(int i=2;i<=int(sqrt(n));i++){if(n%i==0)return false;}return true;}int main(){int q,l,r;cin>>q;for(int i=1;i<100007;i++){if(isp(i)&&isp((i+1)/2))c[i]=1+c[i-1];else c[i]=c[i-1];}for(int i=0;i<q;i++){cin>>l>>r;cout<<c[r+1]-c[l-1]<<endl;}}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C, D = map(int, readline().split())

    print(max(A * B, C * D))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
use proconio::input;
fn main(){
input!{t:usize}
for _ in 0..t{
input!{n:usize,mut a:[(usize,i64,i64);n]}
let mut ans=0;
a.sort();
for(_,l,r)in a.iter(){ans+=std::cmp::min(l,r);}
let mut s=std::collections::BinaryHeap::new();
let mut i=0;
for j in 1..=n{
while i<a.len()&&a[i].0==j{let x=a[i].2-a[i].1;if x<=0{s.push(x)};i+=1}
while s.len()>j{s.pop();}
}
ans-=s.iter().sum::<i64>();
s.clear();
let mut i=a.len();
for j in 1..=n{
while i>0&&a[i-1].0==n{i-=1}
while i>0&&a[i-1].0==n-j{let x=a[i-1].1-a[i-1].2;if x<0{s.push(x)};i-=1}
while s.len()>j{s.pop();}
}
ans-=s.iter().sum::<i64>();
println!("{}",ans);
}
}

Measured memory_bytes: 12504