akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0] + a[1] == a[2]){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

use std::fmt::Display;
pub fn print_vec<T: Display>(v: &Vec<T>, prefix: &str, suffix: &str) {
    if v.is_empty() {
        println!("[]");
        return;
    }
    print!("{}", prefix);
    print!("{}", v[0]);
    for i in 1..v.len() {
        print!(" {}", v[i]);
    }
    println!("{}", suffix);
}

fn traverse(parent: usize, i: usize, x: u32, mut points: &mut Vec<u32>, edge: &Vec<Vec<usize>>) {
    let acc = x + points[i];
    for child in &edge[i] {
        if parent == *child {
            continue;
        }
        // println!("child {}.", *child);
        traverse(i, *child, acc, &mut points, edge);
    }
    points[i] += x;
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, q) = input!(usize, usize);
    let mut points = vec![0; n];
    let mut edge = vec![vec![]; n];

    for _ in 0..(n - 1) {
        let (a, b) = input!(usize, usize);
        edge[a - 1].push(b - 1);
        edge[b - 1].push(a - 1);
    }

    for i in 0..q {
        let (p, x) = input!(usize, u32);
        points[p - 1] += x;
        // println!("processing {}: p = {}, x = {}", i, p, x);
    }

    traverse(0, 0, 0, &mut points, &edge);
        
    print_vec(&points, "", "");
}

fn main() {
    solve();
}


Measured memory_bytes: 34300
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    h, w = input_int_list()
    grid = []
    for i in range(h):
        grid.append(list(input()))

    ver_cnt = [[None for _ in range(w)] for _ in range(h)]
    hor_cnt = [[None for _ in range(w)] for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                # 横方向の数を埋める
                if not hor_cnt[i][j]:
                    j_end = j
                    cnt = 0
                    while j_end < w:
                        if grid[i][j_end] == "#":
                            break
                        else:
                            j_end += 1
                            cnt += 1
                    for _j in range(j, j_end):
                        hor_cnt[i][_j] = cnt
                # 縦方向の数を埋める
                if not ver_cnt[i][j]:
                    i_end = i
                    cnt = 0
                    while i_end < h:
                        if grid[i_end][j] == "#":
                            break
                        else:
                            i_end += 1
                            cnt += 1
                    for _i in range(i, i_end):
                        ver_cnt[_i][j] = cnt
    ans = 0

    for i in range(h):
        for j in range(w):
            if grid[i][j] != "#":
                ans = max(ans, ver_cnt[i][j] + hor_cnt[i][j] - 1)
    print(ans)


if __name__ == "__main__":
    main()


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

int count(int x) {
    if(x == 0) return 0;
    return (x % 10) + count(x / 10);
}

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

    int res = 1001001001;
    for(int i=1; i<N; ++i) {
        int A = i;
        int B = N - i;
        res = min(res, count(A) + count(B));
    }
    cout << res << endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    if (((A - B) >= (A + B)) && ((A - B) >= (A * B)))
        cout << A - B << endl;
    else if (((A * B) >= (A + B)) && ((A * B) >= (A - B)))
        cout << A * B << endl;
    else if (((A + B) >= (A - B)) && ((A + B) >= (A * B)))
        cout << A + B << endl;
    return 0;
}

Measured memory_bytes: 256
// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %d]\n", #x, x)

const int N = 200010;
ll a[N], b[N], n;
vector<pair<ll, ll>> relax;

bool can () {
	priority_queue<ll> Q;
	ll total = 0;
	for (int i = 0; i < n; i++) total += a[i];
	int ind = n - 1;
	for (int i = 0; i < n; i++) {
		while (ind >= 0 && relax[ind].first >= total) Q.push(relax[ind--].second);
		if (Q.empty()) return false;
		total -= Q.top(); Q.pop();
	}
	return (total >= 0);
}

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%lld", &n);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &a[i], &b[i]);
	for (int i = 0; i < n; i++) relax.emplace_back(b[i], a[i]);
	sort(begin(relax), end(relax));
	if (can()) printf("Yes\n"); else printf("No\n");
}

