akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define forx(v) for(int x=0; x<v; x++)
#define ll long long
#define lll __int128
#define MAX (int)(4*pow(10,5) + 100)
#define pb(a) push_back(a)
#define ch (int)(4*pow(10,4) + 100)
#define ld long double
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = pow(10,9)+7 ;
double eps = 1e-9;
ifstream in;
ofstream out;

ll arr[MAX];
ll pv[MAX];
ll invpv[MAX];


ll pow_mod(ll a, ll b){
	a = a%modulo;
	if(!a){
		return 0;
	}
	ll mx = 0;
	ll has = 1;
	for(ll i = 62; i>-1; i--){
		has*=has;
		has%=modulo;
		if(((ll)1<<i)&b)
			has*=a, has%=modulo;
	}
	return has;
}

 

void div_conq(ll& ans, ll l, ll r, string& a){
	if(l > r){
		return;
	}
//	cout<<"\n\n\n we at "<<l<<" "<<r<<"\n\n\n\n";
	ll mid = (l+r)/2;
	ll s=  0;
	ll mult = 1;
	for(ll i = mid; i>=l; i--){
		ll cur = a[i]-'0';
		cur *= mult;
		cur%=modulo;
		s+=cur;
		s%=modulo;
//		cout<<s<<" at "<<i<<endl;
		arr[s]++;
		
		mult*=10;
		mult%=modulo;
	}
	
	ans+=arr[0];
//	cout<<"we added "<<arr[0]<<endl;
	
	s = 0;
	for(ll i = mid+1; i<=r; i++){
		s*=10;
		s+=a[i]-'0';
		s%=modulo;
		ll lz = s;
		lz = modulo-lz;
		lz %= modulo;
		ll dist = i-mid;
		ll ten = invpv[dist];
		if(ten == 0){
			if(lz == 0){
				ans+=(mid-l+1);
			}
			continue;
		}
		lz*=ten;
		lz%=modulo;
		ans+=arr[lz];
//		cout<<"we at "<<i<<" we added "<<arr[s]<<" because we want "<<s<<endl;
		
	}
	
	s=  0;
	mult = 1;
	for(ll i = mid; i>=l; i--){
		ll cur = a[i]-'0';
		cur *= mult;
		cur%=modulo;
		s+=cur;
//		cout<<s<<" at "<<i<<endl;
		s%=modulo;
//		cout<<s<<" at "<<i<<endl;
		arr[s]--;
		
		mult*=10;
		mult%=modulo;
	}
	
	div_conq(ans, l, mid-1, a);
	div_conq(ans, mid+1, r, a);
}
 
void deal(){
	ll n, p;
	cin>>n>>p;
	modulo = p;
	string a;
	cin>>a;
	
	pv[0] = 1, invpv[0] = 1;
	for(ll i = 1; i<MAX; i++){
		pv[i] = pv[i-1] * 10;
		pv[i] %= modulo;
		invpv[i] = pow_mod(pv[i], modulo-2);
	}
	
	ll ans = 0;
	div_conq(ans, 0, n-1, a);
	cout<<ans;
}
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

Measured memory_bytes: 8724
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<int[]> mfrs = new ArrayList<>();

		while(true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();

			if(m == -1 && f == -1 && r == -1) break;

			int[] mfr = new int[] {m, f, r};
			mfrs.add(mfr);
		}
		sc.close();

		for (int[] mfr : mfrs) {
			char result;

			int m = mfr[0];
			int f = mfr[1];
			int r = mfr[2];

			if (m == -1 || f == -1) {
				result = 'F';
			} else if (m + f >= 80) {
				result = 'A';
			} else if (m + f >= 65) {
				result = 'B';
			} else if (m + f >= 50) {
				result = 'C';
			} else if (m + f >= 30) {
				result = 'D';
				if(r >= 50) result = 'C';
			} else {
				result = 'F';
			}
			System.out.println(result);
		}

	}
}

Measured memory_bytes: 26176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    string S;
    cin >> S;
    int size =S.size();
    vector<int> dp(size+1);
    for(int i=0;i<=size-1;i++){
        if(S[i]=='<'){
            dp[i+1]=dp[i]+1;
        }
    }
    for(int i=size-1;i>=0;i--){
        if(S[i]=='>'){
            dp[i]=max(dp[i],dp[i+1]+1);
        }
    }
    ll ans=0;
    for(int i=0;i<=size;i++){
        ans = ans + dp[i];
    }
    cout << ans << endl;
}

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

