akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<set>
#include<climits>
#include<cmath>
#include<sstream>
#include<stdlib.h>
#include<memory.h> 
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+100000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1000000007;
const long long LMOD=998244353;
#define Sf scanf
#define Pf printf
#define ll long long
#define Fi first
#define Se second
#define P2 pair
#define Cb make_pair
#define Vct vector
#define Que queue
#define Era erase
#define Sz size
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Pb push_back
#define Clr clear
#define Cot continue
#define Psh push
#define Ins insertvhjm
#define Str string
#define Pq priority_queue
ll a[400005];
ll b[400005];
ll c[400005];
vector<int>v[2];
bool occ[400005];
int main()
{
	ll n,k;
	Sf("%lld%lld",&n,&k);
	if((2*k+5*n-1)*n/2>=(2*k+2*n-1)*n)
	{
		//puts(":)");
	}
	else
	{
		puts("-1");
		return 0;
	}
	for(ll i=1;i<=n;i++)
	{
		a[i]=k+i-1;
		b[i]=k+2*n-i;
		c[i]=k+i-1+2*n;
	}
	/*
	for(ll i=1;i<=n;i++)
	{
		cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
	}
	*/
	//int t=2*n-b[1];
	
	for(ll i=1;i<=n;i++)
	{
		//v[(2*n-b[i])%2].Pb(b[i]);
		
		if(b[i]>=2*n)
		{
			//cout<<i<<" "<<(2*n-b[i])<<endl;
			//swap(a[i],a[n-t+i]);
			v[(b[i]-2*n)%2].Pb(b[i]);
		}
		else
		{
			break;
		}
		
	}
	reverse(v[0].begin(),v[0].end());
	reverse(v[1].begin(),v[1].end());
	int f=0;
	/*
	for(int i=0;i<=1;i++)
	{
		for(int j=0;j<v[i].Sz();j++)
		{
			cout<<v[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	for(int i=1;i<=n;i++)
	{
		if(v[f].Sz()==0)f++;
		if(f==2)break;
		if(occ[i])continue;
		if(occ[i+v[f][(int)(v[f].Sz())-1]-n*2])continue;
		//cout<<"!"<<b[i]<<" "<<i+n*2-b[i]<<endl;
		b[i]=v[f][(int)(v[f].Sz())-1];
		swap(c[i],c[i+b[i]-n*2]);
		b[i+b[i]-n*2]=n*4-b[i];
		occ[i+b[i]-n*2]=1;
		v[f].pop_back();
	}
	for(ll i=1;i<=n;i++)
	{
		if(a[i]+b[i]>c[i])
		{
			puts("-1");
			return 0;
		}
	}
	for(ll i=1;i<=n;i++)
	{
		//cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
		Pf("%lld %lld %lld\n",a[i],b[i],c[i]);
		/*
		if(a[i]+b[i]<c[i])
		{
			puts("-1");
			return 0;
		}
		*/
	}
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD= 1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  string s;
  cin >> s;
  bool ok=false;
  rep(i,s.size()){
    if(s[i]=='7')ok=true;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>

int main () {
  int n;
  int k;
  int u1,u;
  std::cin>>n;
  int V[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      V[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    std::cin>>u1>>k;
    for(int j=0;j<k;j++){
      std::cin>>u;
      V[u1-1][u-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
      std::cout<<V[i][j]<<" ";
    }
    std::cout<<V[i][n-1]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(0,c - (a - b)) << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())

x = x2-x1
y = y2-y1

x3 = x2 - y
y3 = y2 + x
x4 = x3 - x
y4 = y3 - y

print(x3,y3,x4,y4)

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll ans = 0;
    int j = 0;
    for(int i = 0; i < n-1; i++) {
      ans += a.at(j);
      if(i%2 == 0) j++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int N,K,up,down,div;
    cin >> N >> K;
    div = N/K;
    up = N-K*div;
    down = abs(up - K);
    if(up < down)
        cout << up << "\n";
    else
        cout << down << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
  int a, b, count = 1, sum = 0;
  cin >> a >> b;
  sum = a;
  if (a < b) {
    while (sum < b) {
      sum += a - 1;
      count++;
    }
  } else if (b == 1) {
    count = 0;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DigitsParade solver = new DigitsParade();
        solver.solve(1, in, out);
        out.close();
    }

    static class DigitsParade {
        public static int MOD = 1_000_000_007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] chars = in.next().toCharArray();
            long[][] dp = new long[chars.length + 1][13];
            dp[0][0] = 1;

            for (int i = 0; i < chars.length; i++) {
                for (int k = 0; k < 13; k++) {
                    if (chars[i] == '?') {
                        for (int j = 0; j <= 9; j++) {
                            int index = (k * 10 + j) % 13;
                            dp[i + 1][index] += dp[i][k];
                            dp[i + 1][index] %= MOD;
                        }
                    } else {
                        int j = Integer.parseInt(String.valueOf(chars[i]));
                        int index = (k * 10 + j) % 13;
                        dp[i + 1][index] += dp[i][k];
                        dp[i + 1][index] %= MOD;
                    }
                }
            }
            out.println(dp[chars.length][5]);
        }

    }
}



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

#define N 200010
#define MAX 1000000000000000000

int main (void)
{
    long long n, sum = 0, a, max = 0, i;

    scanf("%lld", &n);

    for (i = 0; i < n; i++) {
        scanf("%lld", &a);

        if (a > max) {
            max = a;
        }

        sum += max - a;
    }

    printf("%lld", sum);

    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;
int main(){
    int n,q;
    cin >> n >> q;
    queue<pair<string,int> > da;
    for(int i=0;i<n;i++){
        string name;
        int time;
        cin >> name >> time;
        da.push(make_pair(name,time));
    }
    int cou=0;
    vector<pair<string,int> > ans(n);
    int ansn=0;
    while(!da.empty()){
        pair<string,int> x=da.front();
        da.pop();
        if(q<x.second){
            x.second-=q;
            cou+=q;
            da.push(x);
        }
        else{
            cou+=x.second;
            ans[ansn]=make_pair(x.first,cou);
          	ansn++;
        }
      	//cout << cou << endl;
    }
    for(int i=0;i<n;i++){
        cout << ans[i].first << ' ' << ans[i].second << endl;
    }
}


Measured memory_bytes: 6768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    char s[200005];
    vector<int>v[100005];
    scanf("%s",s);
    int b[200005];
    int l=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        {
            b[l]=i;
            l++;
        }
    }
    int size1=0;
    b[l]=10000000;
    for(int i=0;i<l;i++)
    {
        if(b[i]==b[i+1]-1)
        {
            v[size1].push_back(b[i]);
        }
        else
        {
            v[size1].push_back(b[i]);
            size1++;
        }
    }
    if(size1==0)
    {
        cout<<n;
        return 0;
    }
   // cout<<size1<<'\n';
    int ans=0;
    for(int i=0;i<size1;i++)
    {
       /* if(i+k>n)
        break;
        else
        {*/
            int g=min(size1,i+k);
            int j=v[g-1][v[g-1].size()-1];
            int j1=v[i][0];
            int ans1=j-j1+1;
           // cout<<ans1<<'\n';
            for(int h=j1-1;h>=0;h--)
            {
                if(s[h]=='1')
                ans1++;
                else
                break;
            }
            for(int h=j+1;h<n;h++)
            {
                if(s[h]=='1')
                ans1++;
                else
                break;
            }
        //    cout<<ans1<<'\n';
            ans=max(ans,ans1);
         //   cout<<ans<<'\n';
        //}
    }
    cout<<ans;
    return 0;
}

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

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

    // 二桁以上で先頭が0、同じ桁に違う数の条件があるとき無効
    if (N == 1) {
        int s[M], c[M];
        for (int i = 0; i < M; i++) {
            cin >> s[i] >> c[i];
        }
        for (int i = 0; i < M-1; i++) {
            if (c[i] != c[i+1]) {
                cout << -1 << endl;
                return 0;
            }
        }
        cout << c[0] << endl;
    }
    else if (N == 2) {
        int ans[2] = {-1, -1};
        for (int i = 0; i < M; i++) {
            int s, m;
            cin >> s >> m;
            if (ans[s-1] == -1 || ans[s-1] == m) {
                ans[s-1] = m;
            }
            else {
                cout << -1 << endl;
                return 0;
            }
        }
        if (ans[0] == 0) {
            cout << -1 << endl;
            return 0;
        }
        if (ans[0] == -1)   ans[0] = 1;
        if (ans[1] == -1)   ans[1] = 0;
        cout << ans[0] *10 + ans[1] << endl;
    }
    else {
        int ans[3] = {-1, -1, -1};
        for (int i = 0; i < M; i++) {
            int s, m;
            cin >> s >> m;
            if (ans[s-1] == -1 || ans[s-1] == m) {
                ans[s-1] = m;
            }
            else {
                cout << -1 << endl;
                return 0;
            }
        }
        if (ans[0] == 0) {
            cout << -1 << endl;
            return 0;
        }
        if (ans[0] == -1)   ans[0] = 1;
        if (ans[1] == -1)   ans[1] = 0;
        if (ans[2] == -1)   ans[2] = 0;
        cout << ans[0] * 100 + ans[1] * 10 + ans[2] << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int s[] = new int[100_000 + 1];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a - 1 >= 0) s[a - 1]++;
            s[a]++;
            if (a + 1 <= 100_000) s[a + 1]++;
        }

        int mx = 0;
        for (int i = 0; i < 100_000; i++) {
            mx = Math.max(mx, s[i]);
        }

        System.out.println(mx);
    }
}

