akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ld> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ld INF=1.0e30L;
const ld EPS=1.0e-15L;
const double PI=M_PI;

vec min_x(3),max_x(3),min_y(3),max_y(3);
ld f(ld T){
    ld Mx=max(max_x[0],max(max_x[1]+T,max_x[2]-T));
    ld mx=min(min_x[0],min(min_x[1]+T,min_x[2]-T));
    ld My=max(max_y[0],max(max_y[1]+T,max_y[2]-T));
    ld my=min(min_y[0],min(min_y[1]+T,min_y[2]-T));
    return (Mx-mx)*(My-my);
}

int main(){
    int N; cin>>N;
    mat X(3),Y(3);
    rep(i,N){
        ld x,y; cin>>x>>y;
        char d; cin>>d;
        if(d=='U'){
            X[0].pb(x); Y[1].pb(y);
        }
        if(d=='D'){
            X[0].pb(x); Y[2].pb(y);
        }
        if(d=='R'){
            X[1].pb(x); Y[0].pb(y);
        }
        if(d=='L'){
            X[2].pb(x); Y[0].pb(y);
        }
    }
    rep(i,3){
        if(X[i].empty()){
            min_x[i]=INF; max_x[i]=-INF;
        }
        else{
            sort(all(X[i])); 
            min_x[i]=X[i][0]; max_x[i]=X[i][SZ(X[i])-1];
        }
        if(Y[i].empty()){
            min_y[i]=INF; max_y[i]=-INF;
        }
        else{
            sort(all(Y[i]));
            min_y[i]=Y[i][0]; max_y[i]=Y[i][SZ(Y[i])-1];
        }
    }
    int count=0;
    ld l=0.0L,r=1.0e10L;
    while(count<500){
        ld m1=(2.0L*l+r)/3.0L, m2=(l+2.0L*r)/3.0L;
        if(f(m1)<f(m2)) r=m2;
        else            l=m1;
        count++;
    }
    printf("%.15Lf\n",f(l));
    return 0;
}

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

typedef long long ll;

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

    int a,b;
    cin >> a >> b;
    if(a<b){
        for(int i=0;i<b;i++) cout << a;
        cout << endl;
    }else{
        for(int i=0;i<a;i++) cout << b;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int t[1000],a[1000];
  long long int rt,ra,r,tt,aa;
  long long int nowt,nowa;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i]>>a[i];
  }
  nowt=t[0];nowa=a[0];
  for(int i=0;i<n;i++){
    rt=(nowt/t[i]);
    if((nowt%t[i])!=0) rt++;
    ra=(nowa/a[i]);
    if((nowa%a[i])!=0) ra++;
    r=max(rt,ra);
    nowt=r*t[i];nowa=r*a[i];
  }
  cout<<nowt+nowa<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <string>
#include <cmath>
#include <iomanip>

int main();


int main(){
	std::stack<int> input;		//入力される数（車両番号）を格納する
	std::vector<int> output;	//出力される車両番号
	int dummy = 0;				//ダミーナンバー
	int count = 0;

	//while (count < 8){
		//std::cin >> dummy;
		//count++;
	while (std::cin >> dummy){
		if ((dummy == 0) && (!input.empty())){
			output.push_back(input.top());
			input.pop();
		}
		else if((1 <= dummy) && (dummy <= 10)){
			input.push(dummy);
		}
		else{
			//何もしない
		}
	}

	for (int i = 0; i < output.size(); i++){
		std::cout << output[i] << std::endl;
	}

	//while (1);
	return 0;
}


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = [i for i in a if i != 1]
ans = 1
if len(b) < 100:
    for i in range(len(b)):
        ans *= b[i]
else:
    ans = 10**18+1
if 0 in b:
    ans = 0
print(ans if ans <= 10**18 else '-1')

Measured memory_bytes: 21796
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  vector<int> b;
  vector<int> c;

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

  REP(i,n){
    if(i%2) b.push_back(a[i]);
    else c.push_back(a[i]);
  }

  if(n%2 == 1) swap(b,c);

  reverse(ALL(b));
  for(auto x : b) cout << x << " ";
  for(auto x : c) cout << x << " ";
  return 0;
}

Measured memory_bytes: 5008
#include<cstdio>
#include<cstring>
int a[200005];
int b[200005];

