akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  queue<int> que[n];
  set<int> se;
  int ans = 0;
  int siai = n*(n-1)/2;

  REP(i,n){
    REP(j,n-1){
      int t;cin>>t;
      t--;
      que[i].push(t);
    }
  }

  int front[n];
  REP(i,n){
    front[i] = que[i].front();
    que[i].pop();
  }

  ans++;
  REP(i,n-1){
    //cout<<"+"<<endl;
    if(front[front[i]] == i && front[i] > i){
      se.insert(i);
      se.insert(front[i]);
      siai--;
      //cout<<"siai = "<<siai<<endl;
    }
  }
  for(auto i:se){
    front[i] = que[i].front();
    que[i].pop();
  }

  if(se.empty()){
    cout<<-1<<endl;
    return 0;
  }



  while(siai>0){

    /*REP(i,n){
      cout<<front[i]+1<<"   ";
    }
    cout<<endl;*/

    ans++;
    //cout<<"++"<<endl;
    set<int> se2;

    for(auto i:se){
      if(front[i] == -1)continue;


      if(front[front[i]] == i){
        if(se2.find(i) == se2.end()){
        se2.insert(i);
        //cout<<"insert "<<i<<endl;
        se2.insert(front[i]);
        //cout<<"insertf "<<front[i]<<endl;
        
        
        siai--;
        //cout<<"siai = "<<siai<<endl;
      }
      }
    }
    for(auto i:se2){
      if(!que[i].empty()){
        front[i] = que[i].front();
        //cout<<"front " << i << " "<<front[i]<<endl;;
        que[i].pop();
      }else{
        front[i] = -1;
      }
    }

    if(se2.empty()){
      cout<<-1<<endl;
      return 0;
    }else{
      se = se2;
    }
  }

  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 200005
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,a,b,c,d;
char s[maxn];
bool able(int l,int r){//l,r are empty.
  for(int i = l + 2;i <= r - 1;i++) if(s[i] == '#' && s[i - 1] == '#') return false;
  return true;
}
int main(){
  n = getint(), a = getint(), b = getint(), c = getint(), d = getint();
  scanf("%s",s + 1);
  if(!able(a,c) || !able(b,d)){
    puts("No");
    return 0;
  }
  if(c > d){
    bool ok = false;
    for(int i = b;i <= d;i++){
      if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.'){
        ok = true;
        break;
      }
    }
    if(!ok){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


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

using namespace std;

typedef long long LL;

LL H,W,h,w;
LL ans[510][510];

int main()
{
	scanf("%lld%lld%lld%lld",&H,&W,&h,&w);
	LL sum = 0;
	for (int i=1;i<=H;i++)
		for (int j=1;j<=W;j++)
		{
			if (i%h==0 && j%w==0)
				ans[i][j] = -(h*w-1)*2LL*max(H,W)-1;
			else
				ans[i][j] = 2LL*max(H,W);
			sum += ans[i][j];
		}
	if (sum > 0)
	{
		puts("Yes");
		for (int i=1;i<=H;i++)
			for (int j=1;j<=W;j++)printf("%lld%c",ans[i][j]," \n"[j==W]);
	}
	else puts("No");
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, k;

int main() {
	cin >> a >> b >> k;
	
	inc(i, k) {
		a -= a % 2;
		b += a / 2;
		a -= a / 2;
		swap(a, b);
	}
	if(k % 2 != 0) { swap(a, b); }
	
	cout << a << " " << b << endl;
	
	return 0;
}


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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = (N % 1000) / 100;
  c = (N % 100) / 10;
  d = N % 10;

  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
    
}

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

using namespace std;
#define N 2005

int main()
{
    ios::sync_with_stdio(0);
    int n;
    string str;
    cin>>str;
    int flag=0;
    if(str[0]==str[1]&&str[1]==str[2]) flag=1;
    if(str[3]==str[1]&&str[1]==str[2]) flag=1;
    /*
    for(int i=0;i<4;++i){
        flag=1;
        for(int j=1;j<3;++j){
            int k=i+j;
            if(k>=4) k-=4;
            if(str[k]==str[i]);
            else {
                flag=0;
                break;
            }
        }
        if(flag)break;
    }
    */
    if(flag)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
def main():
    X, Y = list(map(int, input().split()))
    ans = 0
    if X == 1 and Y == 1:
        ans += 400000

    if X == 1:
        ans += 300000
    elif X == 2:
        ans += 200000
    elif X == 3:
        ans += 100000


    if Y == 1:
        ans += 300000
    elif Y == 2:
        ans += 200000
    elif Y == 3:
        ans += 100000

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
int main(){
  int i,cnt;
  char s[100001];
  char ans[100001];
  scanf("%s",s);
  int len=strlen(s);
  for(i=0; i<len; i+=2){
    ans[cnt]=s[i];
    cnt++;
  }
  printf("%s\n",ans);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> mp;
    mp[a] = 1;
    mp[b] = 1;
    mp[c] = 1;
    if (mp.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;
#define PI 3.14159265358979323846

using namespace std;
int MOD = 1000000007;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string YES = "YES";
  string NO = "NO";
  ll a,v;
  ll b,w;
  ll t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;
  if( a == b ) {
    cout << YES << endl;
    return 0;
  }
  if( a < b ) {
    ll a2 = a + t * v;
    ll b2 = b + t * w;
    if( a2 >= b2 ){
      cout << YES << endl;
      return 0;
    }
    else {
      cout << NO << endl;
      return 0;
    }
  }
  else {
    ll a2 = a - t * v;
    ll b2 = b - t * w;
    if( a2 <= b2 ) {
      cout << YES << endl;
      return 0;
    }
    else {
      cout << NO << endl;
      return 0;
    }
  
  }
  return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e3+100;
const int INF=0x3f3f3f3f;
int T,n,m,k;

int main()
{
    cin>>n;
    if(n%1000==0)
        cout<<0<<endl;
    else
        cout<<(1000-n%1000)<<endl;
        
}

Measured memory_bytes: 3620
#include <algorithm>

#include <bitset>

#include <complex>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <iostream>

#include <istream>

#include <iterator>

#include <limits>

#include <list>

#include <locale>

#include <map>

#include <memory>

#include <new>

#include <numeric>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <typeinfo>

#include <utility>

#include <valarray>

#include <vector>



#if __cplusplus >= 201103L

#include <array>

#include <atomic>

#include <chrono>

#include <condition_variable>

#include <forward_list>

#include <future>

#include <initializer_list>

#include <mutex>

#include <random>

#include <ratio>

#include <regex>

#include <scoped_allocator>

#include <system_error>

#include <thread>

#include <tuple>

#include <typeindex>

#include <type_traits>

#include <unordered_map>

#include <unordered_set>

#endif
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min(b, d) - max(a, c);

	if (ans >= 0)cout << ans << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i, n) for(int i=0;i<n;++i)
#define REPR(i, n) for(int i = n-1;i>=0;--i)
#define REPI(itr, v) for(auto itr=v.begin();itr!=v.end();++itr)
#define SORT(v, n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define pb(a) push_back(a)
#define N 1000000007


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

using namespace std;

int main(){

  int n;
  scanf("%d", &n);

  map<int, int> mp;
  for(int i = 1; i <= n; i++){
    int a = i;
    for(int j = 2; j <= i; j++){
      while(a % j == 0){
        mp[j]++;
        a /= j;
      }
    }
  }

  long long res = 1;
  REPI(itr, mp){
    res = res * (itr->second + 1) % N;
  }

  printf("%lld\n", res);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iomanip> //表示桁数

#include <queue>
#include <unordered_set>

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned char Byte;
using namespace std;

string ans = "Yes";
//double ans;
int N, M;
int rcount = 0;

vector<int> A;
vector<int> B;
vector<unordered_set<int>> rootMap;

vector<int> ansN;
vector<int> disN;


/*
void recruit(int room) {


	if()

	rep(i, N);

}*/

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

	unordered_set<int> argv;
	vector<unordered_set<int>> argvv(N, argv);

	rootMap = argvv;

	vector<int> iargv2(N, -1);
	ansN = iargv2;



	rep(i, M) {
		int tmpA, tmpB;
		cin >> tmpA >> tmpB;
		//A.push_back(tmpA);
		//B.push_back(tmpB);
		rootMap[tmpA - 1].insert(tmpB - 1);
		rootMap[tmpB - 1].insert(tmpA - 1);

	}

	unordered_set<int> sameRank;

	sameRank.insert(0);

	while (rcount < N) {
		unordered_set<int> tmpRank;
		for (int room : sameRank) {
			unordered_set<int> tmpRoom = rootMap[room];
			for (int i : tmpRoom) {
				if (ansN[i] == -1) {
					ansN[i] = room;
					tmpRank.insert(i);
					//rootMap[i].erase(room);
					rcount++;
				}
			}
		}
		sameRank = tmpRank;
	}
	
	cout << ans << endl;
	rep(i, N - 1) {
		cout << ansN[i+1] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 40916
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
}
int main(){
   //Fast_IO();
   ll x;
   cin>>x;
   if(x>=400 && x<=599) cout<<8;
   if(x>=600 && x<=799) cout<<7;
   if(x>=800 && x<=999) cout<<6;
   if(x>=1000 && x<=1199) cout<<5;
   if(x>=1200 && x<=1399) cout<<4;
   if(x>=1400 && x<=1599) cout<<3;
   if(x>=1600 && x<=1799) cout<<2;
   if(x>=1800 && x<=1999) cout<<1;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
  int n,k,h,cnt=0;
  scanf("%d%d", &n, &k);
  for(int i=0; i<n; i++){
    scanf("%d", &h);
    if( h >= k ){ cnt++; }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
#include<math.h>
#include<limits.h>
#define _USE_MATH_DEFINES

using namespace std;

int a, b;

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

	if (a != 2 && b != 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;



int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans= a*x + b*y;
    for(int i=0; i<=max(x,y); i++){
        int tmp = a*max(0, x-i) + b*max(0, y-i) + c*2*i;
        if(tmp < ans) ans = tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			if (check(i)) {
				System.out.print(" ");
				System.out.print(i);
			}
		}
		System.out.print("\n");
	}

	private static boolean check(int i) {
		if (i % 3 == 0) {
			return true;
		}
		int len = (int) Math.log10(i) + 1;
		int tmp = i;
		for (int j = len - 1; j >= 0; j--) {
			int warikitta = tmp / (int) Math.pow(10, j);
			if (warikitta == 3) {
				return true;
			}
			tmp = tmp - warikitta * (int) Math.pow(10, j);
		}
		return false;
	}
}

Measured memory_bytes: 33948
#include <stdio.h>

int main(void)
{
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if(a < b && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    Graph<pii> G(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b, i});
        G[b].push_back({a, i});
    }

    int M;
    cin >> M;

    auto bfs = [&](int u, int v) -> ll {
        vector<ll> passed(N, -1);
        queue<int> que;
        passed[u] = 0;
        que.push(u);
        while (!~passed[v]) {
            int s = que.front();
            que.pop();
            for (auto np : G[s]) {
                int ns = np.first;
                if (~passed[ns])
                    continue;
                passed[ns] = passed[s] | (1LL << np.second);
                que.push(ns);
            }
        }
        return passed[v];
    };

    vector<ll> p(M);
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        p[i] = bfs(u, v);
    }

    ll ans = 0;
    for (int i = 0; i < (1 << M); ++i) {
        ll bit = 0;
        int cnt = 0;
        for (int j = 0; j < M; ++j)
            if (i & (1 << j))
                bit |= p[j], cnt++;
        ll tmp = 1LL << (N - __builtin_popcountll(bit) - 1);
        if (cnt & 1)
            ans -= tmp;
        else
            ans += tmp;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define ll unsigned long long int

using namespace std;

main()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
		

	for(ll i=k;i<n;i++)
	{
		if(a[i]>a[i-k])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
		
		}	
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
int func(int x){
  if(x%100 != 0) return 0;
  return func(x/100)+1;
}
int main(){
  int d,n;
  cin >> d >> n;
  int cnt = 0;
  for(int x=1; ; x++){
    if(func(x) == d){
      cnt++;
      if(cnt==n){
        cout << x << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

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

#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // 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))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

signed main() {
    int N,K; cin >> N >> K;
    string S; cin >> S;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if (i == 0) continue;
        if (S[i] == S[i - 1]) ans++;
    }

    ans += 2 * K;

    chmin(ans, N-1);
    if (ans == N - 2 && S[0] == S[N - 1]) ans++;
    cout << ans << endl;
}
 

Measured memory_bytes: 3644
function main(input) {
  const inputs = input.split('\n')
  const [N, M] = inputs[0].split(' ').map(Number)
  const A = inputs[1].split(' ').map(Number)
  const all = A.reduce((h, e) => { return h + e }, 0)
  const ratio = 1 / (4 * M) * all
  const a = A.filter(e => {
    return ratio <= e
  })
  console.log(a.length >= M ? 'Yes' : 'No')
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 30132
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
ll dp[105][100005];
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
      ll n,w;cin>>n>>w;
      ll vrr[n],wrr[n];
      f(i,0,n)
      {
        cin>>wrr[i]>>vrr[i];
      }
      mem(dp,0);
      dp[0][wrr[0]]=vrr[0];
      f(i,1,n)
      {
        f(j,0,100005)
        {
          dp[i][j]=max(dp[i][j],dp[i-1][j]);
          if(j-wrr[i]>=0)
          dp[i][j]=max(dp[i][j],vrr[i]+dp[i-1][j-wrr[i]]);
        }
      }
      ll ans=0;
      f(i,0,w+1)
      {
        ans=max(ans,dp[n-1][i]);
      }
      cout<<ans;
    }    
} 

Measured memory_bytes: 85684
/**
 *      ABC 58 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 23:32:05
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string O, E; cin >> O >> E;
    int sizeO = O.size(); int sizeE = E.size();
    if (sizeO == sizeE){
        for (int i = 0; i < sizeO; ++i) {
            cout << O[i] << E[i];
        }
    }
    else {
        for (int i = 0; i < sizeE; ++i) {
            cout << O[i] << E[i];
        }
        cout << O[sizeO - 1];
    }

    return 0;
}


Measured memory_bytes: 256
//
// Created on 2020/05/28.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n;
    cin>>n;
    vector<pair<int,int>>work(n);

    for (int i = 0; i < n; ++i) {
        int a,b;
        cin>>a>>b;
        work[i] = {b,a};
        //first=>deadline second=>work time
    }
    sort(rall(work));
    int time = INF;

    for (int j = 0; j < n; ++j) {
        if(time < 0){
            cout<<"No"<<endl;
            return 0;
        }
        if(time > work[j].first){
            time = work[j].first;
        }
        time -= work[j].second;
    }
    if(time < 0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int max = -1000001, min = 1000001;
    long long sum = 0;

    while (N--) {
        int n;
        cin >> n;
        if (n > max) max = n;
        if (n < min) min = n;
        sum += n;
    }
    cout << min << " " << max << " " << sum << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const ll maxn = 2e5;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e9;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);



int main(){
    migmig
    int a , b;
    cin >> a;
    cin >> b;
    cout << max(0 , a - b - b);


    return(0);
}



//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


Measured memory_bytes: 256
a,b,c=map(int,input().split())
k=int(input())
kk=2**k
sum=0
if a>=b and a>=c:
  sum=b+c+kk*a
elif b>=c:
  sum=a+c+kk*b
else:
  sum=a+b+kk*c
print(sum)

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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	if(a >= b && a >= c) cout << 10*a + b + c;
	else if(b >= a && b >= c) cout << 10*b + a + c;
	else if(c >= a && c >= b) cout << 10*c + a + b;
} 

Measured memory_bytes: 256
n, m = gets.strip.split(" ").map(&:to_i)
shop = Array.new(n) do
  gets.strip.split(" ").map(&:to_i)
end

shop.sort_by!(&:first)

b = 0
ans = 0
l = shop.size - 1
0.upto(l) do |i|
  c = [m - b, shop[i].last].min
  b += c
  ans += c * shop[i].first
   
  break if b == m
end

puts ans


Measured memory_bytes: 12664
from _collections import deque
n=int(input())
B=list(map(int,input().split()))
ANS=deque([])
cnt=0
while len(B)>0 and cnt<10**5:
    for i in reversed(range(len(B))):
        if i+1==B[i]:
            B=B[:i]+B[i+1:]
            ANS.appendleft(i+1)
            break
    cnt+=1
if len(B)==0:
    for a in ANS:
        print(a)
else:
    print(-1)

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

using namespace std;

const int N = 25;
const int mod = 1e9 + 7;

int dp[N][1 << 21], a[N][N], n;
vector <int> comp[N];

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> a[i][j];
            if (a[i][j]) comp[i].push_back(j);
        }
    }
    
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int mask = 0; mask < (1 << n); mask++) {
            if (dp[i][mask]) {
                for (auto v: comp[i + 1]) {
                    if (mask & (1 << (v - 1))) continue;
                    add(dp[i + 1][mask | (1 << (v - 1))], dp[i][mask]);
                }
            }
        }
    }
    cout << dp[n][(1 << n) - 1];
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];

  ll ans = INF;
  
  //偶数番目が正

  ll cur = 0;
  ll tmp_ans = 0;
  for(int i = 0; i < n; i++){
    cur += a[i];
    if(i % 2 == 0){
      if(cur <= 0){
        tmp_ans += 1-cur;
        cur = 1;
      }
    }else{
      if(cur >= 0){
        tmp_ans += cur + 1;
        cur = -1;
      }
    }
  }

  chmin(ans, tmp_ans);
  
  //奇数番目が正
  tmp_ans = 0;
  cur = 0;

  for(int i = 0; i < n; i++){
    cur += a[i];
    if(i % 2 == 1){
      if(cur <= 0){
        tmp_ans += 1-cur;
        cur = 1;
      }
    }else{
      if(cur >= 0){
        tmp_ans += cur + 1;
        cur = -1;
      }
    }
  }

  chmin(ans, tmp_ans);

  cout << ans << endl;

  return 0;
}


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

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    int _min = 10e+6;
    for(int i = 0; i < n; i++){
        if(p[i] <= _min){
            ans++;
            _min = p[i];
        }
    }

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

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr long long INF = 1000000000000;
const double PI = acos(-1);

#define int LL

struct edge { int to; double cost; };

typedef pair<double, int> PP;

double d[100010]; //距離
vector<edge> vec[100010];

double dis(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

double dijkstra() {
	for (int i = 0; i < 100010; i++)d[i] = INF;
	priority_queue<PP, std::vector<PP>, std::greater<PP>> pq;
	d[0] = 0;
	pq.push(make_pair(d[0], 0));
	while (!pq.empty()) {
		PP p = pq.top();
		pq.pop();
		int i = p.second;
		if (d[i] < p.first)continue;
		for (int k = 0; k < vec[i].size(); k++) {
			edge e = vec[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(make_pair(d[e.to], e.to));
		}
	}
	return d[1];
}
double x[1002], y[1002], r[1002];
signed main() {
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	r[0] = 0, r[1] = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i+2] >> y[i+2] >> r[i+2];
	}
	for (int i = 0; i < n + 2; i++) {
		for (int j = 0; j < n + 2; j++) {
			if (i == j)continue;
			vec[i].emplace_back(edge{ j, max(0.0, dis(x[i], y[i], x[j], y[j]) - r[i] - r[j]) });
		}
	}
	cout << fixed << setprecision(10) << dijkstra() << endl;
}

Measured memory_bytes: 25328
#include <stdio.h>

int main() {
	int m, d, i, day;
	static const int dm[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	static const char *dayName[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
	for (;;) {
		scanf("%d %d", &m, &d);
		if (m <= 0) { break; }
		--m;
		for (i = 0; i < m; ++i) {
			d += dm[i];
		}
		day = (d + 3 - 1) % 7;
		puts(dayName[day]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <vector>
#include <algorithm>
using std::vector;

int main() {
	int N,i,j,max;
	std::vector<int> a(10000000),b(10000000);
	scanf("%d", &N);
	for(i=0;i<N*2;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<N*2;i+=2){
		j=i/2;
		b[j]=a[i];
	}
	std::vector<int>::iterator iter = max_element(b.begin(), b.end());
	size_t index = distance(b.begin(), iter);
	printf("%d",b[index]+a[index*2+1]);
	return 0;
}

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

int main(void){
	int N,P,a;
	long long cnt;
	cin>>N;
	cin>>a;
	cnt=a-1;
	P=2;
	rep(i,N-1){
		scanf("%d",&a);
		if(P>a)continue;
		else if(P==a)P++;
		else cnt += a/P - (a%P==0);
	}
	cout<<cnt<<endl;

	return 0;
}


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

typedef struct t_node T_NODE;
struct t_node {
	int key;
	T_NODE *next;
	T_NODE *prev;
};

T_NODE *newT_NODE() {
	T_NODE *newT_Node;
	newT_Node = (T_NODE *)malloc(sizeof(T_NODE));
	if( newT_Node == NULL) {
		exit(1);
	}
	newT_Node->next = NULL;
	newT_Node->prev = NULL;
	
	return newT_Node;
}

T_NODE *insert_x(T_NODE *list, int x)
{
	T_NODE *newT_Node	= newT_NODE();
	newT_Node->key		= x;
	if( list != NULL ) {
		newT_Node->next		= list;
		newT_Node->prev		= list->prev;
		
		list->prev = newT_Node;
	}
	else {
		newT_Node->next = NULL;
		newT_Node->prev = newT_Node;
	}
	
	return newT_Node;
}

T_NODE *delete_x(T_NODE *list, int x)
{
	T_NODE *p = list->next;
	T_NODE *tmp;
	
	if( list->key == x ) {
		if( list->prev == list ) {
			free(list);
			return NULL;
		}
		list->next->prev = list->prev;
		return list->next;
	}
	
	
	while( p != NULL ) {
		if( p->key == x ) {
			tmp = p->prev;
			if( p->next != NULL )
				p->next->prev	= tmp;
			else
				list->prev = tmp;
				
			tmp->next = p->next;
			free(p);
			break;
		}
		p = p->next;
	}
	return list;
}

T_NODE *deleteFirst(T_NODE *list)
{
	if( list == NULL ) {
		return list;
	}
	if( list->prev == list ) {
		free(list);
		return NULL;
	}
	
	T_NODE *tmp = list->next;
	tmp->prev = list->prev;
	free(list);
	
	return tmp;
}

T_NODE *deleteLast(T_NODE *list)
{
	if( list == NULL ) {
		return list;
	}
	if( list->prev == list ) {
		free(list);
		return NULL;
	}
	
	T_NODE *Last = list->prev;
	Last->prev->next = NULL;
	list->prev = Last->prev;
	free(Last);
	
	return list;
}

void showList(T_NODE *list)
{
	while(1) {
		printf("%d", list->key);
		list = list->next;
		if(list == NULL)
			break;
		else
			putchar(' ');
			
	}
	printf("\n");
}
	

int main()
{
	T_NODE *list = NULL;
	int i;
	int n;
	
	char str[32];
	
	int x=0;
	char cmd[16];
	
	scanf("%d\n", &n);
	
	for(i=0; i<n; i++)
	{
		fgets(str, 32, stdin);
		if( strstr(str, " ") != NULL )
			sscanf(str, "%s %d", cmd, &x);
		else
			sscanf(str, "%s", cmd);
			
		
		if( !strcmp(cmd, "insert") ) {
			list = insert_x(list, x);
			//~ printf("### ");
			//~ showList(list);
		}
		else if( !strcmp(cmd, "delete") ) {
			list = delete_x(list, x);
			//~ printf("### ");
			//~ showList(list);
		}
		else if( !strcmp(cmd, "deleteFirst") ) {
			list = deleteFirst(list);
			//~ printf("### ");
			//~ showList(list);
		}
		else if( !strcmp(cmd, "deleteLast") ) {
			list = deleteLast(list);
			//~ printf("### ");
			//~ showList(list);
		}
			
	}
	showList(list);
	
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    for(int a = 0; a < z; a++){
        if(a%2 == 0){
            y += x/2;
            x /= 2;
        }
        else{
            x += y/2;
            y /= 2;

        }
    }
    cout << x << ' ' << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define MOD 998244353
#define db(a) cout << a << endl
#define adb(a) for(auto i:a) cout << i << " "
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

long long w[100], v[100];
long long dp[2][100010];

int main()
{
    long long n, W;
    cin >> n >> W;

    long long i, j;
    for(i=0;i<n;i++)
    {
        cin >> w[i];
        cin >> v[i];
    }

    memset(dp, 0, sizeof(dp));
    for(i=0;i<n;i++)
    {
        for(j=0;j<=W;j++)
        {
            if(w[i] <= j) dp[1-i%2][j] = max(dp[i%2][j-w[i]] + v[i], dp[i%2][j]);
            else dp[1-i%2][j] = dp[i%2][j];
        }
    }

    if(n%2) cout << dp[1][W] << endl;
    else cout << dp[0][W] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int read();

int n;
vector<int> e[200005];
void add(int f, int t) { e[f].push_back(t), e[t].push_back(f); }
int fa[200005], mx[200005];
int res[200005], vis[200005];

set<int> s[200005];
set<int>::iterator it;

void work(int t, int u) {
    if (!vis[u]) return;
    vis[u] = 0, s[t].erase(u);
    for (int i = 0, v; i < e[u].size(); ++i)
        if (fa[u] != (v = e[u][i])) work(t, v);
}

void dfs(int u) {
    for (int i = 0, v; i < e[u].size(); ++i)
        if (fa[u] != (v = e[u][i])) {
            mx[v] = max(mx[u], fa[v] = u), dfs(v);
            if (s[u].size() < s[v].size()) swap(s[u], s[v]);
            for (it = s[v].begin(); it != s[v].end(); ++it) s[u].insert(*it);
        }

    while ((it = s[u].upper_bound(mx[u])) != s[u].end()) work(u, *it);
    s[u].insert(u), vis[u] = 1;
    if (u > mx[fa[u]]) return res[u] = s[u].size(), void();
    int ts = s[u].size();
    while ((it = s[u].upper_bound(mx[fa[u]])) != s[u].end()) work(u, *it);
    res[u] = ts - s[u].size();
}

void push(int u) {
    for (int i = 0, v; i < e[u].size(); ++i)
        if (fa[u] != (v = e[u][i])) res[v] += res[u], push(v);
}

int main() {
    n = read();
    for (int i = 1; i < n; ++i) add(read(), read());
    dfs(1), push(1);
    for (int i = 2; i <= n; ++i) printf("%d ", res[i] - 1);
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 69120
def satisfy?(cx,cy,h,x,y,l)
  l==[h-(x-cx).abs-(y-cy).abs,0].max
end

def height(cx,cy,x,y,l)
  l+(x-cx).abs+(y-cy).abs
end

n=gets.to_i
info=n.times.map{gets.split.map(&:to_i)}
k=info.find{|x,y,l|l>0}
0.upto(100){|cx|
  0.upto(100){|cy|
    h=height(cx,cy,*k)
    if info.all?{|x,y,l|satisfy?(cx,cy,h,x,y,l)}
      puts [cx,cy,h]*" "
      exit
    end
}}

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

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

	ll n,k;
	cin>>n>>k;
	map<ll,ll> data;
	for(int i=0; i<n; ++i){
		ll a,b;
		cin>>a>>b;
		data[a] += b;
	}
	for( auto i : data ){
		if( k > i.second ){ k -= i.second; }
		else{ cout<<i.first<<endl; return 0; }
	}

	return 0;
}


Measured memory_bytes: 4224
#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() {
    string S; cin >> S;
    int n = S.size();

    if(S[n-1] == 's'){
        S += "es";
    } else {
        S += "s";
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<complex>
#include<map>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define GROUP first
#define ENE   second
typedef pair<int,int> pii;
const int N = 32;
pii dp[N][N][N][N];
int sum[N][N][N][N];
int in[N][N];
int psum[N][N];

void compute(int y,int x,int y2,int x2){
  if (y == y2 && x == x2){
    sum[y][x][y2][x2]=in[y][x];
    return;
  }
  sum[y][x][y2][x2]=psum[y2][x2];//-psum[y2][x]-psum[y][x2]+psum[y][x];

  if (x-1 >= 0)sum[y][x][y2][x2]-=psum[y2][x-1];
  if (y-1 >= 0)sum[y][x][y2][x2]-=psum[y-1][x2];
  if (y-1 >= 0 && x-1 >= 0)sum[y][x][y2][x2]+=psum[y-1][x-1];
}

void precalc(int r,int c){
  rep(i,r){
    rep(j,c){
      psum[i][j]=0;
      rep(ii,i+1)rep(jj,j+1)psum[i][j]+=in[ii][jj];
    }
  }
  rep(i,r){
    REP(ii,i,r){
      rep(j,c){
        REP(jj,j,c){
          compute(i,j,ii,jj);
        }
      }
    }
  }
}

bool isbigger(pii& ret,pii &a1,pii &a2,int req){
  int retgroup=ret.GROUP,cmpgroup=a1.GROUP+a2.GROUP;
  int minreq=min(a1.ENE,a2.ENE);
  //if (minreq < req)return false;

  if (retgroup < cmpgroup)return true;
  if (retgroup == cmpgroup){
    if(ret.ENE < min(a1.ENE,a2.ENE))return true;
  }
  return false;
}

pii solve(int y,int x,int y2,int x2,int req){
  int tmp=sum[y][x][y2][x2];
  if (tmp < req)return make_pair(0,0);
  if (y == y2 && x == x2)return make_pair(1,tmp-req);
  pii &ret=dp[y][x][y2][x2];
  if (ret.GROUP != -1)return ret;
  if (tmp >= req){
    ret.GROUP=1;
    ret.ENE=tmp-req;
  }
  //cout << ret.GROUP <<" " << ret.ENE << endl;
  //ver
  REP(i,x,x2){
    pii a1=solve(y,x,y2,i,req);
    pii a2=solve(y,i+1,y2,x2,req);
    if (isbigger(ret,a1,a2,req)){
      ret.GROUP=a1.GROUP+a2.GROUP;
      ret.ENE=min(a1.ENE,a2.ENE);
    }
  }

  //hor
  REP(i,y,y2){
    pii a1=solve(y,x,i,x2,req);
    pii a2=solve(i+1,x,y2,x2,req);
    if (isbigger(ret,a1,a2,req)){
      ret.GROUP=a1.GROUP+a2.GROUP;
      ret.ENE=min(a1.ENE,a2.ENE);
    }
  }
  return ret;
}



main(){
  int r,c,sup;
  while(cin>>r>>c>>sup && r){
    rep(i,r)rep(j,c)rep(k,r)rep(l,c){
      dp[i][j][k][l].first=-1;
      dp[i][j][k][l].second=-1;
      sum[i][j][k][l]=0;
    }
    rep(i,r)rep(j,c)cin>>in[i][j];
    precalc(r,c);
    int req=psum[r-1][c-1]-sup;
    pii ans=solve(0,0,r-1,c-1,req);
    cout << ans.GROUP <<" " << ans.ENE << endl;
  }
  return false;
}

Measured memory_bytes: 12000
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
res = 0


def resolve():
    n = int(input())

    def is_ok(L):
        l = "".join(L)
        if int(l) <= n:
            for i in ["7", "5", "3"]:
                if i not in l:
                    return False
            else:
                return True
        else:
            return False

    def dfs(L):
        global res
        if len(L) == len(str(n)):
            return

        for i in ["7", "5", "3"]:
            L.append(i)
            if is_ok(L):
                res += 1
            dfs(L)
            L.pop()

        return res

    print(dfs([]))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, m;
	cin >> n >> m;
	vector<int> occurs(m, 0);
	for(int i = 0; i < n; ++i)
	{
		int k;
		cin >> k;
		while(k--)
		{
			int a;
			cin >> a;
			++occurs[a - 1];
		}
	}
	int answer = 0;
	for(auto &count : occurs) answer += (count == n);
	cout << answer << '\n';
}

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

const int MAX = 100;

int SelectionSort(int A[], int n) {
	int count = 0; //交換回数記録用
	int i = 0; //未ソートの要素の先頭のインデックスを示すループ変数
	int j = 0; //最小の要素のインデックスを探すためのループ変数
	int minj = 0; //最小の要素のインデックスを格納する変数

	//何か「i < n - 1」としてたけど普通に「i < n」で良かった
	for (i; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		swap(A[i], A[minj]);
		if (i != minj) {
			count++;
		}
	}

	return count;
}

void Output(int A[], int n) {
	for (int i = 0; i < n; i++) {
		if (i) cout << ' ';
		cout << A[i];
	}
}

int main() {
	int A[MAX];
	int n;
	int count;

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

	count = SelectionSort(A, n);
	Output(A, n);
	cout << endl;
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> //sort
using namespace std;
static const int max_ans =3000;


int main(void){
    // ~~LからRまでの数字をmod2019でソート~~
    // 入力
    long long L,R; cin >> L >> R;
    if(R-L>2019){
        cout << 0;
    }
    else{
        // 全探索
        vector<long long> a(R-L+1);
        vector<long long> b(R-L+1);
        for(long long i=0; i<=R-L; i++){
            a[i] = (i+L);
            b[i] = (i+L);
        }
        long long ans=max_ans;
        for(int i=0; i<=R-L; i++){
            for(int j=0; j<=R-L; j++){
                if( i<j &&  ((a[i]*b[j])%2019 < ans) ) ans = (a[i]*b[j])%2019;
            }
        }
        cout << ans;
    }
    
    return 0;
}

Measured memory_bytes: 256