Measured memory_bytes: 11244
#include<iostream>
using namespace std;
int main(){
	int l;
	int a;
	int b;
	int c;
	int d;
	int i=0;
	int s=0;
	int n=0;
	cin>>l;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	i=a%c;
	s=(a-i)/c;
	if(i!=0){
		s=s+1;
	}
	i=b%d;
	n=(b-i)/d;
	if(i!=0){
		n=n+1;
	}
	if(s<n){
		s=l-n;
	}else{
		s=l-s;
	}
	cout<<s<<endl;
}
	

Measured memory_bytes: 3084
import java.util.*;

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

        Scanner scanner = new Scanner(System.in);
        String tokens1[] = scanner.nextLine().split(" ");
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        scanner.nextLine().split(" ");
        String tokens3[] = scanner.nextLine().split(" ");
        
        /*
        System.out.println(Arrays.asList(tokens1));
        System.out.println(a);
        System.out.println(b);
        System.out.println(Arrays.asList(tokens3));
        */
        scanner.close();

        if (tokens1[0].equals(tokens3[0])) {
            a--;
        } else {
            b--;
        }
        System.out.println(a + " " + b);
    }
}

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

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

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

	int check = 0;
	int count = 0;

	while(true){
		for (int i = 0; i < n; i++){
			if(blackboard[i] % 2 == 1){
				check++;
			}else{
				blackboard[i] = blackboard[i] / 2;
			}
		}
		if(check > 0) break;
		count++;
	}

	cout << count << "\n";
	return 0;
}


Measured memory_bytes: 256
L=input()
mo=10**9+7
def f(n):  # n = String
    s=len(n)
    dp=[[0]*2 for _ in range(s+1)]  # dp[keta][1 if k<N already else 0]
    
    dp[0][0]=1
    for i in range(1,s+1):
        d=n[i-1]
        if d=='1':
            dp[i][1]+=dp[i-1][1]*3 + dp[i-1][0]
            dp[i][0]+=dp[i-1][0]*2
        else:
            dp[i][1]+=dp[i-1][1]*3
            dp[i][0]+=dp[i-1][0]
        dp[i][1]%=mo
        dp[i][0]%=mo
    return sum(dp[s])%mo
print(f(L))

Measured memory_bytes: 54236
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String[] params = in.nextLine().split(" ");
        long n = Long.parseLong( params[0]);
        long a = Long.parseLong( params[1]);
        long b = Long.parseLong( params[2]);

        if( ( b - a ) % 2 != 0 ){
            long wina = a;
            long winb = b;
            long countWin = wina - 1;
            winb -= countWin;
            countWin++;
            winb--;
            countWin += ( winb - 1 ) / 2;

            long losea = a;
            long loseb = b;
            long countLose = n - loseb;
            losea += countLose;
            countLose++;
            losea++;
            countLose += ( n - losea ) / 2;

            System.out.println( countWin < countLose ? countWin : countLose );
        }
        else {
            System.out.println( ( b - a ) / 2 );
        }

    }

}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {

    ll n,x,y; cin >> n >> x >> y;
    ll d;
    vector<ll> v(n,0);

    for(ll i = 1; i <= n-1; i ++){
        for(ll j = i+1; j <= n; j ++){
            d = j-i;
            if(x >= i && j >= y){
                d -= (y-x-1);
            }else{
                ll d1 = abs(i-x);
                ll d2 = abs(i-y);
                if(d1 < d2){
                    d = min(d, d1 + 1 + abs(y-j));
                }else{
                    d = min(d, d1 + 1 + abs(x-j));
                }
            }
            v[d] ++;

        }
    }

    for(ll i = 1; i <= n-1; i ++){
        cout << v[i] << endl;
    }
    return 0;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int N;

  cin>>N;

  double v[51];
  
  for(int i=0;i<N;i++){

    cin>>v[i];
    
  }


  sort(v,v+N);

  double ans=(v[0]+v[1])/2;
  
  for(int i=2;i<N;i++){

    ans=(ans+v[i])/2;
    
  }
  
  cout<<ans<<endl;


  return 0;

}


