akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll N_MAX = 100;
const ll P_I_MAX = 100;

class Res{
public:
ll n,second;
string first;
};

ll N;
vector<Res> v;
void input() {
	scanf("%lld", &N);

	rep(i, N) {
		string a;ll b;
		cin >> a>>b;
		Res r;
		r.first=a;
		r.second=b;
		r.n=i+1;
		v.push_back(r);
	}
}

void solve() {


	sort(v.begin(), v.end(), [](const Res &x, const Res &y) {
		if(x.first==y.first)return x.second > y.second;
		return x.first < y.first;
	});

	rep(i,N)p(v[i].n);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    bool flag = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i*j == n) {
                flag = true;
                break;
            }
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 120000;
const int LOG = 20;

int n;
ll x[MAXN];
ll l;
ll go[LOG][MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lld", x + i);
	scanf("%lld", &l);
	int now = 0;
	for (int i = 0; i < n; ++i) {
		while (now < n - 1 && x[now + 1] - x[i] <= l)
			++now;
		go[0][i] = now;
	}
	for (int i = 1; i < LOG; ++i)
		for (int j = 0; j < n; ++j)
			go[i][j] = go[i - 1][go[i - 1][j]];
	int q;
	scanf("%d", &q);
	for (int it = 0; it < q; ++it) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a, --b;
		if (a > b)
			swap(a, b);
		int ans = 0;
		for (int i = LOG - 1; i >= 0; --i) {
			if (go[i][a] < b)
				ans += (1 << i), a = go[i][a];
		}
		printf("%d\n", ans + 1);
	}
	return 0;
}




Measured memory_bytes: 17280
import java.util.Scanner;

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

        int k = stdIn.nextInt();
        int n = stdIn.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = stdIn.nextInt();
        }

        int max = 0;
        int sub;
        for(int i=0; i<n-1; i++){
            sub = a[i+1] - a[i];
            if(sub > max){
                max = sub;
            }
        }
        sub = (a[0] + k) - a[n-1];
        if(sub > max){
            max = sub;
        }

        System.out.println(k-max);
    }
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string
#define boost ios_base::sync_with_stdio(false)
#define deb(x) cout << #x" = " << x << '\n'
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;


