akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
 
int change(int x, int y) {
    if(x > y) {
        return x-1;
    }
}
 
int kaijo(int x) {
    int ans=1;
    for(int i=1;i<=x;i++){
        ans*=i;
    }
    return ans;
}
 
int main() {
    int N;
    scanf("%d", &N);
    int *P = (int*)malloc(N * sizeof(int));
    int *Q = (int*)malloc(N * sizeof(int));
    for(int i=0; i<N; i++) {
        scanf("%d", &P[i]);
    }
    for(int i=0; i<N; i++) {
        scanf("%d", &Q[i]);
    }
    int a = 0, b = 0;
    for(int i=0; i<N-1; i++) {
        if(P[i] != 1) {
          a += (P[i] - 1) * kaijo(N-i-1);
        }
        if(Q[i] != 1) {
          b += (Q[i] - 1) * kaijo(N-i-1);
        }
        for(int j=i+1; j<N; j++) {
            if(P[i] < P[j]){
            	P[j]--;
            }
          	if(Q[i] < Q[j]){
            	Q[j]--;
            }
        }
    }
    printf("%d\n", abs(a-b));
 
    free(P);
    free(Q);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;
 
      a=a*a%mod;
      b/=2;
 
      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
 
 
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    // ifstream fin(".in");
    // ofstream fout(".in");
i64 x;
cin>>x;
int hi=1000000,lo=1;
i64 cur=100,taken=0;
while(cur<x){
cur=(1.01*cur);
taken++;
}
cout<<taken;
 
 
    return 0;
  }

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(x,a) for(auto& (x) : (a) )
int main(){
  int a[3][3];
  rep(i,3){
    rep(j,3)cin>>a[i][j];
  }
  int n;
  cin>>n;
  int b[n];
  rep(i,n)cin>>b[i];
  bool c[3][3];
  rep(i,3)rep(j,3)c[i][j]=false;
  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(b[i]==a[j][k])c[j][k]=true;
      }
    }
  }
  rep(i,3){
    if(c[i][0]&&c[i][1]&&c[i][2]){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(c[0][i]&&c[1][i]&&c[2][i]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(c[0][0]&&c[1][1]&&c[2][2]){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(c[0][2]&&c[1][1]&&c[2][0]){
    cout<<"Yes"<<endl;
    return 0;
  }

  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N; cin >> N;
  deque<int> deq;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (i % 2 == 0) deq.push_front(a);
    else deq.push_back(a);
  }
  
  if (N % 2 == 0) {
    for (int i = 0; i < N; i++) {
      cout << deq.back() << " ";
      deq.pop_back();
    }
    cout << endl;
  } else {
    for (int i = 0; i < N; i++) {
      cout << deq.front() << " ";
      deq.pop_front();
    }
    cout << endl;
  }   
}

Measured memory_bytes: 2944
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>()[0];
    //let c = c[0];
    match c {
        'a' | 'i' | 'u' | 'e' | 'o' => println!("vowel"),
        _ => println!("consonant"),
    }
}

Measured memory_bytes: 4352
n = int(input())
h = list(map(int, input().split()))
h = [0] + h

dp = [10 ** 9] * (n+1)
dp[1] = 0

for i in range(1, n+1):
  dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n])

Measured memory_bytes: 13976
#include<cstdio>
#include<bits/stdc++.h>
#define fi first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
 