Measured memory_bytes: 256
use std::io::Read;
use itertools::Itertools;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut n: usize = iterator.next().unwrap().parse().unwrap();

    let mut result = String::new();
    while n > 0 {
        let amari = n % 26;
        let c: char = if amari == 0 {
            n /= 26;
            n -= 1;
            'z'
        } else {
            n /= 26;
            ('a' as u8 + amari as u8 - 1) as char
        };
        result.push(c);
    }

    let result = result.chars().rev().map(|c| c.to_string()).join("");

    return result;
}


Measured memory_bytes: 2152
program ABC_087_B_Coins
   implicit none
   integer A, B, C, X, i, j, k, co
   read(*, *) A
   read(*, *) B
   read(*, *) C
   read(*, *) X
   co = 0   
   X = X / 50
   do k = 0, A
      do j = 0, B
	      do i = 0, C
              if( 10*k + 2*j + 1*i == X ) then
			      co = co + 1
			  end if
		  end do
	  end do
   end do
   write(*, *) co
end program ABC_087_B_Coins

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main ()
{
	int a=0 , b=0 , c=0 , d=0 ;
	cin >> a >> b >> c ;
	for(int i=a; i<=b ; i++)
	{
		if(c%i==0)
		{
			d++ ;
		}
	}
	cout << d << endl ;
	return 0 ;
}



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