int main() {
//    freopen("input.in", "r", stdin);
	int a[5];
	scanf("%d %d %d", a+0, a+1, a+2);
	sort(a, a+3);
//	printf("%d %d %	d\n", a[0], a[1], a[2]);
	bool ok = false;
	while(1) {
		if(a[0]+a[1] == a[2]) ok = true;
//		deb(a[0]);
//		deb(a[1]);
//		deb(a[2]);
		if(!next_permutation(a, a+3)) break;
	}
	puts(ok ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
# 視点を変えてやる全探索 000~999までが達成できたらおｋ
n = int(input())
s = list(input())
ans = 0
for i in range(1000):
    t = list(f"{i:0>3}")
    j = 0
    tmp = ""
    for c in s:
        if t[j] == c:
            j += 1
        if j == 3:
            ans += 1
            break
print(ans)

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

using namespace std;

typedef long long ll;
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;
}

const int MAX = 30;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  COMinit();

  ll N;
  cin >> N;
  ll len = 1;
  for(int i = 0; i < N; i++){
    len *= 2;
  }

  vector<ll> S(len);
  for(int i = 0; i < len; i++){
    cin >> S[i];
  }

  sort(S.begin(), S.end(), greater<ll>());

  bool ans = true;

  vector<int> gen(len);
  vector<int> pre_gen(len);

  pre_gen[0] = 1;
  gen[0] = 1;
  ll cnt = 1;
  for(int i = 0; i < N; i++){

    ll loc = 0;
    ll tmp_cnt = 0;
    for(int j = 0; j < len; j++){
      
      if(pre_gen[j] && tmp_cnt < cnt){
        
        while(loc < len){

          if(!gen[loc] && S[j] > S[loc]){
            gen[loc] = 1;
            loc++;
            tmp_cnt++;
            break;
          }
          loc++;
        }
      }
    }

    pre_gen = gen;
    if(tmp_cnt != cnt){
      ans = false;
    }

    cnt *= 2;

  }

  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 4480
function main(input) {
  const args = input.split(' ').map((n) => parseInt(n, 10));
  const a = args[0],
        b = args[1],
        c = args[2]
  
  const num = (a * 100) + (b * 10) + c
  
  if (num % 4 === 0) {
  	console.log('YES');
  } else {
    console.log('NO');
  }
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pl;
#define pi pair<int,int>
#define MM 1000000000
#define MOD MM+7
#define initial_value -1
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[8] = {-1,0,1,0,1,-1,1,-1};
int dy[8] = {0,-1,0,1,1,1,-1,-1};
struct edge{ll to,cost;};
ll ans = 1LL;

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

ll lcm(ll a, ll b){
    ll g = gcd(a,b);
    return a/g * b;
}
int main(){
    int N; cin >> N;
    ll t;
    for(int i = 0; i < N; i++){
        cin >> t;
        ans = lcm(ans,t);
    }
    cout << ans << endl;
}

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

using namespace::std;

int main() {
	int A, B;
	cin >> A >> B;

	int ans = 0;
	int MAX = max(A, B);
	int MIN = min(A, B);

	ans = MAX + max(MAX - 1, MIN);

	cout << ans << endl;
	return 0;
}

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

int main() {

int A,B,K;
bool ans = false;

cin >> K;
cin >> A >> B;

for (int i=A; i <= B ; i++){
    if(i % K == 0){
        ans = true;
    }
}


if(ans){
    cout << "OK" << endl;
}
else{
    cout << "NG" <<endl;
}

}


Measured memory_bytes: 3596
N,A,B,C,D=map(int,input().split())
s=input()

def solve(r,l):
    for i in range(r,l-1):
        if s[i-1] == "#" and s[i] == "#":
            return False
    return True

def perfect_solve(r,l):
    for i in range(r,l-1):
        if s[i-1] =="#" and s[i] =="#":
            return False

    for i in range(r-1,l):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            return True
    return False

if C < B :
    if solve(A,C) and solve(B,D):
        print("Yes")
    else:
        print("No")
elif C < D :
    if solve(B,D) and solve(A,B):
        print("Yes")
    else:
        print("No")
else:
    if perfect_solve(B,D) and solve(A,B) and solve(D,C):
        print("Yes")
    else:
        print("No")

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

int main() {
    int n, a, x = 0, y = 0, z = 0;
    cin >> n;
    rep(i, n) {
        cin >> a;
        if(a % 2) x++;
        else if(a % 4) y++;
        else z++;
    }
    if(y) x++;
    if(x <= z + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
S = list(input())
T = list(input())

lst_of_values = []
for i in range(len(S)):
    current = 0
    if i + len(T) > len(S):
        break
    for j in range(i, i+len(T)):
        if S[j] != T[j-i]:
            current += 1
    lst_of_values.append(current)

print(min(lst_of_values))

Measured memory_bytes: 8932
N = int(input())

candies = [[int(i) for i in input().split()] for j in range(2)]

max = 0
total = 0
for c in range(N):
    for n in range(N - c):
        total += candies[0][n]
    for n in range(N - c - 1, N):
        total += candies[1][n]
    if max <= total:
        max = total
    total = 0

print(max)


Measured memory_bytes: 3060
import sys

def main():
    TARGET = 753
    ANS = 9999

    x = sys.stdin.readline().strip()
    for i in range(len(x) - 2):
        target = int(x[i:i+3])
        ANS = min(abs(TARGET - target), ANS)
    print(ANS)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();

		System.out.println(Math.min(P + R, Math.min(P + Q, Q + R)));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
    int to,cap,rev;
    edge(){}
    edge(int tt,int cc,int rr){
        to=tt;
        cap=cc;
        rev=rr;
    }
};


class dinic{
public:
    const int INF=1000000;
    vector<edge> G[100005];
    int level[100005];
    int iter[100005];
    void add_edge(int from,int to,int cap){
        G[from].push_back(edge(to,cap,G[to].size()));
        G[to].push_back(edge(from,cap,G[from].size()-1));
    }

    void bfs(int s){
        memset(level,-1,sizeof(level));
        queue<int> que;
        level[s]=0;
        que.push(s);
        while(que.size()){
            int v=que.front();
            que.pop();
            for(int i=0;i<G[v].size();i++){
                edge &e=G[v][i];
                if(e.cap>0 && level[e.to]<0){
                    level[e.to]=level[v]+1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v,int t,int f){
        if(v==t)return f;
        int res=0;
        for(int &i=iter[v];i<G[v].size();i++){
            edge &e=G[v][i];
            if(e.cap>0 && level[v]<level[e.to]){
                int d=dfs(e.to,t,min(e.cap,f));
                if(d>0){
                    e.cap-=d;
                    G[e.to][e.rev].cap+=d;
                    res+=d;
                    f-=d;
                    if(f==0)break;
                }
            }
        }
        return res;
    }

    int max_flow(int s,int t){
        int flow=0;
        while(1){
            bfs(s);
            if(level[t]<0)return flow;
            memset(iter,0,sizeof(iter));
            int f;
            while((f=dfs(s,t,INF))>0){
                flow+=f;
            }
        }
    }
};

dinic di;


int n,m;
vector<int> G[200006];

int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        di.add_edge(a,b,1);
    }
    bool flag=false;
    int over=0;
    int four=0;
    for(int i=0;i<n;i++) {
        if (G[i].size() % 2 != 0) {
            flag = true;
        }
        if (G[i].size() == 4) {
            four++;
        }
        if (G[i].size() >= 6) {
            over++;
        }
    }
    if(flag){
        printf("No\n");
    }else if(over>=1 || four>=3){
        printf("Yes\n");
    }else if(four==2){
        int a=-1,b=-1;
        for(int i=0;i<n;i++){
            if (G[i].size()== 4) {
                if(a==-1){
                    a=i;
                }else{
                    b=i;
                }
            }
        }
        int val=di.max_flow(a,b);
        printf("%s\n",val==2?"Yes":"No");
    }else{
        printf("No\n");
    }
    return 0;
}




Measured memory_bytes: 15360
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){

  int N; cin >> N;
  vector <ll> A(N);
  ll sum = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    sum += A[i];
  }

  ll ans = sum;
  ll now = 0, next = sum;
  for (int i = 0; i < N; i++){
    now += A[i]; next -= A[i];
    if (abs(now - next) < ans){
      ans = abs(now - next);
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x[10],y[10],a,b;
  cin>>x[0]>>y[0]>>x[1]>>y[1];
  
  a=x[1]-x[0];
  b=y[1]-y[0];
  
  x[2]=x[1]-b;
  y[2]=y[1]+a;
  
  x[3]=x[2]-a;
  y[3]=y[2]-b;
  
  cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<" "<<endl;
}



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

using namespace std;

int  divnum(int x){
  int i=2;
  if(x < 2) return 1;
  else if(x == 2) return i;
  if(x%2 == 0) i+=2;
  if(x == 4) return 3;
  for(int j = 3; j*j <= x; j += 1){
	if(x%j == 0){
	  if(x == j) i++;
	  else{
		i+=2;
		if(x == j*j) i--;
	  }
	}
  }
  return i;
}

int main(){
  int n;
  int ans = 0;
  cin >> n;

  for (int i = 1; i <= n; i++)
  {
	if(divnum(i) == 8 && i%2 == 1){
		ans++;
	}
  }

  cout << ans << endl;
}

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

#define mp make_pair
#define pb push_back

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double num;
typedef pair<num, num> nn;
typedef vector<nn> vnn;

int main(){
	int R, G;
  	cin >> R >> G;
  	cout << 2*G - R << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll X, ll A, ll B) {
  if (B <= A) cout << "delicious" << endl;
  else if (B <= A + X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll B;
	ll A;
	ll X;
	scanf("%lld", &X);
	scanf("%lld", &A);
	scanf("%lld", &B);
	solve(X, A, B);
	return 0;
}


Measured memory_bytes: 256
def solve(n, x):
    m = 2 * n - 1

    if x == 1 or x == m:
        print('No')
        return
    if x == n:
        print('Yes')
        print('\n'.join(map(str, range(1, m + 1))))
        return
    if x < n:
        tmp = [1] + list(range(x, m + 1)) + list(range(2, x))
    else:
        tmp = [m] + list(range(x, 0, -1)) + list(range(x + 1, m))
    ans = list(reversed(tmp[0::2])) + tmp[1::2]
    print('Yes')
    print('\n'.join(map(str, ans)))


n, x = map(int, input().split())
solve(n, x)


Measured memory_bytes: 26684
#include <stdio.h>
int main(){
  int n,m,l,i,j,k,a[100][100],b[100][100];
        long long c[100][100]={0};
        scanf("%d %d %d",&n,&m,&l);
        for(i=0;i<n;i++){
                for(j=0;j<m;j++){
                        scanf("%d",&a[i][j]);
                }
        }
        for(i=0;i<m;i++){
                for(j=0;j<l;j++){
                        scanf("%d",&b[i][j]);
                }
        }
        for(i=0;i<n;i++){
                for(j=0;j<l;j++){
                        for(k=0;k<m;k++){
                                c[i][j]+=a[i][k]*b[k][j];
                        }
                        if(j!=0) printf(" ");
                        printf("%lld",c[i][j]);
                }
                puts("");
        }
        return 0;
}



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

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

		Scanner scn = new Scanner(System.in);
		
		int a = scn.nextInt();
		int b = scn.nextInt();
		
		if (a == b){
			System.out.println("a == b");
		}
		else if (a < b){
			System.out.println("a < b");
		}
		else {
			System.out.println("a > b");
		}
	}
}

Measured memory_bytes: 26228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int sum=0;
  int count=0;
  int t=n;
  cin>>n;
    if(n>=10)
    {
        sum=+9;
    }
    else{
        sum+=n%10;
    }
    if(n>=1000)
    {
        sum+=999-99;
    }
    else if(n>99&&n<1000){
        
        sum+=n-99;
    }
    if(n>=100000)
    {
        sum+=99999-9999;
    }
    else if(n>9999&&n<100000){
        
        sum+=n-9999;
    }
    cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int m = 51;
	int f = 51;
	int r = 101;
	char grade;

	do {
		if (m + f + r <= 200) {
			if (m == -1 || f == -1) {
				grade = 'F';
			} else if (m + f >= 80) {
				grade = 'A';
			} else if (m + f >= 65) {
				grade = 'B';
			} else if (m + f >= 50) {
				grade = 'C';
			} else if (m + f >= 30) {
				if (r >= 50) {
					grade = 'C';
				} else {
					grade = 'D';
				}
			} else {
				grade = 'F';
			}
			printf("%c\n", grade);
		}
		scanf("%d %d %d", &m, &f, &r);
	} while (m > -1 || f > -1 || r > -1);
	return 0;
}

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

int main() {
    int max = 0, cnt = 0, i;
    string S;
    cin >> S;
    for (i = 0; i < S.size(); i++) {
        if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
            cnt++;
            if (cnt > max) max = cnt;
        } else cnt = 0;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}
int main() {
    int a[3];
    for (int i = 0; i < 3; i++) {
        scanf("%d", &a[i]);
    }
    qsort(a, 3, sizeof(int), cmpint);
    printf("%d\n", a[2] - a[0]);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}


//modの値の確認をすること
int main(){
    ll n,k;
    string s;
    cin >> n >> k >> s;
    ll c = 0;
    rep0(i, n - 1)if(s[i] != s[i + 1])++c;
    pf(min(n - 1,n - c - 1 + k * 2));
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, res = 0;
    cin >> n;
    rep(i, n) res += (i + 1);
    cout << res << endl;
    // end

    return 0;
}


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

const int MAXN = 2e5 + 10;
int n, m, ans, cnt[MAXN], r[MAXN], a[MAXN];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i = 0; i <= n; i++)
		for (int j = 1; j <= cnt[i]; j++)
			if (i - j >= 0)
				r[i - j]++;
	for (int i = 0; i < n; i++)
		ans += (r[i] == 0);
	for (int i = 0; i < m; i++) {
		int p, c, t;
		cin >> p >> c;
		p--;
		t = a[p] - cnt[a[p]];
		if (t >= 0) {
			r[t]--;
			ans += r[t] == 0;
		}
		cnt[a[p]]--;
		a[p] = c;
		cnt[a[p]]++;
		t = a[p] - cnt[a[p]];
		if (t >= 0) {
			r[t]++;
			ans -= r[t] == 1;
		}
		cout << ans << '\n';
	}
}