Measured memory_bytes: 59700
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    s = s.replace("1","a");
    s = s.replace("9","1");
    s = s.replace("a","9");
    System.out.println(s);
  }
}


Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n; cin >> n;
  int cntodd = 0;
  int cnteven = 0;
  rep(i, n) {
    int a; cin >> a;
    if (a & 1) {
      cntodd++;
    } else {
      cnteven++;
    }
  }

  bool flag = false;
  if(cntodd & 1) {
    flag = false;
  } else {
    flag = true;
  }
  cout << (flag ? "YES" : "NO") << endl;
}

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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

#define int ll

int a, b, ans;

main()
{
    cin >> a >> b;
    ans = abs(abs(a) - abs(b));

    if (a == 0)
    {
        cout << (b > 0 ? ans : ans + 1);
        return 0;
    }
    else if (b == 0)
    {
        cout << (a > 0 ? ans + 1 : ans);
        return 0;
    }
    else if (a > 0 && b > 0 && a > b)
        cout << ans + 2;
    else if (a < 0 && b < 0 && a > b)
        cout << ans + 2;
    else if (a > 0 && b > 0 && a < b)
        cout << ans;
    else if (a < 0 && b < 0 && a < b)
        cout << ans;
    else if (a > 0 && b < 0)
        cout << ans + 1;
    else if (a < 0 && b > 0)
        cout << ans + 1;
}