int main(){
  int n,m,i,j;
  cin >> n >> m;
  int a[100][100], b[100], c = 0;

  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(i = 0; i < m; i++){
    cin >> b[i];
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      c += a[i][j] * b[j];
    }
    cout << c << endl;
    c = 0;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, y;
    cin >> n >> y;
    rep(i, 0, n + 1) {
        rep(j, 0, n + 1) {
            if (i + j > n) continue;
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll l,r,a,b;
    cin>>l>>r;
    if(r-l+1>=2019){
        cout<<0;
    }else{
        ll min=2018;
        FOR(i,l,r){
            FOR(j,i+1,r+1){
                ll value=(i*j)%2019;
                if(min>value){
                    min=value;
                }
                if(min==0){
                    break;
                }
            }
            if(min==0){
                break;
            }
        }
        cout<<min;
    }
    return 0;
}


Measured memory_bytes: 256
import copy


def count_num_flip(S):
    num_flip = 0
    S_prev = S[0]
    for S_next in S[1:]:
        if S_prev == S_next:
            num_flip += 1
            S_prev = not S_next
        else:
            S_prev = S_next
    return num_flip


if __name__ == '__main__':
    S = [bool(int(x)) for x in input()]
    S_prime = copy.copy(S)
    S_prime[0] = not S_prime[0]
    print(min(count_num_flip(S), count_num_flip(S_prime) + 1))


Measured memory_bytes: 5912
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N,K = map(int,input().split())
    treats = [0] * N
    for i in range(K):
        d = int(input())
        A = list(map(int,input().split()))
        for j in range(d):
            treats[A[j]-1] +=1
    def isZero(i):
        return i == 0
    print(len(list(filter(isZero,treats))))
    # Failed to predict input format
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 67744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vi2 vector<vector<int>>
#define vl vector<long long>
#define vl2 vector<vector<long long>>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int n, tmp = INT_MAX, ans = 0;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    rep(i, n){
        if(p[i] < tmp) ans++;
        tmp = min(tmp, p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

    if(a <= 8 && b <= 8){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<ll> a_accum(N+1, 0);
    for (int i = 0; i < N; i++) {
        a_accum[i+1] = (a_accum[i] + a[i]);
    }
    map<ll, ll> m;
    for (auto s : a_accum) {
        m[s]++;
    }
    m[0LL] --;
    ll ans = m[0LL];
    for (auto t : m) {
        ans += (t.second*(t.second-1LL)/2LL);
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    vector<int> av(N);
    int minus = 0;
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> v[i];
        if(v[i] < 0) minus++;
        av[i] = abs(v[i]);
        sum += av[i];
    }
    sort(av.begin(), av.end());
    if(minus % 2 == 0) cout << sum << endl;
    else cout << sum - (2 * av[0]) << endl;
}

Measured memory_bytes: 1024
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio 		ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll          long long
#define int 		ll
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi 		pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define N 2000010

using namespace std;
using namespace __gnu_pbds;

typedef priority_queue<int> maxHeap;
typedef priority_queue<int,vector<int>,greater<int> > minHeap;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    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...);
    }
#else
#define trace(...)
#endif

istream &operator>>(istream &in, vector<int> &arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
    	cin >> arr[i];
    return in;
}

ostream &operator<<(ostream &os, vector<int> arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cout << arr[i] << " ";
    cout << endl;
    return os;
}

void solution(){
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    // ll rem = d % k;
    // ll rem2 = abs(rem - k);
    // cout << min(rem,rem2);
    ll quo = x / d;
    if (quo < k)
    {
        ll xx = x % d;
        ll xx2 = xx - d;
        k = k - quo;
        if (k & 1)
            cout << abs(xx2) << endl;
        else
            cout << abs(xx) << endl;
    }
    else
    {
        cout << x - (k * d) << endl;
    }
}

signed main(){
    fastio

    ll t=1;
    // cin>>t;
    loop(i,1,t+1){
    	//cout<<"Case #"<<i<<": ";
    	solution();
    }
}




Measured memory_bytes: 3640
point = [0,0]
card = ["",""]
n=int(input())
for i in range(n):
    card = input().split()
    if card[0]==card[1]:
        point[0]+=1
        point[1]+=1
    elif card==sorted(card):
        point[1]+=3
    else:
        point[0]+=3
print("{} {}".format(point[0],point[1]))


Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  long long a[5], N;
  cin >> N >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

  long long minv = 10000000000000000LL;

  for (int i = 0; i < 5; i++)
    minv = min(minv, a[i]);

  if(N%minv==0)cout << N / minv + 4 << endl;
  else
    cout << N / minv + 5 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int n;
string s;

bool f(int a){
  return a>0 && a<=12;
}

int main(){
  cin >> s;
  int a = (s[0]-'0')*10+(s[1]-'0');
  int b = (s[2]-'0')*10+(s[3]-'0');
  if(f(a)&&f(b)){
    cout << "AMBIGUOUS" << endl;
  }else if(f(a) && !f(b)){
    cout << "MMYY" << endl;
  }else if((!f(a)) && f(b)){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a);
    vector<ll> q(b);
    vector<ll> r(c);
    priority_queue<ll> que;
    Rep(i,a){
        cin >> p[i];
    }
    Rep(i,b){
        cin >> q[i];
    }
    Rep(i,c){
        cin >> r[i];
    }
    sort(all(p));
    sort(all(q));
    sort(all(r));
    reverse(all(r));
    ll ans = 0;
    Rep(i,x){
        ans += p[a-1-i];
        que.push(-p[a-1-i]);
    }
    Rep(i,y){
        ans += q[b-1-i];
        que.push(-q[b-1-i]);
    }
    rep(i,c){
        ll t = que.top();
        que.pop();
        if(-t<r[i]){
            ans += t;
            ans += r[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
def slove():
    ans = 0
    for a in range(1,N):
        for b in range(1,N):
            c = N-a*b
            if c<=0: #a,b,cは>0なのでcが負になるときは組み合わせ除外
                break
            ans +=1
    return ans
N = int(input())
ans = slove()
print(ans)

Measured memory_bytes: 73424
#include <bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
*/
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
using ll=long long; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
const ll INFLL=(ll)2e18, MOD=1'000'000'007;
const int INF=0x3f3fffff;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"DEBUG:("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// GLOBAL VARIABLES ////////////////////////////
vector<vector<int>> adj; vector<bool> vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
/////////////////// FUNCTIONS ////////////////////////////////////
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
bool ispow2(ll x){ return x && (!(x&(x-1)));}
ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}

/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
  cout<<fixed;cerr<<fixed; cout<<setprecision(8); cerr<<setprecision(3);
  srand(time(NULL)); rand();

#ifdef DEBUG
  clock_t tStart = clock(); //freopen("op.txt","w",stdout);
#endif

  int n,sum=0; cin>>n;
  for(int t=n;t;t/=10){
    sum+=t%10;
  }
  cout<<(n%sum==0?"Yes":"No")<<'\n';


#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

void outYesOrNo(bool res)
{
    cout << (res ? "1" : "0") << endl;
}

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

    int x;

    cin >> x;

    bool dp[100200];
    memset(dp, 0, sizeof(dp));

    dp[0] = true;

    for (int i = 0; i < x; i++)
    {
        if (!dp[i])
            continue;

        for (int j = 0; j <= 5; j++)
        {
            dp[i + 100 + j] = true;
        }
    }

    outYesOrNo(dp[x]);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int x,y;
    cin >> x >> y;
    if(x > y){
        cout << "a > b" << endl;
    }else if(x < y){
        cout << "a < b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int main(){
    string s;cin>>s;int num=0;
    int len=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='R') len++;
        if(s[i]=='S'){
            num=max(num,len);len=0;
        }
    }
    num=max(num,len);
    cout<<num<<endl;
} 

Measured memory_bytes: 3624
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
     string[] str=Console.ReadLine().Split(' ');
     long[] A = str.Select(long.Parse).ToArray();
      int ans=0;
      bool flg=false;
      while(!flg){
    for(int i=0;i<N;i++){
      if(A[i]%2!=0)
      {
        flg=true;
        break;
      }else{
        A[i]=A[i]/2;
      }
    }if(!flg){
        ans++;
    }
      }
      Console.WriteLine(ans);
    }
    
  }

}