Measured memory_bytes: 3712
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cost_a = 0
cost_b = 0

for i in reversed(range(0, X+1)):
  if i-1 in A:
    cost_a += 1
  
for j in range(X, N+1):
  if j in A:
    cost_b += 1

print(min(cost_a, cost_b))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[][] array=new int[12][10];
		for(int i=1; i<=n; i++){
			int bui=sc.nextInt();
			int fl=sc.nextInt();
			int ro=sc.nextInt();
			int ppl=sc.nextInt();
			array[(bui-1)*3+fl-1][ro-1]+=ppl;
		}
		for(int i=0; i<array.length; i++){
			for(int j=0; j<array[0].length; j++){
				System.out.print(" "+array[i][j]);
			}
			System.out.println();
			if((i+1)%3==0 && (i+1)!=12){
				System.out.println("####################");
			}
		}


	}




}


Measured memory_bytes: 29964
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include <cmath> 
using namespace std;
const int p=31;
const int m=1e9+9;
typedef long long ll;
#define PI 3.14159265358979323846264338327950288419716939937510
//return res.empty() ? "0" : res;
/* istringstream ss(text);
    string s;
    while(ss>>s)*/

vector<int> vis(1e5+2,0);
vector<vector<int>>adj(1e5+2,vector<int>(0));