int main(){
	int n;
	while(scanf("%d",&n)==1){
		memset(b,0,sizeof(b));
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		if(n%2==0){
			for(int j=0,i=n-1;j<n/2,i>=0;j++,i-=2)
				b[j]=a[i];
			for(int j=n-1,i=n-2;j>=n/2,i>=0;j--,i-=2)
				b[j]=a[i];
		}
		else{
			for(int j=0,i=n-1;j<=n/2,i>=0;j++,i-=2)
				b[j]=a[i];
			for(int j=n-1,i=n-2;j>n/2,i>=0;j--,i-=2)
				b[j]=a[i];
		}
		for(int i=0;i<n;i++){
			if(i<n-1) printf("%d ",b[i]);
			else printf("%d\n",b[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int m;
int nmin,nmax;
int p[10000];

int main() {
	while (cin >> m >> nmin >> nmax&&m + nmax + nmin) {
		REP(i, m) {
			cin >> p[i];
		}
		int ans;
		int num = -1;
		for (int i = nmin; i <= nmax; i++) {
			if (num <= p[i - 1] - p[i]) {
				num = p[i - 1] - p[i];
				ans = i;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int ans = 0, n = 0;
	for (char c : s) {
		if (c=='R') {
			n++;
		} else {
			ans = max(ans, n);
			n = 0;
		}
	}
	ans = max(ans, n);
	cout << ans << "\n";
	return 0;
}


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

#define XDAY 196471

void solve(int y,int m,int d){
    int today=1;
    for(int i=1;i<y;i++){
        if(i%3) today+=195;
        else today+=200;
    }
    for(int i=1;i<m;i++){
        if(i%2||!(y%3)) today+=20;
        else today+=19;
    }
    today+=(d-1);
    cout<<XDAY-today<<endl;
}

int main(void){
    int n;
    int a,b,c;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        solve(a,b,c);
    }
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int a[10];
  int k;

  for (int i = 0; i < 5; ++i) cin >> a[i];
  cin >> k;

  if (abs(a[4] - a[0]) <= k) puts("Yay!");
  else puts(":(");
  return 0;
}



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



int main() {
  int n, m;
  cin >> n >> m;
  int ans;
  ans = (n*(n-1) + m*(m-1))/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static long naive_solve(long N) {
		long answer = 0;
		
		for(long k = 2; k <= N; k++) {
			long curr = N;
			while(curr % k == 0) { curr /= k; }
			while(curr >= k) { curr -= k; }
			
			if(curr == 1) {
				answer++;
			}
		}
		
		return answer;
	}
	
	public static long smart_solve(long N) {
		HashSet<Long> values = new HashSet<Long>();
		if(N != 2) { values.add(N); }
		
		for(long x = 2; x * x <= N; x++) {
			if(N % x != 0) { continue; }
			
			long curr = N;
			while(curr % x == 0) { curr /= x; }
			if(curr % x == 1) {
				values.add(x);
			}
		}
		
		for(long x = 1; x * x <= (N - 1); x++) {
			if((N - 1) % x != 0) { continue; }
			
			if(x != 1) { values.add(x); }
			values.add((N - 1) / x);
		}
		
		return values.size();
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			
			/*
			for(int i = 2; i <= N; i++) {
				System.out.println(i + " start!");
				final long naive = naive_solve(i);
				final long smart = smart_solve(i);
				
				if(naive != smart) {
					System.out.println(i + " " + naive + " " + smart);
				}
			}
			*/
			
			// System.out.println(values);
			System.out.println(smart_solve(N));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

const long long mod = 1000000007;

class Power
{
public:
  int m, n;
  Power(){}
  Power( int m, int n ) : m(m), n(n) {}
  int solve();
  long long pwr( int n );
};

long long Power::pwr( int x )
{
  long long ret;

  if ( x == 1 )
    ret = m;
  else if ( x % 2 )
    {
      ret = pwr( x / 2 );
      ret = ret * ret % mod;
      ret = ret * m  % mod;
    }
  else
    {
      ret = pwr( x / 2 );
      ret = ret * ret % mod;
    }

  return ret;
}

int Power::solve()
{
  cout << pwr( n ) << endl;

  return 0;
}

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

  Power p(m, n);

  p.solve();

  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s;
	cin >> s;
	cout << s.substr(0,s.length() - 8) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long int a,b,c,k,s=0,p;
  cin>>a>>b>>c>>k;
  s=min(a,k);
  if(s==k)
  cout<<s;
  else 
  {
  	k-=a;
  	p=min(b,k);
  	if(p==k)
  	cout<<s;
  	else
  	{
  		k-=b;
  		p=min(c,k);
  		cout<<s-p;
	  }
  }
}

Measured memory_bytes: 3640
IDENTIFICATION DIVISION.
PROGRAM-ID. 180908A.
 
ENVIRONMENT DIVISION.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S.
  02 S-O        OCCURS 3.
    03 SA       PIC X(1) VALUE SPACE.
01 IDX          PIC 9(6) VALUE ZERO.
01 W_VAL        PIC 9(2).
01 W_SHOW       PIC 9(2).
01 REM          PIC 9(2).
01 ANS          PIC X(3) VALUE "No".
01 W_A			PIC 9.
01 W_B			PIC 9.
PROCEDURE DIVISION.
    ACCEPT S
    PERFORM VARYING IDX FROM 1 BY 1 UNTIL IDX > 3
        MOVE S-O(1) TO W_A
        MOVE S-O(3) TO W_B
        COMPUTE W_VAL = W_A * W_B * IDX
        DIVIDE W_VAL BY 2 GIVING W_SHOW REMAINDER REM
        IF REM = 1 THEN
            MOVE "Yes" TO ANS
        END-IF
    END-PERFORM
    DISPLAY ANS
    STOP RUN.
    

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

using namespace std;

const int N = 1e5+7;

int n, k;
long long now, res;
int vis[N], cnt[N], ck;

struct Node
{
    int t, d = 0, id = 0;
    bool operator < (const Node &cp) const {
        return d > cp.d;
    }
} a[N], b[N];

priority_queue<Node> q;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].t >> a[i].d;
        b[i].t = i;
        a[i].id = i;
        // b[a[i].t].d = max(b[a[i].t].v, a[i].d);
        if (b[a[i].t].d < a[i].d) {
            b[a[i].t].d = a[i].d;
            b[a[i].t].id = i;
        }
    }
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);

    for (int i = 1; i <= k; ++i) {
        if (!b[i].id) break;
        q.push(b[i]);
        if (!cnt[b[i].t]) ++ck;
        ++cnt[b[i].t];
        vis[b[i].id] = 1;
        now += b[i].d;
    }
    int pos = 1;
    while ((int)q.size() < k) {
        if (!vis[a[pos].id]) {
            q.push(a[pos]);
            if (!cnt[a[pos].t]) ++ck;
            ++cnt[a[pos].t];
            vis[a[pos].id] = 1;
            now += a[pos].d;
        }
        ++pos;
    }
    now += 1ll*ck*ck;
    res = now;

    while (pos <= n && q.top().d < a[pos].d) {
        if (vis[a[pos].id]) {
            ++pos;
            continue;
        }
        Node cur = q.top();
        q.pop();
        q.push(a[pos]);
        now -= cur.d;
        if (--cnt[cur.t] == 0) {
            now -= 1ll*ck*ck;
            --ck;
            now += 1ll*ck*ck;
        }
        now += a[pos].d;
        if (!cnt[a[pos].t]) {
            now -= 1ll*ck*ck;
            ++ck;
            now += 1ll*ck*ck;
        }
        ++pos;
        res = max(res, now);
    }
    cout << res << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int A = N / 1000;
  int B = ( N / 100 ) % 10;
  int C = ( N / 10) % 10;
  int D = N % 10;
  int counter = A;
  string opA,opB,opC;
  bool flag = false;

  for(int i = 0;i < 2;i++){
    for(int j = 0;j < 2;j++){
      for(int k = 0;k < 2;k++){
        if(i == 0){
          counter += B;
          opA = "+";
          }
        else {
          counter -= B;
          opA = "-";
          }

        if(j == 0){
          counter += C;
          opB = "+";
          }
        else {
          counter -= C;
          opB = "-";
          }

        if(k == 0){
          counter += D;
          opC = "+";
          }
        else {
          counter -= D;
          opC = "-";
          }
        
        if(counter == 7){
          flag = true;
          break;
        }

        counter = A;
      }
      if(flag == true)break;
    }
    if(flag == true)break;
  }

  cout << A << opA << B << opB << C << opC << D << "=7" << endl;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

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

  ll ans = 0;
  for(ll k = K; k <= N + 1; ++k) {
    ans += k * (N - k + 1) + 1;
    ans %= MOD;
  }

  std::cout << ans << '\n';

}


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

int main(){
  int n;
  string str;
  while(cin>>n,n){
    cin>>str;
    while(n--){
      string nstr;
      for(int i=0;i<str.size();i++){
	int cnt=0;
	char ch=str[i];
	while(ch==str[i])i++,cnt++;
	string num;
	while(cnt)num+=cnt%10+'0',cnt/=10;
	reverse(num.begin(),num.end());
	nstr+=num+ch;
	i--;
      }
      str=nstr;
    }
    cout <<str<<endl;
  }
  return 0;
}

Measured memory_bytes: 1340
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10000000)

def find_negative_loop(n,e):
  d=n*[10**20];d[0]=0
  for h in range(n):
    for i,j,k in e:
      if d[j]>d[i]+k:
        d[j]=d[i]+k
        if h==n-1:return -1
  return max(-d[n-1],0)

from collections import deque
def find_loop(n,e,flag):
  x=[0]*n
  d=deque()
  t=[]
  c=0
  for i in range(n):
    for j in e[i]:x[j]+=1
  for i in range(n):
    if x[i]==0:
      d.append(i)
      t.append(i)
      c+=1
  while d:
    i=d.popleft()
    for j in e[i]:
      x[j]-=1
      if x[j]==0:
        d.append(j)
        t.append(j)
        c+=1
  if flag==0:return c==n
  else:return t

def glaph_bfs(s,n,e):
  ans=[0]*n
  Q=[s]
  visited={s}
  while Q:
    P=[]
    for i in Q:
      ans[i]=1
      for j in e[i]:
        if j in visited:continue
        visited.add(j)
        P.append(j)
    Q=P
  return ans

n,m,p=map(int,input().split())
ef=[[]for _ in range(n)]
ee=[[]for _ in range(n)]
e=[]
for _ in range(m):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  c-=p
  ef[a].append(b)
  ee[b].append(a)
  e.append((a,b,c))
eff=glaph_bfs(0,n,ef)
eef=glaph_bfs(n-1,n,ee)
ee=[]
for a,b,c in e:
  if eff[a]==1 and eef[a]==1 and eff[b]==1 and eef[b]==1:
    ee.append((a,b,-c))
print(find_negative_loop(n,ee))

Measured memory_bytes: 5404
#include <iostream> // cout, endl, cin
#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
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int num;
    cin >> num;
    vector<int> arr(num);
    cins(arr);
    map<int, int> map;
    vector<int> cands;
    cands.push_back(0);
    cands.push_back(0);
    for(int i = 0; i < num; i++) {
        map[arr[i]]++;
        if(map[arr[i]] == 2) {
            cands.push_back(arr[i]);
            map[arr[i]] = 0;
        }
    }
    sort(cands.begin(), cands.end(), greater<int>());

    int64_t ans = (int64_t)cands[0] * cands[1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a,b,c;
int main(void){
    cin>>a>>b>>c;
    a=a%b;
    int A=a;
    while(true){
        A=(A+a)%b;
        if(A==c){
            cout<<"YES"<<endl;
            return 0;
        }
        if(A==a){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    
}


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

int main(){
  int N;
  cin >> N;
  if(N%2==0){
    cout << "0.5000000000" << endl;
  }
  else if(N==1){
    cout << "1.0000000000" << endl;
  }
  else{
    cout << (N/2+1)*1.0/N << "000000000" << endl;
  }

  return 0;
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);	
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		int cnt=0;
		for(int i=a; i<=b; i++)
		{
			if(c % i == 0)
			{
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26096
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] origin = new int[n];
		int[] b = new int[n];
		PriorityQueue<Integer> p_que = new PriorityQueue<>((a1,a2)->-a1+a2);
		for(int i=0;i<n;i++) {
			origin[i] = in.nextInt();
			b[i] = i+1-origin[i];
			if(b[i]==0) p_que.add(i);
		}
		int count = 0;
		int[] ans = new int[n];
		while(!p_que.isEmpty()) {
			int tmp = p_que.poll();
			for(int i=tmp;i<n;i++) {
				b[i]--;
				if(b[i]==0) p_que.add(i);
			}
			ans[count] = origin[tmp];
			count++;
		}
		if(count<n) System.out.println("-1");
		else {
			for(int i=n-1;i>=0;i--) {
				System.out.println(ans[i]);
			}
		}
		in.close();
	}

}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
double d;

/*--------------------template--------------------*/

int main() {
    int A[3][3];
    REP(i,3) {
    	REP(j,3){
        	cin >> A[i][j];
        }
    }
  cin >> n;
    REP(l,n) {
    	cin >> m;
        REP(i,3) {
            REP(j,3){
                if (m == A[i][j]) {
                	A[i][j] = 0;
                }
            }
        }
    	if ((A[0][0]==0&&A[0][1]==0&&A[0][2]==0)
           ||(A[1][0]==0&&A[1][1]==0&&A[1][2]==0)
           ||(A[2][0]==0&&A[2][1]==0&&A[2][2]==0)
           ||(A[0][0]==0&&A[1][0]==0&&A[2][0]==0)
           ||(A[0][1]==0&&A[1][1]==0&&A[2][1]==0)
           ||(A[0][2]==0&&A[1][2]==0&&A[2][2]==0)
           ||(A[0][0]==0&&A[1][1]==0&&A[2][2]==0)
           ||(A[0][2]==0&&A[1][1]==0&&A[2][0]==0)) {
        	dbg("Yes");
          return 0;
        }
    }
  dbg("No");
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

void solve() {
	int n,p,total=0;
	cin >> p;
	
	vector<int> list;
	
	while(p--) {
		cin >> n;
		total += 2*n;
		list.push_back(n);		
	}
 	
 	int val = round((double)total/(double)(list.size()*2));
 	//cout << val << endl;
 	int ans = 0;
 	for(int x: list) {
		ans += pow(val-x,2);
	}
 	
	cout << ans;
 	
 	
}
		
			
		

int32_t main() {
	IOS;
	solve();
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
const int maxn = 1e4;
const int inf = 1<<30;
typedef long long LL;
int n;
int main(){
	cin >> n;
	int num[maxn+5];
	for(int i = 1;i<=2*n;i++)
		cin >> num[i];
	sort(num+1,num+1+2*n);
	int ans = 0;
	for(int i = 1;i<=2*n;i+=2)
		ans += num[i];
	cout << ans << endl;
	return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
    int dp[n],min;
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        min=INT_MAX;
        for(int j=1;j<=k && i>=j ;j++)
        {
            if((abs(a[i]-a[i-j]) + dp[i-j])<min)
            min=(abs(a[i]-a[i-j]) + dp[i-j]);
        }
        dp[i]=min;
    }
    cout<<dp[n-1];
	
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<unordered_map>

#define inf 0x3f3f3f3f
#define ii pair<int,int>
#define iii pair<int, ii>
#define ic pair<int, char>
#define icii pair<ic,ii>

#define pb push_back

using namespace std;
const int maxn = 5e3 + 10;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long i64;
 
 
using namespace std;

int main(){
	//~ freopen("in","r",stdin);
	//~ r = inf;
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, n;
	
	cin >> n >> a;
	
	if( (n%500)  > a || ( n < 500 && n > a)){
		cout << "No";
		return 0;
	}
	cout<< "Yes";
}


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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

long long read(){
	long long i;
	cin >> i;
	return i;
}

template <typename T>
void printV(vector<T> &v, const string &sep = " ") {
	using namespace std;
	if (v.empty()) return;
	cout << v[0];
	for(int i = 1;  i < v.size(); ++i) {
		cout << " " << v[i];
	}
	cout << endl;
	return;
}

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

	const int n = read();
	const int m = read();
	const int l = read();
	vector<vector<int> > a(n, vector<int>(m));
	REP(i, n) {
		REP(j, m) {
			a[i][j] = read();
		}
	}

	vector<vector<int> > b(m, vector<int>(l));
	REP(i, m) {
		REP(j, l) {
			b[i][j] = read();
		}
	}

	vector<vector<long long> > c(n, vector<long long>(l));
	REP(i, n) {
		REP(j, l) {
			REP(k, m) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	REP(i, c.size()) {
		printV(c[i]);
	}
	return 0;
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    for(int i=0; i<Q; i++){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--; B[i]--;
    }
 
    vector<vector<int>> V[11];
    for(int i=1; i<=M; i++) V[1].push_back({i});
    for(int i=1; i<N; i++) for(auto& v : V[i]){
        int b = v.back();
        for(int a=b; a<=M; a++){
            auto v2 = v;
            v2.push_back(a);
            V[i+1].push_back(v2);
        }
    }
 
    int ans = 0;
    for(auto& v : V[N]){
        int res = 0;
        for(int i=0; i<Q; i++) if(v[B[i]] - v[A[i]] == C[i]) res += D[i];
        ans = max(ans, res);
    }
 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16232
class UnionFind:

    def __init__(self, N):
        self.follow = [-1]*(N+1)
        self.num_follower = [1]*(N+1)

    def root_index_of(self, a):
        r = a
        while self.follow[r] > -1:
            r = self.follow[r]
        return r
    
    def connet(self, a, b):
        ra = self.root_index_of(a)
        rb = self.root_index_of(b)
    
        if ra == rb:
            return
        
        if self.num_follower[ra] < self.num_follower[rb]:
            self.follow[ra] = rb
            self.follow[a] = rb
            self.num_follower[rb] += self.num_follower[ra]
        else:
            self.follow[rb] = ra
            self.follow[b] = ra
            self.num_follower[ra] += self.num_follower[rb]
    
    def conneted(self, a, b):
        return self.root_index_of(a) == self.root_index_of(b)

N, M, K = map(int, input().split())
U = UnionFind(N)

cnt_friends = [0]*(N+1)
for i in range(M):
    A, B = map(int, input().split())
    U.connet(A, B)
    cnt_friends[A] += 1
    cnt_friends[B] += 1

cnt = [0]*(N+1)
for i in range(1, N+1):
    r = U.root_index_of(i)
    cnt[i] = U.num_follower[r] - (cnt_friends[i]+1)

for i in range(K):
    C, D = map(int, input().split())
    if U.conneted(C, D):
        cnt[C] -= 1
        cnt[D] -= 1
print(*cnt[1:])

Measured memory_bytes: 71000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif
 
const int mod = 1e9 + 7;

ll pw(ll a, ll x) {
    if (x == 0) return 1;
    if (x % 2 == 0) {
        ll t = pw(a, x / 2);
        return (t * t) % mod;
    }
    return (a * pw(a, x - 1)) % mod;
}

ll inv(ll a) {
    return pw(a, mod-2);
}

int main() {
    int n;
    cin >> n;
    vector<ll> C(n);
    for (int i=0; i<n; ++i) cin >> C[i];
    sort(C.begin(), C.end());
 
    ll cost = 0;
    for (int i=0; i<n; ++i) {
        cost += C[i] * ((1 + (n - i - 1) * inv(2)) % mod);
        cost %= mod;
    }
    (cost *= pw(2, n-1)) %= mod;
    (cost *= pw(2, n)) %= mod;

    cout << cost << endl;
    
    return 0;
}

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


int main() {
  int n;
  cin >> n;
  int mx = 0;
  deque<int> a;
  rep(i,n) {
    int x;
    cin >> x;
    if(a.empty()||a.back()!=x) a.push_back(x);
    if(x>mx) mx = x;
  }
  ll num = 0, ans = 1000;
  int pre = mx;
  while(a.size()>1) {
    int now = a.front();
    a.pop_front();
    //> <
    if(pre>now&&now<a.front()) {
      num += ans/now;
      ans %= now;
    }
    // < >
    else if(pre<now&&now>a.front()) {
      ans += num*now;
      num = 0;
    }
    pre = now;
  }
  if(num>0) ans += a.front()*num;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
// problem: "https://atcoder.jp/contests/abc153/tasks/abc153_b"

#include<bits/stdc++.h>

using namespace std;

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

    vector<int>A(n);
    int i;

    for(i=0;i!=n;i++)
        cin>>A[i];

    for(i=1;i!=n;i++)
        A[i] += A[i-1];

    (A[n-1] >= h) ? cout<<"Yes" : cout<<"No";

    return 0;
}


Measured memory_bytes: 640
s = input()

l = len(s)
a, b = '0', '1' 
res_a = res_b = 0 
for i in range(l):
    if s[i] != a:
        res_a += 1                                                                                             
    if s[i] != b:
        res_b += 1
    a, b = b, a

print(min(res_a, res_b))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(void){
    ll n,m,c,x=0;cin>>n>>m>>c;
    vector<ll> b(m);
    For(i,m)cin>>b.at(i);
    For(i,n){
        ll ans=0;
        For(j,m){
            ll t;cin>>t;ans+=t*b.at(j);
        }
        if(ans+c>0)x++;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
         long long int n,k,i;
                cin>>n;
                cout<<10-n/200<<endl;
               
       // }
   return 0;    
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int N;
        cin >> N;
        vector<string> word(N);
        for (int i = 0; i < N; i++)
        {
                cin >> word[i];
        }
        bool osiri = true;
        bool hukusuu = true;

        for (int i = 1; i < N; i++)
        {
                char matu = word[i - 1].back();
                if (matu != word[i].front())
                {
                        osiri = false;
                }
        }
        for (int i = 0; i < N; i++)
        {
                for (int j = 0; j < N; j++)
                {
                        if (i == j)
                        {
                                continue;
                        }
                        else
                        {
                                if (word[i] == word[j])
                                {
                                        hukusuu = false;
                                }
                        }
                }
        }

        if (osiri && hukusuu)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll =  long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 1e5+10;
int a[MAX_N];
int N;
int L[MAX_N], R[MAX_N];

void solve()
{
	// L[i] a[1]....a[i-1]'s gcd
	for(int i=2;i<=N;++i){
		L[i]=__gcd(L[i-1],a[i-1]);
	}
	for(int i=N;i>=1;--i){
		R[i]=__gcd(R[i+1],a[i]);
	}
	int ans = 1;
	for(int i=1;i<=N;++i){
		ans = max(ans, __gcd(L[i],R[i+1]));
	}
	cout << ans << "\n";
}

int main()
{
	cin >> N;
	for(int i=1;i<=N;++i)cin >> a[i];
	solve();
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

    ll n; cin>>n;
    ll ans =0;
    for(ll i=1;i<=n;i++){
        if(to_string(i).size()%2!=0) ans++;
    }
    cout <<ans;
    return 0;
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Modulo Calculation
const int MOD = 998244353;
//ModInt
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
  
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    ModInt &operator++ () { *this += 1; return *this;}
    ModInt operator++ (int) { *this += 1; return *this - 1;}
    ModInt &operator-- () { *this -= 1; return *this;}
    ModInt operator-- (int) { *this -= 1; return *this + 1;}
    bool operator==(ModInt rhs) const { return x == rhs.x; }    
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    bool operator<=(ModInt rhs) const { return x <= rhs.x; }
    bool operator>=(ModInt rhs) const { return x >= rhs.x; }
    bool operator<(ModInt rhs) const { return x < rhs.x; }
    bool operator>(ModInt rhs) const { return x > rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
  
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<MOD>;

//二項定理計算
const int MAX = 1000010;
mint 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]*(mint)i;
        inv[i]=(mint)MOD-inv[MOD%i]*(mint)(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

//nCkを求める
mint COM(int n,int k){
    if(n < k or n < 0 or k < 0)return 0;
    return fac[n]*finv[k]*finv[n-k];
}

struct maketable{
    maketable(){COMinit();}
}maketable_;

mint res;
int main(){
    int n, k;
    cin >> n >> k;
    for(int r = n - 1; r < k; r++) res += COM(k - 1, r);
    cout << res << '\n';
}

Measured memory_bytes: 15336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    ll n,k,ans = 0;
    cin >> n >> k;
    vector<pair<ll,ll>> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(),p.end());
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += p[i].second;
        if(sum >= k){
            ans = p[i].first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main() {
  int n;
  string s;
  cin >> n;
  vector<char> a(n);
  rep(i,n) cin >> a.at(i);
  vector<char> b;
  for(int i = 1; i < n; i++){
    if(a.at(i) != a.at(i-1)) b.push_back(a.at(i));
  }
  cout << b.size() +1 << endl;
  }


Measured memory_bytes: 512
require 'prime'
if true then
  fh=STDIN
else
  fh=open("in0222.txt")
end

ns=[]
while true
  n=fh.gets.chomp.to_i
  break if n==0
  ns.push n
end

nmax=ns.max

p1=Prime.each(nmax).to_a.reverse.each_cons(4)
p2= p1.select{|x,y,z,u| y==x-2 and z==x-6 and u==x-8}

#puts p2.map{|x| x.map{|y| y.to_s}.join(':')}
ns.each{|m|
  ans=p2.find{|x,y,z,u| x<=m}
  puts ans.first
}

Measured memory_bytes: 76184
import itertools
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

cost = -10**10
for a in itertools.product((0, 1), repeat=10):
    if a==(0, 0, 0, 0, 0, 0, 0, 0, 0, 0):
        continue
    tmp_cost = 0
    for i in range(N):
        tmp_c = 0
        l = 0
        for j in range(5):
            for k in range(2):
                tmp_c += F[i][l]*a[l]
                l += 1
        tmp_cost += P[i][tmp_c]
    cost = max(cost, tmp_cost)

print(cost)


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<queue>
#include<list>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
const ll maxn = 200000 + 5;
string s, t;

bool judge(int ru, int rd, int cl, int cr, int h, int w){
	if(ru < 1 || rd > h || cl < 1 || cr > w)return true;
	return false;
}

int main(){
//	ios::sync_with_stdio(false);
//	ifstream cin("data.txt");
//	freopen("data.txt", "r", stdin);
	int h, w, n, r, c, ru, rd, cl, cr;
	cin >> h >> w >> n >> r >> c;
	ru = r;
	rd = r;
	cl = c;
	cr = c;
	
	cin >> s >> t;
	bool flag = true;
	for(int i = 0; i < n; i++){
		if(s[i] == 'L'){
			cl--;
		}
		else if(s[i] == 'R'){
			cr++;
		}
		else if(s[i] == 'U'){
			ru--;
		}
		else{
			rd++;
		}
		if(judge(ru, rd, cl, cr, h, w)){
			flag = false;
			break;
		}
		if(t[i] == 'L'){
			if(cr > 1)cr--;
		}
		else if(t[i] == 'R'){
			if(cl < w)cl++;
		}
		else if(t[i] == 'U'){
			if(rd > 1)rd--;
		}
		else{
			if(ru < h)ru++;
		}
	}
	cout << (flag ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 776
h,w = [int(i) for i in input().split()]

M = [[int(i) for i in input().split()] for j in range(10)]

for i in range(10):
    for j in range(10):
        for k in range(10):
            M[j][k] = min(M[j][k],M[j][i]+M[i][k])

ans = 0            
for i in range(h):
    a = [int(i) for i in input().split()]
    for j in a:
        if j == -1:
            continue
        else:
            ans += M[int(j)][1]

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);

    if (a<b && b<c && a<c)
    printf("Yes\n");

    else
    printf("No\n");
    return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x;
    vector<long long int>v,b;
    cin>>n;
    for(long long int i=0; i<n; i++)
    {
        cin>>x;
        if(i%2==0)
            v.push_back(x);
        else
            b.push_back(x);
    }
    if(n%2==0)
    {

        reverse(b.begin(),b.end());
        for(long long int i=0; i<b.size(); i++)
        {
            cout<<b[i]<<" ";
        }
        for(long long int i=0; i<v.size(); i++)
        {
            cout<<v[i]<<" ";
        }

        cout<<endl;
    }
    else
    {
        reverse(v.begin(),v.end());
        for(long long int i=0; i<v.size(); i++)
        {
            cout<<v[i]<<" ";
        }
        for(long long int i=0; i<b.size(); i++)
        {
            cout<<b[i]<<" ";
        }

        cout<<endl;
    }
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1e9 + 7; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    static ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
} 

void solve_test() {
  ll a, v;
  ll b, w;
  ll t; 
  cin >> a >> v >> b >> w >> t;
  ll d = abs(a - b);
  ll dv = v - w; 
  cout << (t*dv >= d ? "YES" : "NO") << endl;
}

void setup() {
}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve_test();
    }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
n=1<<18;L[1<<18],p;F[1<<18],X[1<<18];i;long D[1<<20],Z[1<<20],A[1<<18],x;long f(a,k,l,r,b){return(Z[k]+=(b=a>l|-r<~i)?0:x)+(D[k]=l<=i&a<r&b?fmax(f(a,2*k,l,b),f(a,2*k+1,b=l+r>>1,r)):D[k]);}main(j){for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];for(;p?:(p=F[++i],f(i,1,0,n),n/i);p=X[p])x=A[p],x=f(L[p],1,0,n);printf("%ld",x);}

Measured memory_bytes: 17152