int main() {
	ll n, W;
	cin >> n >> W;
	ll v[n + 1], w[n + 1];
  ll sum = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (ll i = 1; i <= n; i++)
		sum += v[i];
	ll dp[sum + 1];
 
	for (ll i = 1; i <= sum; i++)
		dp[i] = INT_MAX;
	dp[0] = 0;
	for (ll i = 1; i <= n; i++) {
		for (ll j = sum; j >= v[i]; j--) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	for (ll i = sum; i >= 0; i--) {
		if (dp[i] <= W) {
			cout << i; break;
		}
	}
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    n++;
    if (n / 2 >= k)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
x = i()
a = x//500
b = x%500
c = b//5
print(1000*a+5*c)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()
i = 0
C = True
  
while C:
  for j in range(1,X+i):
    if gcd(j, X+i) != 1:
      i += 1
      break
  else:
    C = False
    
print(X+i)

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

int main(){
    long long n, x;
    long long i, j, k;
    long long counta;
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0){
            break;
        }
        counta = 0;
        for(i = 1; i <= n-2; i++){
            for(j = i+1; j <= n-1; j++){
                for(k = j+1; k <= n; k++){
                    if(i+j+k == x){
                        counta++;
                    }
                }
            }
        }
        cout << counta << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<ll,ll>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  vector<int> a(5);
  rep(i,5){
    cin>>a[i];
    if(a[i]==0){
      cout<<i+1<<endl;
    }
  }
}


Measured memory_bytes: 3628
// AOJ 2508: King's Inspection
// 2017.10.5 bal4u@uu

#include <stdio.h>

int k[102];
char lst[102], *p;
int c2d[128];
char d2c[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
char ans[102], *q;

int main()
{
	int n, i, j;

	for (i = 0; i < 26; i++) c2d['a'+i] = i;
	for (j = 0; j < 26; j++) c2d['A'+j] = i++;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d", k+i);
		scanf("%s", lst);
		i = 0; p = lst, q = ans;
		while (*p) {
			 j = c2d[*p++] - k[i];
			 while (j < 0) j += 52;
			 *q++ = d2c[j];
			 if (++i == n) i = 0;
		}
		*q = 0;
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 1704
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  ll A, B; cin >> A >> B;
  vector<ll> cnt(3, 0);
  rep(i, n) {
    ll p; cin >> p;
    if (p <= A) cnt[0]++;
    else if (p <= B) cnt[1]++;
    else cnt[2]++;
  }
  cout << min(min(cnt[0], cnt[1]), cnt[2]) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  int a, b, c;
  a = A + B;
  b = A - B;
  c = A * B;
  if (a < b) a = b;
  if (a < c) a = c;
  cout << a << endl;
}

Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll cnt[100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    for (int i = 0; i <m; ++i)
    {
    	ll l,r;
    	cin>>l>>r;
    	cnt[l]++;
    	cnt[r+1]--;
    }
    ll ans=0;
    for (int i = 1; i <=100000; ++i)
    {
    	cnt[i]+=cnt[i-1];
    	if(cnt[i]==m)
    	{
    		ans++;
    	}
    }
   	cout<<ans<<'\n';
}


Measured memory_bytes: 1024
N, K = map(int,input().split())
A = list(map(int,input().split()))

check = [0] * (N+1) #対象の町を訪問するのが初めてか
li = [] #町の移動順
i, j = 1, 1 #現在の町の番号と移動回数

while True:
  k = A[i-1] #移動先の町の番号
  if check[k] == 1:
    #前に訪問したことがある場合
    n = li.index(k)+1 #ループに入った時点での移動回数
    break
  check[k] = 1
  li.append(k)
  i = k
  j += 1

if K < n: print(li[K-1])
else: print(li[(K-n) % (j-n) + n - 1])

Measured memory_bytes: 32164
import java.util.Scanner;

public class Main {

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

		int N = scan.nextInt();
		int K = scan.nextInt();
		boolean[] doHave = new boolean[N + 1];
		int answer = 0;

		for (int i = 0; i < K; i++) {
			int d = scan.nextInt();
			for (int k = 0; k < d; k++) {
				doHave[scan.nextInt()] = true;
			}
		}

		for (int i = 1; i <= N; i++) {
			if (!doHave[i]) answer++;
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 45848
def dfs(i, formula):
    if i + 1 == num_digits:
        return sum(list(map(int, formula.split("+"))))

    return dfs(i + 1, formula + "+" + s[i + 1]) + dfs(i + 1, formula + s[i + 1])


s = input()
num_digits = len(s)

print(dfs(0, s[0]))


Measured memory_bytes: 39152
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
typedef long long LL;
typedef unsigned long long ULL;
template<typename T>
 T gcd(T a,T b)
{
    return b==0?a:gcd(b,a%b);
}
template<typename T>
 T lcm(T a,T b)
{
    LL g=gcd(a,b);
    return (a/g)*b;
}
int main()
{
    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    vector< pair <LL,LL > > a;
    while(cin>>n>>m)
    {
        c=0;
        bool f=1;
        rep(k,n)
        {
            cin>>i>>j;
            a.pb({i,j});
        }
        sort(all(a));
        rep(k,n)
        {
            c+=a[k].second;
            if(c>=m)
            {
                cout<<a[k].first<<endl;
                break;
            }
        }
    }
}


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



int main() {

	int x, y;
	int ans = 1;
	std::cin >> x >> y;

	for (int i = 2;i <= x && i <= y;) {
		if (x % i == 0 && y % i == 0) {
			ans *= i;
			x /= i;
			y /= i;
		}
		else i++;
	}

	printf("%d\n", ans);

	//system("pause");
	return 0;
}


Measured memory_bytes: 3208
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う

void main()
{
    auto N = scanElem;
	writeln(24-N+24);
}

void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
int H[MAX_N];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> H[n];
    if(n>=1) {
      if(H[n-1] - H[n] >= 1) {
        cout << "No" << endl;
        return 0;
      }
      if(H[n] > H[n-1]) {
        H[n]--;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,u,v,h[N],ans;
struct edge{
    int v,next;
}edges[N<<1];
int tot,head[N];
void add_edges(int u,int v)
{
    edges[++tot].v=v;edges[tot].next=head[u];head[u]=tot;
    edges[++tot].v=u;edges[tot].next=head[v];head[v]=tot;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>h[i];
    for(int i=1;i<=m;i++)cin>>u>>v,add_edges(u,v);
    for(int i=1;i<=n;i++){
        bool flag=true;
        for(int j=head[i];j;j=edges[j].next){
            if(h[edges[j].v]>=h[i])flag=false;
        }
        if(flag)ans++;
    }   
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5916
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using namespace std;

const int N = 2032;
int n, a[N];
bitset<N * N / 2 + N> kn;

int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	kn.set(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		kn |= kn << a[i];
	}
	cout << kn._Find_next((accumulate(a, a + n, 0) - 1) / 2) << "\n";
	return 0;
}



Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

struct Graph
{
	struct Edge
	{
		Edge()
		{}

		Edge(int u, int v, int w)
			: u(u)
			, v(v)
			, w(w)
		{}

		int u, v, w;
	};

	vector< vector<int> > ve;
	vector<Edge> edges;
	int nvert, nedge;

	vector<int> d;
	vector<int> h;
	vector<int> w;
	vector<int> mark;
	vector<int> maxd;
	vector<int> c;

	Graph(int nvert)
		: nvert(nvert)
		, nedge(0)
		, ve(nvert)
		, d(nvert, 999999999)
		, h(nvert, -1)
		, w(nvert, 999999999)
		, mark(nvert, -1)
		, maxd(nvert, 0)
		, c(nvert, 0)
	{
		id = 1;
	}

	void add_edge(int u, int v, int w)
	{
		ve[u].push_back(nedge);
		ve[v].push_back(nedge);
		edges.push_back(Edge(u, v, w));
		++nedge;
	}

	int id;
	void bfs(int io, int color, int len)
	{
		++id;
		d[io] = 0;
		maxd[io] = len;
		if(c[io] == 0)
			c[io] = color;
		mark[io] = id;
		
		priority_queue< pair<int,int> > q;
		q.push( make_pair(0,io) );

		while(!q.empty())
		{
			int u = q.top().second;
			int dd = -q.top().first;
			q.pop();
			if(len <= dd)
				break;
			
			for(int i=0; i<ve[u].size(); ++i)
			{
				Edge &e = edges[ve[u][i]]; 
				int v = (u == e.v ? e.u : e.v);
				if(mark[v] != id)
					d[v] = 999999;
				mark[v] = id;
								
				if(c[v] == 0)
					c[v] = color;

				if(d[u] + e.w  < d[v])
					d[v] = d[u] + e.w;

				if(len-d[v] > maxd[v])
					q.push( make_pair(-d[v], v) );
				maxd[v] = max(maxd[v], len-d[v]);
			}
		}

		
	}
};


int main()
{
	ios::sync_with_stdio(false);

	int n, m, q;
	cin >> n >> m;
	Graph gr(n+1);

	for(int i=0; i<m; ++i)
	{
		int u, v, w=1;
		cin >> u >> v;
		gr.add_edge(u, v, w);
		gr.add_edge(v, u, w);
	}

	cin >> q;
	vector<int> v(q), d(q), c(q);
	for(int i=0; i<q; ++i)
	{
		cin >> v[i] >> d[i] >> c[i];
	}
	for(int i=q-1; 0<=i; --i)
	{
		gr.bfs(v[i], c[i], d[i]);
	}
	
	for(int i=1; i<=n; ++i)
		cout << gr.c[i] << "\n";
	
	return 0;
}


Measured memory_bytes: 15016
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, pre = -1 ; 
    cin >> n ; 
    vector <int>  dp(200005,0), c(200005,-1) ; 
    dp[0] = 1 ; 
    for (int i=1,x ;i<=n; i++) { 
        cin >> x ; 
        dp[i] = dp[i-1];
        if ( c[x] != -1 and pre != x ) dp[i] += dp[c[x]] ; 
        c[x] = i ; 
        pre = x ; 
        dp[i] %= 1000000007;
    } 
    cout << dp[n] << endl ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 6412
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
char s[10][10];
int  r[10],c[10];
int dp[10][10];
void solve()
{
	int n,m;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	ans=a[1];
	int k=n-2;
	for(int i=2;i<=n;i++)
	{
		if(k>=2)
		{ 
			ans+=a[i]*2,k-=2;
				continue; 
		} 
		if(k==1)
		{
			ans+=a[i],k-=1;
			break;
		}	
		if(k==0)
			break;
	}
	cout<<ans<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 4432
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def z(q):
    n = len(q)
    z = [0] * n
    if n == 0:
        return z
    z[0] = n
    ii = 1
    l = 0
    r = 0
    while ii < n:
        if r >= ii and z[ii-l] < r-ii+1:
            z[ii] = z[ii-1]
        else:
            l = ii
            if r < ii: r = ii
            while r < n and q[r-l] == q[r]:
                r += 1
            z[ii] = r-l
            r -= 1
        ii += 1
    return z

s = ns()
t = ns()
while len(s) <= len(t):
    s = s + s

zs = z(s)
zt = z(t)
zst = z(t+s+s)

pes = len(s)
for i in range(1, len(s)):
    if len(s) % i == 0 and zs[i] >= len(s)-i:
        pes = i
        break

pet = len(t)
for i in range(1, len(t)):
    if len(t) % i == 0 and zt[i] >= len(t)-i:
        pet = i
        break

# print(pes, pet)
if pes % pet == 0:
    for i in range(pet):
        if zst[len(t)+i] >= pes:
            print(-1)
            sys.exit(0)

lt = len(t)
m = s + s
while len(m) <= 4*len(t):
    m = m + m
while len(t) < len(m):
    t = t + t
# print(t, m, s)
zx = z(t+"$"+m)
# print(zx)
ans = max(zx[len(t)+1:])
print(ans//lt)



Measured memory_bytes: 251212
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll x,y,z,len;
  cin >> x >> y >> z;
  for(int i=1;;i++){
    len = y*i+z*(i+1);
    if(len>x){
      cout << i-1<<endl;
      break;
    }else if(len==x){
      cout << i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define ld 	 long double
#define F 	 first
#define S 	 second
#define P 	 pair<int,int>
#define pb 	 push_back
#define mod  1000000007
#define inf  1e18
#define endl '\n'
const int N = 1e4 + 5; //change it when needed
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
int cache[N][105][2];
string K;
int  D;
int dp(int pos, int d, int tight) {
	if (pos == K.size()) {
		return (d == 0);
	}
	int &ans = cache[pos][d][tight];
	if (ans != -1)
		return ans;
	int ub = ((tight == 1) ? K[pos] - '0' : 9);
	ans = 0;
	for (int i = 0; i <= ub; i++) {
		ans += dp(pos + 1, (d + i) % D, (tight & (i == ub)));
		ans %= mod;
	}

	return ans % mod;
}
void solve() {

	cin >> K >> D;
	memset(cache, -1, sizeof(cache));
	cout << (mod + dp(0, 0, 1) - 1) % mod;
	//last -1 is because of 00000000 case
	// I am adding it to my answer
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    string a, b, c;
    cin >> a >> b >> c;
    ll ans = 0;
    rep(i,N){
        set<char> st;
        st.emplace(a[i]), st.emplace(b[i]), st.emplace(c[i]);
        ans += st.size() - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000]={0};
int main(void){
   int n;
   cin>>n;
   int c=1;
  while(a[n]==0){
        a[n]=1;
        n=(n%2 ? 3*n+1 : n/2); 
        c++;
        if(a[n]!=0){
                cout<<c;
                break;
        }
    }
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto X = readln.chomp.to!int;
    auto DP = new int[][](6, 10^^5+1);
    int solve(int i, int x) {
        if (i == 6) return x == 0 ? 1 : -1;
        if (DP[i][x] != 0) return DP[i][x];
        int r = solve(i+1, x);
        if (x >= 100 + i) r = max(r, solve(i, x - (100+i)));
        DP[i][x] = r;
        return DP[i][x];
    }

    writeln(solve(0, X) == 1 ? 1 : 0);
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
int main () {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    long long ans = 100000000000;
    for(int i =0;  i < 100001; i ++){
        int a = max(0,X-i);
        int b = max(0,Y-i);

        ans = min(ans,(long long ) C*2*i+A*a+B*b );
    }

    cout << ans << endl;

}


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

int main(void){
    // Your code here!
    string S;cin>>S;
    for(int i=S.size()-2;i>0;i-=2){
        if(S.substr(0,i/2)==S.substr(i/2,i/2)){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  lint i,sz;string s;cin>>s;
  //caricurate
  sz=s.size();
  if(sz==2){if(s.at(0) ==s.at(1)){cout<<1<<" "<<2<<endl;return 0;}}
  for(i=0;i<sz-2;i++){
    if((s.at(i) ==s.at(i+1))||(s.at(i) ==s.at(i+2))){
      cout<<i+1<<" "<<i+3<<endl;return 0;
    }
  }
  //output
  cout<<-1<<" "<<-1<<endl;return 0;
}

Measured memory_bytes: 512
n,m = map(int,input().split())
war = [list(map(int,input().split())) for i in range(m)]
war.sort(key=lambda x: x[1])
broken = 0
ans = 0
for i in range(m):
   if war[i][0] > broken:
       ans += 1
       broken = war[i][1]-1
print(ans)



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

int main() {

	int N;
	cin >> N;

	vector<string> s(N);
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

	sort(s.begin(), s.end());

	long long ans = 0;
	int count = 0;
	for (int i = 1; i < N; i++)
	{
		if (s[i] == s[i-1]) {
			count++;
			ans += count;
		}
		else {
			count = 0;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int N,M;
	cin>>N>>M;
	int A[N];
	rep(i,N) cin>>A[i];
	ll wa[N+1]={};
	map<ll,ll> mod;
	ll ans=0;
	mod[wa[0]]++;
	rep(i,N) wa[i+1]=wa[i]+A[i];
	for(int i=1; i<N+1; i++) mod[wa[i]%M]++;
	for(auto itr=mod.begin(); itr!=mod.end(); itr++){
		ans+=(itr->second)*(itr->second-1)/2;
	}
	cout<<ans<<endl;
}

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


int main()
{
	int n; cin >> n;
	double t, a; cin >> t >> a;
	int index = 0;
	double minval = 1e9;
	for (int i = 0; i < n; ++i)
	{
		double h; cin >> h;
		if (abs(a-t+h*.006) < minval)
		{
			minval = abs(a-t+h*.006);
			index = i+1;
		}
	}
	cout << index << endl;
}




Measured memory_bytes: 3696
while(True):
    try:
        a,b,c,d,e,f = map(float, input().split(" "))
        z = a*e - b*d
        if(z!=0):
            x = (c*e - b*f)/z
            y = (a*f - c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
    except:
        break

Measured memory_bytes: 7348
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    ll D, G;
    cin>>D>>G;
    ll p[D], c[D];
    for(ll i=0;i<D;++i){
        cin>>p[i]>>c[i];
    }
    ll ans = big;
    ll tmpans;
    ll tmpscore;
    for(ll bit=0;bit<(1<<D);++bit){
        tmpans = 0;
        tmpscore = 0;
        for(ll i=0;i<D;++i){
            if((bit&(1<<i))!=0){
                tmpans += p[i];
                tmpscore += p[i] * 100 * (i+1);
                tmpscore += c[i];
            }
        }
        if(tmpscore<G){
            for(ll j=D-1;j>=0;--j){
                if((bit&(1<<j))==0){
                    if(tmpscore + (p[j]-1) * 100 * (j+1) >= G){
                        if((G-tmpscore)%(100*(j+1))==0){
                            tmpans += (G-tmpscore)/(100*(j+1));
                            tmpscore = G;
                        }
                        else{
                            tmpans += (G-tmpscore)/(100*(j+1)) + 1;
                            tmpscore = G;
                        }
                    }
                    break;
                }
            }
        }
        //cout<<bit<<endl;
        //cout<<tmpans<<" "<<tmpscore<<endl;
        if((tmpans<ans)&(tmpscore>=G))ans = tmpans;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
//Name: Area of Polygon
//Level: 1
//Category: 幾何,やるだけ
//Note:

/*
 * 凸多角形の面積は，適当な点Oを取り，隣接する頂点の組(P,Q)すべてに対して外積 OP×OQ を足し合わせることで計算できる．
 */
#include <cstdio>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

typedef complex<double> Vector;

double cross(const Vector &v1, const Vector &v2) {
    return v1.real()*v2.imag() - v1.imag()*v2.real();
}

int main() {
    vector<Vector> v;
    double X, Y;
    while(scanf("%lf,%lf", &X, &Y) != -1) {
        v.push_back(Vector(X, Y));
    }
    const int N = v.size();
    double area = 0;
    for(int i = 0; i < N; ++i) {
        const int next = (i+1) % N;
        area += cross(v[i], v[next]);
    }
    printf("%f\n", fabs(area)/2);
    return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;
const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>

void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

signed main(){
	int n=read();
	vi dp(n,0),sum(n,0);
	dp[0]=n;sum[0]=n;
	FOR(i,1,n){
		if(i==1)
			dp[i]=n*n;
		else{
			add(dp[i],(n-1)*(n-1));
			if(i-3>=0)add(dp[i],sum[i-3]);
			add(dp[i],n-(i-1));
			add(dp[i],dp[i-1]);
		}
		sum[i]=(sum[i-1]+dp[i])%mod;
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int n;
    int a[3];
    int count = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[2];
        if (i >= 2) {
            if (a[0] < a[1] && a[1] < a[2]) {
                count++;
            } else if (a[0] > a[1] && a[1] > a[2]) {
                count++;
            }
        }
        a[0] = a[1];
        a[1] = a[2];
    }

    cout << count << endl;
    return 0;
}

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

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 998244353  
#define M 998244353  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  

long long qpow(long long a, long long n) {
    long long ret = 1;
    a = (a % M + M) % M;
    for (; n; n >>= 1) {
        if (n & 1) ret = (ret * a) % M;
        a = (a * a) % M;
    }
    return ret;
}

int n;
vector<string> vs, l, r;
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        vs.push_back(s);
    }
    priority_queue<pii> va, vb;
    ll nsum = 0;
    for (auto &s : vs) {
        pii a(0,0);
        for (int i = 0; i < s.size(); ++i) {
            a.fi += s[i] == '(' ? 1:-1;
            a.se = min(a.se, a.fi);
        }
        if (a.se >= 0) nsum += a.fi; 
        else if (a.fi >= 0)
            va.push(a);
        else vb.push((pii){a.fi-a.se, -a.se});
    }
    while (!va.empty()) {
        pii p = va.top(); va.pop();
        if (nsum + p.se <= 0) {
            cout << "No" << endl; return 0;
        }
        nsum += p.fi;
    }

    while (!vb.empty()) {
        pii p = vb.top(); vb.pop();
        if (nsum - p.se < 0) {cout << "No" << endl; return 0;}
        nsum += p.fi - p.se;
    }
    if (nsum == 0)
        cout << "Yes"  << endl;
    else 
        cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 42632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 int n,m,res=0; cin>>n>>m;
 map<int,int> mp;
 REP(i,m)mp[i]=0;
 REP(i,n){
     int k; cin>>k;
     REP(j,k){
         int a; cin>>a;
         mp[a-1]++;
     }
 }

 REP(i,m)if(mp[i]==n)res++;
 cout<<res<<endl;
}

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


int main(void)
{
    int hour,minute,hand_hour,hand_minute;
    double angle=0;
    cin>>hand_hour>>hand_minute>>hour>>minute;
    minute=minute+60*hour;
    angle=minute*11.0*atan(1.0)/90.0;
    printf("%.10f\n",sqrt(hand_hour*hand_hour+hand_minute*hand_minute-2.0*hand_hour*hand_minute*cos(angle)));

    return 0;
}


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

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
	ll ret;
	
	cin >> n;
	
	if ( n % 1000 != 0 ) {
		cout << 1000 - ( n % 1000 ) << endl;
	}
	else {
		cout << 0 << endl;
	}
	

	return 0;
}

Measured memory_bytes: 3624