static auto speedup = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return nullptr;
}();

queue<int> q;
std::vector<int> path(1e5+2);
void bfs(int x){	
	q.push(x);
	vis[x]=1;
	while(!q.empty()){
		int v=q.front();
		q.pop();
		for(int i:adj[v]){
			if(path[i]==0)
				path[i]=v;	
			if(!vis[i]){
				q.push(i);
				vis[i]=1;
			}
		}
	}

}
/*void dfs(int x){	
	s.push(x);
	while(!s.empty()){
		int v=s.top();
		s.pop();
		if(vis[v])continue;
		vis[v]=1;
		for(int i:adj[v]){
			//if(path[i]==0)
			path[i]=v;	
			if(!vis[i]){
				s.push(i);
			}
		}
	}

}
*/
int main (){

    #ifndef ONLINE_JUDGE					
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n,m,x,y;
    cin>>n>>m;

    for(int i=1;i<=m;i++){
    	cin>>x>>y;
    	adj[x].push_back(y);
    	adj[y].push_back(x);
    }

    bfs(1);
    for(int i=1;i<=n;i++){
    	if(vis[i]==0){
    		cout<<"No";
    		return(0);
    	}	
    }
    cout<<"Yes"<<'\n';
    for(int i=2;i<=n;i++){
    	cout<<path[i]<<'\n';
    }


}


