akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
    using namespace std;
     
/// DID IT BEFORE


    #define fren bigounce
    #define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    #define endl "\n"
    #define mt make_tuple
    #define mp make_pair
    #define pb push_back
    #define ff first
    #define ss second
    #define usaco(in,out) ifstream cin(in); ofstream cout(out)
    #define all(X) (X).begin(), (X).end()
    #define sz(X) ((int)X.size())
    #define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
    #define decimal(X) cout << fixed << setprecision(X)
    #define mst(X,Y) memset(X,Y,sizeof(X));
     
    typedef long long LL;
    typedef double DBL;
    typedef pair<int,int> PII; 
    typedef pair<LL,LL> PLL;
    typedef pair<string, int> PSI;
    typedef pair<int,string> PIS;
    typedef vector<PSI> VPSI;
    typedef vector<PIS> VPIS;
    typedef pair<char,int> PCI;
    typedef pair<int,char> PIC;
    typedef vector<PCI> VPCI;
    typedef vector<PIC> VPIC;
    typedef vector<PII> VPII;
    typedef vector<PLL> VPLL;
    typedef vector<LL> VLL;
    typedef vector<int> VI;
    typedef vector<string> VS;
    typedef vector<char> VC;
    typedef long double LD;
    typedef pair<LD,LD> PLD;
    typedef vector<LD> VLD;
    typedef vector<PLD> VPLD;
     
    template<class TH> void _dbg(const char *sdbg, TH h) { 
    	cerr<<sdbg<<" = "<<h<<endl;
    }
     
    template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
      while(*sdbg!=',') cerr<<*sdbg++;
      cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
    }
     
    #define LOCAL
    #define SEPERATOR cout << "-----------------------------------------" << endl;
     
    #ifdef LOCAL
    	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #else
    	#define dbg(...)
    	#define cerr if(0)cout
    #endif
     
    const int maxn = 1e5+7;
    const int inf = 1e9+7;
    const LL LLinf = ((LL)1e18)+7LL;
    const LD eps = 1e-9;
     
    // **************************************** NICE **************************************** //
    // ~/~/~/~/~/~/~/~/~/~/~/~/~/~/ A PRO_GEMR Special... Enjoy! \~\~\~\~\~\~\~\~\~\~\~\~\~\~ //
     
    int n;
    VI dp(3), dp2(3), a(3);
     
    int main() {
    	speedup
    	
    	cin >> n;
    	for (int i = 0; i < n; i++) {
    		cin >> a[0] >> a[1] >> a[2];
    		for (int j = 0; j < 3; j++) {
    			for (int k = 0; k < 3; k++) {
    				if (j != k) {
    					dp2[k] = max(dp2[k],dp[j]+a[k]);
    				}
    			}
    		}
    		dp = dp2;
    	}
    	
    	cout << max({dp[0],dp[1],dp[2]});
    }

