akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=1e5+5;
int n,k,v[3];
string t;
bool used[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> n >> k;
	ll ans = 0LL;
	for(int i=0; i<3; i++)cin >> v[i];
	cin >> t;
	for(int i=0; i<n; i++){
		if(t[i]=='r')t[i]='2';
		else if(t[i]=='p')t[i]='1';
		else t[i]='0';
		if(i<k){
			ans += v[t[i]-'0'];
			used[i]=1;
		}else{
			if(t[i]==t[i-k]&&used[i-k])continue;
			ans += v[t[i]-'0'];
			used[i]=1;
		}
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN
	

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a>b && b>c){
    cout << c << " " << b << " " << a << endl;
  }
  if(c>b && b>a){
    cout << a << " " << b << " " << c << endl;
  }
  if(b>c && c>a){
    cout << a << " " << c << " " << b << endl;
  }
  if(a>c && c>=b ){
    cout << b << " " << c << " " << a << endl;
  }
  if(b>a && a>=c){
    cout << c << " " << a << " " << b << endl;
  }
  if(c>a && a>b){
    cout << b << " " << a << " " << c << endl;
  }
}  


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

int main(void)
{
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    rep(i, n) cin >> v[i], v[i] = abs(v[i] - x);
    int ans = v[n - 1];
    rep(i, n - 1) ans = __gcd(ans, v[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3712
W,H,N = map(int,input().split())
point = [list(map(int,input().split())) for i in range(N)]
x_min = 0
x_max = W
y_min = 0
y_max = H

for i in point:
    if i[2] == 1:
        x_min = max(x_min,i[0])
    elif i[2] == 2:
        x_max = min(x_max,i[0])
    elif i[2] == 3:
        y_min = max(y_min,i[1])
    else:
        y_max = min(y_max,i[1])

x_line = x_max - x_min
y_line = y_max - y_min

if x_line > 0 and y_line > 0:
    print(x_line*y_line)
else:
    print(0)    


Measured memory_bytes: 3064
while True:
    n,x=map(int,input().split())
    if n==x==0:
        break
    s=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    s+=1
    print(s)


Measured memory_bytes: 5592
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
typedef pair<long long int, long long int> ii;
typedef vector<long long int> vi;
typedef vector<ii> vii;
// #define INF 1000000000000000
       
#define endl '\n'
#define MOD 1000000007
// #define INF 1ll<<30
long long int inf =  100000000000000000;
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout<<fixed;

// #ifndef ONLINE_JUDGE
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

    string a;
    cin>>a;
    long long int ans = (a.size()*(a.size()-1))/2;
    long long int count[26]={0};
    for(int i=0;i<a.size();i++)
    {
    	count[a[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {	
    	ans-=((count[i]*(count[i]-1))/2);
    }
    cout<<ans+1<<endl;

// #ifndef ONLINE_JUDGE
//     cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
// #endif

    return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
int main(){
	int H,W;
	int i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main() {
  string n;
  int a, b, c, d;
  cin >> n;
  a = n[0] - '0';
  b = n[1] - '0';
  c = n[2] - '0';
  d = n[3] - '0';

  for (int bs = -1; bs <= 1; bs+=2) {
    for (int cs = -1; cs <= 1; cs+=2) {
      for (int ds = -1; ds <= 1; ds+=2) {
        if (a + b * bs + c * cs + d * ds == 7) {
          cout << a;
          cout.setf(std::ios::showpos);
          cout << b * bs << c * cs << d * ds << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,roof=1,b=0;
    cin>>a;
    // Your code here!
	for(int i = 1; i <= 1000000; i++){
	    if(a%2==0 && b==0){
	        i=3;
	        b=1;
	    }
		int count = 0;
		for(int j = 1; j <= i; j++){
			if(i % j == 0){
				count++;
			}
			if(count > 2){
				break;
			}
		}
		if(count == 2 && roof<=a && i%10==1){
			cout << i << endl;
			roof++;
		}else if(roof>a){
		    break;
		}
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int ans = 1e9;
	rep(i, 3) rep(j, 3) if(i != j) ans = min(ans, (a[i] + a[j]));
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
// abc048_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll a, b, x;
    cin >> a >> b >> x;

    ll p = b / x;
    ll q = (a - 1) / x;
    if (a == 0) q = -1;

    print(p - q);


    return 0;
}


Measured memory_bytes: 256
/*
  -------------
  Prateek Celly
  DA-IICT
  -------------
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,d,ans=0;
  cin>>n>>d;
  ll a[n][d];
  for(ll i=0;i<n;i++) for(ll j=0;j<d;j++) cin>>a[i][j];
  for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
      ld x=0;
      for(ll k=0;k<d;k++){
        x+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
      }
      x=sqrt(x);
      if(floor(x)==ceil(x)) ans++;
    }
  }
  cout<<ans;
  return 0;
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  string x;cin>>x;
  int n = sz(x);

  int spool = 0;
  int cnt = 0;
  rep(i, n){
    if (x[i]=='T') {
      if (spool) {
        cnt++; spool--;
      }
      else{
      }
    }
    else{
      spool++;
    }
  }
  cout << n - cnt*2 << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 720
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int N; cin >> N;
	map<int, int> m;
	rep(i, N) {
		int X, L; cin >> X >> L;
		m[X] = L;
	}
	int edge = -1, ans = 0;
	each(mi, m) {
		if (edge > -1) {
			if (edge < mi.first - mi.second) {
				edge = mi.first + mi.second - 1;
				ans++;
			}
			else if (edge < mi.first + mi.second) {

			}
			else {
				edge = mi.first + mi.second - 1;
			}
		}
		else {
			edge = mi.first + mi.second - 1;
			ans++;
		}
	}
	cout << ans << endl;
}

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

int main( int argc, char *argv[] )
{
int i;
int A;
int B;
int C;

	cin >> A;
	cin >> B;
	cin >> C;
	for( i = 1; i <= B; i++ )
	{
		if( ( A * i ) % B == C )
		{
			cout << "YES" << endl;

			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}






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

int main() {
    vector<int> team(101, 0), rank(31, 0), tmp;
    int num, solved;
    char c;
    while (cin >> num >> c >> solved, num) {
        team[num] = solved;
        tmp.push_back(solved);
    }
    sort(tmp.begin(), tmp.end());
    tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
    sort(tmp.begin(), tmp.end(), greater<int>());
    for (int i=0; i<(int)tmp.size(); ++i) {
        rank[tmp[i]] = i+1;
    }
    int n;
    while (cin >> n) {
        cout << rank[team[n]] << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  string o,e;
  cin >> o >> e;

  int moji = max(o.size(),e.size());
  if((o.size()+e.size())%2==1){
    moji--;
    rep(i,moji)
      cout << o[i] << e[i];
    cout << o[moji];
  }

  else
    rep(i,moji)
      cout << o[i] << e[i];
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		String T = sc.get();
		var pd = T.replace("P?", "PD").replace("?D", "PD").replace("??", "PD").replace("?", "D");
		System.out.println(pd);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 37820
#include<bits/stdc++.h>
using namespace std;
int arr[100010],n,m;
const int mod=1e9+7;
int main()
{
    cin>>n>>m;
    while(m--)
    {
        int tmp;
        cin>>tmp;
        arr[tmp]=-1;
    }
    arr[0]=1;
    for(int i=1; i<=n; ++i)
    {
        if(arr[i]==-1)
        {
            arr[i]=0;
            continue;
        }
        else arr[i]=(i>=2?arr[i-2]:0)%mod+arr[i-1]%mod;
        arr[i]%=mod;
    }
    cout<<arr[n]<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

vector<int> vx;
vector<int> vy;

bool OK(vector<int>& v, int x) {
  bool A[8001] = {true};
  int sum = 0;
  for(int k : v){
  	for(int i = 8000; i >= 0; --i) {
  	  if(i - k < 0) continue;
      A[i] |= A[i - k];
  	}
    sum += k;
  }
  return (x + sum) % 2 == 0 && A[(x + sum) / 2];
}


int main (){
  string s;
  int x,y;
  cin >> s;
  cin >> x >> y;
  s.push_back('T');
  
  int i = s.find('T');
  int to;
  x -= i;
  bool is_y = true;
  while((to = s.find('T', i + 1)) != string::npos){
	(is_y ? vy : vx).push_back(to - (i + 1));
    is_y = !is_y;
    i = to;
  }
  
  cout << (OK(vx, x) && OK(vy, y) ? "Yes" : "No") << endl;
  
  return 0;
}


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

int main() {
  string a,b;
  cin>>a>>b;
  int c;
  for(int i=0;i<3;i++){
    if(a.at(i)==b.at(i)){
      c=c+1;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5; 

#define endl "\n"

int p[N];

bool isok(int a,int b,int c){
	if(b>a&&b>c) return 0;
	if(b<a&&b<c) return 0;
	return 1;
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,cnt;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i];
	cnt=0;
	for(int i=2;i<n;i++){
		if(isok(p[i-1],p[i],p[i+1])) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main(){
	int n;
	long debt=100, tmp; // x1000 yen

	scanf("%d", &n);

	for(; n>0; n--)
		debt=(int)ceil(debt*1.05);
	
	printf("%d000\n", debt);

 return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a.begin(),a.end());
    ll opt = a[n/2];
    ll ans = 0;
    rep(i,n){
        ans += abs(a[i]-opt);
    }
    cout << ans;
}

Measured memory_bytes: 1792
def main():
    import sys
    import math
    def input():
        return sys.stdin.readline()[:-1]
    A,B,H,M=map(int,input().split())
    C=0
    Hsita=360*(H/12)+30*(M/60)
    Msita=360*(M/60)
    sita=Hsita-Msita
    if sita>180:
        sita=360-sita
    C=math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(sita)))

    if sita==180:
        C=A+B
    
    print(C)
    

    

        


if __name__ == '__main__':
    main()


Measured memory_bytes: 9396
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

	int N;
	cin >> N;
	int A[N];
	rep(i,N) cin >> A[i];
	if(N % 2 == 0){
		int dp[N][2];
		rep(i,N){
			rep(j,2){
				dp[i][j] = -1 * INF;
			}
		}
		rep(i,N){
			if(i == 0){
				dp[i][0] = A[0];
				continue;
			}
			if(i == 1){
				dp[i][0] = A[0];
				dp[i][1] = A[1];
				continue;
			}
			if(i % 2 == 0){
				dp[i][0] = dp[i-1][0] + A[i];
				dp[i][1] = dp[i-1][1];
			}
			else{
				dp[i][0] = dp[i-1][0];
				dp[i][1] = dp[i-1][1] + A[i];
			}

			if(i % 2 == 0){
				dp[i][1] = max(dp[i-1][0], dp[i][1]);
			}


		}
		cout << max(dp[N-1][0], dp[N-1][1]) << endl;
	}
	else{
		int dp[N][3]{};
		rep(i,N){
			rep(j,3){
				dp[i][j] = -1 * INF;
			}
		}

		rep(i,N){
			if(i == 0){
				dp[0][0] = A[0];
				dp[0][1] = 0;
				continue;
			}
			if(i == 1){
				dp[1][0] = A[0];
				dp[1][1] = A[1];
				continue;
			}
			if(i == 2){
				dp[i][2] = A[2];
			}

			if(i % 2 == 0){
				dp[i][0] = max(dp[i][0], dp[i-1][0] + A[i]);
				dp[i][2] = max(dp[i][2], dp[i-1][2] + A[i]);
				dp[i][1] = max(dp[i][1], dp[i-1][1]);
				if(i == N-1) dp[i][0] = dp[i-1][0];
			}
			else{
				dp[i][1] = dp[i-1][1] + A[i];
				dp[i][0] = dp[i-1][0];
				dp[i][2] = dp[i-1][2];
			}
			if(i % 2 == 0){
				dp[i][1] = max(dp[i-1][0], dp[i][1]);
			}
			else{
				dp[i][2] = max(dp[i-1][1], dp[i][2]);
			}

		}
		int ans = max(dp[N-1][0], dp[N-1][1]);
		ans = max(ans, dp[N-1][2]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 9888
def main():
    n, d = map(int, input().split())
    ans = 0
    
    for i in range(n):
        x, y = map(int, input().split())
        r = (x**2 + y**2)**(0.5)
        
        if r<=d:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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

int gcd(int a, int b) {
    if (a<b) swap(a,b);
    int r;
    while(a%b != 0) {
        r = a%b;
        a = b;
        b = r;
    }
    
    return b;
}

int main() {
    int a, b;
    cin >> a >> b;
    
    cout << gcd(a,b) << endl;
    
    return 0;
}


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

bool judge(long long N, vector<long long> A, long long c) {
	stack<pair<long long,long long>> S;
	long long L = A[0];
	S.push(make_pair(L, 0));
	for(int i = 1; i < N; ++i) {
		/*
		stack<pair<ll,ll>> T = S;
		while(!T.empty()) {
			cerr << "(" << T.top().first << "," << T.top().second << ")";
			T.pop();
		}
		cerr << endl;
		*/
		if(A[i] > A[i - 1]) {
			S.push(make_pair(A[i] - A[i - 1], 0));
			L = A[i];
		} else {
			pair<ll, ll> p;
			do {
				p = S.top(); S.pop();
				L -= p.first;
			} while((L >= A[i] || p.second >= c - 1) && !S.empty());
			
			//cerr << L << "," << S.size() << "," << p.second << "," << c << endl;
			if(S.empty() && p.second == c - 1) {
				return false;
			}

			if (L + p.first > A[i]) {
				p.first = A[i] - L;
			}

			if(p.first > 1) {
				S.push(make_pair(p.first - 1, p.second));
			}
			S.push(make_pair(1, p.second + 1));

			L += p.first;
			if(L < A[i]) {
				S.push(make_pair(A[i] - L, 0));
				L += A[i] - L;
			}
		}
	}
	return true;
}

void solve(long long N, vector<long long> A){
	long long l = 0, u = A.size();
	//cerr << judge(N, A, 3) << endl;
	//return;
	while(u - l > 1) {
		long long c = (l + u) / 2;
		if (judge(N, A, c)) {
			u = c;
		} else {
			l = c;
		}
	}
	cout << u << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int n = S.size();
  if(S.at(n-1) != 's') S += "s";
  else S += "es";
  cout << S << endl;  
}

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

long long pow(long long m,long long n)
{
	long long res;
	if(n==0) return 1;
	res=pow(m*m%1000000007,n/2);
	if(n%2==1) return res*m%1000000007;
	return res;
}

int main()
{
	long long m,n;
	
	cin >> m >> n;
	
	cout << pow(m,n) << endl;
	
	return 0;
}

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

int main(){
    char x = ' ';
    int sum=0;
    while(cin>>x){
            sum = (sum + x-'0')%9;
    }
    if(sum==0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i = 0; i < N; i++) {
    cin >> p[i];
  }
  int tmp = 0;
  for(int i = 0; i < N; i++) {
    if(p[i] != i + 1) { tmp++; }
  }
  if(tmp > 2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,anss,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> s;
    ans = (Size(s) - 1) * 9;
    ans += (s[0] - '0');
    ans--;
    rrrep(i, Size(s) - 1, 0){
        anss += (s[i] - '0');
    }
    Cout(max(ans, anss));
    return 0;
}


Measured memory_bytes: 256
#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 d;
  cin>>d;
  cout<<"Christmas";
  rep(i,25-d){
    cout<<" Eve";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b<<endl;
    }else{
        cout<<0<<" ";
        k=k-a;
        if(b>=k)cout<<b-k<<endl;
        else cout<<0<<endl;
    }
}



Measured memory_bytes: 3624
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def per(n, r, p):
    if r < 0 or n < r:
        return 0
    return fact[n] * factinv[n-r] % p

p = 10 ** 9 + 7#mod
N = 5*pow(10, 5)  # N は必要分だけ用意する。大体問題設定のオーダーに合わせる(N >= max(n, r)。上のcmb関数のリスト同士の掛け算において、fact[n], factinv[r]を参照するため)
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n, m = map(int, input().split())
ans = 0
for i in range(n+1):
    ans += pow(per(m-i, n-i, p), 2) * per(m, i, p) * cmb(n, i, p) * (-1)**i % p
ans = ans % p
print(ans)

Measured memory_bytes: 185584
use std::collections::BTreeMap;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(from: usize, depth: i64, childs: &Vec<Vec<usize>>) -> i64 {
    let mut ret = depth;
    for &to in childs[from].iter() {
        ret += dfs(to, depth + 1, childs);
    }
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut items = BTreeMap::<i64, usize>::new();
    for i in 0..n {
        let v = read::<i64>();
        items.insert(v, i);
    }
    let mut childs = vec![vec![]; n];
    let mut parents = vec![n; n];
    let mut cnts = vec![1; n];
    for (&v, &index) in items.iter().rev() {
        let tv = v - (n as i64 - 2 * cnts[index]);
        if cnts[index] == n as i64 || tv <= 0 || tv == v {
            break;
        }
        if let Some(&nindex) = items.get(&tv) {
            parents[index] = nindex;
            childs[nindex].push(index);
            cnts[nindex] += cnts[index];
        } else {
            println!("-1");
            return;
        }
    }
    let root = *items.iter().next().unwrap().1;
    let root_weight = *items.iter().next().unwrap().0;
    let weight = dfs(root, 0, &childs);
    if weight != root_weight {
        println!("-1");
        return;
    }
    for i in 0..n {
        if parents[i] == n {
            continue;
        }
        println!("{} {}", i + 1, parents[i] + 1);
    }
}


Measured memory_bytes: 18044
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 A, B;
  cin >> A >> B;
  i64 b = B % A;
  for(i64 i = 0;i < A;i++) {
    i64 bx = b * i % A;
    i64 y = (A - bx) % A;
    i64 z = (B * i + y) / A;
    if(z < i + y) {
      cout << B * i + y << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}



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

int CalcID(int r, int t) { return r + 5*t; }

int main() {

    int n, r, t;
    cin >> n;
    for ( int i=0; i<n; ++i ) {

	cin >> r >> t;

	bool onR = r%100 == 0;
	bool onT = t%30 == 0;
	r /= 100;
	t /= 30;

	if ( onR && onT ) cout << CalcID(r, t) << endl;
	else if ( onR ) cout << CalcID(r, t) << " " << CalcID(r, t+1) << endl;
	else if ( onT ) cout << CalcID(r, t) << " " << CalcID(r+1, t) << endl;
	else cout << CalcID(r, t) << " " << CalcID(r+1, t) << " "
		  << CalcID(r, t+1) << " " << CalcID(r+1, t+1) << endl;
    }

    return 0;
}



Measured memory_bytes: 3108
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_STR_MAX		100005									// 最大文字数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_STR_MAX];									// 文字列

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 実行メイン
int
fMain(
)
{
	int i;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 色数 - 取得
	int liRCnt = 0;
	int liBCnt = 0;
	for (i = 0; ; i++) {
		if (sc1Str[i] == '0') {
			liRCnt++;
		}
		else if (sc1Str[i] == '1') {
			liBCnt++;
		}
		else {
			break;
		}
	}

	// 小さい方を取得
	if (liRCnt < liBCnt) {
		return liRCnt * 2;
	}
	else {
		return liBCnt * 2;
	}
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 結果 - セット
	sprintf(lc1Out, "%d\n", liRet);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne(0);
#endif

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int main() {
    ll N, A, B; cin >> N >> A >> B;
    vector<int> x(N);
    for (int i = 0; i < N; i++) cin >> x[i];
    priority_queue<int> q;
    for (int i = 1; i < N; i++) q.push(-(x[i] - x[i - 1]));
    ll sum = 0;
    ll ans = (N - 1) * B + sum * A;
    for (int k = N - 2; k >= 0; k--) {
        sum += -q.top(); q.pop();
        ll cost = k * B + sum * A;
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
const int MOD = 998244353;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	int n, s; cin >> n >> s;
	vector<int> dp(s + 1, 0);
	dp[0] = 1;
	for(int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		for(int j = s; j >= 0; j--) {
			dp[j] = dp[j] * 2 % MOD;
			if(j >= a) dp[j] += dp[j - a];
			dp[j] %= MOD;
		}
	}
	cout << dp[s] << endl;
	return 0;
}

Measured memory_bytes: 3684
class Unionfind():  # Unionfind
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):  # 根のリスト
        return [i for i, x in enumerate(self.parents) if x < 0]


n, m = map(int, input().split())
xyz = sorted([list(map(int, input().split())) for _ in range(m)])

uf = Unionfind(n)
for x, y, z in xyz:
    uf.union(x - 1, y - 1)
print(len(uf.roots()))


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int d = in(), n = in();

  int cnt = 0;
  for (int i = 1;; ++i) {
    int po = 0;
    int m = i;
    while (m % 100 == 0) {
      po++;
      m /= 100;
    }

    if (po == d) cnt++;
    if (cnt == n) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;




long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Ans{
public:
	long long x;
	long long y;
	long long x_;
	long long y_;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long a,b;
	cin>>b>>a;
	cout<<max(0LL,b-2*a)<<endl;
}


Measured memory_bytes: 256
n = int(input())
sp = []
for i in range(n):
    sp.append([i+1,input().split()])
for i in range(n):
    sp[i][1][1] = int(sp[i][1][1])
temp1 = sorted(sp, key=lambda x:x[1][1], reverse=True)
temp2 = sorted(temp1, key=lambda x:x[1][0])
for i in range(n):
    print(temp2[i][0])

Measured memory_bytes: 3064
import java.util.Scanner;
class Main {
    public void kami() {
        		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
    }
    public static void main(String[] args) {
        new Main().kami();
	}

}

Measured memory_bytes: 17156
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>


using namespace std;
#define ll long long


int main(void){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(N),B(N);
    for(ll i=0;i<N;i++) cin>>A.at(i)>>B.at(i);
    vector<pair<ll,ll>> AB(N);
    for(ll i=0;i<N;i++) AB.at(i)=make_pair(A.at(i),B.at(i));
    sort(AB.begin(),AB.end());
    ll num=0,ans=0;
    while(M>0){
        if(M>=AB.at(num).second){
            M-=AB.at(num).second;
            ans+=AB.at(num).first*AB.at(num).second;
            num++;
        }
        else{
            ans+=AB.at(num).first*M;
            M=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H, N;
    cin>>H >> N;
    vector <ll> ans(1e4+1, 1e9), cost(1e4+1, 1e9);
    ll cheapest=1e9;
    loop(i,0,N)
    {
        ll a,b;
        cin >>a>>b;
        cost[a]=min(cost[a],b);
        cheapest=min(cheapest, b);
    }
    if (cost[1]==1e9) cost[1]=cheapest;
    ans[1]=cost[1];
    loop(i,2,1e4+1) ans[i]=cost[i];
    loop(i,2,H+1)
    {
        ans[i]=cost[i];
        loop(j, 1, i)
        {
            ans[i]=min(ans[i], ans[j]+ans[i-j]);
        }
        loop(j, i+1, 1e4+1)
        {
            ans[i]=min(ans[i], ans[j]);
        }
    }
    cout << ans[H] << "\n";
    return 0;
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	int n = read.to!int;
	
	long[] as;
	foreach(i; 0 .. n) as ~= read.to!long;
	debug writeln("as: ", as);
	
	long[] bs;
	foreach(i; 0 .. n) bs ~= read.to!long;
	debug writeln("bs: ", bs);
	
	long[] xs;
	long amount;
	int count;
	foreach(i; 0 .. n){
		if(bs[i] == as[i]) continue;
		if(bs[i] > as[i]) count += 1, amount += bs[i] - as[i];
		if(bs[i] < as[i]) xs ~= as[i] - bs[i];
	}
	debug writeln("xs: ", xs);
	
	xs.sort!"a > b"();
	debug writeln("xs: ", xs);
	
	for(int k = 0; k < xs.length && amount > 0; k ++){
		count += 1;
		amount -= xs[k];
	}
	if(amount > 0) count = -1;
	
	count.writeln;
}


Measured memory_bytes: 10216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(a + b, min(a + c, b + c)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll k;cin>>k;
    ll now=0;
    rep(i,1,k+1){
        now=now*10+7;
        now%=k;
        if(now==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <algorithm>

using namespace std;
int main(int argc, char const *argv[])
{
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> P(A);
    vector<int> Q(B);
    vector<int> R(C);
    for (int i = 0; i < A; i++)
    {
        cin >> P.at(i);
    }
    for (int i = 0; i < B; i++)
    {
        cin >> Q.at(i);
    }
    for (int i = 0; i < C; i++)
    {
        cin >> R.at(i);
    }
    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    sort(R.begin(), R.end());
    reverse(R.begin(), R.end());
    int i = A - X;
    int j = B - Y;
    long int p, q, r;
    for (int k = 0; k < C; k++)
    {
        // cout << i << " " << j << " " << k << endl;
        if (i < A)
        {
            p = P.at(i);
        }
        else
        {
            p = 20000000000000;
        }
        if (j < B)
        {
            q = Q.at(j);
        }
        else
        {
            q = 20000000000000;
        }
        r = R.at(k);
        if (r - p <= 0 && r - q <= 0)
        {
            break;
        }
        if (r - p > r - q)
        {
            if (r - p > 0)
            {
                P.at(i) = r;
                i++;
            }
        }
        else
        {
            if (r - q > 0)
            {
                // cout << r << " " << q << endl;
                Q.at(j) = r;
                // cout << j << endl;
                j++;
            }
        }
    }
    long long result = 0;
    for (int i = A - X; i < A; i++)
    {
        result += P.at(i);
    }
    for (int i = B - Y; i < B; i++)
    {
        result += Q.at(i);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1408