akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	int n, m,k;
	cin >> n >> m >> k;
	bool ans = false;
	rep(i, 0, n + 1) {
		rep(j, 0, m + 1) {
			int s = i * (m-j) + j * (n-i);
			if (s == k)ans = true;
		}
	}
	Yes(ans)
	return 0;
}

Measured memory_bytes: 256
import sys
def sol(s,t):
    m = sys.maxsize
    for i in range(len(s)-len(t)+1):
        c = 0
        for j in range(i,i+len(t)):
            if t[j-i]!=s[j]:
                c+=1
        m = min(m,c)
    print(m)
s = input()
t = input()
sol(s,t)


Measured memory_bytes: 67504
import sys
sys.setrecursionlimit(10**6)

N=int(input())
h=list(map(int,input().split()))
memo=[-1]*(N+1)
def a(j):
    if j==0:
        return 0
    elif j==1:
        return abs(h[1]-h[0])
    else:
        if memo[j]==-1:
            memo[j]=min(a(j-1)+abs(h[j]-h[j-1]),a(j-2)+abs(h[j]-h[j-2]))
        return memo[j]

print(a(N-1))

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

using namespace std;

const int maxn = 2e5;
vector<pair<int, int>> g[maxn];

int c[maxn];

int colors = 0;

void dfs(int v, int p, int pc) {
	int cur_color = 0;
	for (auto edge : g[v]) {
		if (edge.first == p)continue;
		cur_color++;
		if (cur_color == pc) {
			cur_color++;
		}
		c[edge.second] = cur_color;
		dfs(edge.first, v, cur_color);
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back({ b,i });
		g[b].push_back({ a,i });
	}
	for (int i = 1; i <= n; i++) {
		colors = max(colors, (int)g[i].size());
	}
	dfs(1, -1, -1);
	cout << colors << endl;
	for (int i = 0; i < n - 1; i++) {
		cout << c[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double PI = acos(-1);
const double EPS = 1e-7; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) - (m) < EPS)
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
// !!! 誤差に注意 !!! (掛け算したものとかなり小さいものを比べているので)
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}


// 2円の交点
VP crosspointCC(Point a, double ar, Point b, double br) {
  VP ps;
  Point ab = b-a;
  double d = abs(ab);
  double crL = (norm(ab) + ar*ar - br*br) / (2*d);
  if (EQ(d, 0) || ar+EPS < abs(crL)) return ps;

  // 円が接する時、こことEPSの設定をうまくしないとsqrt(sub)がnanになるので注意
  double sub = ar*ar - crL*crL;
  if(EQ(sub,0)) sub = 0;

  Point abN = ab * Point(0, sqrt(sub) / d);
  Point cp = a + crL/d * ab;
  ps.push_back(cp + abN);
  if (!EQ(norm(abN), 0)) ps.push_back(cp - abN);
  return ps;
}



Point READ(){
    double x,y;
    cin >>x >>y;
    return {x,y};
}

int main(){
    int n;
    while(cin >>n,n){
        VP p(n);
        vector<double> v(n);
        rep(i,n){
            p[i] = READ();
            cin >>v[i];
        }

        auto check = [&](double t){
            vector<double> r(n);
            rep(i,n) r[i] = v[i]*t;

            VP cand;
            rep(i,n)rep(j,i){
                double d = abs(p[i]-p[j]);
                if( d+EPS > r[i]+r[j]) return false;

                for(Point cp:crosspointCC(p[i],r[i],p[j],r[j])) cand.pb(cp);
            }
            rep(i,n) cand.pb(p[i]);

            for(Point c:cand){
                bool ok = true;
                rep(i,n){
                    double tt = abs(c-p[i])/v[i];
                    if(tt > t+EPS){
                        ok = false;
                        break;
                    }
                }
                if(ok) return true;
            }
            return false;
        };

        double ng=0, ok=100;
        rep(loop,40){
            double mid = (ng+ok)/2;
            if(check(mid)) ok = mid;
            else ng = mid;
        }
        printf("%.10f\n", ok);
    }
    return 0;
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



void test_case()
{
    int x;
    cin>>x;

    cout<<1-x<<endl;
    
    
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

using namespace std;


int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans1 = a * c;
    long long ans2 = a * d;
    long long ans3 = b * c;
    long long ans4 = b * d;
    cout << max({ans1, ans2, ans3, ans4}) << "\n";
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int dp[] = new int[n + 1];
        dp[0] = 0;
        dp[1] = 1;
        for (int i = 1; i < n + 1; i++) {
            dp[i] = 1 + dp[i - 1];
            int j = 6;
            while (j <= i) {
                int tmp = 1 + dp[i - j];
                j *= 6;
                dp[i] = Math.min(dp[i], tmp);
            }
            j = 9;
            while (j <= i) {
                int tmp = 1 + dp[i - j];
                j *= 9;
                dp[i] = Math.min(dp[i], tmp);
            }
        }
        System.out.println(dp[n]);

    }
}

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