Measured memory_bytes: 28524
#!/usr/bin/env python
# -*- coding: utf-8 -*-

ans = input()
if ans[0] == ans[1] == ans[2] == ans[3]:
    print("Yes")
elif ans[0] == ans[1] == ans[2]:
    print("Yes")
elif ans[1] == ans[2] == ans[3]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
void insertionSort(int A[],int n){
	cout<<A[0];
		for(int j=1;j<n;j++)
			cout<<" "<<A[j];
		cout<<endl;
	for(int i=1;i<n;i++){
		int v=A[i];
		int j=i-1;
		while(j>=0&&A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		cout<<A[0];
		for(int j=1;j<n;j++)
			cout<<" "<<A[j];
		cout<<endl;
		
	}
}
int main(){
	
	int A[101]={0};
	int n;
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	
	insertionSort(A,n);
	
	
	
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FOR(i,S.size()-1) if(S.substr(i,2)=="AC") return _P("Yes\n");
	_P("No\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
    int N,M,C;
    cin >> N >> M >> C;
    int B[M];
    int A[N][M];
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<M;j++){
            sum+=A[i][j]*B[j];
        }
        sum+=C;
        if(sum>0){
            ans++;
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    map<string, ll> m;
    ll ans = 0;
    rep(i, n){
        string s;
        cin >> s;
        sort(all(s));
        m[s]++;
    }
    for(auto mm = m.begin(); mm != m.end(); mm++){
        ans += (mm->second * (mm->second-1))/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11344
#include <stdio.h>
int main()
{
    int n,k,x,i,dis=0;

    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){
        scanf("%d",&x);
        if((k-x)<x){
            dis = dis + 2*(k-x);
        }
        else{
            dis = dis + 2*x;
        }
    }
    printf("%d\n",dis);
    return 0;
}


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

int main(){
	int n;string s;cin>>n>>s;
	if(n%2==1){
		puts("No");return 0;
	}
	string t=s.substr(0,n/2);
	if(s==t+t){
		puts("Yes");
	}
	else puts("No");
}

Measured memory_bytes: 256
## Quick Sort

import copy

N = int(input())
lst1 = [list(input().split()) for i in range(N)]
lst2 = copy.copy(lst1)
INF = 10**9 + 1

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    L.append(("", INF))  # 番兵
    R = A[mid:right]
    R.append(("", INF))  # 番兵
    i, j = 0, 0
    for k in range(left, right):
        if (int(L[i][1]) <= int(R[j][1])):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def merge_sort(A, left, right):
    if (right - left > 1):
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
        
def partition(A, p, r):
    x = int(A[r][1])
    i = p - 1
    for j in range(p, r):
        if (int(A[j][1]) <= x):
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)

quick_sort(lst1, 0, N-1)
merge_sort(lst2, 0, N)
ans = 'Stable'
if (lst1 != lst2):
    ans = 'Not stable'
print(ans)
for i in lst1:
    print(*i)



Measured memory_bytes: 24600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int n,d;
  cin>>n>>d;
  int pts[n][d];
  int i,j;
  for(i=0;i<n;i++)
  {
    for(j=0;j<d;j++)
    {
      cin>>pts[i][j];
    }
  }
  int cnt=0;
  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
        double dist = 0;
   		for(int k=0;k<d;k++)
        {
          dist+=(pts[j][k]-pts[i][k])*(pts[j][k]-pts[i][k]);
        }
      int est = sqrt(dist);
      if(sqrt(dist)==est) cnt++;
    }
  }
  cout<<cnt;       
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long

