akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;
    private static int[][] neg8 = new int[][]{{-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            int[] arr1 = new int[N];
            for (int i = 0; i <N; i++) {
                arr1[i] = sc.nextInt();
            }
            int [] arr2 = new int[N];
            for (int i = 0; i <N; i++) {
                arr2[i] = sc.nextInt();
            }

            int max = 0;
            for (int i = 0; i < N; i++) {
                int count = 0;
                for (int j = 0; j <= i; j++) {
                    count+=arr1[j];
                }
                for (int j = i; j <N ; j++) {
                    count+=arr2[j];
                }
                max = Math.max(max, count);
            }
            System.out.println(max);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

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

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

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



Measured memory_bytes: 21844
lines = $stdin.read
array = lines.split("\n")

def knapsack(n,w,items)

  dp = Array.new(N+1).map{Array.new(W+1, 0)}

  for i in 1...N+1
    for w in 1...W+1
      if items[i].w <= w
        if items[i].v + dp[i-1][w - items[i].w] > dp[i-1][w]
          dp[i][w] = items[i].v + dp[i-1][w - items[i].w]
          #G[i][w] = DIAGONAL # ?????? i ????????¶
        else
          dp[i][w] = dp[i-1][w]
          #G[i][w] = TOP
        end
      else
        dp[i][w] = dp[i-1][w]
        #G[i][w] = TOP     # ?????? i ???????????????
      end
    end
  end

  dp
end

Item  = Struct.new(:v, :w)
N,W   = array[0].split(" ").map(&:to_i)

items = [Item.new(0,0)]
array[1..array.length].each do |s|
  item = Item.new
  item.v, item.w = s.split(" ").map(&:to_i)
  items << item
end

dp = knapsack(N,W,items)
puts dp.max.max

Measured memory_bytes: 16772
#include<iostream>
#include<vector>
using namespace std;
class queue{
  public:
    queue(const int n, const int q);
    void enqueue(const pair<int,char*>& data);
    void dequeue();
    void operation ();
    int calculate (int time);
 
  private:
    vector< pair< int, char*> > mData;
    int mOperationTime;
    int mHead;
    int mTail;
    int mBufferSize;
    int mDone;
    int mTimeFromStart;
};
 
queue::queue(const int n ,const int q){
  mHead = 0; mTail = 0;
  mData.reserve(n);
  mBufferSize = n;
  mDone = 0;
  mTimeFromStart = 0;
  mOperationTime = q;
}
 
void queue::enqueue(const pair<int,char*>& data){
    mData.push_back(data);
    mTail++;
    if(mTail==mBufferSize) 
        mTail=0;
};
 
void queue::dequeue(){
    //cout << mData[mHead].second << " " << mTimeFromStart << "\n";
    printf("%s %d\n", mData[mHead].second, mTimeFromStart);
    mData.erase(mData.begin() + mHead);
    mHead--;
    mDone++;
};
 
int queue::calculate(int time){
    //if(mData[mHead].first != 0) {
        if(mData[mHead].first - time <= 0) {                     
            mTimeFromStart += mData[mHead].first;                
            mData[mHead].first = 0;
            dequeue();
            return 0;
        }
        else {
            mData[mHead].first -= time; 
            mTimeFromStart += time;
            return 0;
        }
    //}
    //else {
    //    return time;
    //}
};
 
void queue::operation (){
    int operation_time = mOperationTime;
    while(1){
        operation_time = calculate(operation_time);
        if(operation_time==0) {
            operation_time = mOperationTime;
        }
        mHead++;
        if(mHead == mData.size()) {
            mHead = 0;
        }
        if(mDone == mBufferSize) {
            break;
        }
    }
    return;
}
 
int main(int argc,char* argv[]){
    int n,q;
    scanf("%d", &n);
    scanf("%d", &q);
    queue Q(n, q);
    char name[n][10];
    for(int i=0;i<n;i++) {
        int time;
        scanf("%s", name[i]);
        scanf("%d", &time);
        pair< int, char* > p {time, name[i]};
        Q.enqueue(p);
    }
     
    Q.operation();
 
    return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-8
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define hash Hash
#define list List
using namespace std;
typedef long long LL;
using namespace std;
int main(){
	int q,h,s,d,n;
	scanf("%d %d %d %d %d",&q,&h,&s,&d,&n);
	int unit= min(q*4,h*2);
	unit=min(unit,s);
	LL ans = min((LL)n*unit,(LL)n/2*d+(LL)n%2*unit);
	printf("%lld\n",ans);
}

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

int main(){
    char a,b,c,d;
  	string ans;
    
    cin>>a>>b>>c>>d;
  	ans= (a==b && b==c || b==c && c==d) ? "Yes":"No";
    
    cout<<ans<<endl;
    return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 200005
#define INF 1000000000
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
vector<ll>vt;;
int main()
{
    ll i,j,k,l,n,m,r;
    string s;
    in(n);
    cin>>s;
    ll cnt=0;
    m=count(all(s),'R');
    for(i=0;i<m;i++)if(s[i]=='R')cnt++;
    out(m-cnt);endl;
}


Measured memory_bytes: 3884
o[256],z[256];main(N,S,A,C,s,a,c,r,i){for(;scanf("%d",&N),N;printf("%d %d %d\n",S,A,C)){
	double H=9,h,n=N;
	for(i=0;i<N;i++)scanf("%d",z+i);
	for(s=0;s<16;s++)for(a=0;a<16;a++)for(c=0;c<16;c++){
		for(r=s,i=0;i<N;)o[z[i++]+(r=(a*r+c)&255)&255]++;
		for(h=i=0;i<256;i++)if(o[i])h-=o[i]/n*log(o[i]/n),o[i]=0;
		if(h+1e-9<H)H=h,S=s,A=a,C=c;
	}
}exit(0);}

Measured memory_bytes: 640
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

n = int(input())
t = [int(input()) for i in range(n)]


for i in range(n - 1):
    t[i + 1] = t[i] * t[i + 1] // gcd(t[i], t[i + 1])

print(t[n - 1])


Measured memory_bytes: 2940
# coding: utf-8
import sys
import numpy as np
from functools import lru_cache

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# bit毎で１と０の多い方の値、K以下でdfs
N, K = lr()
A = lr()
limit = max(max(A), K).bit_length()
X = [0] * (limit)
for a in A:
    for i in range(limit):
        if (a >> i) & 1:
            X[i] += 1

Y = [max(x, N-x) for x in X]

@lru_cache(None)
def cal(index, total):
    total += sum([y * 2 ** i for i, y in enumerate(Y[:index+1])])
    return total

@lru_cache(None)
def dfs(index, sum, y):
    if index == limit:
        return sum
    i = limit - 1 - index
    if y + 2 ** (i + 1) <= K:
        return cal(i, sum)
    ret = dfs(index+1, sum + X[i] * 2 ** i, y)
    if y + 2 ** i <= K:
        ret = max(ret, dfs(index+1, sum+(N-X[i])*2**i, y+2**i))
    return ret

answer = dfs(0, 0, 0)
print(answer)


Measured memory_bytes: 23584
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> man(n, 0);
    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        a--;
        man[a]++;
    }
    for (int i = 0; i < n; i++) {
        cout << man[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  int best = 1e9;
  auto get = [&] (int x) {
    int ret = 0;
    while (x > 0) {
      ret += x % 10;
      x /= 10;
    }
    return ret;
  };
  for (int a = 1; a < n; ++a) {
    int b = n - a;
    best = min(best, get(a) + get(b)); 
  }
  cout << best << '\n';
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    long long A,B,C;
    
    cin >> A >> B >> C;
    
    if ( A%2 == 0 || B%2 == 0 || C%2 == 0 ) {
        cout << 0 << endl;
        return 0;
    }
    
    cout << min( A*B, min(  B*C , C*A ) ) << endl;
    
    return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())

if(x>=0 and y>0):
    if(abs(x)>abs(y)):
        print(abs(x-y)+2)
    else:
        print(abs(x-y))

if(x>=0 and y<=0):
    if(abs(x)>abs(y)):
        print(abs(x+y)+1)
    else:
        print(abs(x+y)+1)
        
if(x<0 and y>0):
    if(abs(x)>abs(y)):
        print(abs(x+y)+1)
    else:
        print(abs(x+y)+1)
        
if(x<0 and y<=0):
    if(abs(x)>abs(y)):
        print(abs(x-y))
    else:
        print(abs(x-y)+2)
        

Measured memory_bytes: 3064
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

N, K = MAP()
A = [a-1 for a in LIST()]
C = LIST()
MAX = 32

N = len(A)
nxt = list2d(MAX, N, -1)
score = list2d(MAX, N, -1)
mx = list2d(MAX, N, -1)
for i, a in enumerate(A):
    nxt[0][i] = a
    score[0][i] = C[a]
    mx[0][i] = max(C[a], 0)

for k in range(1, MAX):
    for i in range(N):
        nxt[k][i] = nxt[k-1][nxt[k-1][i]]
        score[k][i] = score[k-1][i] + score[k-1][nxt[k-1][i]]
        mx[k][i] = max(mx[k-1][i], score[k-1][i] + mx[k-1][nxt[k-1][i]])

ans = -INF
K -= 1
for a in A:
    cur = a
    sm = C[a]
    for k in range(MAX-1, -1, -1):
        if K >> k & 1:
            ans = max(ans, sm + mx[k][cur])
            sm += score[k][cur]
            cur = nxt[k][cur]
    ans = max(ans, sm)
print(ans)


Measured memory_bytes: 78912
#include<bits/stdc++.h>
using namespace std;
vector<int>arr;
int n,k,temp;
int dp[100002];
void solve()
{
    memset(dp , -1 ,sizeof dp);
    cin>>n>>k;
    for(int  i = 0;i<n;i++)
      {
          cin>>temp;arr.push_back(temp);
      }
     
     dp[0] = 0;

     for(int  i = 1;i<=k;i++)
     {
        dp[i] = 0;
        for(auto moves : arr)
        {
            if((i-moves)>=0)
            {
                  if(dp[i-moves]==0)
                    dp[i] = 1;
            }
        }
     }
     if(dp[k]==1)
       cout<<"First"<<endl;
     else
      cout<<"Second"<<endl;
}
int main(void)
{
   solve();
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  int n,p[20],i,j,k;
  int cnt=0;
  cin>>n;
  for(i=0;i<n;i++)cin>>p[i];

  for(i=0;i<n-2;i++){
    
    if(p[i]<p[i+1]&&p[i+2]>p[i+1])cnt++;
    else if(p[i]>p[i+1]&&p[i+2]<p[i+1])cnt++;

  }
  cout<<cnt<<endl;

	return 0;
}


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

int main() {
  string s;
  while(cin >> s) {
    int p=0;
    vector<string> v;
    char c;
    cin >> c;
    if (c == 'X') break;
    
    for (int i=0; i<s.length(); i++) {
      if (s[i] == '_') {
        v.push_back(s.substr(p,i-p));
        p=i+1;
      }
      if (i>0 && isupper(s[i])) {
        v.push_back(s.substr(p,i-p));
        p=i;
      }
    }
    v.push_back(s.substr(p));
    
    string ans;
    for (int i=0; i<v.size(); i++) {
      string s1 = v[i];
      if (c == 'U') {
        s1[0] = toupper(s1[0]);
        ans += s1;
      }
      if (c == 'L') {
        if (i==0) {
          s1[0] = tolower(s1[0]);
          ans += s1;
        } else {
          s1[0] = toupper(s1[0]);
          ans += s1;
        }
      }
      
      if (c == 'D') {
        s1[0] = tolower(s1[0]);
        if (i>=1)
          ans += "_" + s1;
        else
          ans += s1;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	fmt.Scan(&x)

	for i:= x; i < 10000000; i++ {
		if isPrime(i){
			fmt.Println(i)
			return
		}
	}
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n%2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n%i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int, input().split())) 
m = 1000
tmp = 999
kb = 0

for i in range(n):
    if tmp > a[i]:
        kb = int(m / a[i])
        d = m - kb * a[i]
        tmp = a[i]
    elif tmp < a[i] and kb != 0:
        m = kb * a[i] + d
        tmp = a[i]
        if i < n - 1:
            if a[i] > a[i+1]:
                kb = 0

print(m)

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

int main()
{
    map<string, int> m;

    int n;
    cin >> n;

    while (n--)
    {
        int x;
        int y;
        string z;

        cin >> x;
        if (x == 0)
        {
            cin >> z >> y;
            //m.insert(make_pair(z, y));
            m[z] = y;
        }
        if (x == 1)
        {
            cin >> z;
            cout << m[z] << endl;
        }
        if (x == 2)
        {
            cin >> z;
            m.erase(z);
        }
    }
    return 0;
}


Measured memory_bytes: 27724
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;
int n,d[50];
int main(){
	cin>>n;
	rep(i,n)
	cin>>d[i];
	int ans=0;
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++){
		ans+=d[i]*d[j];
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
dp[1][1] = 1
for i in range(0, n+1):
    for j in range(0, i+1):
        if i == 0 or j == 0 or i == j:
            dp[i][j] = 1
            continue

        dp[i][j] = dp[i-1][j-1] + dp[i-1][j]

for i in range(1, k+1):
    print(dp[n-k+1][i]*dp[k-1][i-1]%(10**9+7))

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

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

  string a, b;
  cin >> a >> b;

  ll c = stoi(a + b);

  ll low = 1, high = c;

  while (low <= high) {
    ll mid = low + (high - low) / 2;
    ll x = mid * mid;

    if (x < c) {
      low = mid + 1;
    } else if (x > c) {
      high = mid - 1;
    } else {
      cout << "Yes" << "\n";
      return 0;

    }
  }

  cout << "No" << "\n";
}


Measured memory_bytes: 3644
n, q = map(int, input().split())
s = ' ' + input()
heap = [0] * (n + 1)
cnt = 0
for i in range(2, n + 1):
    if s[i - 1] == 'A' and s[i] == 'C':
        cnt += 1;
    heap[i] = cnt
ans = []
for i in range(q):
    l, r = map(int, input().split())
    ans.append(heap[r] - heap[l])
for i in ans:
    print(i)

Measured memory_bytes: 10384
#include <stdio.h>
#include <string.h>

int main(void){
    // Your code here!
    int N,i;
    char b;
    char buf[100000];
    int cnt = 0;
    int flg = 0;

    scanf( "%d" , &N );
    scanf( "%s" , buf );
    
    b = buf[0];
    
    for( i = 1 ; i < N; i++ ){
        
        if( flg == 1 ){
            b = buf[i];
            flg = 0;
            //printf("%d----------\n" , i );
            continue;
        }
        
        if( strncmp ( &b,&buf[i],1 ) == 0 ){
            //printf("%d==========\n" , i );
            continue;
        }else{
            //printf("%d no--%c--%c\n" , i , b , buf[i]);
            cnt++;
            flg = 1;
        }
    }
    
    printf( "%d\n" , cnt );
    
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int N,M;
vector<int> g[size];
int visit[size] = {};
void dfs(int v){
	if(visit[v]) return;
	else visit[v] = 1;
	for(int u:g[v]){
		dfs(u);
	}
}
int main(){
	cin>>N>>M;
	rep(i,0,N){
		int k,l; cin>>k;
		rep(j,0,k){
			cin>>l; l--;
			g[i].push_back(l + N);
			g[l + N].push_back(i);
		}
	}
	dfs(0);
	rep(i,0,N){
		if(visit[i] == 0){ cout<<"NO"<<endl; return 0; }
	}cout<<"YES"<<endl;
}

Measured memory_bytes: 8960
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n /= 2LL;
  }
  return res;
}

int main() {
  ll n, k, ans = 0LL, cnt[100001] = {};
  vector<int> v[100001];
  int a[1001] = {};
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= k; i++) {
    for (int j = 2 * i; j <= k; j += i) {
      v[j].push_back(i);
    }
  }
  for (ll i = k; i >= 1LL; i--) {
    ll num = mod_pow(k / i, n, MOD);
    num += MOD - cnt[i];
    num %= MOD;
    for (int j = 0; j < v[i].size(); j++) {
      cnt[v[i][j]] += num;
      cnt[v[i][j]] %= MOD;
    }
    num *= i;
    num %= MOD;
    ans += num;
    ans %= MOD;
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 14368
# ????????£???????¨????????§£???????????°??????
# ax + by = c
# dx + ey = f
import sys

def inverse(a, b, d, e):
    deta = a * e - b * d
    return (deta, e, -b, -d, a)

while True:
    data = sys.stdin.readline()
    if data is None or data.strip() == '':
        break
    data = data.strip().split(' ')
    a, b, c, d, e, f = [float(i) for i in data]

    inv = inverse(a, b, d, e)
    x = (inv[1] * c + inv[2] * f) / inv[0] + 0
    y = (inv[3] * c + inv[4] * f) / inv[0] + 0

    print('%.3f %.3f' % (x, y))

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

class Program
{
    void solve()
    {
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        byte[] said = new byte[N];
        byte[,] who = new byte[4, N];

        who[0, 0] = 0; who[0, N - 1] = 0;
        who[1, 0] = 0; who[1, N - 1] = 1;
        who[2, 0] = 1; who[2, N - 1] = 0;
        who[3, 0] = 1; who[3, N - 1] = 1;


        for (int i = 0; i < N; ++i)
            said[i] = (byte)(s[i] == 'o' ? 0 : 1);

        for (int i = 0; i < N; ++i)
        {
            for (int j = 0; j < 4; ++j)
            {
                who[j, (i + 1) % N] = (byte)(said[i] ^ who[j, (N + i - 1) % N] ^ who[j, i]);
            }
        }

        int k = -1;
        if (who[0, 0] == 0 && who[0, N - 1] == 0)
            k = 0;
        else if (who[1, 0] == 0 && who[1, N - 1] == 1)
            k = 1;
        else if (who[2, 0] == 1 && who[2, N - 1] == 0)
            k = 2;
        else if (who[3, 0] == 1 && who[3, N - 1] == 1)
            k = 3;

        string ans = string.Empty;
        if (k == -1)
        {
            ans = "-1";
        }
        else
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < N; ++i)
            {
                sb.Append(who[k, i] == 1 ? 'W' : 'S');
                //ans += who[k, i] == 1 ? "W" : "S";
            }
            ans = sb.ToString();
        }
        Console.WriteLine(ans);
    }
    public static int Main()
    {
        bool loop = false;
#if ES_DEBUG
        loop = true;
#endif
        do
        {
            new Program().solve();
        } while (loop);
        return 0;
    }
}


Measured memory_bytes: 12512
<?php
While ($line = fgets(STDIN) ) {
    $stdin[] = trim($line);
}
$a = explode(" ", $stdin[1] );
$b = explode(" ", $stdin[2] );

$cnt=0;
$amari=0;

for($i=0; $i<$stdin[0];  $i++){
    $cnt+=min($a[$i],$amari);
    $a[$i]=max(0, $a[$i]-$amari);
    If($b[$i]>=$a[$i]){
        $cnt+=$a[$i];
        $amari=$b[$i]-$a[$i];
    }else{
        $cnt+=$b[$i];
        $amari=0;
    }
}
$cnt+=min($a[$i],$amari);
echo $cnt;

Measured memory_bytes: 40580
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = br.readLine()) != null) {
			String[] arr = line.split(" ");
			int h = Integer.parseInt(arr[0]);
			int w = Integer.parseInt(arr[1]);
			if (h == 0 && w == 0)
				break;

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 25896
#include<stdio.h>
#include<math.h>
#include<iostream>

int prime(int data){
	int i;
	for(i=3;i<=sqrt(data);i+=2){
		if(data%i==0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int list[1000000]={0,1};
	int i,data,cnt;
	for(i = 3;i <= 999999;i++){
		if(i%2==0){
			list[i-1]=0;
		}else{
			list[i-1] = prime(i);
		}
	}
	while(std::cin >> data){
		cnt = 0;
		for(i=0;i<data;i++){
			if(list[i] == 1){
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using ld = long double;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
// const int mod = 998244353;
const ll inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-7;
// const ld PI = acos(-1.0);

const int N = 5e5 + 55;

int cnt[N][26];

void upd (int pos, int c, int val) {
	for (; pos < N ; pos |= pos + 1) {
		cnt[pos][c] += val;
	}
}

int get (int pos, int c) {
	int res = 0;
	for (; ~pos ; pos &= pos + 1, pos --) {
		res += cnt[pos][c];
	}
	return res;
}

int get (int l, int r, int c) {
	return get (r, c) - (l ? get (l - 1, c) : 0);
}

void solve () {
	int n, q; string s;
	cin >> n >> s >> q;
	for (int i = 0 ; i < n ; ++ i) {
		upd (i, s[i] - 'a', 1);
	}
	while (q--) {
		int t, l, r, i; char c; cin >> t;
		if (t == 1) {
			cin >> i >> c; --i;
			upd (i, s[i] - 'a', -1);
			s[i] = c;
			upd (i, s[i] - 'a', 1);
		}
		else {
			cin >> l >> r; -- l, -- r;
			int res = 0;
			for (int c = 0 ; c < 26 ; ++ c)
				res += get (l, r, c) != 0;
			cout << res << "\n";
		}
	}
}

int main () {
	ios;
	// double start_time = clock();
	// cout << fixed << setprecision (10);
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
		cout << "\n";
	}
	// cerr << (clock() - start_time) / CLOCKS_PER_SEC;
}

Measured memory_bytes: 51740
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
string s;
int const MAXN=10010, MAXD=110, MOD=1e9+7;
int d, memo[MAXN][MAXD][2], n;
int dp(int digit, int rem, int change){
	int &x=memo[digit][rem][change];
	if(x!=-1)
		return x;
	if(digit==n)
		return rem==0;
	if(change){
		x=0;
		for(int i=0;i<=9;i++)
			x=(x+dp(digit+1,(rem+i)%d,change))%MOD;
		return x;
	}
	x=0;
	for(int i=s[digit]-'0';i>=0;i--)
		x=(x+dp(digit+1,(rem+i)%d,i!=s[digit]-'0'))%MOD;
	return x;
}
int main(){
	cin>>s>>d;
	n=(int)s.length();
	memset(memo,-1,sizeof(memo));
	int ans=dp(0,0,0);
	if(ans)
		cout<<ans-1;
	else cout<<MOD-1;
}


Measured memory_bytes: 9984
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mod=1e9+7;
double N;
double memo[309][309][309];
//bool vis[3009][3009];
double sol(int a,int b,int c){
  if(a<0 || b<0 || c<0)return -1;
  if(a+b+c==0)return 0;
  if(memo[a][b][c])return memo[a][b][c];
  return memo[a][b][c]=-1+N/(a+b+c)+(sol(a-1,b,c)+1)*a/(a+b+c)+(sol(a+1,b-1,c)+1)*b/(a+b+c)+(sol(a,b+1,c-1)+1)*c/(a+b+c);
}
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
		cin>>N;
		int k[3]={0,0,0};
		for(int i=0;i<N;i++){
      int a;
      cin>>a;
      k[a-1]++;
		}
		cout<<fixed<<setprecision(20)<<sol(k[0],k[1],k[2]);
    return 0;
}

Measured memory_bytes: 225536
A, B = map(int,input().split())
X = 0
if A > B:
    X = A
    A -= 1
    if A > B:
        X += A
        print(X)
    else:
        X += B
        print(X)    
else:
    X = B
    B -= 1
    if A > B:
        X += A
        print(X)
    else:
        X += B
        print(X)



Measured memory_bytes: 3060
import java.util.Scanner;
	class Main {
	public static void main(String[] args){
        
		Scanner s = new Scanner(System.in);
		int i,j,k,m,n,l;
        
                  n=s.nextInt();
      			  m=s.nextInt();
        		  l=s.nextInt();
        long[][] A=new long[n][m];
        long[][] B=new long[m][l];
        long[][] C=new long[n][l];
        
      
        for(i=0;i<n;i++)
            for(j=0;j<m;j++)
                A[i][j]=s.nextInt();
        
        for(i=0;i<m;i++)
            for(j=0;j<l;j++)
                B[i][j]=s.nextInt();
        
        for(i=0;i<n;i++){
            for(j=0;j<l;j++){
                for(k=0;k<m;k++){
               C[i][j]+=A[i][k]*B[k][j];
                }
            }
        }
        for(i=0;i<n;i++){
            for(j=0;j<l;j++){
                System.out.print(C[i][j]);
                if(j!=l-1)System.out.print(" ");
            }
            System.out.println();
        }
        

            
	}
}


Measured memory_bytes: 52832
n = gets.to_i
rest = Array.new(n).map{Array.new}
for i in 0..n-1
  rest[i] = gets.chomp.split
  rest[i][1] = rest[i][1].to_i
  rest[i].push(i+1)
end
rest.sort! do |a,b|
  (a[0] <=> b[0]).nonzero? || (b[1] <=> a[1])
end
n.times do |i|
  p rest[i][2]
end

Measured memory_bytes: 1788
n,k=map(int,input().split())
a=[]


for i in range(n):
    s,p=map(int,input().split())
    a+=[[s, p] ]
    

import operator as op
a.sort(key = op.itemgetter(0))

ans=0
get=0
look=0
while get<k:
    get=get+1
    a[look][1]=a[look][1]-1
    ans=ans+a[look][0]
    if a[look][1]==0:
        look=look+1

print(ans)

Measured memory_bytes: 21292
#include<bits/stdc++.h>
using namespace std;
int now,n,ans=0;
string s;
int main(){
    cin>>n>>s;
    now=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='I') now++;
    	if(s[i]=='D') now--;
    	ans=max(ans,now);
    }
    cout<<ans<<endl;
	return 0;
}

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

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    ll L, R;
    cin >> L >> R;

    ll ans = 2020*2020;
    int const mod = 2019;
    FOR(f,L,R) {
        FOR(s,f+1,R+1) {
            ll l = f%mod;
            ll r = s%mod;
            ll m = (l*r)%mod;
            ans = min(ans, m);

            if (ans == 0) {
                cout << ans << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  ll a, b; cin >> a >> b;

  if (a*b<=0) cout << "Zero" << endl;
  else if (a>0) cout << "Positive" << endl;
  else if ((b-a+1)%2==0) cout << "Positive" << endl;
  else cout << "Negative" << endl;
  


  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;
use 5.010;

use Data::Dumper;
use List::Util qw(min);

chomp(my $line = <STDIN>);
my ($n, $m, $x) = split / /, $line;
chomp($line = <STDIN>);
my %A;
$A{$_} = undef for(split / /, $line);

sub calc {
    my ($n, $x, $A, $d) = @_;
    my $ret = 0;
    # print Dumper @_;
    while ($x != 0 and $x != $n) {
        # say "x = $x";
        $ret++ if exists($A->{$x});
        $x += $d;
    }
    # say "$ret";
    $ret;
}

my $ans = min(calc($n, $x, \%A, 1), calc($n, $x, \%A, -1));

say "$ans";


Measured memory_bytes: 1920
h,w = map(int,input().split())
zero = ['0' for i in range(w+2)]
S = [['0']+list(input())+['0'] for i in range(h)]
S = [zero] + S + [zero]
for i in range(1,h+1):
  for j in range(1,w+1):
    if S[i][j] == '#':
      if S[i+1][j] == '#' \
      or S[i-1][j] == '#' \
      or S[i][j+1] == '#' \
      or S[i][j-1] == '#':
        continue
      else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
char a[100][101],b[102][102];

int main() {
  int H,W;cin >> H >> W;
  for(int i=0;i<H;i++){
		scanf("%s",a[i]);
  }
 
  for(int i=0;i<H+2;i++){
 	for(int j=0;j<W+2;j++){
      b[i][j] = '#';
    }
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      b[i+1][j+1] = a[i][j];
    }
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      	cout << b[i][j];
    }
    cout << endl;
  }
  
}
  

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

int main() {
	int n,i,c=0,j;
	set<int>s;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++){
	cin>>a[i];
	s.insert(a[i]);}
	if(s.size()!=n)
	cout<<"NO";
	else
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    map<int,int> m;
    m[0]++;
    int sum=0,ans=0;
    rep(i,N){
        int a; cin >> a;
        sum += a;
        ans += m[sum%M];
        m[sum%M]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int max_x = 0;
    rep(i, n){
        if(s[i] == 'I'){
            x ++;
            max_x = max(max_x, x);
        }else if(s[i] == 'D'){
            x --;
            max_x = max(max_x, x);
        }
    }
    cout << max_x << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Class1
{
    static void Main(string[] args)
    {
        var D = int.Parse(Console.ReadLine());
        var c = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();
        int[][] ds = new int[D][];

        for (int i = 0; i < D; i++)
        {
            ds[i] = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();
        }

        int[] ts = new int[D];
        for (int i = 0; i < D; i++)
        {
            ts[i] = int.Parse(Console.ReadLine());
        }

        var M = int.Parse(Console.ReadLine());
        int[][] dq = new int[M][];
        for (int i = 0; i < M; i++)
        {
            dq[i] = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();
        }

        // 問題Cのアレンジするコード
        var newTs = new int[D];
        Array.Copy(ts, newTs, D);
        for (int i = 0; i < M; i++)
        {
            // dqをベースにして変えてみる
//            Console.WriteLine($"{dq[i][0]}日目を{dq[i][1]}に変えて実施");
            newTs[dq[i][0] - 1] = dq[i][1];

//            Console.WriteLine(string.Join(", ", newTs));

            var newAns = _Calc(D, c, ds, newTs);
            Console.WriteLine(newAns[D - 1]);
        }
    }

    private static long[] _Calc(int D, int[] c, int[][] ds, int[] ts)
    {
        long[] t_ans = new long[D];
        int[] c_history = new int[26];
        long sum = 0;
        long minus = 0;

        for (int i = 0; i < D; i++)
        {
            long v = ds[i][ts[i] - 1];
            for (int j = 0; j < 26; j++)
            {
                if (j == ts[i] - 1)
                {
                    if (i > 0)
                    {
//                        Console.WriteLine($"plus_prev: {i}, {c[j]}");
//                        Console.WriteLine($"c_history[j]: {c_history[j]}");
                        minus -= c[j] * (i - c_history[j]);
                        continue;
                    }

//                    Console.WriteLine($"skip: {i}, {c[j]}");
                    continue;
                }

                minus += c[j];
            }

//            Console.WriteLine("minus: " + minus);
//            Console.WriteLine("v: " + v);

            sum += v - minus;
            c_history[ts[i] - 1] = i + 1;


//            Console.WriteLine(sum);
            t_ans[i] = sum;
        }

        return t_ans;
    }
}

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

using namespace std;

int n,k,A[5005];
bool dp[5005][5005];
int main(){
	//freopen("noneed.in", "r", stdin);
	cin >> n >> k;
	for(int i = 1; i<=n; i++) cin >> A[i];
	sort(A+1, A+n+1, greater<int>());
	int ans = n;
	dp[0][0] = 1;
	for(int i = 1; i<=n; i++){
		bool can = false;
		for(int j = 0; j<=k; j++){
			if(j < k and dp[i-1][j] and j+A[i]>=k){
				can = true;
			}
			dp[i][j] = (j-A[i]>=0?dp[i-1][j-A[i]]:0) | dp[i-1][j];
		}
//		printf("%d %d : ", A[i], can); for(int j = 0; j<=k; j++) printf("%d ", dp[i][j]); printf("\n");
		if(can){
			ans = n-i;
		}
	}
	cout << ans;
}

/*
sort by descending order

for every element, dp[i][s] = true or false
dp[i][s] can come from dp[i-1][s-A[i]<k] or dp[i][s]
if(dp[i][>=k]) then i is useful

*/


Measured memory_bytes: 24704
#include <iostream>

using namespace std;

int main()
{
   int K,i;
   int h;
   cin >> K;
   string s;
   cin >> s;
   h = s.length();
   if(h<=K) cout << s;
   if(h>K){
       for(i=0;i<K;i++){
           cout << s[i];
       }
       cout << "...";
   }
   
   return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
    // Your code here!
    
    int l,r,d=0;
    int ans=0;
    
    scanf("%d %d %d",&l,&r,&d);
    
    for(int i=l;i<=r;i++) if( i%d==0 ) ans++;
    
    printf("%d\n",ans);
    
    
    return 0;
    
}


Measured memory_bytes: 2152
n = (int)(input())
a_list = list(map(int, input().split()))

ret = "APPROVED"
for a in a_list:
    if a % 2 == 0 and not (a % 3 == 0 or a % 5 == 0):
        ret = "DENIED"
        break

print("{}".format(ret))

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    ll k;
    cin >> n >> k;
    map<int, ll> mp;

    roop(i, n){
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    ll tmp = k;
    for(auto a: mp){
        tmp -= a.second;
        if(tmp <= 0){
            cout << a.first << endl;
            return 0;
        }
    }

    return 0;
}


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


int main()
{
	long X;
	cin >> X;

	bool isfinish = false;
	map<long, long> m;
	for (long i = -118; i <= 119; i++)
	{
		long i5;
		if (m.count(i) == 0)
		{
			//i5 = (long)pow(i, 5);
			i5 = i * i;
			i5 = i5 * i5 * i;
			m.emplace(make_pair(i, i5));
		}
		else
		{
			i5 = m.at(i);
		}

		for (long j = -118; j <= 119; j++)
		{
			long j5;
			if (m.count(j) == 0)
			{
				//j5 = (long)pow(j, 5);
				j5 = j * j;
				j5 = j5 * j5 * j;
				m.emplace(make_pair(j, j5));
			}
			else
			{
				j5 = m.at(j);
			}

			if (i5 - j5 == X)
			{
				cout << i << " " << j << endl;
				isfinish = true;
				break;
			}
		}

		if (isfinish)
			break;
	}


	return 0;
}



Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

ll N, Q;
vector<vector<int>> path;
vector<int> parent,pl;

void dfs(int pos, int prev) {
	if(prev !=-1)pl[pos] += pl[prev];
	for (int i = 0; i < path[pos].size(); i++) {
		if (path[pos][i] != prev) {
			dfs(path[pos][i], pos);
		}
	}
}

int main() {
	cin >> N >> Q;
	path = vector<vector<int>>(N+1, vector<int>());
	parent = pl = vector<int>(N + 1, 0);

	for (int i = 0; i < N - 1; i++) {
		ll a, b;
		cin >> a >> b;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	for (int i = 0; i < Q; i++) {
		int p, x;
		cin >> p >> x;
		pl[p] += x;
	}

	dfs(1, -1);
	for (int i = 0; i < N; i++) {
		if (i != N - 1)cout << pl[i + 1] << " ";
		else cout << pl[i+1] << endl;
	}

}


Measured memory_bytes: 21120
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <cstdlib>
using namespace std;

#define ll long long 
#define mem(a) memset(a,0,sizeof a)
int a[100005];

int main() {
	
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", &a[i]);

	sort(a, a + n);
	
	int l = 0, r = 0;
	int f1 = 0, f2 = 0;
	for (int i = n - 1; i > 0; i--) {
		if (l == 0) {
			if (a[i] == a[i - 1]) {
				l = a[i];
				i--;
			}
		}
		else {
			if (a[i] == a[i - 1]) {
				r = max(r, a[i]);
				break;
			}
		}
	}
	printf("%lld\n",1ll* l*r);



	//system("pause");

	return 0;
}

Measured memory_bytes: 640
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int main() {
	cin >> n;
	set<long long> s;
	for (int i = 0; i < n; ++i) {
		int a[3];
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		s.insert(a[0] * n * n + a[1] * n + a[2]);
	}
	cout << n - s.size() << endl;
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    ll ans = 0;
    REP(i, n){
        ll h; cin >> h;
        ans += (h >= k);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    if (a.contains(0)) {
        println(0)
        return
    }
    
    val max = 1_000_000_000_000_000_000

    var ans = 1L
    a.forEach {
        val tmp = ans * it
        if (tmp > max) {
            println(-1)
            return
        }
        if (tmp < ans) {
            println(-1)
            return
        }
        ans = tmp
    }

    println(ans)
}


fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}


Measured memory_bytes: 62980
def div(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
  import functools
  import operator
  import numpy as np
  import itertools
  import math
  lis = [1]
  N = int(input())
  x = div(N)
  A = []
  for i in range(math.ceil(len(x)/2)):
    A.append(x[i]+x[len(x)-i-1])
  ans = min(A)-2
  print(ans)
main()

Measured memory_bytes: 26884