int main(){
  int a,b,c;

  scanf("%d %d %d", &a, &b, &c);

  c -= a - b;

  if(c < 0) printf("0\n");

  else printf("%d\n", c);

  return 0;
}

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

fn main() {
    let mut a:usize = read!();
    let b:usize = read!();
    for i in 0..10000 {
        if (i*8)/100 == a{
            if (i*10)/100 == b {
                println!("{}",i);
                exit(0);
            }
        }
    }
    println!("-1");
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
char str[12];
int main()
{
	cin>>str;
	int n=strlen(str);
	long long ret=0;
	for(int S=0;S<1<<(n-1);S++)
	{
		long long now=0,sum=0;
		for(int i=0;i<n;i++)
		{
			now*=10;
			now+=str[i]-'0';
			if(i<n-1 && (S>>i&1))
			{
				sum+=now;
				now=0;
			} 
		}
		sum+=now;
		ret+=sum;
	}
	cout<<ret<<"\n";
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
typedef long long ll;
typedef long double ld;

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

 while (a > 0)
 {

  c -= b;
  if (c <= 0)
  {
   cout << "Yes" << endl;
   break;
  }

  a -= d;
  if (a <= 0)
  {
   cout << "No" << endl;
   break;
  }
 }
 return 0;
};


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

int main() {
  int N; cin >> N;
  double T, A; cin >> T >> A;
  double h[N];
  int res;
  double temp = 1000000.0;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
    double t = T-0.006*h[i];
    if (abs(temp-A) > abs(t-A)) {
      temp = t;
      res = i+1;
    }
  }
  cout << res << endl;
}
  

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