Measured memory_bytes: 10652
b,n,ans,i,l,r;calc(a){b=0;while(a)b+=a%10,a/=10;return b;}
main(){scanf("%d%d%d",&n,&l,&r);for(i=1;i<=n;++i)if(calc(i)<=r&&calc(i)>=l)ans+=i;printf("%d",ans);
}

Measured memory_bytes: 128
var
  i,j,n:longint;
  ans:qword;
  s:ansistring;
begin
  read(s);
  n:=length(s);
  for i:=1 to n do
    begin
      if s[i]='W' then
        begin
          inc(j);
          ans:=ans+(i-j);
        end;
    end;
  write(ans);
end.

Measured memory_bytes: 384
from math import *
from collections import *
n=int(input())
a=list(map(int,input().split()))
f=Counter(a)
q=int(input())
r=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    re=f[b]
    del f[b]
    if(c in f):
        f[c]+=re
    else:
        f[c]=re
    r+=(c-b)*re
    print(r)


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

struct Dense2DSegmentTree {
  using T = int;
  static T op(const T& a, const T& b) { return min(a, b); }
  static constexpr T e() { return ~(~0 << 31); }

  struct SegmentTree {
    const int n;
    V<T> t;
    SegmentTree(int n) : n(n), t(2 * n, e()) {}
    T& operator[](int i) { return t[i + n]; }
    void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
    T acc(int l, int r) const {
      T res = e();
      for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if (l & 1) res = op(res, t[l++]);
        if (r & 1) res = op(res, t[--r]);
      }
      return res;
    }
    void set(int i, const T& a) {
      t[i += n] = a;
      while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
    }
  };
  const int n;
  V<SegmentTree> st;
  Dense2DSegmentTree(int n, int m) : n(n), st(2 * n, SegmentTree(m)) {}
  T acc(int x0, int x1, int y0, int y1) const {
    T res = e();
    for (x0 += n, x1 += n; x0 < x1; x0 >>= 1, x1 >>= 1) {
      if (x0 & 1) res = op(res, st[x0++].acc(y0, y1));
      if (x1 & 1) res = op(res, st[--x1].acc(y0, y1));
    }
    return res;
  }
  void set(int x, int y, const T& a) {
    for (x += n; x; x >>= 1) st[x].set(y, op(st[x][y], a));
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int r, c, q; cin >> r >> c >> q;
    if (!r) break;
    Dense2DSegmentTree st(r, c);
    for (int i = 0; i < r; ++i) for (int j = 0; j < c; ++j) {
      int x; cin >> x;
      st.set(i, j, x);
    }
    while (q--) {
      int r0, c0, r1, c1; cin >> r0 >> c0 >> r1 >> c1, ++r1, ++c1;
      cout << st.acc(r0, r1, c0, c1) << '\n';
    }
  }
}


Measured memory_bytes: 128012
N, M = map(int, raw_input().split())
pyi = {}
for i in range(M):
  pi, yi = map(int, raw_input().split())
  if pi not in pyi:
    pyi[pi] = []
  pyi[pi].append((yi,i))