Measured memory_bytes: 256
while line = gets.chomp
  break if line == "0"
  ary = []
  max = -100001
  line.to_i.times do
    n = gets.to_i
    ary << 0
    ary.map! do |v|
      v = v + n
      max = v if v > max
      v
    end
  end
  puts max
end

Measured memory_bytes: 6100
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////


/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n; cin >> n;
	long double p[n];
	For(i,n)cin >> p[i];
	long double dp[2][2][n+2];
	memset(dp,0,sizeof(dp));
	dp[0][0][1] = p[0];
	dp[0][1][0] = (1.0-p[0]);
	int flag = 0;
	For(i,n){
		For(j,n){
			For(k,2){
				if(k==0){
					dp[1-flag][k][j+1] = p[i+1]*(dp[flag][k][j]+dp[flag][1-k][j]);
				}
				else{
					dp[1-flag][k][j] = (1.0-p[i+1])*(dp[flag][k][j]+dp[flag][1-k][j]);
				}
			}
		}
		flag = 1-flag;
	}
	long double ans = 0.0;
	FOR(i,n/2+1,n+1){
		For(j,2){
			ans += dp[1-flag][j][i];
		}
	}
	cout << fixed << setprecision(10) << ans <<"\n";
	

}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

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

    int b1[3][10]={
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0}
    };
    int b2[3][10]={
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0}
    };
    int b3[3][10]={
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0}
    };
    int b4[3][10]={
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0}
    };
    int n; cin >> n;
    int b, f, r, v;

    for (int i=1;i<=n;i++){
        cin >> b;
        if (b == 1){
            cin >> f >> r >> v;
            b1[f-1][r-1]+=v;
            b=0;f=0;r=0;v=0;
            continue;
        }

        else if (b == 2){
            cin >> f >> r >> v;
            b2[f-1][r-1]+=v;
            b=0;f=0;r=0;v=0;
            continue;
        }

        else if (b == 3){
            cin >> f >> r >> v;
            b3[f-1][r-1]+=v;
            b=0;f=0;r=0;v=0;
            continue;
        }

        else if (b == 4){
            cin >> f >> r >> v;
            b4[f-1][r-1]+=v;
            b=0;f=0;r=0;v=0;
            continue;
        }


    }

    for (int i=0;i<3;i++){
        for (int j=0;j<10;j++){
            cout <<" "<< b1[i][j];
            if (j == 9)cout << endl;
        }

    }

    cout << "####################" << endl;

      for (int i=0;i<3;i++){
        for (int j=0;j<10;j++){
            cout <<" "<< b2[i][j];
            if (j == 9)cout << endl;
        }

    }

    cout << "####################" << endl;

      for (int i=0;i<3;i++){
        for (int j=0;j<10;j++){
            cout <<" "<< b3[i][j];
            if (j == 9)cout << endl;
        }

    }

    cout << "####################" << endl;

      for (int i=0;i<3;i++){
        for (int j=0;j<10;j++){
           cout <<" "<< b4[i][j];
            if (j == 9)cout << endl;
        }

    }

}


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