bool check(ll k, ll N, ll M) {

}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> f;
    for ( ll i = 1; i * i <= M ; i++ ) {
        if ( M % i == 0 ) f.push_back(i);
    }
    ll ans = -1;
    for ( int i = 0; i < f.size(); i++ ) {
        ll k = M / f[i];
        if ( M / k >= N ) {
            ans = k;
            break;
        }
    }
    if ( ans < 0 ) {
        for ( int i = f.size()-1; i >= 0; i-- ) {
            ll k = f[i];
            if ( M / k >= N ) {
                ans = k;
                break;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int keta(int N)
{
        int cnt;
        if (N < 10)
        {
                cnt = N;
        }
        else if (N < 1000)
        {
                if (N - 100 + 1 > 0)
                {
                        cnt = 9 + (N - 100 + 1);
                }
                else
                {
                        cnt = 9;
                }
        }
        else if (N < 100000)
        {
                if (N - 10000 + 1 > 0)
                {
                        cnt = 9 + 900 + (N - 10000 + 1);
                }
                else
                {
                        cnt = 9 + 900;
                }
        }
        else
        {
                cnt = 9 + 900 + 90000;
        }

        return cnt;
}

int main()
{
        int N;
        cin >> N;
        int ans = keta(N);
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        int[][] c = Enumerable.Repeat(0, 3).Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToArray()).ToArray();
        
        if ((c[0][1] - c[0][0]) == (c[1][1] - c[1][0]) && (c[2][1] - c[2][0]) == (c[1][1] - c[1][0]))
        {
            
        }
        else
        {
            Console.WriteLine("No");
            return;
        }

        if ((c[0][2] - c[0][1]) == (c[1][2] - c[1][1]) && (c[2][2] - c[2][1]) == (c[1][2] - c[1][1]))
        {

        }
        else
        {
            Console.WriteLine("No");
            return;
        }

        if ((c[1][0] - c[0][0]) == (c[1][1] - c[0][1]) && (c[1][2] - c[0][2]) == (c[1][1] - c[0][1]))
        {

        }
        else
        {
            Console.WriteLine("No");
            return;
        }

        if ((c[2][0] - c[1][0]) == (c[2][1] - c[1][1]) && (c[2][2] - c[1][2]) == (c[2][1] - c[1][1]))
        {

        }
        else
        {
            Console.WriteLine("No");
            return;
        }

        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 13524
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//おまじない



int main() {

	char a, b;
	cin >> a >> b;

	if (a == 'H'&&b == 'H') {
		cout << 'H' << endl;
	}
	if (a == 'H'&&b == 'D') {
		cout << 'D' << endl;
	}
	if (a == 'D'&&b == 'H') {
		cout << 'D' << endl;
	}
	if (a == 'D'&&b == 'D') {
		cout << 'H' << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,c,d;
    double e;

    scanf("%d %d", &a, &b);
    c = a/b;
    d = a%b;
    e = (double)(a)/(double)(b);

    printf("%d %d %0.5f\n", c,d,e);

    return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  int x; cin >> x;
  if (x == 0) cout << 1 << endl;
  else        cout << 0 << endl;
  return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

void solve(long long A, long long B, long long Q, std::vector<long long> s, std::vector<long long> t, std::vector<long long> x){
    REP(i, Q){
        vector<LL> s_move, t_move;
        int sm = distance(s.begin(), lower_bound(ALL(s), x[i]));
        if(0 <= sm && sm < s.size()) { s_move.PB(s[sm] - x[i]); }
        if(0 <= sm-1 && sm-1 < s.size()) { s_move.PB(s[sm-1] - x[i]); }

        int tm = distance(t.begin(), lower_bound(ALL(t), x[i]));
        if(0 <= tm && tm < t.size()) { t_move.PB(t[tm] - x[i]); }
        if(0 <= tm-1 && tm-1 < t.size()) { t_move.PB(t[tm-1] - x[i]); }

        LL min_cost = INFL;
        REP(j, s_move.size()){
            REP(k, t_move.size()){
                if(s_move[j] < 0 && t_move[k] < 0){
                    min_cost = min(min_cost, max(s_move[j] * -1, t_move[k] * -1));
                }else if(s_move[j] > 0 && t_move[k] > 0){
                    min_cost = min(min_cost, max(s_move[j], t_move[k]));
                }else{
                    min_cost = min(min_cost, abs(s_move[j]) * 2 + abs(t_move[k]));
                    min_cost = min(min_cost, abs(s_move[j]) + abs(t_move[k]) * 2);
                }
            }
        }

        cout << min_cost << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> s(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&s[i]);
    }
    std::vector<long long> t(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&t[i]);
    }
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&x[i]);
    }
    solve(A, B, Q, std::move(s), std::move(t), std::move(x));
    return 0;
}


Measured memory_bytes: 3712
#!/usr/bin/env ruby

cls = {
  'light fly': 48.0,
  'fly': 51.0,
  'bantam': 54.0,
  'feather': 57.0,
  'light': 60.0,
  'light welter': 64.0,
  'welter': 69.0,
  'light middle': 75.0,
  'middle': 81.0,
  'light heavy': 91.0,
  'heavy': 151.0
}

while line = gets
  w = line.chomp!.to_f

  cls.each do |cl, max|
    if max >= w
      puts cl
      break
    end
  end
end

Measured memory_bytes: 8736
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll n;
vector<ll> a(3030);
vector<vector<ll>> dp(3030, vector<ll>(3030, -1));

ll dfs(ll l, ll r) {
	if(dp[l][r] != -1) return dp[l][r];
	ll ret = 0;
	if(l == r) {
		if((n - (r - l + 1)) % 2) ret = -a[l];
		else ret = a[l];
	}
	else {
		if((n - (r - l + 1)) % 2) {
			ret = min(dfs(l + 1, r) - a[l], dfs(l, r - 1) - a[r]);
		} else {
			ret = max(dfs(l + 1, r) + a[l], dfs(l, r - 1) + a[r]);
		}
	}
	return dp[l][r] = ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i, n) cin >> a[i];
	cout << dfs(0, n - 1) << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 72320
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
    while(t--){
      string s;
      cin>>s;
      int i,j,n=s.size();
      string ans="keyence";
      if(s==ans)
      {
        cout<<"YES";
        return 0;
      }
      fr(i,0,n)
      {
        fr(j,i,n)
        {
          string temp;
          int k;
          fr(k,0,i)
          temp+=s[k];
          fr(k,j+1,n)
          temp+=s[k];
          if(temp==ans)
          {
            cout<<"YES";
            return 0;
          }
        }
      }
      cout<<"NO";
      
       
    }
  return 0;
  }



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

int main(){
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,ll> > data(n);

  rep(i,n){
    ll a,b;
    cin >> a >> b;
    data[i] = make_pair(a,b);
  }
  sort(all(data));
  ll left = m;
  ll ans = 0;

  //rep(i,n) cout<<data[i].first<<data[i].second<<endl;

  rep(i,n){
    ll cost = data[i].first;
    ll num = data[i].second;
    //cout<<cost<<numdi;
    if(left > num){
      ans += cost * num;
      left -= num;
    }
    else{
      ans += cost * left;
      break;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}

void porm(string &N,string S, ll i, ll sum, string &ans){
  if(4 == i){
    if(sum == 7)
      ans = S + "=7";
    return;
  }
  string pS = S + "+";
  pS += N.at(i);
  ll psum = sum + (N.at(i) - '0');
  porm(N, pS, i+1, psum, ans);
  string mS = S + "-";
  mS += N.at(i);
  ll msum = sum - (N.at(i) - '0');
  porm(N, mS, i+1, msum, ans);
}

int main() {
  IN(string, N);
  string ans = "";
  string S = to_string(N.at(0) - '0');
  ll sum = N.at(0) - '0';
  porm(N, S, 1, sum, ans);
  OUT(ans);
}




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

bool fun(const pair<int,int>& p1, const pair<int,int> & p2 ) { 
    return p1.second > p2.second ; 
}

void solve() {
    int n , m ; 
    cin >> n >> m ;
    vector<int> a(n) ;
    ll sum = 0 ; 
    for(int i =0 ; i < n; ++i) {
        cin >> a[i] ;
        sum += a[i] ; 
    }

    sort(a.begin(), a.end()) ; 
    vector<pair<int,int>> b(n) ; 
    int x , y ; 
    for(int i= 0; i < m ; ++i) {
        cin >> x >> y ; 
        b.pb(make_pair(x,y)) ;
    }
    sort(b.begin(), b.end(), fun) ;
    int cur = 0 ; 
    for(int i = 0; i < m ; ++i)  {
        int cnt = b[i].first ; 
        while(cnt && cur < n ) {
            if(b[i].second < a[cur]) {
                cout << sum ; 
                return ; 
            }
            sum += b[i].second - a[cur] ; 
            cnt-- ; 
            cur++;
        }
    }
    cout << sum ; 

}

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

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


Measured memory_bytes: 6140
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private boolean check(char[] S, char[] T, int si, int sj) {
        int N = S.length;
        for (int i = 0; i < N; i++) {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        }
        return true;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        boolean rotatable = false;
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        
        System.out.println("No");

        return;
    }

}

Measured memory_bytes: 21844
if __name__ == '__main__':
	n,m = map(int,input().split())

	A = []
	for i in range(m):
		a,b = map(int,input().split())
		A.append([a,b,i,""])

	#各内部配列でソートする
	B = sorted(A,key=lambda x:(x[0],x[1]))

	no = 1
	tmp = 0
	for b in B:
		if tmp == b[0]:
			no += 1
		else:
			tmp = b[0]
			no = 1

		#市通番
		cityno = str(b[0]).zfill(6) + str(no).zfill(6)
		b[3] = cityno

	#再ソートする
	C = sorted(B,key=lambda x:(x[2]))
	
	for c in C:
		print(c[3])


Measured memory_bytes: 38308
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
	int n,zs,i,c,j,k,l,p,q,d;
	while((cin>>n)&&n!=0)
	{ 
		int temp3=0,a[100][100],b[100][100];
		//int (*a)[100],(*b)[100];
		//a=new int[100][100],b=new int[100][100];
		int *temp0=new int[n],*temp=new int[n];
		memset(b,0,sizeof(b));
		memset(temp,0,sizeof(temp));
		for(c=0;c<n;c++)
		{
			for( d=0;d<n;d++)
			{
				cin>>a[c][d];
			}
		}
		for(i=0;i<n;i++)
		{
			zs=a[i][0];
			temp[i]=0;
			for(j=1;j<n;j++)
			{if(zs>a[i][j]) 
			{
				zs=a[i][j];
				temp[i]=j;//隶ー蠖穂ス咲スョ蜿キ
			}
			}
			for(j=0;j<n;j++)
			{
				if(zs==a[i][j])
     			b[i][j]++;
			}
		}
		for(k=0;k<n;k++)
		{
			zs=a[0][k];
			temp0[k]=0;
			for(l=1;l<n;l++)
			{
				if(a[l][k]>zs)
				{
					zs=a[l][k];
					temp0[k]=l;
				}
			}
			for(l=0;l<n;l++)
			{
				if(zs==a[l][k])
		        b[l][k]++;
			}
		}
		for(p=0;p<n;p++)
		{
			if(temp3==1)break;
			for(q=0;q<n;q++)
             if(b[p][q]==2)
			 {
				 cout<<a[p][q]<<endl;temp3=1;break;}
		}
		if(temp3==0)
			cout<<"0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh, Dw = map(int, input().split())
Dh -= 1
Dw -= 1
S = [input() for _ in range(H)]

dh = [-1, 0, 0, 1]
dw = [0, 1, -1, 0]

INF = pow(10, 10)
seen = [[INF] * W for _ in range(H)]
seen[Ch][Cw] = 0
q = deque()
q.append([Ch, Cw])

while q:
    th, tw = q.pop()
    for i in range(4):
        nh = th + dh[i]
        nw = tw + dw[i]
        if nh < 0 or nh > H - 1 or nw < 0 or nw > W - 1:
            continue
        if S[nh][nw] == '#':
            continue
        if seen[nh][nw] <= seen[th][tw]:
            continue
        seen[nh][nw] = seen[th][tw]
        q.append([nh, nw])
    for dh2 in range(-2, 3):
        for dw2 in range(-2, 3):
            if dh2 == 0 and dw2 == 0:
                continue
            nh = th + dh2
            nw = tw + dw2
            if nh < 0 or nh > H - 1 or nw < 0 or nw > W - 1:
                continue
            if S[nh][nw] == '#':
                continue
            if seen[nh][nw] <= seen[th][tw] + 1:
                continue
            seen[nh][nw] = seen[th][tw] + 1
            q.appendleft([nh, nw])

if seen[Dh][Dw] is INF:
    print(-1)
else:
    print(seen[Dh][Dw])

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

using ll = long long;
using namespace std;

ll mod = 1e9+7;

#define int ll

std::vector<int> PrimeFactoring(int N){
    std::vector<int> ans;
    bool f = true;
    while(N != 1 && f){
        for(int a = 2;a <= N && f;a++){
            if(N % a == 0){
                N /= a;
                ans.push_back(a);
                break;
            }
            if(a > sqrt(N)){
                f = false;
                break;
            }
        }
    }
    if(N != 1)ans.push_back(N);
    return ans;
}

signed main() {
    ll A, B;cin >> A >> B;
    vector<int> X = PrimeFactoring(A);
    vector<int> Y = PrimeFactoring(B);
    //cout<<"AA"<<endl;
    set<int> Q, W;
    for(int i : X){
        Q.insert(i);
    }
    for(int j : Y){
        W.insert(j);
    }
    ll ans = 0;
    for(auto a : Q){
        if(W.find(a) != W.end())ans++;
    }
    cout<<ans + 1<<endl;
}


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

int main() {
    int n;cin>>n;
    int a[n];
    for (int i=0;i<n;i++) {
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(a,a+n);
    ll ans=0;
    for (int i=0;i<n;i++)
        ans+=abs(a[i]-a[n/2]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
from heapq import heappush, heappop

n = int(input())
A = list(map(int, input().split()))

hq = []
for i in range(n):
    heappush(hq, (-A[i], i))
    
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    x, pi = heappop(hq)
    for l in range(i+1):
        r = i-l
        dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi-l)*A[pi])
        dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((n-r-1)-pi)*A[pi])

ans = 0
for i in range(n+1):
    ans = max(ans, dp[n][i])
print(ans)

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

int main()
{
	int N;
	int l, r;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> l>> r;
		ans += r - l + 1;
	}
	cout << ans;

    return 0;
}

Measured memory_bytes: 256
s = input()
t = "".join([m for m in s if m != "x"])
u = t[::-1]
#print(t,u)
if t != u:
    print(-1)
    exit()
else:
    i = 0
    j = len(s)-1
    ans = 0
    while i <= j:
        if s[i] != s[j]:
            if s[i] == "x":
                ans += 1
                i += 1
            else:
                ans += 1
                j -= 1
        else:
            i += 1
            j -= 1
    print(ans)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>A;
    for(int i=0;i<n;i++)
    {
        ll c;
        cin>>c;
        A.push_back(c);
    }
    int r = 0;
    long long ans =0;
    int  sum =0;
    for(int l=0;l<n;++l){
        while(r<n & (sum ^ A[r])==(sum + A[r])){
            sum += A[r];
            r++;
        }
        ans += r - l;
        if(l==r)ans++;
        else {
            sum -= A[l];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2420
n = gets.to_i
d = n.times.map{ gets.split.map(&:to_i) }

if (n-2).times.any?{|i| d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]}
  puts "Yes"
else
  puts "No"
end

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

using namespace std;

typedef long long int ll;

const int N = (int) 4e2 + 10;
const ll oo = (ll) 1e18;

int n;
int a[N];
ll prefix[N];
ll memo[N][N];

ll sum(int l, int r) {
    ll ans = prefix[r];
    if(l > 0) ans -= prefix[l - 1];
    return ans;
}

ll dp(int l, int r) {
    if(l == r) return 0;
    ll &ans = memo[l][r];
    if(ans != -1) return ans;
    ans = oo;
    for(int i = l; i < r; ++i) {
        
        ll tot=sum(l,r);
        ll cur = tot + dp(l, i) + dp(i + 1, r);
        
        ans = min(ans, cur);
    }
    return ans;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    memset(memo, -1, sizeof(memo));
    for(int i = 0; i < n; ++i) {
        prefix[i] = a[i];
        if(i > 0) prefix[i] += prefix[i - 1];
    }
    cout << dp(0, n - 1) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>

using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORR(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair

#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9 + 7;

const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

int frog(vector<int>& heights, int N, int currentIteration)
{
    if (currentIteration + 2 == N)
    {
        return abs(heights[currentIteration] - heights[currentIteration + 1]);
    }
    else if (currentIteration + 2 >= N)
    {
        return 0;
    }

    return min(
        frog(heights, N, currentIteration + 1) + abs(heights[currentIteration] - heights[currentIteration + 1]),
        frog(heights, N, currentIteration + 2) + abs(heights[currentIteration] - heights[currentIteration + 2]));
}


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

    vector<int> heights(N, 0);
    vector<int> dp(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> heights[i];
    }

    dp[1] = abs(heights[0] - heights[1]);
    for (int i = 2; i < N; i++)
    {
        dp[i] = min(dp[i - 1] + abs(heights[i - 1] - heights[i]), abs(dp[i - 2] + abs(heights[i] - heights[i - 2])));
    }
    
    cout << dp[N - 1] << endl;
    //cout << frog(heights, N, 0);
    return 0;
}

Measured memory_bytes: 1024
def swap(str, a, b)
  tmp = str.dup
  tmp[a], tmp[b] = tmp[b], tmp[a]
  return tmp
end

def breadth_first_search(answers, queue, move_list)
  loop do
    move_num, search = queue.shift
    break unless search

    a = search.index('0')
    move_list[a].each do |b|
      next_str = swap(search, a, b)
      next if answers[next_str]
      answers[next_str] = move_num + 1
      queue.push([move_num + 1, next_str])
    end
  end
  return answers
end

move_list = [[1, 4], [0, 2, 5], [1, 3, 6], [2, 7], [0, 5], [1, 4, 6], [2, 5, 7], [3, 6]].freeze
goal = '01234567'
answers = {goal => 0}
queue = [[0, goal]]
answers = breadth_first_search(answers, queue, move_list)

while gets
  s = $_.chomp.gsub(' ', '')
  puts answers[s]
end

Measured memory_bytes: 9172
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <ctime>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
#define ll long long
#define endl '\n'
const int MAX = 2e5 + 4;
const int MOD = 1e9 + 7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a[3][3], c[3][3] = { 0 };
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	vector<int> b(n);
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				if (a[j][k] == b[i])
					c[j][k] = 1;
			}
		}
	}
	int flag = 0;
	for (int i = 0; i < 3; i++)
	{
		if (c[i][0] && c[i][1] && c[i][2])
			flag = 1;
		if (c[0][i] && c[1][i] && c[2][i])
			flag = 1;
	}
	if (c[0][0] && c[1][1] && c[2][2])
		flag = 1;
	if (c[2][0] && c[1][1] && c[0][2])
		flag = 1;
	if (flag) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

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

	try{
	    String str = reader.readLine();
	    String origin = "CODEFESTIVAL2016";
	    int count = 0;
	    
	    for(int i = 0; i < 16; i++){
		if(str.charAt(i) != origin.charAt(i))
		    count++;			      		
	    }

	    System.out.println(count);
	    
	}catch(IOException e){
	    System.out.println(e);
	}	
    }
}