using namespace std;

int main(){
    string S;
    cin >> S;
    int g1=0,g2=0,k1=0,k2=0;
    string copy;
    copy = S;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i]=='1'){
                S[i]='0';
                g1++;
            }
        }
        else if(i%2==1){
            if(S[i]=='0'){
                S[i]='1';
                g1++;
            }
        }
    }
    S=copy;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i]=='0'){
                S[i]='1';
                g2++;
            }
        }
        else if(i%2==1){
            if(S[i]=='1'){
                S[i]='0';
                g2++;
            }
        }
    }
    S=copy;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i]=='0'){
                S[i]='1';
                k1++;
            }
        }
        else if(i%2==1){
            if(S[i]=='1'){
                S[i]='0';
                k1++;
            }
        }
    }
    S=copy;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i]=='1'){
                S[i]='0';
                k2++;
            }
        }
        else if(i%2==1){
            if(S[i]=='0'){
                S[i]='1';
                k2++;
            }
        }
    }
    cout << min(min(g1,g2),min(k1,k2)) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,Y[26]={-1},Z[26]={-1},A,B,i,j,k,Ls,Lu,a,b,c,Q,T,F,n,m,u,v,w,side,ts,num[26]={0},G[26][200000];

char S[300001],U[200000],C[0],D[0];

