akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};


ll r[maxn],g[maxn],l[maxn];
bool cmp(int a,int b){
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    r[0]=g[0]=l[0]=inf;
    for(int i=1;i<=a;i++)cin>>r[i];
    for(int i=1;i<=b;i++)cin>>g[i];
    for(int i=1;i<=c;i++)cin>>l[i];
    sort(r+1,r+1+a,cmp);
    sort(g+1,g+1+b,cmp);
    sort(l+1,l+1+c,cmp);
    ll ans=0;
    for(int i=1;i<=x;i++)ans+=r[i];
    for(int i=1;i<=y;i++)ans+=g[i];
    for(int i=1;i<=c;i++){
        if(l[i]<=r[x]&&l[i]<=g[y])continue;
        if(l[i]>r[x]&&l[i]>g[y]){
            if(r[x]>g[y])ans+=l[i]-g[y],y--;
            else ans+=l[i]-r[x],x--;
        }
        else if(l[i]>r[x]){
            ans+=l[i]-r[x],x--;
        }
        else if(l[i]>g[y])
            ans+=l[i]-g[y],y--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

double cross(Point a, Point b)
{
	return a.real()*b.imag() - a.imag()*b.real();
}

int main()
{
	Point o, a, b;
	scanf("%lf,%lf", &o.real(), &o.imag());
	scanf("%lf,%lf", &b.real(), &b.imag());
	
	double area = 0.0;
	while(scanf("%lf,%lf", &a.real(), &a.imag()) != EOF){
		area += fabs(cross(a-o, b-o)) / 2.0;
		b = a;
	}
	printf("%f\n", area);

	return 0;
}

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

using namespace std;

vector<string> cities(110);
vector<int> probabilities(110);

bool cmp(int a,int b){
    if(cities[a] < cities[b]) 
        return true;
    if(cities[a] > cities[b]) 
        return false;
    if(probabilities[a] > probabilities[b]) 
        return true;
    return false;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        int p; cin >> p;
        cities[i] = s;
        probabilities[i] = p; 
        a[i] = i;
    } 
    sort(a.begin(), a.end(), cmp);
    for(int i : a) cout << i + 1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T>
inline void read(T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return ;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1:1;
    ret = (c == '-') ? 0:(c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return ;
}
inline void outi(int x) {if (x > 9) outi(x / 10);putchar(x % 10 + '0');}
inline void outl(ll x) {if (x > 9) outl(x / 10);putchar(x % 10 + '0');}
const int maxn = 2e5 + 10;
typedef long long ll;
ll x,k,d;
int main()
{
    read(x);
    read(k);
    read(d);
    x=abs(x);
    ll a=x%d;
    ll b=x/d;
    if(k<=b)
        x-=k*d;
    else
    {
        if((k-b)%2==1)
            x=d-a;
        else
        x=a;
    }
    cout<<x<<endl;
}









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

char f,g;
bool flag;
string s;
vector < int > v,va,vb;
int arr[sz],brr[sz],crr[sz];



int main(){

    priority_queue< long long int > pq;
    long long int n,m, i,j,k, x,y,z;
    cin>>s>>k;
    for(i=0; i<s.size(); i++){
        if(i+1==k || s[i]!='1'){
            cout<<s[i]<<endl;
            break;}
    }


    return 0;

}

Measured memory_bytes: 3600
import sys
import io

# 関数 solve は，もちろん，問題に応じて書き換える

def solve(N): 
    hantei = 0
    for i in range(26):
        for j in range(20): 
            if 4*i + 7*j == N : 
                hantei = 1
    if hantei == 1:            
        return('Yes')
    else: 
        return('No')
    
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
      System.out.println(A * B);
    } else {
      System.out.println(-1);
    }
  }
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=-1;
  for(int i=1; i <=1000; i++){
    if(i*8/100==a&&i*10/100==b) {
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll I, O, T, J, L, S, Z;
  std::cin >> I >> O >> T >> J >> L >> S >> Z;
  ll length = O + (L/2)*2 + (J/2)*2 + (I/2)*2;
  if(L%2==1&&J%2==1&&I%2==1) length += 3;
  if(L>=1&&J>=1&&I>=1&&(L%2==0?1:0)+(J%2==0?1:0)+(I%2==0?1:0)==1) length += 1;
  std::cout << length << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  string n;
  cin >> n;
  if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    S = []
    for _ in range(N):
        S.append(ST())
    cnt = Counter(S)
    print('AC x', cnt['AC'])
    print('WA x', cnt['WA'])
    print('TLE x', cnt['TLE'])
    print('RE x', cnt['RE'])

if __name__ == '__main__':
    main()

Measured memory_bytes: 84808
#include <iostream>
#include <cmath>
#include <string.h>
#include <string>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
int a,s,d,f;
int z;
int num;
int x;
int c;
int e;
cin>>a>>s>>d>>f;
z=a-d;
x=s-f;
e=x*z;
cout<<e;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

val sc = Scanner(System.`in`)

fun main(args : Array<String>) {
    val n = sc.nextInt()
    val dd = listOfInt(n)

    var sum = 0
    for (i in 0 until n-1) {
        for (j in i+1 until n) {
            sum += dd[i] * dd[j]
        }
    }

    println(sum)
}

fun listOfInt(n: Int) = (1..n).map { sc.nextInt() }.toList()

Measured memory_bytes: 31768
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

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

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

// M: 初項, N: 項数
ll calc(ll M, ll N)
{
    return N * (2 * M + N - 1) / 2;
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int mod = 1000000007;

vector<int> v[200000];
ll c[200000]={};

void dfs(int i, ll cv = 0, int parent = -1){
    cv += c[i];
    c[i] = cv;
    for(int j: v[i]){
        if(j==parent) continue;
        dfs(j,cv,i);
    }
}

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

    int N,Q; cin >> N >> Q;
    REP(i, N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    REP(i,Q){
        int p,x; cin >> p >> x;
        c[p-1] += x;
    }

    dfs(0);

    REP(i,N){
        cout << c[i] << ' ';
    }

    cout << endl;

    return 0;
}


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

int main(){
  long long N;
  long long a = 0;
  long long b = 0;
  long long c = 0;
  long long d = 0;
  cin >> N;
  vector<string> A(N+1);

  rep(i,N){
    cin >> A.at(i);
  }

  rep(i,N){
    if(A.at(i) == "AC"){
      a++;
    }
    if(A.at(i) == "WA"){
      b++;
    }
    if(A.at(i) == "TLE"){
      c++;
    }
    if(A.at(i) == "RE"){
      d++;
    }
  }

  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;

}



  

Measured memory_bytes: 6420
#include "bits/stdc++.h"
using namespace std;

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

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct S{
  vector<int> v;
  int t;
  S() {}
  S(vector<int>& v, int t) : v(v), t(t) {}
};

int main(){
  int N;
  while(cin>>N && N){
    vector<int> A(N);
    vector<int> goal(N);
    REP(i, N) goal[i] = i;
    REP(i, N) {
      cin>>A[i];
      A[i]--;
    }
    queue<S> que;
    que.push(S(A, 0));
    map< vector<int>, int > dist;
    while(!que.empty()){
      S s = que.front(); que.pop();
      if(s.t == 4) break;
      if(dist[s.v] != s.t) continue;
      REP(i, N)FOR(j, i + 1, N){
        vector<int> B = s.v;
        reverse(B.begin() + i, B.begin() + j + 1);
        if(dist.count(B)) continue;
        dist[B] = s.t + 1;
        que.push(S(B, s.t + 1));
      }
    }
    int ans = N - 1;
    que = queue<S>();
    que.push(S(goal, 0));
    set< vector<int> > used;
    while(!que.empty()){
      S s = que.front(); que.pop();
      if(s.t == 4) break;
      if(dist.count(s.v)){
        ans = min(ans, s.t + dist[s.v]);
      }
      REP(i, N)FOR(j, i + 1, N){
        vector<int> B = s.v;
        reverse(B.begin() + i, B.begin() + j + 1);
        if(used.count(B)) continue;
        used.insert(B);
        que.push(S(B, s.t + 1));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 79144
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    string s;
    cin >> s;
    int odd=0,even=0;//white
    for(int i=0; i<s.length(); i++){
        if(i%2==0 && s[i]=='1')even++;
        else if(s[i]=='1')odd++;
    }
    int n=s.length();
    cout << min(even+n/2-odd,(n+1)/2-even+odd) << endl;
    return 0;
}

Measured memory_bytes: 512
n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=-10**18
for l in range(min(n,k)+1):
  for r in range(min(n,k)+1):
    if l+r>n or l+r>k:
      continue
    trg=v[:l]+v[n-r:]
    trg.sort(reverse=True)
    for i in range(k-l-r+1):
      ans=max(ans,sum(trg[:len(trg)-i]))
print(ans)

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

int main()
{
  int h,m,s, Sec;

  cin >> Sec;   // 秒数

  s= Sec % 60;  // 秒
  Sec /= 60;    // 分単位に・・・
  m= Sec % 60;  // 分
  h = Sec / 60; // 時

  cout << h << ":"<< m << ":" << s << endl;

  return 0;
}



Measured memory_bytes: 3096
n,k=map(int,input().split())
#a%kを決めればb%kとc%kが決まる
cnt=0
ans=0

for a_mod in range(k):
  if a_mod==0:
    b_mod,c_mod=0,0
  else:
    b_mod=k-a_mod
    c_mod=k-b_mod
    if c_mod!=k-a_mod:
      continue

  cnt_a=0
  for a in range(a_mod,n+1,k):
    if a!=0:
      cnt_a+=1
  ans+=cnt_a**3
print(ans)

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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    string s;
    cin>>s;
    cout<<s.substr(0, 4)<<" "<<s.substr(4)<<endl;
    return 0;
}

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

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int ans;
    rep(i, X) {
        if (X < i * Y + (i + 1) * Z) { // 超えたら、一つ前の値を答えとする
            ans = i - 1;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define tr(x,i) for(vi::iterator i = x.begin() ; i != x.end() ; i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define T ll t;cin>>t;while(t--)
ll powmod(ll a,ll b){ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
signed main() 
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n;
	
	
	cin>>n;
	ll a[200005],arr[n];
	memset(a,0,sizeof(a));
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		a[arr[i]]++;
	}
	ll ans=0;
	for(ll i=0;i<200004;i++)
	{
		ans+= a[i] * (a[i] - 1 )/2;
	}
	for(ll i=0;i<n;i++)
	{
		cout<<ans - (a[arr[i]] - 1)<<endl;
	}

}


Measured memory_bytes: 5760
mod = 998244353
n = gets.to_i
ds = gets.split.map(&:to_i)

if ds[0] != 0
  puts 0
  exit
end

h = Hash.new(0)
mx = -1
ds.map do |d|
  h[d] += 1
  mx = d if d > mx
end

ans = 0
0.upto(mx).each do |i|
  if i == 0
    if h[0] != 1
      puts 0
      exit
    end
  elsif i == 1
    ans = 1
  else
    ans *= (h[i - 1] ** h[i])
    ans %= mod
  end
end
p ans


Measured memory_bytes: 15372
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main(){
	ll n, m;
	cin >> n >> m;
	vector<pair<ll,ll>> d(n);
	rep(i,n) cin >> d[i].fi >> d[i].se;

	stable_sort(all(d));

	ll num = 0;	// すでに何個買ったか
	ll ans = 0;
	rep(i,n){
		if(num + d[i].se > m){
			ans += d[i].fi * (m - num);
			break;
		}
		else{
			ans += d[i].fi * d[i].se;
			num += d[i].se;
		}
		// debug
		// cout << i << " " << num << " " << ans << endl;
	}

	cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010
typedef long int li;
typedef struct{
  int a;
  int b;
}data;
data array[MAX];
int comp(const void*a,const void*b){
  data x=*((data*)a),y=*((data*)b);
  return x.a-y.a;
}

int main(){
  if(df)printf("*** debug mode ***\n");
  long int n,k,i;
  scanf("%ld%ld",&n,&k);
  for(i=0;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    array[i].a=a;
    array[i].b=b;
  }
  qsort(array,n,sizeof(data),comp);
  i=0;
  while(k>0){
    k-=array[i].b;
    i++;
  }
  
  printf("%d",array[i-1].a);
  return 0;
}


/// confirm df==0 ///


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

int main() {
    ll n;
    cin >> n;
    ll arr[n][3];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<3;j++){
            cin >> arr[i][j];
        }
    }
    ll dp[n][3];
    for(ll i=0;i<3;i++)
        dp[0][i] = arr[0][i];
    
    for(ll i=1;i<n;i++){
        dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    
    ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout << ans;
    
	return 0;
}

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

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

    if (n >= 10)
    {
        cout << r << endl;
    }
    else
    {
        int ans = r + 100 * (10 - n);
        cout << ans << endl;
    }
}


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


int solve(string &s) {
    string left = "qwerasdfzxcvtgb";
    int ret = 0;
    int hand = -1;
    for (size_t i = 0; i < s.length(); i++) {
        for (size_t j = 0; j < left.size(); j++) {
            if (left[j] == s[i]) {
                if (hand) {
                    ret++;
                    hand = 0;
                }
                break;
            }
            if (j+1 == left.size()) {
                if (hand != 1) {
                    hand = 1;
                    ret++;
                }
            }
        }
    }
    return ret-1;
}

int main(void){
    string s;
    vector<int> ans;
    while (1) {
        cin >> s;
        if (s == "#") break;
        ans.push_back(solve(s));
    }
    for (auto &i: ans) {
        cout << i << endl;
    }
}



Measured memory_bytes: 3192
#include<cstdio>
using namespace std;

int main(){
  long long n, m[5] = {0,0,0,0,0};
  long long ans = 0;
  char s[20];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%s",s);
    if(s[0] == 'M') m[0]++;
    else if(s[0] == 'A') m[1]++;
    else if(s[0] == 'R') m[2]++;
    else if(s[0] == 'C') m[3]++;
    else if(s[0] == 'H') m[4]++;
  }
  for(int j = 0; j < 3; j++)
    for(int k = j+1; k < 4; k++)
      for(int l = k+1; l < 5; l++)
        ans += m[j]*m[k]*m[l];
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int count=0;
    for (int i=1;i<=n;i++) {
      String ans=String.valueOf(i);
      if (ans.length()%2!=0) {
        count++;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 27732
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(){
    double result;
    int R;

    cin >> R;

    result = M_PI * 2 * R;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3240
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	string s, s2;
	cin >> s >> s2;
	reverse(s2.begin(), s2.end());
	if (s == s2)
		cout << "YES";
	else
		cout << "NO";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<map>


using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define y1 Emilia
#define forit(s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n, A, B;

int del(int A, int ind){
    int res = 0;
    for(int i = 0; i < ind; ++i){
        int ok = (int)(A & (1 << i));
        if(ok)
            res += (1 << i);
    }
    for(int i = ind + 1; i < 17; ++i){
        int ok = (int)(A & (1 << i));
        if(ok)
            res += (1 << (i - 1));
    }
    return res;
}
vector<int> solve(int n, int A, int B){
    vector<int> res;
    if(n == 1){
        res.push_back(A);
        res.push_back(B);
        return res;
    }
    int ind = -1;
    for(int i = 0; i < 17; ++i){
        int a = (int)((A & (1 << i)));
        int b = (int)((B & (1 << i)));
        if(a != b){
            ind = i;
            break;
        }
    }
    
    int A1 = del(A, ind);
    int B1 = del(B, ind);
    
    int C = A1 ^ 1;
    vector<int> v1 = solve(n - 1, A1, C);
    vector<int> v2 = solve(n - 1, C, B1);
    for(int i = 0; i < (int)v1.size(); ++i){
        int x = v1[i];
        v1[i] = 0;
        for(int j = 0; j < ind; ++j){
            int ok = (int)((x & (1 << j)));
            if(ok)
                v1[i] += (1 << j);
        }
        v1[i] += ( (A & (1 << ind)) );
        for(int j = ind; j < 17; ++j){
            int ok = (int)((x & (1 << j)));
            if(ok)
                v1[i] += (1 << (j + 1));
        }
    }
    for(int i = 0; i < (int)v2.size(); ++i){
        int x = v2[i];
        v2[i] = 0;
        for(int j = 0; j < ind; ++j){
            int ok = (int)((x & (1 << j)));
            if(ok)
                v2[i] += (1 << j);
        }
        
        v2[i] += ( (B & (1 << ind)) );
        for(int j = ind; j < 17; ++j){
            int ok = (int)((x & (1 << j)));
            if(ok)
                v2[i] += (1 << (j + 1));
        }
    }
    for(int i = 0; i < (int)v1.size(); ++i) res.push_back(v1[i]);
    for(int i = 0; i < (int)v2.size(); ++i) res.push_back(v2[i]);
    return res;
}
int main(){
    dracarys
    cin >> n >> A >> B;
    if((__builtin_popcount(A) - __builtin_popcount(B)) % 2 == 0){
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    vector<int> v = solve(n, A, B);
    for(int i = 0; i < (int)v.size(); ++i)
        cout << v[i] << " ";
    return 0;
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	bool E=0,W=0,N=0,S=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	switch(s[i]){
		case 'E':E=1;break;
		case 'W':W=1;break;
		case 'S':S=1;break;
		case 'N':N=1;break;
	}
	if(E==W&&S==N)cout<<"Yes";
	else cout<<"No";
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;
#define VI vector<int>

#define rep(i,a) for(int i=0;i<(a);i++)
#define all(i) i.begin(),i.end()
#define INF 1000000000


using namespace std;


/**/
VI y;
pair<int,int> x[31];


int main(){
	int w,n;
	rep(i,31){
		y.push_back(i);
	}
	cin>>w>>n;
	rep(i,n){
		char c;
		cin>>x[i].first>>c>>x[i].second;
		x[i].first--,x[i].second--;
	}
	rep(i,n){
		swap(y[ x[i].first ],y[ x[i].second ]);
	}
	rep(i,w){
		cout<<y[i]+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int top=0;
int S[100];

int main(){
  int a,b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop() + pop());
    } else if ( s[0] == '-' ){
      a = pop();
      push(pop() - a);
    } else if ( s[0] == '*' ){
      push(pop() * pop());
    } else {
      b = atoi(s);
      push(b);
    }
  }
  
    printf("%d\n",S[top]);

  return 0;
}
int initialize(void){
  top = 0;
}
int isEmpty(void){
  return top == 0;
}
int isFull(void){
  return top >= 100;
}
void push(int x){
  if(isFull()){
    printf("Overflow\n");
  }
  top++;
  S[top] = x;
}
int pop(void){
  if(isEmpty()){
    printf("Underflow\n");
  }
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
<?php
$lengthA = (int) fgets(STDIN);
$stdinA = explode(" ",fgets(STDIN));
$lengthKey = (int) fgets(STDIN);
$stdinKey = explode(" ",fgets(STDIN));

$count = 0;
for($j=0; $j<$lengthKey; ++$j){
    $result = BinarySearch($lengthA, $stdinA, $stdinKey[$j]);
    if($result == 1){
        $count++;
    }
}
echo $count.PHP_EOL;

function BinarySearch($N, $A, $key){
    $left = 0;
    $right = $N;
    while ($left < $right){
        //探索の範囲内の中央の要素を調べる
        $mid = ($left + $right) / 2;
        //目的のキーと中央の要素のキーが一致すれば探索を終了
        if ((int)$A[$mid] == (int)$key){
            return 1;
        }
        //前半部分を探索範囲とする
        if ((int)$key < (int)$A[$mid]){
            $right = $mid;
        }
        //後半部分を探索範囲とする
        else{
            $left = $mid + 1;
        }
    }
    return 0;
}


Measured memory_bytes: 35888
#include<bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define endl "\n"
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
 
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pp;
typedef pair<ll,pair<ll,ll> > ppp;
 
const ll N    = 5e5+5;
const ll INF  = 1e9;
const ll mod  = 1e9+7;

ll a[N];

void solve()
{
    ll n,d;
    string s;

    cin>>n>>d;
    if(n<d){
        cout<<1<<endl;
        exit(0);
    }
    int cnt = ceil(1.0*n/(2*d+1));
    cout<<cnt<<endl;


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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;



int main() {
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<ll, vector<ll>, greater<ll>> que1;
    priority_queue<ll, vector<ll>, greater<ll>> que2;
    for(ll i=0,d;i<a;i++){
        cin>>d;
        if(que1.size()==x){
            que1.push(d);
            que1.pop();
        }
        else{
            que1.push(d);
        }
    }
    for(ll i=0,d;i<b;i++){
        cin>>d;
        if(que2.size()==y){
            que2.push(d);
            que2.pop();
        }
        else{
            que2.push(d);
        }
    }

    vector<ll>r(c);
    for(ll i=0;i<c;i++){
        cin>>r.at(i);
    }

    for(ll i=0;i<c;i++){
        if(que1.top()<=que2.top() && que1.top()<r.at(i)){
            que1.pop();
            que1.push(r.at(i));
        }
        else if(que1.top()>que2.top() && que2.top()<r.at(i)){
            que2.pop();
            que2.push(r.at(i));
        }
    }
    ll ans=0;
    while(que1.size()>x){
        que1.pop();
    }
    while(que2.size()>y){
        que2.pop();
    }
    while(!que1.empty()){
        ans+=que1.top();
        que1.pop();
    }
    while(!que2.empty()){
        ans+=que2.top();
        que2.pop();
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 2548
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a = (n/100)%10;
  int b = (n/10)%10;
  int c = n%10;
  int answer;
  if(a > b){
    answer = a*111;
    cout << answer << endl;
    }
  if(a < b){
    answer = (a + 1)*111; 
    cout << answer << endl;
  }
  if(a == b){
    if(b >= c){
       answer = a*111;
    cout << answer << endl;
    }
    else{
       answer = (a + 1)*111;
      cout << answer << endl;
    }
  }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc001/tasks/agc001_a

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int main() {
    int n, t;
    vector<int> v;

    cin >> n;
    for (int i = 0; i < 2 * n; i++) {
        cin >> t;
        v.push_back(t);
    }
    // 小さい順にソートする
    sort(v.begin(), v.end());
    int sum = 0;
    // ペアの小さい方を合計に加算する
    for (int i = 0; i < 2 * n; i += 2) {
        sum += v[i];
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	vector<int> dis(n);
	rep(i, n) cin >> a.at(i);
	
	dis.at(0) = a.at(0) + (k-a.at(n-1));
	
	int total = dis.at(0);
	int longest_dis = dis.at(0);
	for(int i = 1; i < n; i++){
		dis.at(i) = a.at(i) - a.at(i-1);
		total += dis.at(i);
		longest_dis = (longest_dis < dis.at(i))?dis.at(i):longest_dis;
	}
	cout << total - longest_dis << endl;
	
}

Measured memory_bytes: 4852
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///======code start here======///

signed main() {
	fastio;
	int n, k; cin >> n >> k;
	ll h[n + 1]; h[0] = 12345678901234567;
	rep(i, 1, n + 1) cin >> h[i];
	ll dp[n + 1]; dp[0] = 0; dp[1] = 0;
	rep(i, 2, n + 1) dp[i] = 12345678901234567;
	rep(i, 2, n + 1) {
		rep(j, 1, k + 1) {
			dp[i] = min(dp[max(i - j, 0)] + abs(h[max(i - j, 0)] - h[i]), dp[i]);
		}
		
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e18+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

ll a,b,c;

double f(double t){
  return a*t + b*sin(c*t*acos((long double)(-1)));
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n;cin>>n;
  vector<ll> A(n+2);
  A[0] = -LINF;
  reps(i,n){
    cin>>A[i];
  }
  A[n+1] = -LINF;
  ll ans = 0;
  vector<ll> left(n+2), right(n+2);
  vector<Pll> stack;
  rep(i,n+2){
    while(stack.size() != 0 && stack.back().first > A[i]){
      right[stack.back().second] = i;
      stack.pop_back();
    }
    stack.push_back({A[i], i});
  }

  stack.clear();
  REP(i,n+2){
    while(stack.size() != 0 && stack.back().first > A[i]){
      left[stack.back().second] = i;
      stack.pop_back();
    }
    stack.push_back({A[i], i});
  }

  reps(i,n){
    ans += (right[i] - i) * (i - left[i]) * A[i];
    //cout<<i<<" "<<num<<" "<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    if(n > m)cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include <algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define forz(i,a,b) for(int i=(a);i<=(b);i++)
#define forf(i,a,b) for(int i=(a);i>=(b);i--)
#define mems(x,v) memset(x,v,sizeof(x))
using namespace std;
int n,i,j,q,f,x,y,m;
struct dyy
{
    int f;
    int v;
}a[10];
int main()
{
scanf("%d%d",&n,&m);
for(i=1;i<=3;i++)a[i].f=0;
f=1;
for(i=1;i<=m;i++)
{
    scanf("%d%d",&x,&y);
    if(a[x].f==1&&a[x].v!=y){f=0;}
    else
    {
        a[x].f=1;
        a[x].v=y;
    }
}
if(a[1].f==1&&a[1].v==0&&n>1)f=0;
for(i=1;i<=n;i++)
    if(a[i].f==0)a[i].v=0;
if(a[1].f==0)a[1].v=1;
if(n==1&&m==0)a[1].v=0;
if(f==0)printf("-1");
else
{
    for(i=1;i<=n;i++)
    printf("%d",a[i].v);
}
return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010
#define MAX_K 1010

// 二次元累積和
// コンストラクト時に幅と高さを与える必要がある
template< class T >
class CumulativeSum2D
{
public:
    vector< vector< T > > m_data;

    CumulativeSum2D(int W, int H) : m_data(W + 1, vector< int >(H + 1, 0)) {}

    // 要素 (x,y) に値 z を加える O(1)
    void Add(int x, int y, int z) {
        ++x, ++y;
        if(x >= m_data.size() || y >= m_data[0].size()) { return; }
        m_data[x][y] += z;
    }

    // 累積和の構築 O(WH)
    void Build() {
        for(int i = 1; i < m_data.size(); i++) {
            for(int j = 1; j < m_data[i].size(); j++) {
                m_data[i][j] += m_data[i][j - 1] + m_data[i - 1][j] - m_data[i - 1][j - 1];
            }
        }
    }

    // 左上 [sx, sy], 右下(gx, gy) の矩形内の和を求める O(1)
    // 右下は含まないので注意
    T Query(int sx, int sy, int gx, int gy) {
        return (m_data[gx][gy] - m_data[sx][gy] - m_data[gx][sy] + m_data[sx][sy]);
    }
};

int N, K;

int main()
{
    cin >> N >> K;
    CumulativeSum2D<int> cs_b(2 * K, 2 * K);   // 黒用
    CumulativeSum2D<int> cs_w(2 * K, 2 * K);   // 白用
    REP(i, N) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W') { cs_w.Add((int)(x % (2 * K)), (int)(y % (2 * K)), 1); }
        else { cs_b.Add((int)(x % (2 * K)), (int)(y % (2 * K)), 1); }
    }
    cs_w.Build();
    cs_b.Build();
    // DEBUG
    /*
    printf("-- white --\n");
    REP(y, K) {
        REP(x, K) {
            DBG("%d ", cs_w.Query(x, y, x+1, y+1));
        }
        DBG("\n")
    }
    printf("-- black --\n");
    REP(y, K) {
        REP(x, K) {
            DBG("%d ", cs_b.Query(x, y, x+1, y+1));
        }
        DBG("\n")
    }
    */
    int ans = 0;
    REP(y, K) {
        REP(x, K) {
            int white1 = cs_w.Query(0, 0, x+1, y+1) + cs_w.Query(x+1+K, 0, 2*K, y+1)
                         + cs_w.Query(x+1, y+1, x+1+K, y+1+K) + cs_w.Query(0, y+1+K, x+1, 2*K)
                         + cs_w.Query(x+1+K, y+1+K, 2*K, 2*K);
            int black2 = cs_b.Query(0, 0, x+1, y+1) + cs_b.Query(x+1+K, 0, 2*K, y+1)
                         + cs_b.Query(x+1, y+1, x+1+K, y+1+K) + cs_b.Query(0, y+1+K, x+1, 2*K)
                         + cs_b.Query(x+1+K, y+1+K, 2*K, 2*K);
            int white2 = cs_w.Query(x+1, 0, x+1+K, y+1) + cs_w.Query(0, y+1, x+1, y+1+K)
                         + cs_w.Query(x+1+K, y+1, 2*K, y+1+K) + cs_w.Query(x+1, y+1+K, x+1+K, 2*K);
            int black1=  cs_b.Query(x+1, 0, x+1+K, y+1) + cs_b.Query(0, y+1, x+1, y+1+K)
                         + cs_b.Query(x+1+K, y+1, 2*K, y+1+K) + cs_b.Query(x+1, y+1+K, x+1+K, 2*K);

            ans = max( { ans, (white1 + black1), (white2 + black2) } );
        }
    }

    printf("%d\n", ans);
    return 0;
}


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

int main() {
    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    for(int i=0; i<N; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int amax = a[N-1];
    int ans = 0;
    for(int i=N-1; i>=0; --i) {
        if(b[i] > amax) {
            H -= b[i];
            ++ans;
        }
        if(H <= 0) break;
    }
    if(H > 0) {
        ans += H / amax;
        if(H % amax) ++ans;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans;
  while(1){
    int a = n /100;
    int b = (n % 100) / 10;
    int c = n % 10;
    if (a == b && b == c) break;
    n++;
  }
  cout << n << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll h,w,n;
  std::cin>>h>>w>>n;

  if(h<w)std::swap(h,w);

  ll cnt=0;
  while(cnt*h<n)cnt++;

  std::cout<<cnt<<"\n";

  return 0;
}

Measured memory_bytes: 256
n = int(input())
abc = [tuple(int(x) for x in input().split()) for _ in range(n)]

dp = [abc[0][0], abc[0][1], abc[0][2]]

for i in range(1, n):
    a, b, c = abc[i]
    a += max(dp[1] , dp[2])
    b += max(dp[0] , dp[2])
    c += max(dp[0] , dp[1])
    dp = [a,b,c]

print(max(dp))


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

int main(){
    ll H, N;
    cin >> H >> N;
    ll sum = 0;
    for(int i = 0; i < N; i++){
        ll a;
        cin >> a;
        sum += a;
    }

    if(sum >= H){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 1e2 + 7;///

void solve(){
    int a , b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
}
int main(){
    TIME
    int tt = 1;
    //cin >> tt;
    while(tt --){
        solve();
    }
}
/**

**/


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

using namespace std;

int const N = 141;

int cnt[N], n, a[N], maxi;


void ok(){
	printf("Possible\n");
	exit(0);
}

void bad(){
	printf("Impossible\n");
	exit(0);	
}

void check(){
	for(int i=0;i<N;++i){
		if(cnt[i] < 0){
			bad();
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		int d;
		scanf("%d",&d);
		++cnt[d];
		maxi = max(maxi, d);
	}
	if(maxi == 1){
		if(n == 2){
			ok();
		}else{
			bad();
		}
	}
	cnt[maxi] -= 2;
	for(int i=1;i<=maxi-1;++i){
		--cnt[max(i, maxi-i)];
	}
	check();
	for(int i=0;i<N;++i){
		if(cnt[i] > 0){
			if(i >= ((maxi/2 + maxi%2) + 1) && i <= maxi){
				continue;
			}else{
				bad();
			}
		}
	}

	ok();


	return 0;
}

Measured memory_bytes: 256