Measured memory_bytes: 8148
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Mod = int(1e9) + 7

func main() {
	S = ReadString()

	baser = make([]int, len(S))
	b := 1
	for i := 0; i < len(S); i++ {
		baser[i] = b
		b *= 10
		b %= 13
	}

	memo = make([][]*int, len(S))
	for i := 0; i < len(S); i++ {
		memo[i] = make([]*int, 13)
	}
	fmt.Println(recur(0, 0))
}

var S string
var baser []int
var memo [][]*int

func recur(i int, r int) int {
	if i == len(S) {
		if r == 5 {
			return 1
		}
		return 0
	}
	if memo[i][r] != nil {
		return *memo[i][r]
	}
	base := baser[len(S)-i-1]
	ans := 0
	if S[i] == '?' {
		for x := 0; x <= 9; x++ {
			ans += recur(i+1, (r+x*base)%13)
			ans %= Mod
		}
	} else {
		x := int(S[i] - '0')
		ans += recur(i+1, (r+x*base)%13)
		ans %= Mod
	}
	memo[i][r] = &ans
	return ans
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 35524
H,W = map(int,input().split())
K = []
for i in range(H):
  K.append(list(input()))
dp = []
for i in range(H):
  L = [0]*W
  dp.append(L)
dp[0][0] = 1
for i in range(H):
  for j in range(W):
    if K[i][j] == '.':
      if i == 0:
        if j >= 1:
          dp[i][j] = dp[i][j-1]
      else:
        if j == 0:
          dp[i][j] = dp[i-1][j]
        else:
          dp[i][j] = dp[i-1][j]+dp[i][j-1]
print(dp[i][j]%(10**9+7))

Measured memory_bytes: 165264
<?php
$n = trim(fgets(STDIN));
$ac = 0;
$wa = 0;
$tle = 0;
$re = 0;
for($i = 0; $i < $n; $i++){
    $str = trim(fgets(STDIN));
    if($str == "AC"){
        $ac++;
    } elseif($str == "WA"){
        $wa++;
    } elseif($str == "TLE"){
        $tle++;
    } else {
        $re++;
    }
}

echo "AC x ".$ac."\n";
echo "WA x ".$wa."\n";
echo "TLE x ".$tle."\n";
echo "RE x ".$re;

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int x = n % 10;
    if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
        cout << "hon\n";
    }
    else if(x == 0 || x == 1 || x == 6 || x == 8){
        cout << "pon\n";
    }
    else{
        cout << "bon\n";
    }
}


Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define N_ 20100
#define M_ 101000
struct Edge {
	int b, e, f;
};
struct MaxFlow {
	Edge E[M_];
	vector<int>G[N_];
	int EC, flow, PV[N_], Q[N_], Level[N_], n, source, sink, INF = 1e9;
	void init(int N, int S, int T) {
		source = S, sink = T, flow = EC = 0;
		n = N;
		for (int i = 0; i <= n; i++)G[i].clear();
	}
	void Add_Edge(int a, int b, int f) {
		G[a].push_back(EC);
		G[b].push_back(EC + 1);
		E[EC++] = { a,b,f };
		E[EC++] = { b,a,0 };
	}
	int BlockFlow(int a, int f) {
		if (a == sink)return f;
		for (int &i = PV[a]; i >= 0; i--) {
			int t = G[a][i];
			if (E[t].f && Level[E[t].e] == Level[a] + 1) {
				int ff = BlockFlow(E[t].e, min(E[t].f, f));
				if (ff) {
					E[t].f -= ff;
					E[t ^ 1].f += ff;
					return ff;
				}
			}
		}
		return 0;
	}
	bool GetLevel() {
		int head = 0, tail = 0, i;
		for (i = 1; i <= n; i++)Level[i] = -1;
		Q[++tail] = source; Level[source] = 0;
		while (head < tail) {
			int x = Q[++head];
			for (auto &t : G[x]) {
				if (E[t].f && Level[E[t].e] == -1) {
					Level[E[t].e] = Level[x] + 1;
					Q[++tail] = E[t].e;
				}
			}
		}
		return Level[sink] != -1;
	}
	void Dinic() {
		int i, t;
		flow = 0;
		while (GetLevel()) {
			for (i = 1; i <= n; i++)PV[i] = G[i].size() - 1;
			while (t = BlockFlow(source, INF)) {
				flow += t;
			}
		}
	}
}G1;
int w[110][110], n, m, vis[110][110], T[110][110], R[110][110];
int C[110][110];
int main() {
	int i, j, k;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			scanf("%d", &w[i][j]);
			C[i][((w[i][j] - 1) / m)+1]++;
		}
	}
	for (i = 1; i <= m; i++) {
		G1.init(n + n + 2, n + n + 1, n + n + 2);
		for (j = 1; j <= n; j++) {
			G1.Add_Edge(G1.source, j, 1);
			G1.Add_Edge(n + j, G1.sink, 1);
			for (k = 1; k <= n; k++) {
				if (C[j][k]) {
					G1.Add_Edge(j, n+k,1);
				}
			}
		}
		G1.Dinic();
		for (j = 1; j <= n; j++) {
			for (auto &t : G1.G[j]) {
				Edge tp = G1.E[t];
				if (tp.e > n && tp.e <= n + n && !tp.f) {
					for (k = 1; k <= m; k++) {
						if (!vis[j][k] && (w[j][k] - 1) / m + 1 == tp.e - n) {
							T[j][i] = w[j][k];
							vis[j][k] = 1;
							break;
						}
					}
					C[j][tp.e - n]--;
				}
			}
		}
	}

	for (i = 1; i <= n; i++)for (j = 1; j <= m; j++)vis[i][j] = 0;
	for (i = 1; i <= m; i++) {
		for (j = 1; j <= n; j++) {
			int Mn = 1e9, pv = 0;
			for (k = 1; k <= n; k++) {
				if (!vis[k][i] && Mn > T[k][i]) {
					Mn = T[k][i];
					pv = k;
				}
			}
			vis[pv][i] = 1;
			R[j][i] = T[pv][i];
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			printf("%d ", T[i][j]);
		}
		puts("");
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			printf("%d ", R[i][j]);
		}
		puts("");
	}
}