int main()
{
  cin>>S>>Q;
  
  Ls=strlen(S);
  Lu=0;
  side=0;
  for(i-0;i<Q;i++)
  {
    cin>>T;
    if(T==1)
    {
      side++;
      side%=2;
    }
    else
    {
      cin>>F>>C[0];
      ts=side+F+1;
      ts%=2;
      if(ts==0)///先頭
      {
        U[Lu]=C[0];
        Lu++;
      }
      else//最後尾
      {
        S[Ls]=C[0];
        Ls++;
      }
    }
  }
  
  if(side==0)
  {
    for(i=0;i<Lu;i++)
    {
      cout<<U[Lu-1-i];
    }
    for(i=0;i<Ls;i++)
    {
      cout<<S[i];
    }
  }
  else
  {
    
    for(i=0;i<Ls;i++)
    {
      cout<<S[Ls-1-i];
    }
    for(i=0;i<Lu;i++)
    {
      cout<<U[i];
    }
  }
  
  
}

Measured memory_bytes: 896
N = int(input())
h = list(map(int,input().split()))
ans = [0]*N
ans[1] = abs(h[1] - h[0])
for i in range(N - 2):
  p1 = ans[i] + abs(h[i] - h[i + 2])
  p2 = ans[i + 1] + abs(h[i+1] - h[i+2])
  ans[i + 2] = min([p1,p2])
print(ans[N-1])  

Measured memory_bytes: 20524
#include<bits/stdc++.h>
using namespace std;
int flag[1001];
map<int,int>mp;
map<int,int>mp1;