ix = [0]*M
for p in pyi:
  pyi[p].sort()
  j = 1
  for y, i in pyi[p]:
    ix[i] = "%06d%06d" % (p, j)
    j += 1
for x in ix:
  print x

Measured memory_bytes: 42412
#include <bits/stdc++.h>
/*...
  ...
  author 
  @
  Aman Kothari
  .....
  .....*/
using namespace std;
#define ll long long
#define dl double

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
   	cin>>n;
	string s;
	cin>>s;
	ll ans=0,r=0;
	for(ll i=0;i<s.length();i++){
		if(s[i]=='R'){
			r++;
		}
	}
	for(ll i=0;i<r;i++){
		if(s[i]=='R'){
			ans++;
		}
	}
	// cout<<r<<"\n";
	cout<<r-ans<<"\n";
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,ans=0;
	cin >> n>>m;
	for (int i = m/n; i >=0; --i) {
		if (!(m%i)) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

a.sort()
ans1 = a[n-1]
ans2 = 0
minabs = 10**9+1
x = a[n-1]//2

for i in range(n-1):
    y = abs(a[i]-x)
    if a[n-1]%2 == 0:
        if minabs > y:
            ans2 = a[i]
            minabs = y
    else:
        if minabs > min(y,abs(a[i]-x-1)):
            ans2 = a[i]
            minabs = y
 
print(ans1,ans2)

Measured memory_bytes: 14052
#include<iostream>
#include<complex>
#include<algorithm>
#include<vector>
#include<cstdio>
#define LT(x,y) ((x)<=(y)-EPS)
using namespace std;
typedef complex<double> Point;
const double EPS = 1e-6;
const int BUF = 55;
const int INF = 1 << 30;


vector<Point> calcCircle(Point &a, Point &b, double r) {
    double abDistance = abs(a - b);
    double angle = acos((abDistance / 2) / r);
    vector<Point> ret;
    ret.push_back((b - a) * polar(r / abDistance,   angle) + a);
    ret.push_back((b - a) * polar(r / abDistance, - angle) + a);
    return ret;
}


int nPt;
Point pt[BUF];

void read() {
    cin >> nPt;
    for (int i = 0; i < nPt; ++i) {
        int x, y;
        cin >> x >> y;
        pt[i] = Point(x, y);
    }
}


bool isOk(double r) {
   for (int i = 0; i < nPt; ++i) {
        for (int j = i + 1; j < nPt; ++j) {
            if (LT(r * 2, abs(pt[i] - pt[j]))) continue;
            vector<Point> circleList = calcCircle(pt[i], pt[j], r);
            for (int k = 0; k < 2; ++k) {
                for (int l = 0; l < nPt; ++l) {
                    if (LT(r, abs(pt[l] - circleList[k]))) {
                        goto _fail;
                    }
                }
                return true;
            _fail:;
            }
        }
   }
   return false;
}

void work() {
    int LOOP = 1000;
    double NG = 0, OK = INF;
    
    for (int loop = 0; loop < LOOP; ++loop) {
        double mid = (NG + OK) / 2;
        if (isOk(mid)) {
            OK = mid;
        } else {
            NG = mid;
        }
    }
    
    printf("%.12lf\n", (OK + NG) / 2);
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
const lint INF = 1e18;

template<class T> struct BIT{
    int n;
    vector<T> node;
    
    BIT(int n_){
        n = n_;
        node.resize(n+1, 0);
    }
    
    T sum(int i){
        T s = 0;
        while(i){
            s += node[i];
            i -= i & -i;
        }
        return s;
    }
    
    void add(int i, T x){
        while(i <= n){
            node[i] += x;
            i += i & -i;
        }
    }
};

int main(){
    int n;
    scanf("%d", &n);
    char c[n*2];
    int a[n*2];
    rep(i, n*2) scanf(" %c%d", &c[i], &a[i]);
    BIT<lint> wbit(n);
    BIT<lint> bbit(n);
    lint ww[n+1], wb[n+1][n+1], bw[n+1][n+1], bb[n+1];
    rep(i, n+1){
        rep(j, n+1) wb[i][j] = bw[i][j] = 0;
        ww[i] = bb[i] = 0;
    }
    rep(i, n*2){
        if(c[i] == 'W'){
            ww[a[i]] = wbit.sum(n) - wbit.sum(a[i]);
            wbit.add(a[i], 1);
            For(j, 1, n+1) wb[a[i]][j] = bbit.sum(j);
        }
        else{
            bb[a[i]] = bbit.sum(n) - bbit.sum(a[i]);
            bbit.add(a[i], 1);
            For(j, 1, n+1) bw[a[i]][j] = wbit.sum(j);
        }
    }
    lint dp[2][n+1];
    rep(i, 2)rep(j, n+1) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, 2*n){
        rep(j, n+1)if(dp[0][j] < INF){
            if(j < n) dp[1][j+1] = min(dp[1][j+1], dp[0][j] + bb[j+1] + bw[j+1][n] - bw[j+1][i-j]);
            if(i-j < n) dp[1][j] = min(dp[1][j], dp[0][j] + ww[i+1-j] + wb[i+1-j][n] - wb[i+1-j][j]);
        }
        rep(j, n+1){
            dp[0][j] = dp[1][j];
            dp[1][j] = INF;
        }
    }
    printf("%lld\n", dp[0][n]);
}

Measured memory_bytes: 62976
// C - Attack Survival
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K,Q; cin>>N>>K>>Q;
	vector<int> ans(N+1);
	for(int i=0; i<Q; ++i){ int a; cin>>a; ans[a]++; }
	for(int i=1; i<=N; ++i) cout<< (K-Q+ans[i]>0? "Yes":"No") <<endl;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr int INF = 1000000;

string replace_string(string source, string find, string alt) {
    string result = source;
    string::size_type pos = 0;
    while (pos = result.find(find, pos), pos != string::npos) {
	result.replace(pos, find.length(), alt);
	pos += alt.size();
    }
    return result;
}

int bfs(vector<string> &a, vector<string> &b, int N, string s, string Q, int d) {
    if (s.size() > Q.size()) return INF;
    if (d > 10) return INF;
    if (s == Q)return d;
    int ret = INF;
    for (int i = 0; i < N; i++) {
	if (s.find(a[i]) != string::npos) {
	    string t = replace_string(s, a[i], b[i]);
	    ret = min(ret, bfs(a, b, N, t, Q, d + 1));
	}
    }
    return ret;
}

int main() {

    while (true) {

	int N;
	cin >> N;

	if (N == 0) break;

	vector<string> a(N), b(N);
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];

	string R, Q;
	cin >> R >> Q;

	int ans = bfs(a, b, N, R, Q, 0);

	if (ans == INF) cout << -1;
	else cout << ans;
	cout << endl;

    }

    return 0;
}







Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int r, d;
	int x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = x * r - d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))