Measured memory_bytes: 1408
s = input()
m = 0
for i in range(len(s)):
    if (i + 1) % 2 == 0:
        t = s[:i+1]
        b = True
        for j in range(len(t) // 2):
            if t[j] != t[j+len(t)//2]:
                b = False
        if b:
            if s != t:
                m = max(m, len(t))
print(m)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

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

int main(){
    string inp_str, judge_str;
    cin >> inp_str >> judge_str;

    bool success = false;
    rep(start, inp_str.size()){
        string tmp = "";
        for(int i = start; i < start+inp_str.size(); i++){
            tmp += inp_str[i%inp_str.size()];
        }

        if(tmp == judge_str){
            success = true;
        }
    }

    if(success){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 50000001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

int main() {
	ll x;
	cin >> x ;

	while (true) {
		if (IsPrime(x)) {
			cout << x << endl;
			break;
		}
		x++;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 1000000;

class Node{
  public:
        int value;
        Node *prev, *next;
};

class DoublyLinkedList{
        Node *nil;
  public:
        DoublyLinkedList(){
                nil = new Node;
                nil->prev = nil;
                nil->next = nil;
        };
        void print(){
                Node *i = nil->next;
                while(i!=nil){
                        cout<< i->value;
                        if(i->next!=nil) cout<<" ";
                        i = i->next;
                }
                cout<<endl;
        };
        void insert(int v){
                Node *a = new Node;
                a->value = v;
                a->prev = nil;
                a->next = nil->next;
                a->next->prev = a;
                nil->next = a;
        };
        void deletekey(int v){
                if(nil->next==nil) return;
                Node *j = nil->next;
                while(j!=nil && j->value!=v){
                        j = j->next;
                }
                if(j!=nil){
                        j->prev->next = j->next;
                        j->next->prev = j->prev;
                        delete j;
                }
        };
        void deleteFirst(){
                if(nil->next==nil) return;
                Node *i = nil->next;
                nil->next = i->next;
                i->next->prev = nil;
                delete i;
        };
        void deleteLast(){
                if(nil->next==nil) return;
                Node *i = nil->prev;
                nil->prev = i->prev;
                i->prev->next = nil;
                delete i;
        };
};
int main(){
        DoublyLinkedList a;
        int n;
        cin>>n;
        string s;
        int v;
        for(int i=0;i<n;i++){
                cin >>s;
                if(s=="insert") {cin>>v; a.insert(v);}
                else if(s=="delete") {cin>>v; a.deletekey(v);}
                else if(s=="deleteFirst") a.deleteFirst();
                else if(s=="deleteLast") a.deleteLast();
        }
        a.print();
        return 0;
}


Measured memory_bytes: 34400
#include<bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

ll cho(ll x){
    return x*(x-1)/2;
}

int main()
{
    int n;cin >>n;
    V c(n,0);
    V a(n);rep(i,n){
        cin >>a[i];
        a[i]--;
        c[a[i]]++;
    }
    ll sum=0;
    rep(i,n)sum+=cho(c[i]);
    rep(i,n){
        ll ans=sum;
        ans-=cho(c[a[i]]);
        ans+=cho(c[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4096
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int[] l = new int[n];
        for (int i = 0;i<n;i++) {
            l[i] = scanner.nextInt();
        }

        int d = 0;
        int count = 1;
        for (int i = 0;i<n;i++) {
            d += l[i];
            if (d <= x) {
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int main(){
long long a,b;
cin>>a>>b;
int ans=0;
while(a<=b){
	a*=2;
	ans++;
}
cout<<ans;
    return 0;
}

Measured memory_bytes: 256
W,H,N = map(int,input().split())
XYA = [tuple(map(int,input().split())) for i in range(N)]

l,r,d,u = 0,W,0,H
for x,y,a in XYA:
    if a==1:
        l = max(l,x)
    elif a==2:
        r = min(r,x)
    elif a==3:
        d = max(d,y)
    else:
        u = min(u,y)
w = max(0,r-l)
h = max(0,u-d)
print(w*h)

Measured memory_bytes: 3064
def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(M)]
    AB.sort(key=lambda x: x[1])
    c = -1
    r = 0
    for a, b in AB:
        if a >= c:
            c = b
            r += 1
    return r

print(main())


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

int main(){
    int x,y,s;
    while(cin>>x>>y>>s,x){
        int res=0;
        for(int i=1;i<=s;i++){
            for(int j=1;j<=s;j++){
                int iv=i*(100+x)/100;
                int jv=j*(100+x)/100;
                if(iv+jv==s){
                    res=max(res,i*(100+y)/100+j*(100+y)/100);
                }
            }

        }
	cout<<res<<endl;
    }


}


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

int main() {

	int k,a,b,sum;
	cin >> k >> a >> b;

	
	for (int i = 0; i < b+1; i++) {
		sum = i*k;
		if (sum >= a&& sum <= b) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;


}


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

int main() {
  vector<int> a(5);
  for(int i=0;i<5;i++) {
    cin >> a[i];
  }
  int min = 10000000;
  do {
    int time = 0;
    for(int i=0;i<5;i++) {
      if(time % 10 == 0) {
        time += a[i];
      } else {
        int b = time + 10 - time % 10;
        time = b + a[i];
      }
    }
    if(time < min) {
      min = time;
    }
  } while ( next_permutation(a.begin(), a.end()) );

  cout << min << endl;

}

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

using namespace std;




int main(){

    long long A,B,K;
    cin >> A >> B >> K;

    for(long long a = A ; a < min(A+K,B-K+1) ; a++){
        cout << a << endl;
    }

    for(long long b = max(B-K+1,A) ; b <= B ; b++){
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt

    def s(i: Int): Long = {
      i * (i + 1L) / 2
    }

    out.println(s(n) - s(n / 3) * 3 - s(n / 5) * 5 + s(n / 15) * 15)

    out.flush()
  }
}


Measured memory_bytes: 54632