#define int long long

#define mod (int)1000000007
#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)
#define For(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)
#define trfor(i, s, t) for(int i = (t); i >= (s); i--)

int dp[1 << 5][1 << 7][1 << 5];
int tmp[1 << 5][1 << 7][1 << 5];

signed main() {
  int n, x, y, z;
  cin >> n >> x >> y >> z;
  rep(i, 1 << x) {
    rep(j, 1 << y) {
      rep(k, 1 << z) {
        dp[i][j][k] = 0;
      }
    }
  }
  dp[1][0][0] = 1;
  int ans = 0;
  rep(_, n) {
    rep(i, 1 << x) {
      rep(j, 1 << y) {
        rep(k, 1 << z) {
          tmp[i][j][k] = 0;
        }
      }
    }
    ans = ans * 10 % mod;
    tfor(l, 1, 10) {
      rep(i, 1 << x) {
        rep(j, 1 << y) {
          rep(k, 1 << z) {
            int xt = (i << l) | 1;
            int yt = j << l;
            int zt = k << l;
            if(xt & (1 << x)) {
              yt |= 1;
            }
            if(yt & (1 << y)) {
              zt |= 1;
            }
            if(zt & (1 << z)) {
              ans = (ans + dp[i][j][k]) % mod;
            }
            else {
              tmp[xt & ((1 << x) - 1)][yt & ((1 << y) - 1)][zt & ((1 << z) - 1)] += dp[i][j][k];
            }
          }
        }
      }
    }
    rep(i, 1 << x) {
      rep(j, 1 << y) {
        rep(k, 1 << z) {
          dp[i][j][k] = tmp[i][j][k] % mod;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2304
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main() {

    int n;                  // XとYの次元数n
    int x[100];             // ベクトル
    int y[100];             // ベクトル

    double S[4] = {0};
    double D[4];  // ミンコフスキー距離

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }

    for (double p = 0; p < 3; p++) {

        for (int i = 0; i < n; i++) {
            S[(int)p] += pow(abs(x[i] - y[i]), p + 1);
        }

        D[(int)p] = pow(S[(int)p], 1 / (p + 1));

    }

    D[3] = x[0] - y[0];

    for (int i = 0; i < n; i++) {
        if (abs(x[i] - y[i]) > D[3]) {
            D[3] = abs(x[i] - y [i]);
        }
    }

    cout << fixed;

    for (int i = 0; i < 4; i++) {
        cout << setprecision(10) << D[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3476
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>
#include <stack>
using namespace std;
    
int main(){
    int X;
    cin >> X;
    vector<int> prime;
    prime.push_back(2);
    int cnt=0;
    for (int i = 3; i <= X; i++){
        for(auto j: prime){
            if(i%j==0){
                break;
            }
            else{
                cnt++;
            }
        }
        if(cnt==prime.size()){
            prime.push_back(i);
        }
        cnt=0;
    }
    

    bool flag=true;
    int i=0;
    if(X==prime[prime.size()-1]){
                cout << X;
                flag=false;
    }
    else{
        while(flag){
            cnt=0;
            for(auto j: prime){
                if((X+i)%j==0){
                    break;
                }
                else{
                    cnt++;
                }
            }
            if(cnt==prime.size()){
                cout <<  X+i;
                flag=false;
            }
            i++;
        }
    }
}



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

int main(){
  int a,b;
  cin >> a >> b;
  int flag=1;
  for(int i = a*10; i < 10000; i++){
    if(floor(i*0.08)==a&&floor(i*0.1)==b){
      cout << i << endl;
      flag = 0;
      break;
    }
  }
  if(flag)cout << -1 << endl;
  return 0;
}

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

const int N = 200005;
const int MOD = 1000000007;

int n;
int a[N];

int solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  long long sum = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] < a[i-1]) {
      sum += a[i-1] - a[i];
      a[i] = a[i-1];
    }
  }

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

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


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

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

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

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




void _main() {
        int a, b, c, d; cin >> a >> b >> c >> d;
        if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) cout << "Yes";
        else cout << "No";
}



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


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
#include<set>
//int mod(int a,int b,int d);

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

int main() {
  ll x,k,d;
  cin >> x >> k >> d;

  x = abs(x);
  ll a;

  if(x>=0){
    a = x/d;
    if(a>k){
      cout<<x-k*d<<endl;
      return 0;
    }
    x -= a*d;
    if((k-a)%2==0) cout<<x<<endl;
    else cout<<d-x<<endl;
  }




}

Measured memory_bytes: 3604
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
#include<queue>
#include <iomanip>
#include<string.h>
using namespace std;
const int  N = 105;
int arr[N];



int main()
{
    int number ;
    int count =0;
    cin>>number;
    for(int i =1;i<=number;i++)
    {
        int temp ;
        cin>>temp;
       if(i%2==1&&temp%2==1)
           count++;
    }
    cout<<count;
}


Measured memory_bytes: 3628
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int main() {
  ios::sync_with_stdio(false);
  int k;
  for(cin>>k;k;k--){
    cout<<"ACL";
  }
  return 0;
}

Measured memory_bytes: 3652
from collections import Counter

N=int(input())
A=[int(input()) for _ in range(N)]

c = Counter(A)

if len(c)==N:
  print(N)
  exit()
elif len(c)==N-1:
  print(N-2)
  exit()

ans = 0
for k in c.keys():
  if c[k] % 2 == 1:ans += 1
    
print(ans)

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	string t, b;
  cin >> t >> b;
  ll dp[b.size() + 1] = {0};
  dp[0] = 1;
  rep(i, t.size()) {
    dep(j, b.size() - 1, 0) {
      if(t[i] == b[j]) {
        dp[j + 1] += dp[j];
        dp[j + 1] %= mod;
      }
    }
  }
  cout << dp[b.size()] << endl;
	return 0;
}


Measured memory_bytes: 3204
def remove_island(i, j, map)
  map[i][j] = '0'
  [[0, 1], [1, 0], [0, -1], [-1, 0]].each do |x, y|
    next if !(0..11).include?(i + x) || !(0..11).include?(j + y)
    if map[i + x][j + y]=='1'
      remove_island(i + x, j + y, map)
    end
  end
end

loop do
  map = 12.times.map{ gets.chomp }
  count = 0
  12.times do |i|
    12.times do |j|
      if map[i][j] == '1'
        count += 1
        remove_island(i, j, map)
      end
    end
  end
  puts count
  break if gets.nil?
end

Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007
#define SEP " "

int		main(void)
{
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	vector<int> f(n);
	int c = 0;
	while (true)
	{
		int tmp = -1;
		int i = 0;
		while (i < n)
		{
			if (f[i] < h[i])
			{
				tmp = f[i++]++;
				break ;
			}
			i++;
		}
		if (tmp == -1)
			break ;
		while (i < n && f[i] == tmp && f[i] < h[i])
		{
			f[i++]++;
		}
		c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j;
	scanf("%d %d %d %d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
	printf("%d\n",a+b+c+d+e+f+g+h+i+j);
	return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> h(n + 1);
  vector<int> dp(n + 1);
  for( int i = 1 ; i <= n ; i++ ){
    int tmp;
    cin >> tmp;
    h[i] = tmp;
  }
  dp[0] = 0;
  dp[1] = 0;
  dp[2] = abs( h[1] - h[2] );

  for( int i = 3 ; i <= n ; i++ ){
    int t1 = dp[i-1] + abs( h[i] - h[i-1] );
    int t2 = dp[i-2] + abs( h[i] - h[i-2] );
    dp[i] = min( t1 , t2 ); 
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
from itertools import count

N, K = map(int, input().split())
As = [int(n) for n in input().split()]

visited = []
visited_set = set()
now = 0
num = 0
idx = 0
for i in count():
    if now in visited_set:
        idx = visited.index(now)
        num = len(visited) - idx
        break
    visited_set.add(now)
    visited.append(now)
    now = As[now] - 1

if K <= idx:
    print(visited[K] + 1)
else:
    print(visited[idx + (K - idx) % num] + 1)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n, l;cin>>n>>l;
  vector<int>a(n);
  rep(i, n)cin>>a[i];

  int last_knot = -1;
  rep(i, n-1)if(a[i]+a[i+1]>=l){
    last_knot=i;
    break;
  }

  if(last_knot==-1) { cout<<"Impossible"<<endl; return 0; }

  cout<<"Possible"<<endl;

  for(int i=0; i<last_knot; i++) cout<<i+1<<endl;
  for(int i=n-1; i>last_knot+1; i--) cout<<i<<endl;
  cout<<last_knot+1<<endl;

  return 0;
}

Measured memory_bytes: 3792
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    
    cin >> a >> b;
    
    for(int i = 0; i < 1000000000; i++){
        if(abs(a - i) == abs(b - i)){
            cout << i << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
}


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

int main() {

	int N, Y;
	cin >> N >> Y;
	int x, y, z;
	bool is_possible = false;
	for (y = 0; y <= N; y++) { // 5000円がy枚
		for (x = 0; x <= N - y; x++) { // 10000円がx枚
			z = N - y - x; // 1000円がz枚
			if (Y == (10000 * x + 5000 * y + 1000 * z)) {
				is_possible = true;
				break;
			}
		}
		if (is_possible) break;
	}
	if (!is_possible) x = y = z = -1;
	cout << x << " " << y << " " << z << endl;
}

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

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        T solver = new T();
        solver.solve(1, in, out);
        out.close();
    }

    static class T {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n  = in.nextInt(), k = in.nextInt();
            final int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            final long[] prefSum = new long[n];
            final long[] posSum = new long[n];
            for (int i = 0; i < n; i++) {
                if (i == 0) {
                    prefSum[i] = arr[i];
                    if (arr[i] > 0)
                        posSum[i] = arr[i];
                } else {
                    prefSum[i] = prefSum[i - 1] + arr[i];
                    posSum[i] = posSum[i - 1] + (arr[i] > 0 ? arr[i] : 0);
                }
            }

            long ans = 0;
            for (int i = 0; i < n; i++) {
                int j = i + k - 1;
                if (j >= n) break;
                long as = rangePosSum(0, i - 1, posSum) + rangePosSum(j + 1, n - 1, posSum);
                as = Math.max(as, as + rangePrefSum(i, j, prefSum));
                ans = Math.max(ans, as);
            }
            out.println(ans);

        }

        private long rangePosSum(int i, int j, long[] posSum) {
            if (j < i) return 0;
            if (i == 0) return posSum[j];
            return posSum[j] - posSum[i - 1];
        }

        private long rangePrefSum(int i, int j, long[] prefSum) {
            if (i == 0) return prefSum[j];
            return prefSum[j] - prefSum[i - 1];
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// Unionfind
struct UF {
	vector<int> p;

	UF() = default;
	explicit UF(int n) : p(n + 1, -1) { p.back() = n; }

	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		p.back()--;
		return true;
	}
	int find(int x) { return (p[x] < 0 ? x : p[x] = find(p[x])); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -p[find(x)]; }
	int count() { return p.back(); }
};

int N, M, K;
int A[100010], B[100010];
int C[100010], D[100010];
int num[100010];

void _main() {
    cin >> N >> M >> K;
    UF uf(N);
    REP (i, M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        uf.unite(A[i], B[i]);
        num[A[i]]++;
        num[B[i]]++;
    }
    REP (i, K) {
        cin >> C[i] >> D[i];
        C[i]--; D[i]--;
        if (uf.same(C[i], D[i])) {
            num[C[i]]++;
            num[D[i]]++;
        }
    }
    REP (i, N) cout << uf.size(i) - num[i] - 1 << " \n"[i+1==N];
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;
typedef long long ll;

const int maxn=1e6+6;

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

bool vis[maxn];

void init(){
	memset(vis,0,sizeof(vis));
	for(int i=2;i<maxn;i++){
		if(!vis[i]){
			for(int j=i+i;j<maxn;j+=i){
				vis[j]=1;
			}
		}
	}
}

int main(){
	init();
	ll a,b;
	scanf("%lld%lld",&a,&b);
	ll tmp=gcd(a,b);
//	printf("%lld\n",tmp);
	if(tmp==1) printf("1");
	else{
		ll num=1;
		ll k=tmp;
		for(ll i=2;i*i<=tmp;i++){
			if(tmp%i==0&&!vis[i]){
				while(k%i==0) k/=i;
				num++;
			}
		}
		if(k!=1) num++;
		printf("%lld\n",num);
	}
	return 0;
}

Measured memory_bytes: 1280
require 'prime'

class Dictionary
  CHAR_MAP = {
    'A' => 1,
    'C' => 2,
    'G' => 3,
    'T' => 4
  }

  def initialize(size)
    @size = size
    @m = Prime::EratosthenesGenerator.new.find {|p| p > @size }
    @values = Array.new(@m)
  end

  def insert(value)
    key = get_key(value)
    i = 0

    loop do
      h = (h1(key) + i * h2(key)) % @m

      if value == @values[h]
        return true
      elsif !@values[h]
        @values[h] = value
        return false
      end

      i += 1
    end
  end

  def find(value)
    key = get_key(value)
    i = 0

    loop do
      h = (h1(key) + i * h2(key)) % @m

      if value == @values[h]
        return true
      elsif !@values[h]
        return false
      end

      i += 1
    end
  end

  private

  def h1(key)
    key % @m
  end

  def h2(key)
    1 + (key % (@m - 1))
  end

  def get_key(value)
    factor = 1
    value.each_char.inject(0) do |memo, char|
      memo += factor * char_code(char)
      factor *= 5
      memo
    end
  end

  def char_code(value)
    CHAR_MAP[value] || 0
  end
end

n = gets.to_i

dict = Dictionary.new(n)

while line = gets
  command, value = line.split

  case command
  when 'insert'
    dict.insert(value)
  when 'find'
    puts dict.find(value) ? 'yes' : 'no'
  else
    abort "unknown command: #{command}"
  end
end

Measured memory_bytes: 41632
#include<stdio.h>
 

 

int main()
{
int F[44];
int n,i;
F[0]=1;
F[1]=1;
 
scanf("%d",&n);
 
for(i=2;i<n+2;i++)
{
 F[i] = F[i-2] + F[i-1];
}
 
printf("%d\n",F[n]);
return 0;
 
}
 
 

Measured memory_bytes: 596
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]
 
def main():
    a,b = inpm()
    if b>a:
        a,b = b,a
    ans = []
    for i in range(a):
        ans.append(str(b))
    print(''.join(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 39020
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	vector<string> days{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string x;
	cin >> x;
	int pos;
	rep(i,0,sz(days)) {
		if (days[i] == x) {
			cout << 7 - i << endl;
		}
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll K, i;
    string S;

    cin >> K >> S;

    if(S.size()<=K) cout << S << endl;
    else{
        string T = S.substr(0,K);
        cout << T << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long LL;

int main(){
    int n,m,a,b,cnt;
    LL ans=0;
    cin>>n>>m;
    cnt=m;
    vector<pair<LL,LL> > AB(n);
    for(int i=0;i<n;i++){
        cin>>AB[i].first>>AB[i].second;
    }
    sort(AB.begin(),AB.end());
    for(int i=0;i<n;i++){
        if(AB[i].second>=cnt){
            ans+=AB[i].first*cnt;
            break;
        }else{
            ans+=AB[i].first*AB[i].second;
            cnt-=AB[i].second;
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  long ans = 0, mod = 1e9 + 7;
  for (long k = K; k <= N + 1; k++) {
    ans += (N - k + 1) * k + 1;
  }
  cout << ans % mod << "\n";
}

Measured memory_bytes: 3660
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	int x, y;
	cin >> x >> y;

	if (x + y < 10) {
		cout << x + y << endl;
	}
	else
		cout << "error" << endl;
	
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int b[256];

int winner(char s, char t, vector<string>& a) {
	vector<int> x(4);
	for (int i = 0; i < 4; i++)
		if (a[i][1] == s) x[i] = b[a[i][0]];
		else if (a[i][1] == t) x[i] = 13 + b[a[i][0]];
		else x[i] = -1;
	int _i, maxi = -1;
	for (int i = 0; i < 4; i++)
		if (x[i] > maxi) {
			_i = i;
			maxi = x[i];
		}
	return _i;
}

int main() {
	b['2'] = 0;
	b['3'] = 1;
	b['4'] = 2;
	b['5'] = 3;
	b['6'] = 4;
	b['7'] = 5;
	b['8'] = 6;
	b['9'] = 7;
	b['T'] = 8;
	b['J'] = 9;
	b['Q'] = 10;
	b['K'] = 11;
	b['A'] = 12;
	for (;;) {
		string _t; cin >> _t;
		char t = _t[0];
		if (t == '#') break;
		vector< vector<string> > c(4, vector<string>(13));
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 13; j++)
				cin >> c[i][j];
		int _i = 0, ns = 0, ew = 0;
		for (int j = 0; j < 13; j++) {
			vector<string> a(4);
			for (int i = 0; i < 4; i++)
				a[i] = c[i][j];
			_i = winner(c[_i][j][1], t, a);
			if (_i % 2 == 0) ns++;
			else ew++;
		}
		if (ns > ew) cout << "NS " << ns - 6 << endl;
		else cout << "EW " << ew - 6 << endl;
	}
}

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

int twice(int start, int end) {
	int count = 0;
	if (start < end) {
		return twice(start * 2, end) + 1;
	}
	else {
		return count;
	}
}

int main() {
	int n, k;
	double ans = 0;

	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		ans += pow(0.5, twice(i, k));
	}
	printf("%.12lf\n", ans /(double)n);
}

Measured memory_bytes: 256
import math
a, b, C = map(float, input().split())
S = 0.5 * a * b * math.sin(C * math.pi / 180.0)
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C * math.pi / 180.0))
h = b * math.sin(C * math.pi / 180.0)
print("{:.10f}".format(S))
print("{:.10f}".format(a + b + c))
print("{:.10f}".format(h))


Measured memory_bytes: 5692
h, w = gets.chomp.split.map(&:to_i)
a = []
h.times{a << gets.chomp.split.map(&:to_i)}
min = nil
for y in 0...h
    for x in 0...w
        dist = 0
        for y2 in 0...h
            for x2 in 0...w
                dist += [(y2-y).abs, (x2-x).abs].min * a[y2][x2]
            end
        end
        min = dist if min.nil? || min > dist
    end
end
puts min


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

class Solve {
private:
	std::string inputCode;
	using vm = std::map<int64_t, int64_t>;
	using vvm = std::vector<vm>;

	vvm arrayNumbers;
	std::vector<int64_t> arraySize;

	bool isValidLine()
	{
		int s_i{};
		int array_name{calcArrayName(s_i)};
		s_i++;
		int64_t array_index{calcExpression(s_i)};
		s_i++;
		if (array_index < 0) return false;
		if (s_i == (int)inputCode.size())
			arraySize[array_name] = array_index;
		else
		{
			s_i++;
			int64_t assigned{calcExpression(s_i)};
			if (assigned < 0) return false;
			if (array_index >= arraySize[array_name])
				return false;
			arrayNumbers[array_name][array_index] = assigned;
		}
		return true;
	}

	int calcArrayName(int& s_i)
	{
		s_i++;
		if (islower(inputCode[s_i - 1])) return inputCode[s_i - 1] - 'a';
		else return inputCode[s_i - 1] - 'A' + 26;
	}

	int64_t calcExpression(int& s_i)
	{
		if (isdigit(inputCode[s_i]))
			return calcNumber(s_i);
		int array_name{calcArrayName(s_i)};
		s_i++;
		int64_t array_index{calcExpression(s_i)};
		s_i++;
		if (array_index >= arraySize[array_name] || arrayNumbers[array_name].find(array_index) == arrayNumbers[array_name].end())
			return -1;
		return arrayNumbers[array_name][array_index];
	}

	int64_t calcNumber(int& s_i)
	{
		int64_t ret{};
		while (s_i != (int)inputCode.size() && isdigit(inputCode[s_i]))
		{
			ret = 10 * ret + inputCode[s_i] - '0';
			s_i++;
		}
		return ret;
	}
public:
	bool is_last_query{};
	Solve()
	{
		std::cin >> inputCode;
		if (inputCode == ".")
		{
			is_last_query = true;
			return;
		}
		arrayNumbers.resize(52);
		arraySize.resize(52);
		for (int i{1};; i++)
		{
			if (inputCode == ".")
			{
				puts("0");
				break;
			}
			if (!isValidLine())
			{
				printf("%d\n", i);
				while (true)
				{
					std::cin >> inputCode;
					if (inputCode == ".")
						break;
				}
				break;
			}
			std::cin >> inputCode;
		}
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> v;
  int sum = 0;
  for(int i = 0; i < n; ++i){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
    sum += tmp;
  }
  if (sum % 10 != 0){
    cout << sum << endl;
  }else{
    sort(v.begin(), v.end());
    bool b = true;
    for(int i = 0; i < n; ++i){
      if (v[i] % 10 != 0){
        cout << sum-v[i] << endl;
        b = false;
        break;
      }
    }
    if (b){
      cout << 0 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256