cnt = 0
a_before = 1
while cnt <= n:
    cnt += 1
    if a[a_before] == 2:
        print(cnt)
        break
    a_before = a[a_before]
else:
    print(-1)

Measured memory_bytes: 12708
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	cin >>n;
	vector<int>a(n),ans(n,0);
	rep(i,n-1){
		cin>>a[i];
		ans[a[i]-1]++;
	}
	rep(i,n){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 4844
N,T=map(int,input().split())
ct = [[0,0] for i in range(N)]
for i in range(N):
  ct[i]=list(map(int,input().split()))
ct.append([-1,T])
ct.sort(key=lambda x:x[1])
index = ct.index([-1,T])
if index==0:
  print("TLE")
else:
  ans = sorted(ct[:index],key=lambda x:x[0])
  print(ans[0][0])

Measured memory_bytes: 3064
#!/usr/bin/python
# -*- coding: utf-8 -*-



def gen(start, s):
	for i in xrange(1, len(s)+1):
		c = start[i]
		h = s[i] if i < len(s) else s[0]
		if h == 'o':
			if c == 'S':
				start += start[i-1]
			else:
				start += 'S' if start[i-1] == 'W' else 'W'
		else:
			if c == 'S':
				start += 'S' if start[i-1] == 'W' else 'W'
			else:
				start += start[i-1]

	if start[:2] == start[-2:]:
		return start[:-2]
	return ''


def main():
	n = int(raw_input())
	s = raw_input()

	for x in ('SS', 'SW', 'WW', 'WS'):
		ans = gen(x, s)
		if ans:
			print ans
			return
	print -1

if __name__ == '__main__':
	main()

Measured memory_bytes: 3072
# AGC036A - Triangle
def main():
    # fix two coordinates
    # -> S = |ad - bc|/2 ((0, 0), (a, b), (c, d))
    S = int(input())
    x1, y1, x2, y2 = 0, 0, 1, 10 ** 9
    x3 = (S - 1) // y2 + 1
    y3 = -(S - x3 * y2)
    print(x1, y1, x2, y2, x3, y3)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    string S;
    cin >> A >> B >> S;

    bool ok = true;
    REP(i, A) ok &= isdigit(S[i]);
    ok &= S[A] == '-';
    REP(i, B) ok &= isdigit(S[i + A + 1]);

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>

using namespace std;

typedef long long ll;

int N;
ll ans = 0;

void check(ll x) {
		bitset<3> used;

		ll l = log(x) + 1;
		ll t1 = x, t2;
		for (int i = 0; i < l; i++) {
				t2 = t1 % 10;
				if ( t2 == 7 ) used[2] =true;
				else if ( t2 == 5 ) used[1] = true;	
				else if ( t2 == 3 ) used[0] = true;	
				t1 /= 10;
		}

		if ( used.all() && (N >= x) ) ans++;
}

void dfs(ll x) {
		check(x);
		if ( x <= 1000000000 ) {
				dfs(10 * x + 3);
				dfs(10 * x + 5);
				dfs(10 * x + 7);
		}
}

int main() {
		cin >> N;

		dfs(0);

		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(0);
        String res0 = sc.next();
        if (res0.equals("Vacant")) {
            return;
        }

        System.out.println(1);
        String res1 = sc.next();
        if (res1.equals("Vacant")) {
            return;
        }

        int left = 1;
        int right = N;
        String oddKey = res1; 

        // binary search
        while (left < right) {
            int mid = (left+right)/2;
            System.out.println(mid);
            String resm = sc.next();
            if (resm.equals("Vacant")) {
                return;
            }
            if ((mid%2 == 0 && resm.equals(oddKey))
                || (mid%2 == 1 && !resm.equals(oddKey))) {
                right = mid;
            } else {
                left = mid;
            }
        }
    }
}