typedef pair<int, int> pi;

 
int main() {   
	int X, A, B;
	cin >> X >> A >> B;
	X -= A;
	cout << X - (X / B)  * B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int x,y,z,k; cin >> x >> y >> z >> k;
  vector<ll> a(x),b(y),c(z);
  rep(i,x) cin >> a[i]; rep(i,y) cin >> b[i]; rep(i,z) cin >> c[i];
  
  vector<ll> ab,ab_k,abc;
  rep(i,x) rep(j,y){
    ab.push_back(a[i]+b[j]);
  }
  sort(ab.begin(),ab.end(),greater<ll>());
  int s = ab.size();
  int t = min(k,s);
  rep(i,t) ab_k.push_back(ab[i]);
  
  rep(i,t)rep(j,z){
    abc.push_back(ab_k[i]+c[j]);
  }
  
  sort(abc.begin(),abc.end(),greater<ll>());
  
  rep(i,k){
    cout << abc[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 43400
#include<bits/stdc++.h>
#define INF 1<<30
#define MAX 100005
#define ll long long
#define speed ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
int main()
{
    speed;
    ll N;
    cin>>N;
    double dp[N+5][N+5],p[N+1];
    memset(dp,0.0,sizeof(dp));
    for(ll i=1;i<=N;i++) cin>>p[i];
    dp[1][0]=1-p[1];
    for(ll i=2;i<=N;i++) dp[i][0]=dp[i-1][0]*(1-p[i]);
    dp[1][1]=p[1];
    for(ll i=2;i<=N;i++)
        dp[i][i]=dp[i-1][i-1]*p[i];
    for(ll i=1;i<=N;i++)
        for(ll j=1;j<i;j++)
            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
    double res=0;
    for(ll i=N/2+1;i<=N;i++)
        res+=dp[N][i];
    cout << fixed << setprecision(10) << res;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>

using namespace std;

int N, X[3];
string S[100000];

void choose(int inc, int dec, vector<int>* result) {
  result->push_back(inc);
  X[inc]++;
  X[dec]--;
}

bool solve(vector<int>* result) {
  for (int i = 0; i < N; ++i) {
    int x = S[i][0] - 'A';
    int y = S[i][1] - 'A';
    if (X[x] == 0 && X[y] == 0) {
      return false;
    }
    if (X[y] == 0) {
      swap(x, y);
    }
    if (X[x] == 0) {
      choose(x, y, result);
    } else if (X[x] == 1 && X[y] == 1) {
      if (i == N - 1) {
        choose(x, y, result);
      } else {
        int nx = S[i+1][0] - 'A';
        int ny = S[i+1][1] - 'A';
        if (x == nx || x == ny) {
          choose(x, y, result);
        } else {
          choose(y, x, result);
        }
      }
    } else if (X[x] == 1) {
      choose(x, y, result);
    } else {
      choose(y, x, result);
    }
  }
  return true;
}

int main() {
  cin >> N >> X[0] >> X[1] >> X[2];
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }
  vector<int> result;
  if (solve(&result)) {
    cout << "Yes"<< endl;
    for (int i = 0; i < result.size(); ++i) {
      cout << (char)('A' + result[i]) << endl;
    }
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 7028
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define X real()
#define Y imag()
using P=complex<double>;
double dot(P a, P b) {
    return (a.X*b.X + a.Y*b.Y);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    P p1, p2;
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    p1 = P(x1, y1);
    p2 = P(x2, y2);
    p2 -= p1;
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> x1 >> y1;
        P p0;
        p0 = P(x1, y1);
        p0 -= p1;
        p0 = p1 + dot(p0, p2)/norm(p2)*p2;
        printf("%.9f %.9f\n", p0.X, p0.Y);
    }
    return 0;
}



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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    Int n;
    cin >> n;
    dump(a[n - 1]);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a = 0;
  int b = 0;
  int c = 0;
  scanf("%d %d %d",&a,&b,&c);
  if(a == b || a == c || b == c)
  {
    if(a == b && a == c)
    {
      printf("No");
    }
    else
    {
      printf("Yes");
    }
  }
  else
  {
    printf("No");
  }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main{

public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt();s.nextLine();
       char[] arr=s.nextLine().toCharArray();
       int res=0;
       for(int i=0;i<n;i++){
       	while(i+1<n&&arr[i]==arr[i+1]){
       		i++;
       	}
       	res++;
       }
       	
       System.out.println(res); 
    }
}
    
  












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

int main(){
  int N;
  int c5=0; 
  int c7=0;
  
  for(int i=0; i<3; i++){
    cin >> N;
    if(N==5) c5++;
    else if(N==7) c7++;
  }
  
  if(c5==2 && c7==1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc;
vector<ll> va,vb,vc;

int gcd(ll tara,ll tarb){ //最大公約数
    ll am=1;
    while(am){
        am=tara%tarb;
        tara=tarb;
        tarb=am;
    }
    return tara;
}

int lcm(ll tara,ll tarb){ //最小公倍数
    return tara*tarb/gcd(tara,tarb);
}

int main(){
    cin>>n>>a;
    
    
    
    for(int i=0;i<n;i++){
        cin>>aa[i];
    }
    x=aa[0];
    m=aa[0];
    
    for(int i=1;i<n;i++){
        x=gcd(x,aa[i]);
        m=max(m,aa[i]);
    }
    
    C(a%x==0 and a<=m ? "POSSIBLE":"IMPOSSIBLE");
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }

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

    double ans = v[0];

    for(int i = 1;i < n;i++){
        ans = (ans + v[i]) / 2;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	a, b, m := scanInt(), scanInt(), scanInt()
	amin := math.MaxInt64
	as := make([]int, a)
	for i := range as {
		as[i] = scanInt()
		amin = min(amin, as[i])
	}
	bmin := math.MaxInt64
	bs := make([]int, b)
	for i := range bs {
		bs[i] = scanInt()
		bmin = min(bmin, bs[i])
	}

	ans := amin + bmin
	for i := 0; i < m; i++ {
		x, y, c := scanInt(), scanInt(), scanInt()
		ans = min(ans, as[x-1]+bs[y-1]-c)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4864
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long X = sc.nextLong();
	for(long a = -200 ; a < 200 ; a++){
      for(long b = -200 ; b < 200 ; b++){
        if(gojyou(a) - gojyou(b) == X){
          System.out.println(a + " " + b);
          return;
        }
      }
    }
	}
  static long gojyou(long a){
  return a * a * a * a * a;
} 
} 

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s; cin >> s;
    int n = s.length();
    bool f = true;
    if(n<6) f = false;
    if(s[2] != s[3]) f = false;
    if(s[4] != s[5]) f = false;
    cout<<(f?"Yes\n":"No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,x; cin >> a >> b >> x;
    if (a > x || a+b < x)
    {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	int ans = 0;
	while (N) {
		ans++;
		N /= M;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x;
    cin>>n>>x;
    
    int d=0,ans=1;
    for(int i=0;i<n;i++){
        int newp;
        cin>>newp;
        int newd=d+newp;
        if(newd<=x)
            ans++;
        else
            break;
        
        d= newd;
    }
cout<<ans;
}


Measured memory_bytes: 3156
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 1e9
#define MOD 1000000007;//1e9+7

int main() {
    int N, R;
    cin >> N >> R;
    if (N >= 10)cout << R;
    else cout << R + 100 * (10 - N);

    return 0;
}

Measured memory_bytes: 256
#include<boost/multiprecision/cpp_int.hpp>
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define f(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define vl vector<ll>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";
#define printv(v) for(auto it : v) cout<<it<<" ";



//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("O3")
//uncoment for large int requirement
using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;
const long long int MOD = 1000000007;
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);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

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

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{
ll n;
cin>>n;
vector<cpp_int> v(n);
for(int i = 0 ; i<n ;i++) cin>>v[i];
cpp_int sum = 0 ; 
cpp_int tmp = 0 ; 
for(int i = 0 ; i<n ;i++){
    sum = (sum+v[i])%MOD;
   
}
//sum = (sum*sum)%MOD;
cpp_int res = 0 ; 
for(int i = 0 ; i<n ;i++){
    sum-=v[i];
    sum = (sum+MOD)%MOD;
    res = (res + (sum*v[i])%MOD)%MOD;
}
cout<<res<<endl;
}
}


Measured memory_bytes: 9584
#![allow(dead_code)]
use std::cmp;
use std::collections::*;

pub struct Scanner {
    bytes: Vec<u8>,
    begin: usize,
    end: usize,
}

impl Scanner {
    pub fn new() -> Self {
        use std::io::Read;
        let mut buffer: Vec<u8> = Vec::new();
        std::io::stdin().read_to_end(&mut buffer).unwrap();
        let end = (0..)
            .find(|i| *i == buffer.len() || buffer[*i].is_ascii_whitespace())
            .unwrap();
        Scanner {
            bytes: buffer,
            begin: 0,
            end: end,
        }
    }
    pub fn next<T: std::str::FromStr>(&mut self) -> T {
        let s: &str = unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
        let ret: T = s.parse::<T>().ok().expect("Parse error.");
        self.skip();
        ret
    }
    pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }
    pub fn next_word(&mut self) -> Vec<u8> {
        let r = Vec::from(&self.bytes[self.begin..self.end]);
        self.skip();
        r
    }
    fn skip(&mut self) {
        self.begin = (self.end..)
            .find(|i| *i == self.bytes.len() || !self.bytes[*i].is_ascii_whitespace())
            .unwrap();
        self.end = (self.begin..)
            .find(|i| *i == self.bytes.len() || self.bytes[*i].is_ascii_whitespace())
            .unwrap();
    }
}

fn lower_bound<T: std::cmp::Ord>(v: &Vec<T>, val: &T) -> usize {
    let mut lb: isize = -1;
    let mut ub: isize = v.len() as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        if *val <= v[mid as usize] {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return ub as usize;
}

fn dfs(
    u: usize,
    p: usize,
    dp: &mut Vec<i32>,
    ans: &mut Vec<usize>,
    a: &Vec<i32>,
    edge: &Vec<Vec<usize>>,
    pans: usize,
) {
    let idx = lower_bound(dp, &a[u]);
    let prev = dp[idx];
    ans[u] = if dp[idx] == i32::max_value() {
        pans + 1
    } else {
        pans
    };
    dp[idx] = a[u];

    for v in &edge[u] {
        if *v == p {
            continue;
        }
        dfs(*v, u, dp, ans, a, edge, ans[u]);
    }
    dp[idx] = prev;
}

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let a: Vec<i32> = scan.next_vec(n);
    let mut edge: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let u: usize = scan.next();
        let v: usize = scan.next();
        let (u, v) = (u - 1, v - 1);
        edge[u].push(v);
        edge[v].push(u);
    }
    let mut dp: Vec<i32> = vec![i32::max_value(); n];
    let mut ans: Vec<usize> = vec![0; n];
    dfs(0, 0, &mut dp, &mut ans, &a, &edge, 0);
    for x in ans {
        println!("{}", x);
    }
}


Measured memory_bytes: 39108
s = input()
n = len(s)

digitssum = [0] * n

for i, c in enumerate(s):
    digitssum[i] = int(c) * pow(10, n-i-1, 2019)

for i in range(1, n):
    digitssum[i] += digitssum[i-1]
    digitssum[i] %= 2019

counter = [0] * 2019
counter[0] = 1

for d in digitssum:
    counter[d] += 1

print(sum((counter[i] * (counter[i]-1) // 2) for i in range(2019)))


    

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

using namespace std;
int memo[100100],h[100100],n,k;
int dp(int i){
if(i > n)
    return 2e9;

if(i==n){

    return 0;
}
    if(memo[i]!=-1)
        return memo[i];

        int res=2e9;

for(int j=1; j<=k; j++){
res=min(abs(h[i]-h[i+j])+dp(i+j),res);
}

return memo[i]=res;
}

int main()
{
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>h[i];
        memset(memo,-1,sizeof(memo));
    cout<<dp(1);

    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<vector<Pi>> A(N);
    rep(i,N){
        int a; cin >> a;
        rep(j,a){
            int x,y; cin >> x >> y;
            x--;
            A[i].emplace_back(x,y);
        }
    }
    int ans = 0;
    rep(i,1<<N){
        set<int> st;
        rep(j,N){
            if(i>>j&1){
                rep(k,A[j].size()){
                    if(A[j][k].second == 1){
                        st.insert(A[j][k].first);
                    }
                }
                st.insert(j);
            }
        }
        bool ok = true;
        for(int u : st){
            rep(j,A[u].size()){
                if(A[u][j].second == 1 && !(i>>A[u][j].first&1)) ok = false;
                if(A[u][j].second == 0 && i>>A[u][j].first&1) ok = false;
            }
        }
        if(ok) ans = max(ans,(int)st.size());
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int a = Integer.parseInt(br.readLine());
			int b = Integer.parseInt(br.readLine());
			int c = Integer.parseInt(br.readLine());
			int x = Integer.parseInt(br.readLine());
			int answer = 0;

			for (int i = 0; i < a + 1; i++) {
				for (int j = 0; j < b + 1; j++) {
					for (int  k = 0;  k < c + 1;  k++) {

						int sum = 500*i + 100*j + 50*k;
						if (sum == x) {
							answer++;
						}
					}
				}
			}
			System.out.println(answer);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}

Measured memory_bytes: 32612
w, h, n = map(int, input().split())
l = list()
for i in range(0, n):
    x, y, a = map(int, input().split())
    l.append([x, y, a])

white_check = list()
for a in range(0, h):
    white_check.append([1]*w)

for i in range(0, n):
    a = l[i][2]
    height = l[i][1]
    width = l[i][0]

    if a == 1:
        for y in range(0, h):
            for x in range(0, width):
                white_check[y][x] = 0
    elif a == 2:
        for y in range(0, h):
            for x in range(width, w):
                white_check[y][x] = 0
    elif a == 3:
        for y in range(0, height):
            for x in range(0, w):
                white_check[y][x] = 0
    else:
        for y in range(height, h):
            for x in range(0, w):
                white_check[y][x] = 0

s = 0

for a in range(h):
    s += sum(white_check[a])

print(s)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3],s=0,t,t1,t2;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	t1=a[2]-a[0];
	s+=t1/2;
	t2=a[2]-a[1];
	s+=t2/2;
	t=t1%2+t2%2;
	s+=t/2;
	t%=2;
	if(t!=0)
	{
		s+=2;
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

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

ll LCM(ll a, ll b){
    ll gcd = GCD(a, b);
    ll lcm = (a / gcd) * b;
    return lcm;
}

int main(){
    int N;
    cin >> N;
    vector<ll> T(N);
    rep(i, N) cin >> T[i];
    ll lcm = 1;
    rep(i, N){
        lcm = LCM(lcm, T[i]);
    }
    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int n,x,y;
        cin>>n>>x>>y;
        vector<int> ans(n,0);
        loop(i,1,n-1){
            loop(j,i+1,n){
                if(i<=x && j>=y) ans[j-i-(y-x-1)]++;
                else if(i<=x && j<y) ans[min(x-i+y-j+1,j-i)]++;
                else if(x<i && j>=y) ans[min(i-x+j-y+1,j-i)]++;
                else ans[min(j-i,i-x+y-j+1)]++;
            }
        }
        loop(i,1,n-1) cout<<ans[i]<<"\n";
    }
    return 0;
}

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

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define digits(x) floor(log10(x) + 1)
#define countbits(x) ((int)log2(x)+1)
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define deb(x) cout << #x << "=" << x << endl;
#define test unsigned int tet;cin >> tet;while(tet--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

signed main(void)
{
    	fastio
        int n,W,ans = 0;
        cin >> n >> W;
        int w[n+1],v[n+1];
        for(int i=1; i<=n; i++){
            cin >> w[i] >> v[i];
        }

        vector<int> knapsack[n+1];
        for(int i=1; i<=n; i++){
            knapsack[i].resize(W+1,0);
        }

        knapsack[1][w[1]] = v[1];

        for(int i=2; i<=n; i++){
            for(int j=1; j<=W; j++){
                if(j < w[i]){
                    knapsack[i][j] = knapsack[i-1][j];
                }
                else{
                    knapsack[i][j] = max(knapsack[i-1][j],v[i] + knapsack[i-1][j-w[i]]);
                }
            }
        }

        for(int j=0; j<=W; j++){
            ans = max(ans,knapsack[n][j]);
        }

        cout << ans;

    	return 0;
}



Measured memory_bytes: 81508
dice = list(map(int, input().split()))
mask = {
    'N': (1, 5, 2, 3, 0, 4),
    'R': (0, 2, 4, 1, 3, 5)
    }


for i in range(int(input())):
    a, b = map(int, input().split())

    lim = 0
    while dice[0] != a:
        dice = [dice[x] for x in mask['N']]
        lim += 1
        if lim == 4:
            dice = [dice[x] for x in mask['R']]
            lim = 0
    while dice[1] != b:
        dice = [dice[x] for x in mask['R']]
    print(dice[2])



Measured memory_bytes: 5604
import math
n,d = list(map(int,input().split()))
l = [0]*n
for i in range(n):
    ipt = list(map(int,input().split()))
    l[i] = ipt
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        sm = 0
        for k in range(d):
            sm += abs(l[i][k] - l[j][k])**2
        sm = math.sqrt(sm)
        if sm%1 == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main() {
	ll n;
	cin >> n;
	bool is_one = true;
	vector<ll> a(n);
	for(int i=0;i<n;i++) {
		cin >> a[i];
		if(i != a[i]) {
			is_one = false;
		}
	}
	if(is_one) {
		cout << 3 << endl;
		return 0;
	}

	vector<ll> num(3,0);
	ll ans = 1;
	for(int i=0;i<n;i++) {
		ll same_num = 0;
		for(int j=0;j<3;j++) {
			if(a[i] == num[j]) {
				same_num++;
			}
		}
		ans *= same_num;
		ans %= MOD;
		for(int j=0;j<3;j++) {
			if(a[i] == num[j]) {
				num[j]++;
				break;
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

/* template */

using ll = long long;

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

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

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

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

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

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


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

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

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

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

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


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

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<string> s(n);
    rep(i,0,n){
        cin >> s[i];
    }
    int ans = 0;
    rep(i,0,n){
        int flag = 1;
        rep(j,0,n){
            rep(k,0,n){
                if(s[j][k]!=s[(k+i)%n][(n+j-i)%n]){
                    flag = 0;
                }
            }
        }
        ans += flag;
    }
    ans *= n;
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

int main()
{
	int k;
	std::string s;
	std::cin >> k >> s;
	
	if (s.size() > k) {
		s.resize(k);
		s += "...";
	}
	
	std::cout << s << std::endl;
	
	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge {ll s,t,d;};
typedef vector<vector<Edge>> Graph;

int main(){
  ll V,E; cin>>V>>E;
  Graph G(V);
  REP(i,E) {Edge e; cin>>e.s>>e.t>>e.d; G[e.t].PB(e);}
  vvi dist((1ll<<V),vi(V,INF));
  dist[1][0]=0;

  FOR(i,2,(1ll<<V)) REP(j,V) {
    if((1ll<<j)&i) for(Edge e:G[j]) dist[i][j]=min(dist[i][j],dist[(1ll<<j)^i][e.s]+e.d);
  }

  ll ans=INF;
  for(Edge e:G[0]) ans=min(ans,dist[(1ll<<V)-1][e.s]+e.d);
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
}

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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    deque <int> bst;
    int a;
    cin >> a;
    bst.push_back(a);
    for (int i = 1; i < n; i++) {
        cin >> a;
        auto ptr = lower_bound(bst.begin(), bst.end(), a);
        if (ptr == bst.begin()) {
            bst.push_front(a);
        } else {
            int itr = ptr - bst.begin();
            bst[itr - 1] = a;
        }
    }
    cout << bst.size() << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int[] b=new int[n];
    int ac=0;
    int wa=0;
    for(int i=0;i<m;i++){
      int mon=sc.nextInt()-1;
      String st=sc.next();
      if(b[mon]==-1){
        
      }else if(st.equals("AC")){
        ac++;
        wa+=b[mon];
        b[mon]=-1;
      }else if(st.equals("WA")){
        b[mon]++;
      }
    }
    System.out.println(ac+" "+wa);
  }
}

Measured memory_bytes: 63904
#include <iostream>
#include <cmath>
#define pb push_back
#define ll long long
#define in insert
#define sz(x) ((int)(x).size())
using namespace std;
const int N = 1e5 + 123;
ll a[N];
ll dp[N];

void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
      
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);

    for (int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }

    cout << dp[n] << endl;

}
// 1 5 10 1
int main()
{
    solve();
    //cerr << printf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
    return (0);
}




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

typedef long long int ll;
double PI = 3.14159265358979;

int main(){
 ll N,M;
 cin >> N >> M;
 ll ans = 0;
 ll c = max(N,M) - min(N,M);
 if(max(N,M) - min(N,M) > 1){
     cout << 0 << endl;
     return 0;
 }
 ll a = 1;
 ll b = 1;
 for(int i = 1;i < N+1;i++){
     a = a * i % 1000000007;
 }
 for(int i = 1;i < M+1;i++){
     b = b * i % 1000000007;
 }
 if(c == 0){
 cout << 2 * a * b % 1000000007<< endl;
 }else{
     cout << a * b % 1000000007 << endl;
 }
}

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

int main() {
	string sin,ans;
	while(cin >> sin && sin != "0"){
		queue<string> Q;
		map<string,int> B;
		ans = "";
		Q.push(sin);
		B[sin] = 0;
		while(!Q.empty()){
			string s = Q.front();Q.pop();
			char t = s[0];
			bool allF = true;
			for(int i = 0;i<s.length();i++){
				if(s[i] != t){
					allF = false;
					break;
				}
			}
			if(allF){
				ans = s;
				break;
			}
			for(int i = 1;i<s.length();i++){
				string ss = s;
				if(s[i] != s[i-1]){
					char c = 'r' + 'g' + 'b' - s[i] - s[i-1];
					ss[i] = c;
					ss[i-1] = c;
					if(B[ss] == 0){
						B[ss] = B[s] + 1;
						Q.push(ss);
					}
				}
			}
		}
		if(!ans.empty()){
			cout << B[ans] << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int a,b,d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=a/(b*1.0);
    cout<<d<<" "<<r<<" ";
    cout<<fixed<<setprecision(5)<<f;

}



Measured memory_bytes: 3244
N = int(input()) 
l = list(map(int,input().split()))
mini = max(l) +1
mini_idx = N+1
while mini != sum(l):
    for i, point in enumerate(l):
        if point < mini and point != 0:
            mini = point
            mini_idx = i

    for i, point in enumerate(l):
        if mini_idx != i:
            l[i] = l[i] % mini
print(mini)

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


int  main()
{
    long long  n,i,x,j;
    cin>>n;
    vector<int> a,b;
    for(i=0; i<n; i++)
        {
            cin>>x;
            a.push_back(x);
        }


    for(i=0; i<n; i++)
        {
            cin>>x;
            b.push_back(x);
        }
        i=0;
if(a<b)
while(a!=b)
   next_permutation(a.begin(),a.end()),i++;
   else
while(b!=a)
   next_permutation(b.begin(),b.end()),i++;

cout<<i<<endl;

    return 0;
}


Measured memory_bytes: 256
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let mut a:usize = read!();
    let mut b:usize = read!();
    let mut c:usize = read!();
    if a>=c {
        println!("{} {}",a-c,b);
    }
    else if a+b>=c{
        println!("0 {}",a+b-c);
    }
    else {
        println!("0 0");
    }
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << ((B % A == 0) ? A + B : B - A) << "\n";
}

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

#define max(a,b) a > b ? a : b

int main() {

    string S, T, U;
    int A, B;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (S == U)
    {
        cout << A - 1 << " " << B << endl;
    }
    else
    {
        cout << A << " " << B-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
n,m=map(int,input().split())
dic={}
for i in range(n):
    x,y=map(int,input().split())
    if x not in dic:
        dic[x]=y
    else:
        dic[x]+=y
for i in sorted(dic.items()):
    m-=i[1]
    if m<=0:
        print(i[0])
        break;


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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int M; cin >>M;
    cout << 48 - M << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int a[maxn], L[maxn], R[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		L[i] = max(L[i - 1], a[i]);
	}
	for (int i = n; i >= 1; i--) {
		R[i] = max(R[i + 1], a[i]);
	}
	for (int i = 1; i <= n; i++) {
		cout << max(L[i - 1], R[i + 1]) << endl;
	}
	return 0;
}

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

int f(int n){
	int a = 0;
	while(0 < n){
		a += n%10;
		n /= 10;
	}
	return a;
}
int main(){
	int n;
	cin >> n;
	int sum_digit = f(n);

	if(n%sum_digit == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N,K,l[100];
    cin >> N >> K;
    HAIRETU(N, l);
    sort(l, l+N);
    reverse(l, l+N);
    
    int total=0;
    for (int i = 0; i < K; i++) {
        total += l[i];
    }
    
    
    cout << total << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }

    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }

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

    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

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

    // Kruskal法
    // O(ElogE)
    // Kruskal 法で使用する枝
    using pint = pair<int,int>;
    using Edge = pair<ll, pint>;
    vector<Edge> edges;
    //枝入力
    rep(i,M) {
        int u,v;
        ll c;
        cin>>u>>v>>c;
        edges.push_back({c, pint(u, v)});
    }
    // Kruskal 法
    sort(all(edges));
    // unionfindのスニペット読み込んで
    UnionFind uf(N);
    ll res = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        ll cost = e.first;
        if (uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += cost;
    }
    cout << res << endl;
}


 


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n+1);
    for(int i=0; i<n; i++) cin >> v[i];

    int cnt = 0;
    while(true){
        bool flag = true;
        for(int i=0; i<n; i++) if(v[i] != 0) flag = false;
        if(flag) break;

        int l = 0;
        while(v[l] == 0) l++;

        int r = l;
        while(r < n && v[r+1] != 0) r++;

        for(int i=l; i<=r; i++) v[i]--;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
const int inf=1e9;
int main() {
 
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
    	ll n;cin>>n;
    	ll a[n];
    	rep(i,n)cin>>a[i];
    	map<ll,ll> m;
    	rep(i,n)m[a[i]]++;
    	ll ans=0;
    	for(auto j:m){
    		ans+=((j.snd)*(j.snd-1)/2);
    	}
    	rep(i,n){
    		ll temp;
    		ll c=m[a[i]];
    		temp=ans-c*(c-1)/2;
    		c--;
    		temp+=c*(c-1)/2;
    		cout<<temp<<endl;
    	}
    }   
    return 0;   
}   	

Measured memory_bytes: 11136
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var N = one[0];
  var D = one[1];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = myconv(next(),4);
  }
  
  var output = 0;
  for(var i = 0; i < N - 1; i++){
    for(var j = i + 1; j < N; j++){
      var sum = 0;
      for(var k = 0; k < D; k++){
        sum += Math.pow(Math.abs(list[i][k] - list[j][k]),2);
      }
      myerr(Math.sqrt(sum));
      if(Math.sqrt(sum) % 1 == 0){
         output++;
      }
    }
  }
  myout(output);
}

Measured memory_bytes: 7756
// Coder: @SumitRaut
#include <bits/stdc++.h>
#define speedup ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
const int mod = 1e9+7;
template<typename T> T pwm(T a,T b,T md=mod) { T p=1,one=1; while(b) { if(b&one) p=p*a%md; a=a*a%md; b >>=1; } return p; }

using namespace std;
class Timer { chrono::high_resolution_clock::time_point start_t, end_t; public: Timer() { start_t=chrono::high_resolution_clock::now(); } ~Timer() { end_t = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(end_t-start_t); cerr<<"\nRunTime: "<<duration.count()<<"ms"<<'\n'; } };

void solve() {
    ll n;
    cin>>n;
    cout<<((pwm(10ll,n)-2ll*pwm(9ll,n)%mod+pwm(8ll,n))%mod+mod)%mod<<'\n';
}
int main()
{
    speedup;
    #ifndef ONLINE_JUDGE
    Timer timer;
    #endif
    solve();
    return 0;
}


Measured memory_bytes: 3600
<?php
/**
 * Created by PhpStorm.
 * User: souta
 * Date: 2018/02/13
 * Time: 9:30
 */

# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $a, $b);

if( ($a*$b)%2 == 0 ){
    echo 'Even'."\n";
}else{
    echo 'Odd'."\n";
}

?>

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

bool check(string s)
{
    if (s.size() % 2 != 0)
    {
        cout << "error" << endl;
        return false;
    }
    else
    {
        bool ans = true;
        int ssize = s.size();
        for (int i = 0; i < ssize / 2; i++)
        {
            if (s[i] != s[ssize / 2 + i])
            {
                ans = false;
                break;
            }
        }
        return ans;
    }
}

int main()
{
    string s;
    cin >> s;
    int ssize = s.size();
    for (int i = 1; i < ssize; i++)
    {
        int sizetmp = s.size();
        //       cout << "sizetmp=" << sizetmp << endl;
        if ((sizetmp - 1) % 2 != 0)
        {
            s = s.erase(sizetmp - 1);
            continue;
        }
        else
        {
            s = s.erase(sizetmp - 1);
            //         cout << "s=" << s << endl;
            if (check(s))
            {
                cout << s.size() << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256