Measured memory_bytes: 256
function Main(input){
  input = input.split('\n');
  input.shift();
  input.pop();
  input = input.map((a)=>Number(a));
  var dnum = input.filter((a,b,c)=>c.indexOf(a)===b);
  console.log(dnum.length);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
    long long int a,b,k,x,y;
    scanf("%lld %lld %lld", &a,&b,&k);
    if(k-a==0)
    {
        x=0;
        y=b;
    }
    else if(k-a>0)
    {
        x=0;
       if(k-a>=b)
       {
           y=0;
       }
       else
       {
           y=b-(k-a);
       }
    }
    else
    {
        x=a-k;
        y=b;
    }
    printf("%lld %lld\n", x,y);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> s(N);
	int sum = 0;
	rep(i, N) {cin >> s[i]; sum += s[i];}
	if (sum % 10 != 0) { co(sum);return 0;}
	else
	{
		sort(ALL(s));
		for (int i = 0; i < N; i++)
		{
			if (s[i] % 10 != 0)
			{
				co(sum - s[i]);
				return 0;
			}
		}
		co(0);
	}
	return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

//National Budget
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			BigInteger b = sc.nextBigInteger().add(sc.nextBigInteger());
			System.out.println(b.toString().length()>80?"overflow":b.toString());
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  string s;
  cin>>s;
  map<string,int> m;
  m["SUN"]=7;
  m["MON"]=6;
  m["TUE"]=5;
  m["WED"]=4;
  m["THU"]=3;
  m["FRI"]=2;
  m["SAT"]=1;
  cout<<m[s];
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    string abcd;
    cin >> abcd;
    vector<int> nums(4);
    rep(i, 4)
    {
        nums.at(i) = int(abcd.at(i)) - 48;
    }
    rep(i, 2)
    {
        rep(j, 2)
        {
            rep(k, 2)
            {
                int ans = nums.at(0);
                if (i == 0)
                {
                    ans += nums.at(1);
                }
                else
                {
                    ans -= nums.at(1);
                }
                if (j == 0)
                {
                    ans += nums.at(2);
                }
                else
                {
                    ans -= nums.at(2);
                }
                if (k == 0)
                {
                    ans += nums.at(3);
                }
                else
                {
                    ans -= nums.at(3);
                }
                if (ans == 7)
                {
                    string op = "";
                    op.push_back(abcd.at(0));
                    if (i == 0)
                    {
                        op.push_back('+');
                    }
                    else
                    {
                        op.push_back('-');
                    }
                    op += abcd.at(1);
                    if (j == 0)
                    {
                        op += '+';
                    }
                    else
                    {
                        op += '-';
                    }
                    op += abcd.at(2);
                    if (k == 0)
                    {
                        op += '+';
                    }
                    else
                    {
                        op += '-';
                    }
                    op += abcd.at(3);
                    op += "=7";
                    cout
                        << op << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
string s;
int a,b;
int main(){
	cin>>a>>b;
	cin>>s;
	int  len=s.length();
	if(len!=a+b+1){
		cout<<"No";
		return 0;
	}
	for(int i=0;i<a;i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No";
			return 0;
		}
	}
	if(s[a]!='-'){
		cout<<"No";
		return 0;
	}
	for(int i=a+1;i<len;i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

bool is_haiku(const vector<int>& w, int s) {
  int word[] = {5, 7, 5, 7, 7};
  int st = 0;
  rep(i, s, w.size()) {
    word[st] -= w[i];
    if (word[st] < 0) return false;
    if (word[st] == 0) {
      st++;
      if (st == 5) return true;
    }
  }
  return false;
}

signed main() {
  int N;
  while (N = in(), N) {
    vector<int> w;
    rep(i, N) { w.pb(in<string>().size()); }
    rep(i, N) {
      if (is_haiku(w, i)) {
        pr(i + 1);
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


typedef pair<int,int> pint;

int N, M;
int c[11][11];
int dp[11];

int main() {
  while (cin >> N >> M) {
	for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) cin >> c[i][j];
	for (int i = 0; i < 11; ++i) dp[i] = 1<<29;
	dp[1] = 0;
	priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > que;
	que.push(pint(0, 1));
	while (!que.empty()) {
	  pint cur = que.top();
	  que.pop();
	  if (dp[cur.second] < cur.first) continue;
	  for (int i = 0; i < 10; ++i) {
		if (chmin(dp[i], dp[cur.second] + c[i][cur.second])) {
		  que.push(pint(dp[cur.second] + c[i][cur.second], i));
		}
	  }
	}

	for (int i = 0; i < 10; ++i) {
	  //cout << i << ": " << dp[i] << endl;
	}
	  
	
	int res = 0;
	for (int i = 0; i < N; ++i) {
	  for (int j = 0; j < M; ++j) {
		int a;
		cin >> a;
		if (a == -1) continue;
		res += dp[a];
	  }
	}
	cout << res << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back

#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const double pi=acos(-1);
void solve()
{
    double r;
    cin>>r;
    double ans=pi*2*r;
    printf("%.6f\n",ans);
}
int main()
{
	//int _;cin>>_;while(_--)
	solve();
}


Measured memory_bytes: 3788
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>

typedef long long ll;

const int INF=0x7fffffff;
const int MAXN=1e5+5;

using namespace std;

ll a[MAXN];


int main() {
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);//从小到大排序 
	int ans=0;
	for(int i=1;i<=n;i++){
		int j=i;
		while(a[i]==a[j]&&j<=n){
			j++;
		}
		int now=j-i;
		if(now>a[i]){//太多了，把多的一部分删除 
			ans+=now-a[i];
		}
		else if(now<a[i]){//太少了，全部删除 
			ans+=now;
		}
		i=j-1; 
	} 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
   a,b=map(int,input().split())
   A.append(a)
   B.append(b)

DP=[[0]*(H+max(A)) for i in range(N)]
DP.insert(0,[10**8+1]*(H+max(A)))
DP[0][0]=0

for i in range(1,N+1):
   for j in range(1,H+max(A)):
      if j-A[i-1]>0:
         DP[i][j]=min(DP[i-1][j],DP[i][j-A[i-1]]+B[i-1])
      else:
         DP[i][j]=min(DP[i-1][j],B[i-1])

print(DP[N][H])

Measured memory_bytes: 126960
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define pll pair<long long,long long>
using namespace std;
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int b[1000005],n,a[2000005];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=1;i<n;i++){
		if(a[i]==a[i-1]){
			b[a[i]]=1;
		}
	}
	int res=0;
	for(int i=0;i<n;i++){
		if(!b[a[i]])
			res++;
		if(a[i]!=a[i-1]){
			for(int j=2*a[i];j<=1000000;j+=a[i]){
				b[j]=1;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

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

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

int main() {
    long long N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    long long GCD = gcd(N, M), LCM = N / GCD * M, RS = M / GCD, RT = N / GCD;
    map<long long, char> keep;

    bool exist = true;
    for (long long i = 0; i < N; i++) {
        keep[RS * i] = S.at(i);
    }
    for (long long i = 0; i < M; i++) {
        keep[RT * i] = T.at(i);
    }
    for (long long i = 0; i < N; i++) {
        if (keep.count(RS * i) && keep.at(RS * i) != S.at(i)) {
            exist = false;
        }
    }

    if (exist) {
        cout << LCM << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

int main(){
    string s; cin >> s;
    int n = s.size() - 2;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n / 2; j++) {
            if (s[j] != s[n / 2 + j]) {n -= 2; break;}
            if (j == n / 2 - 1) {cout << n << endl; return 0;}
        }
    }
    puts("2");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	ll N, sum = 0; cin >> N;
	vector<ll> a(N);
	rep(i, N) {
		cin >> a[i];
		sum += a[i];
	}
	ll sumsum = 0, ans = 1e18;
	rep(i, N) {
		sumsum += a[i];
		if (i != N - 1)ans = min(ans, abs(sum - 2 * sumsum));
	}
	cout << ans << endl;
	cin >> N;
}

Measured memory_bytes: 1792
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const D = parseInt(arg[0].split(" ")[1]);
    
    const lange = (D * 2) + 1;
    
    console.log(Math.ceil(N / lange));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
ll n,k,x,y;
 
int main(){
  ll ans=0;
  cin >> n ;
  vi a(n+1),b(n+1),c(n+1),d(n+1);
  REP(i,n+1) cin>>a[i];



  if (n==0){
    if (a[0]==1){
      cout<<1<<endl;
      return 0;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  


  if (a[0]!=0){
    cout<<-1<<endl;
    return 0;
  }

 
 

  d[n]=a[n];
  for(ll i=n-1;i>=0;i--){
    d[i]=d[i+1]+a[i];
  }

  ll nown=1;
  b[0]=1;
  c[0]=1;
  for(ll i=1;i<n+1;i++){
    nown=min(min(nown*2,d[i]),llMAX);
    b[i]=nown;
    nown-=a[i];
    if (nown<0){
      cout<<-1<<endl;
      return 0;
    }


    c[i]=nown;
  }

  

 
 
 
  int flag=0;
  for(ll i=0;i<n+1;i++){
    ans+=b[i];
    flag+=(b[i]<=0);
    //flag+=(c[i]<0);
  }
  /*
  if (flag!=0){
    cout<<-1<<endl;
    return 0;
  }
  */
 
 
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6352
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
int g[5];
int main()
{
	int a,b;
	for(int i=1;i<=3;i++)
	{
		scanf("%d%d",&a,&b);
		g[a]++;
		g[b]++;
	}
	for(int i=1;i<=4;i++)
	{
		if(g[i]>2)
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 256
S = input()
g = 0
p = 0
ans = 0
for s in S:
    if s=="g":
        if g>p:
            p+=1
            ans+=1
        else:
            g+=1
    else:
        if g>p:
            p+=1
        else:
            g+=1
            ans-=1
print(ans)

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

int main()
{
	int N=0,T=0,c[100],t[100];
	int a=0,i,min=0,count=0;

	cin >> N >> T;

	for (i = 0;i < N;i++) {
		cin >> c[i];
		cin >> t[i];	
	}

	min = c[0];

	for (i = 0;i < N;i++) {
		if (t[i] <= T) {
			if (c[i] < min) {
				min = c[i];
				a = i;
			}
			count++;
		}
	}
	if (count==0) {
		cout << "TLE";
	}
	else {
		cout << c[a];
	}

	return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
dic = {}
cnt = [0 for i in range(100001)]
for i in range(n):
    s, t = map(int, input().split())
    cnt[s] += t
for i in range(1, 100002):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]


Measured memory_bytes: 45292
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)s

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}

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

    long double bunsi=0.0;
    for(int i=1;i<=N;i++){
        bunsi+=pow(0.5,retl(K,i));
    }

    long double ans=bunsi/N;
    //ans=1.0/3;
    cout << setprecision(16) <<ans << endl;

    return 0;
}

Measured memory_bytes: 256
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy

setrecursionlimit(10**6)

n=int(stdin.readline().rstrip())
s=stdin.readline().rstrip()
cntw=[0]*(n+2);cnte=[0]*(n+2)
ans=10**6

for i in range(1,n+1):
    if s[i-1]=="W":
        cntw[i]=cntw[i-1]+1
        cnte[i]=cnte[i-1]
    elif s[i-1]=="E":
        cnte[i]=cnte[i-1]+1
        cntw[i]=cntw[i-1]
sumw,sume=cntw[n],cnte[n]
for i in range(n):
    now=cntw[i]+(sume-cnte[i+1])
    ans=min(ans,now)
print(ans)

Measured memory_bytes: 47064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  deque<char> sq, tq;
  rep(i, s.size()) sq.push_back(s.at(i));
  rep(i, t.size()) tq.push_back(t.at(i));
  rep(i, s.size()){
    if(sq == tq){
      cout << "Yes" << endl;
      return 0;
    }
    sq.push_front(sq.back());
    sq.pop_back();
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
unittest
{
	assert( [ "5", "1 3 3 3 3", "3 3 2 2 2" ].parse.expand.solve == 4 );
	assert( [ "5", "1 1 1 2 2", "3 2 1 1 1" ].parse.expand.solve == 0 );
	assert( [ "10", "1 3776 3776 8848 8848 8848 8848 8848 8848 8848", "8848 8848 8848 8848 8848 8848 8848 8848 3776 5" ].parse.expand.solve == 884111967 );
	assert( [ "1", "17", "17" ].parse.expand.solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto ts = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( ts, as );
}

auto solve( long[] ts, long[] as )
{
	const MOD = 10L ^^ 9 + 7;
	
	// 高さが確定する山を判定
	auto ms = new long[ ts.length ];
	auto p = 0L;
	foreach( i, ref m; ms )
	{
		if( p < ts[ i ] )
		{
			if( as[ i ] < ts[ i ] ) return 0;		// 矛盾するのでダメ
			m = 1;		// 確定したときは1(パターン数)を入れておく
		}
		else
		{
			m = ts[ i ];		// 確定しないときはtとaの低いほうを入れておく
		}
		p = ts[ i ];
	}
	p = 0L;
	foreach_reverse( i, ref m; ms )
	{
		if( p < as[ i ] )
		{
			if( ts[ i ] < as[ i ] ) return 0;		// 矛盾するのでダメ
			m = 1;		// 確定したときは1(パターン数)を入れておく
		}
		else
		{
			m = min( m, as[ i ] );		// 確定しないときはtとaの低いほうを入れておく
		}
		p = as[ i ];
	}
	
	// 山脈のパターン数を計算
	return reduce!( ( a, b ) => a * b % MOD )( 1L, ms );
}


Measured memory_bytes: 12488
#include<iostream>
#include <iomanip> 
#include<math.h>
#include<vector>
using namespace std;
int n;
vector<vector<double>> dp(3000,vector<double>(3000,-1.0)); 
vector<double> a(3000);
double probability(int h, int t) {
  if(t>(n>>1)) return 0.0;
    if(h+t==n)  return 1.0;
    if(dp[h][t]!=-1.0) return dp[h][t]; 
    double left = a[h+t] * probability(h+1, t); 
    double right = (1.0-a[h+t]) * probability(h, t+1); 
    dp[h][t] = left + right;
    return dp[h][t];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }
    cout << fixed << setprecision(10) << probability(0,0); 
    return 0;
}


Measured memory_bytes: 74452
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {
	rapid_pleaseAC_fast;

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " ";
	if (a + b <= n) {
		cout << 0 << rt;
	}
	else {
		cout << a + b - n << rt;
	}

	please AC;
}
//参考：---

Measured memory_bytes: 256
tmp=input()
solution=7
numbers=[]
for i in range(len(tmp)):
    numbers.append(int(tmp[i]))

n = len(numbers)
for i in range(n ** 2):
    ops = ["-"] * (n-1)
    for j in range(n-1):
        if ((i>>j) & 1):
            ops[n-1-j-1]="+"
    #print(ops)
    shiki = str(numbers[0])
    for j in range(n-1):
        shiki = shiki + ops[j] + str(numbers[j+1])
    #print(shiki)
    if int(eval(shiki)) == int(solution):
        print(shiki+"="+str(solution))
        break


Measured memory_bytes: 9132
fun main(args: Array<String>) {
    val (a, b, m) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong)
    val bList = readLine()!!.split(' ').map(String::toLong)
    val xycList = (1..m).map {
        val (x, y, c) = readLine()!!.split(' ').map(String::toLong)
        Triple(x, y, c)
    }

    var minCost = aList.min()!! + bList.min()!!
    for (i in 0 until m) {
        val (x, y, c) = xycList[i.toInt()]
        minCost = Math.min(minCost, aList[x.toInt() - 1] + bList[y.toInt() - 1] - c)
    }
    println(minCost)
}


Measured memory_bytes: 109584
import std.algorithm;
import std.stdio;

int solve (int a, int b)
{
	return a <= b ? b - a : int.max - 20;
}

int solveAll (int a, int b)
{
	return min (solve (+a, +b) + 0,
	    solve (+a, -b) + 1, solve (-a, +b) + 1, solve (-a, -b) + 2);
}

void main ()
{
	int a, b;
	while (readf (" %s %s", &a, &b) > 0)
	{
		writeln (solveAll (a, b));
	}
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[])=>{for(let i=0;i<a.length;i+=2)if(s==a[i])return a[i+1]};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};
const main = ()=>{
  out(nin()===1?'Hello World':nin()+nin());
}
main();

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

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

using namespace std;

int main(){
  string o,e;cin>>o>>e;

  rep(i, max(o.size(), e.size()) ){
    if(i<o.size())cout<<o[i];
    if(i<e.size())cout<<e[i];
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
using namespace std;

int main() {
	int ans = 0;
	string str;
	while(cin >> str){
		stack<int> st;
		for(int i = 0;i < str.size();i++){
			if(str[i] >= '0' && str[i] <= '9') {
				st.push(str[i] - '0');
			}
			else if(!st.empty()) {
				int num = 0;
				for(int j = 0;!st.empty();j++) {
					num += st.top() * (int)pow(10.0,(double)j);
					st.pop();
				}
				ans += num;
			}
			if(i + 1 == str.size()){
				int num = 0;
				for(int j = 0;!st.empty();j++) {
					num += st.top() * (int)pow(10.0,(double)j);
					st.pop();
				}
				ans += num;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1228
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;

int main()
{
    int t;
    cin >> t;
    map<string,int>m;
    vector<string>st({"AC","WA","TLE","RE"}); 
    while(t--)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    for (int i = 0; i < st.size(); ++i)
    {
        cout << st[i] <<" x " << m[st[i]] << "\n"; 
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  map<int, int> m;
  REP(i, N){
    int A;
    cin >> A;
    m[A]++;
  }

  int ans = 1;
  for(int i = N-1; i >= 0; i -= 2){
    if(i != 0 && m[i] != 2) ans = 0;
    else if(i == 0){
      if(m[i] != 1) ans = 0;
    }else{
      (ans *= 2) %= MOD;
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
int main(){
    ll K;
    cin>>K;
    string S;
    cin>>S;
    if(S.size()>K)cout<<S.substr(0,K)<<"...";
    else cout<<S;
    
    
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3632
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(int)).array;
		sort (a);
		int res = 0;
		for (int i = 0; i < cast (int) a.length; i += 2)
		{
			res += a[i];
		}
		writeln (res);
	}
}


Measured memory_bytes: 360
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
int t[maxn],x[maxn],y[maxn];
main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d%d",&t[i],&x[i],&y[i]);
    bool flag=1;
    for(int i=0;i<n;i++)
    {
        int tt=t[i+1]-t[i];
        int dis=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if(tt<dis || (tt+dis)&1){flag=0;break;}
    }
    puts(flag ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	  int n=sc.nextInt();
	 long a[]=new long[n];
	  for(int i=0;i<n;i++) {
	    a[i]=sc.nextLong();
	  }
	 long sum=a[0];
	 long operations=0;
	 if(a.length==1) {
	   if(a[0]!=0) {
	     System.out.println(0);
	   }else {
	     System.out.println(1);
	   }
	 }else {
	 if(sum<=0) {
	 sum=1;
	   operations=Math.abs(a[0]-1);
	 }
	  for(int i=1;i<n;i++) {
	    if(sum>0) {
	      if(sum+a[i]<0) {
	        sum+=a[i];
	      }else {
	        if(sum+a[i]==0) {
	          sum=-1;
	          operations++;
	        }else {
	          long req=(long)-1-1l*sum;
	          sum=-1;
	          operations+=(-1l*req+a[i]);     
	        }
	      }
	    }else {
	      if(sum+a[i]>0) {
	        sum+=a[i];
	      }else {
	        if(sum+a[i]==0) {
	          sum=1;
	          operations++;
	        }else {
	          long req=(long)1+-1l*sum;
	          sum=1;
	          operations+=(req-a[i]);
	        }
	      }
	    }

	  }
	  sum=a[0];
	  long op1=0;
	  if(sum>=0) {
	    sum=-1;
	    op1=Math.abs(a[0]+1);
	  }
	  for(int i=1;i<n;i++) {
     if(sum>0) {
       if(sum+a[i]<0) {
         sum+=a[i];
       }else {
         if(sum+a[i]==0) {
           sum=-1;
           op1++;
         }else {
           long req=(long)-1-1l*sum;
           sum=-1;
           op1+=(-1l*req+a[i]);     
         }
       }
     }else {
       if(sum+a[i]>0) {
         sum+=a[i];
       }else {
         if(sum+a[i]==0) {
           sum=1;
           op1++;
         }else {
           long req=(long)1+-1l*sum;
           sum=1;
           op1+=(req-a[i]);
         }
       }
     }

   }
	  System.out.println(Math.min(operations,op1));
	    }
	}
	
	static boolean vis[]=new boolean[10001];
	      static int gcd(int a, int b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 
	    
	      // Function to find gcd of array of 
	      // numbers 
	      static int f(int arr[], int n) 
	      { 
	          int result = n; 
	          int max=-1;
	          int ans=0;
	          for (int element: arr){ 
	                if(vis[element]==false)
	                     
	              result = gcd(n, element); 
	              if(result>max) {      
	                    max=result;
	                    ans=element;
	           
	              }
	           
	            
	          } 
	     
	               
	          return ans; 
	      } 
	     
	      
}

Measured memory_bytes: 60356
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  string S;
  cin >> S;
  vector<int> two_bit(pow(2, S.length()-1));
  llong ans = 0;
  if(S.length()==1) cout << S << endl;
  else{
    for(llong i=0; i<pow(2, S.length()-1); ++i){
      llong remain = i;
      for(int j=0; j<S.length()-1; ++j){
        two_bit[j] = remain / pow(2, S.length()-2-j);
        remain = remain % (llong) pow(2, S.length()-2-j);
      }
      int count = 0;
      llong tmp_sum = 0;
      for(int j=0; j<S.length()-1; ++j){
        tmp_sum += ctoi(S[S.length()-1-j]) * pow(10, count);
        if(two_bit[S.length()-2-j]==1){
          count = 0;
          ans -= tmp_sum;
          tmp_sum = 0;
        }else if(two_bit[S.length()-2-j]==0){
          count = 0;
          ans += tmp_sum;
          tmp_sum = 0;
        }
      }
      ans += ctoi(S[0]) * pow(10, count);
      if(ans == 7){
        for(int j=0; j<S.length()-1; ++j){
          cout << S[j];
          if(two_bit[j]==1) cout << "-";
          else if(two_bit[j]==0) cout << "+";
        }
        cout << S[S.length()-1] << "=7" << endl;
        return 0;
      }else ans = 0;
    }
    return 0;
  }
}

Measured memory_bytes: 256
from collections import deque, defaultdict

def topological_sort(V, E):
    '''
    Kahn's Algorithm (O(|V| + |E|) time)
    Input:
    V = [0, 1, ..., N-1]: a list of vertices of the digraph
    E: the adjacency list of the digraph (dict)
    Output:
    If the input digraph is acyclic, then return a topological sorting of the digraph.
    Else, return None.
    '''
    indeg = {v: 0 for v in V}
    for ends in E.values():
        for v in ends:
            indeg[v] += 1
    
    q = deque([v for v in V if indeg[v] == 0])
    top_sorted = []
    while q:
        v = q.popleft()
        top_sorted.append(v)
        
        for u in E[v]:
            indeg[u] -= 1
            if indeg[u] == 0:
                q.append(u)
    if len(top_sorted) == len(V): # The input digraph is acyclic.
        return top_sorted
    else: # There is a directed cycle in the digraph.
        return None

N, M = map(int, input().split())
V = range(N)
E = defaultdict(list)
for _ in range(M):
    s, t = map(int, input().split())
    E[s].append(t)
print(1 if topological_sort(V, E) is None else 0)


Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int INF=1e20;

signed main(){
   int N,K;cin>>N>>K;
   vector<int>X(N);
   vector<int>Y(N);
   REP(i,N)cin>>X[i]>>Y[i];
   vector<int>Xc(N);
   vector<int>Yc(N);
   Xc=X;
   Yc=Y;
   sort(Xc.begin(),Xc.end());
   sort(Yc.begin(),Yc.end());
   int ans=INF;
   for(int i=0;i<N-1;i++){
       for(int j=i+1;j<N;j++){
           for(int k=0;k<N-1;k++){
               for(int l=k+1;l<N;l++){
                   int xl=Xc[i];
                   int xh=Xc[j];
                   int yl=Yc[k];
                   int yh=Yc[l];
                   int count=0;
                   for(int q=0;q<N;q++){
                       if(X[q]>=xl&&X[q]<=xh&&Y[q]>=yl&&Y[q]<=yh){
                           count++;
                       }
                   }
                   if(count>=K){
                       ans=min(ans,(xh-xl)*(yh-yl));
                   }
               }
           }
       }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

template <class T>
bool chmax(T &a, T b) {
  if (a < b) return (a = move(b)), true;
  return false;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) return (a = move(b)), true;
  return false;
}

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  auto dp = make_vec(n + 1, n + 1, 0);
  for (int i = n - 2; i >= 0; --i) {
    for (int j = i + 1; j < n; ++j) {
      if (s[i] == s[j]) {
        dp[i][j] = dp[i + 1][j + 1] + 1;
        chmax(ans, min(dp[i][j], j - i));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 101112
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=100;
const int M=20;

int main(){
    ll dp[N-1][M+1];
    int n,num[N];

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>num[i];
    }

    for(int i=0;i<N-1;i++){
        for(int j=0;j<=M;j++){
            dp[i][j]=0;
        }
    }

    for(int i=0;i<=M;i++){
        dp[0][i]=0;
    }

    dp[0][num[0]]=1;

    for(int i=1;i<n-1;i++){
        for(int j=0;j<=M;j++){
            if(j-num[i]>=0){
                dp[i][j]+=dp[i-1][j-num[i]];
            }
            if(j+num[i]<=M){
                dp[i][j]+=dp[i-1][j+num[i]];
            }
        }
    }

    cout<<dp[n-2][num[n-1]]<<endl;

    return 0;
}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int main(){
    int i,a;
    int A[50];
    cin>>a;
    A[0]=A[1]=1;
    for(i=2;i<=a;i++) A[i]=A[i-1]+A[i-2];
    cout<<A[a]<<endl;
    return 0;
}


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


int main() {
int n;
cin >> n;
if (n == 1) cout << 1 << endl;
else if (n%2 == 0) {
  double a = n/2;
  cout << a/n  << endl;
} else {
  double a = n/2+1;
  cout << a/n << endl;
}
return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
   string s;    cin >> s;
   int n = s.size();
   if(s.at(n-1) == 's') cout << s + "es" << endl;
   else cout << s+'s' << endl;
}

Measured memory_bytes: 3632
n = gets.chomp.to_i
l = gets.chomp.split(" ").map(&:to_i)

l.sort! { |a, b| b <=> a }

r = 0
#for i in 0..(2 * n - 1) do
(0...(2 * n - 1)).step(2) do |i|
  r += l[i + 1]
end

print r


Measured memory_bytes: 1912
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N=200010;

int n,a[N],b[N*3],l,r;

#define rea(x) scanf("%d",&x)

int main(){
  rea(n); l=n+1; r=n+2;
  for(int i=1;i<=n;i++) rea(a[i]);
  for(int i=1;i<=n;i++){
    if(i&1) b[r++]=a[i];
    else b[l--]=a[i];
  }
  if(~n&1) for(int i=l+1;i<r;i++) printf("%d ",b[i]);
  else for(int i=r-1;i>l;i--) printf("%d ",b[i]);
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<int> vec;
    int temp;
    REP(i,N){
        cin>>temp;
        vec.pb(temp);
    }
    sort(all(vec));
    double val;val=vec[0];
    REP1(i,N-1){
        val=val+vec[i];
        val/=2;
    }
    cout<<setprecision(10);
    print(val);
    return 0;
}


Measured memory_bytes: 256