Measured memory_bytes: 24100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>
//#include <stack>

using namespace std;

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

#define max_n 100

string S;
int N;

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

	rep(i, S.size()) {
		if (S[i] + N > 'Z')S[i] = 'A' + S[i] + N - 'Z' - 1;
		else S[i] = S[i] + N;
	}	

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = s.nextInt();
		}
		boolean flag = true;
		for(int i=0;i<n;i++) {
			if( (a[i] & 1 ) == 0) {
				if (a[i] % 3 == 0 || a[i] % 5 == 0) {
					continue;
				} else {
					flag = false;
				}
			} else {
				continue;
			}
		}
		if(!flag) {
			System.out.println("DENIED");
		}else {
			System.out.println("APPROVED");
		}
	}
}


Measured memory_bytes: 23124
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

using namespace std;
typedef long long ll ;

int main(){
  int n;
  cin >> n;
  vector<int> v(n);

  for (auto&& it : v) {
    cin >> it;
  }
  sort(v.begin(),v.end());
  for (int i = n%2; i < n; i+=2) {
    if(v[i]!=v[i+1]){
      cout << 0<<endl;
      return 0;
    }
  }
  if(v[0]!=0&&n%2){
      cout << 0<<endl;
      return 0;
  }
  long long ans=1;
  for (int i = 0; i < n/2; i++) {
    ans=ans<<1;
    ans=ans%1000000007LL;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

struct MQ{//平方分割 0-index
	ll n,rn,bn,Q=0;
	vector<ll> a,b,at,bt;
	MQ(ll n_){
		n = n_; rn = sqrt(n); bn = ceil((double)n/rn);
		a.resize(n,INF);at.resize(n,0);
		b.resize(bn,INF);bt.resize(n,0);
	}
	ll value(ll s){
		if(a[s]>b[s/rn])a[s] = b[s/rn];
		return a[s];
	}
	void updete(ll s,ll t,ll x){
		Q++;
		FOR(i,s,t+1){
			if(i%rn==0 && (i+rn-1)<=t){
				if(x<b[i/rn])b[i/rn]=x;
				bt[i/rn] = Q;
				i += rn-1;
			}else{
				if(a[i]>x)a[i]=x;
				at[i] = Q;
			}
		}
	}
};



int main(){
	ll N,M;
	cin >> N >> M;
	vector< tuple<ll,ll,ll> > LRC(M);
	FOR(i,0,M){
		ll l,r,c;
		cin >> l >> r >> c;
		l--;r--;
		LRC[i] = tie(l,r,c);
	}
	SORT(LRC);
	MQ minq(N);
	minq.updete(0,0,0);
	FOR(i,0,M){
		ll l,r,c;
		tie(l,r,c) = LRC[i];
		ll v = minq.value(l);
		if(v>=INF)continue;
		minq.updete(l+1,r,c+v);
	}
	ll ans = minq.value(N-1);
	if(ans==INF)ans=-1;
	cout << ans << endl;
}


Measured memory_bytes: 4864