int main()
{
    string s,s1;
    int c=0;
    cin>>s>>s1;
    if(s[0]==s1[0])
        c++;
    if(s[1]==s1[1])
        c++;
    if(s[2]==s1[2])
        c++;

    cout<<c<<"\n";

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
vector<ll>g[10010];
bool visited[10010];
int A(int x){
    if(x>=0)return x;
    else return -x;
}
int main(void){
    int n,Z,W;
    cin>>n>>Z>>W;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    if(n==1){
        cout<<A(W-a[n-1])<<endl;
        return 0;
    }
    cout<<max(A(W-a[n-1]),A(a[n-1]-a[n-2]))<<endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int l = 0, r = 0;
  rep(i, 2){
    l *= 10; r *= 10;
    l += s.at(i)-'0'; r += s.at(i+2)-'0';
  }
  bool f1 = (r != 0 && r <= 12), f2 = (l != 0 && l <= 12);
  if(f1 == true && f2 == true) cout << "AMBIGUOUS" << endl;
  else if(f1 == true) cout << "YYMM" << endl;
  else if(f2 == true) cout << "MMYY" << endl;
  else cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int dice_1[] = new int[6];
		int dice_2[] = new int[6];
		int pip[] = new int[6];
		int count = 0;
		int order = 0;
		boolean bdice_front = false;
		int dice_front = 0;
		boolean bdice_up = false;
		int dice_up = 0;
		boolean judge = false;
		
		//サイコロの目の入力
		dice_1 =  make_dice(scanner);
		dice_2 =  make_dice(scanner);
		
		pip = dice_1;
		
		//命令数実行
		do {
			dice_up = dice_2[0];
			dice_front = dice_2[1];
			bdice_front = false;
			bdice_up = false;
			
			for( int i = 0; i < 4; i ++ ){
				for( int j = 0; j < 2; j ++ ){
					if(!bdice_front) {
						for( int k = 0; k < 4; k ++ ){
							if( !bdice_front ) {
								pip = diceroll_s(pip);
								if( pip[1] == dice_front ){
									bdice_front = true;
								}
							}
						}
						pip = diceroll_e(pip);
					}
				}
				if( pip[0] == dice_up ){
					bdice_up = true;
					break;
				}
				pip = diceroll_e(pip);
				
			}
			
			if( dice_2[2] == pip[2] ){
				if( dice_2[3] == pip[3] ){
					if( dice_2[4] == pip[4] ){
						if( dice_2[5] == pip[5] ){
							judge = true;
						}
					}
				}
			}else{
				judge = false;
			}
			//右面出力
			if( judge ){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
			
			count ++;
			if( count >= order){
				break;
			}
		}while(true );
		
		scanner.close();
	}
	
	public static int[] make_dice ( Scanner scanner){
		int dice[] = new int[6];
		
		for(int i = 0; i < 6; i ++){
			dice[i] = scanner.nextInt();
		}
		
		return dice;
	}

	public static int[] diceroll_n(int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[1];
		pip[1] = dice[5];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[0];
		pip[5] = dice[4];
		
		return pip;
	}

	public static int[] diceroll_e (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[3];
		pip[1] = dice[1];
		pip[2] = dice[0];
		pip[3] = dice[5];
		pip[4] = dice[4];
		pip[5] = dice[2];
		
		return pip;
	}

	public static int[] diceroll_w (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[2];
		pip[1] = dice[1];
		pip[2] = dice[5];
		pip[3] = dice[0];
		pip[4] = dice[4];
		pip[5] = dice[3];
		
		return pip;
	}

	public static int[] diceroll_s (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[4];
		pip[1] = dice[0];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[5];
		pip[5] = dice[1];
		
		return pip;
	}
	
}



Measured memory_bytes: 26424
#include <bits/stdc++.h>
using namespace std;
// clang-format off

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on

void solve(long long N) {
  // solver code

  LL sum = 0;
  for (LL i = 0; i <= N; i++) {
    if ((i % 3) != 0 && (i % 5) != 0) {
      sum += i;
    }
  }

  cout << sum << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3764
n=int(input())
if n==1:
  print(1)
  exit()
l=[list(map(int,input().split())) for _ in range(n)]
d=[]
for i in range(n):
  for j in range(n):
    if i!=j:
      d.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter as c
print(n-c(d).most_common()[0][1])

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    ULL ans = 0;

    for(int i = 1; i <= n; ++i){
        ULL num = n / i;
        ans += num*(num + 1)*i/2;
    }

    cout << ans << endl;

    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


const int MOD = 1E9 + 7, N = 1e5 + 10;
ll fact[N];
ll exp(int a, int n) {
        if (n == 0) return 1;
        ll b = exp(a, n / 2);
        (b *= b) %= MOD;
        if (n & 1) (b *= a) %= MOD;
        return b;
}

ll C(int n, int k) {
        if (k > n) return 0;
        return fact[n] * exp(fact[k], MOD - 2) % MOD * exp(fact[n - k], MOD - 2) % MOD;
}

void _main() {
        int n; cin >> n;
        fact[0] = 1;
        for (int i = 1; i <= n + 1; i++) fact[i] = fact[i - 1] * i % MOD;
        vector<int> freq(n + 1), where(n + 1);
        int a, b;
        for (int i = 1; i <= n + 1; i++) {
                int x; cin >> x;
                if (++freq[x] == 2) {
                        b = i;
                        a = where[x];
                        break;
                }
                where[x] = i;
        }



        for (int i = 1; i <= n + 1; i++) {
                cout << (C(n + 1, i) - C(n + 1 - (b - a + 1), i - 1) + MOD) % MOD << '\n';
        }
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n;
    cin >> n;
    int dp[n+1];
    int fact[n+1];
    dp[0] = dp[1] = 1;
    dp[2] = 2;
    fact[0] = fact[1] = 1;
    fact[2] = 2;
    for (int i = 3; i <= n; ++i) {
        dp[i] = (i-1) * dp[i-1];
        fact[i] = i * fact[i-1];
    }

    int x[n], y[n];
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    double ans = 0.0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ans += (double)(dp[n]) * sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    ans /= (double)(fact[n]);
    cout << fixed << setprecision(10) << ans << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=998244353;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
void answer(){
    long N, K;
    cin>>N>>K;

    map<long, long> count;
    long a, b;
    for(int i=0; i<N; ++i){
        cin>>a>>b;
        auto itr = count.find(a);
        if(itr != count.end()){
            count[a] += b;
        }else{
            count[a] = b;
        }
    }

    for (const auto& [key, value] : count){
        if(K - value > 0){
            K -= value;
        }else{
            cout<<key<<endl;
            break;
        }
    }

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    answer();

    return 0;
}


Measured memory_bytes: 7600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>

using namespace std;
vector<int> o;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,m,k;
    while(cin>>n>>m>>k)
    {
        o.clear();
        n=__gcd(n,m);
        for(int i=1;i<=sqrt(n);i++)
            if(n%i==0)
            {
                if(i!=n/i)
                    o.push_back(n/i);
                o.push_back(i);
            }
        sort(o.begin(),o.end());
        n=o.size();
        cout<<o[n-k]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

typedef std::pair<i64, int> P;

i64 solve(int a, int b, i64 mast = (1LL << 51) - 1) {
	std::priority_queue<P, std::vector<P>, std::greater<P>> qu;
	std::vector<i64> min_cost(51, 1LL << 60); qu.push({0, a});
	min_cost[a] = 0;
	
	while(!qu.empty()) {
		auto p = qu.top(); qu.pop();
		
		for(int k = 1; k < 51; k++) {
			if(!((mast >> k) & 1)) continue;
			
			i64 cost = p.first | (1LL << k);
			int to = p.second % k;
			
			if(cost >= min_cost[to]) continue;
			min_cost[to] = cost;
			qu.push({cost, to});
		}
	}
	
	
	if(min_cost[b] == 1LL << 60) return -1;
	return min_cost[b];
}
			
int main(){
	int n; cin >> n; std::vector<int> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	
	std::vector<i64> ans(n);
	for(int i = 0; i < n; i++) {
		ans[i] = solve(a[i], b[i]);
		if(ans[i] == -1) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	i64 mask = 0;
	for(int i = 50; i > 0; i--) {
		bool f = true;
		i64 bit = (1LL << i) - 1 | mask;
		for(int j = 0; j < n; j++) f &= (solve(a[j], b[j], bit) != -1);
		if(!f) mask |= 1LL << i;
	}
		
	cout << mask << endl;
	return 0;
}


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

#define LL long long
using namespace std;


int main(void){

    vector<double> value;
    vector<string> currency;
    LL N = 0;
    double sum = 0;
    cin >> N;

    for(LL i = 0; i < N; i++){
        double tmp;
        string tmpStr;
        cin >> tmp;
        value.push_back(tmp);
        cin >> tmpStr;
        currency.push_back(tmpStr);
    }

    for (LL i = 0; i < N; i++){
        if(currency[i] == "JPY"){
            sum += value[i];
        }else{
            sum += value[i] * 380000.0;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

MOD = 10 ** 9 + 7 

def make_table(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    return fac, ifac

fac, ifac = make_table(2*10**5)

def comb(n, r, mod=MOD):
    if r > n or r < 0: return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

n, m, k = map(int, sys.stdin.readline().split())

def main():
    vert = list(range(n+1))
    horiz = list(range(m+1))
    for i in range(1, n):
        vert[i+1] += vert[i]
        vert[i+1] %= MOD
    for i in range(1, m):
        horiz[i+1] += horiz[i]
        horiz[i+1] %= MOD
    
    res = 0
    for i in range(1, n):
        res += (vert[n] - vert[i] - i * (n - i)) * m % MOD * m % MOD
        res %= MOD
    for i in range(1, m):
        res += (horiz[m] - horiz[i] - i * (m - i)) * n % MOD * n % MOD
        res %= MOD
    
    res *= comb(n*m-2, k-2)
    res %= MOD
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 26740
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin>>N;
  int s=0;
  int a;
  int c=1000000000;
  for(int i=0;i<N;i++)
  {
   cin>>a;
   int b=0;
   for(;a%2==0;b++){a=a/2;}
   if(b<=c)c=b;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int a[1000006];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++ i)
		if (a[i] != i){
			int j = i;
			bool tmp = false;
			while (((a[j] != j) ^ tmp) && j <= n){
				++ j;
				tmp = ! tmp;
			}
			bool flag = false;
			int lastl = 0, lastr = 0;
			for (int k = i; k < j; ++ k){
				if (a[k] < i || j <= a[k]){
			//		cout << a[k] << " " << i << " " << j << endl;
					flag = true;
				}
				if (a[k] < k){
					if (lastl < a[k])
						lastl = a[k];
					else
						flag = true;
				}
				if (a[k] > k){
					if (lastr < a[k])
						lastr = a[k];
					else
						flag = true;
				}
			}
			if (flag){
				cout << "No" << endl;
				return 0;
			}
			i = j - 1;
		}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  map<int, char> mp;
  rep(i, 26) {
    mp[i%26]='a' + i;
  }
  mp[-1] = 'z';
  string ans = "";
  while(n>0){
    n--;
    int x = n % 26;
    n /= 26;
    ans = mp[x] + ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588